/* ── xrda3 brand design tokens (matches xrda3.com) ───────────────────── */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --row-border: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --dim: #94a3b8;
  --accent: #bf2c31;          /* xrda3 red */
  --accent-2: #d63a3f;
  --accent-3: #e85a5e;
  --accent-soft: #fbe9ea;
  --accent-contrast: #ffffff;
  --unread: #ffffff;
  --hover: #f1f5f9;
  --star: #f4b400;
  --danger: #d93025;
  --radius: 12px;
  --gradient-brand: linear-gradient(135deg, #bf2c31 0%, #d63a3f 50%, #e85a5e 100%);
  --font-display: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #111b2e;
    --surface-2: #1b2740;
    --border: #2a3a55;
    --row-border: #1b2740;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --dim: #64748b;
    --accent: #f06a6f;
    --accent-2: #e85a5e;
    --accent-soft: #3a1f22;
    --accent-contrast: #ffffff;
    --unread: #16223a;
    --hover: #1b2740;
  }
}

/* Manual theme override (profile-menu toggle) */
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111b2e; --surface-2: #1b2740; --border: #2a3a55;
  --row-border: #1b2740; --text: #e2e8f0; --muted: #94a3b8; --dim: #64748b;
  --accent: #f06a6f; --accent-2: #e85a5e; --accent-soft: #3a1f22;
  --accent-contrast: #ffffff; --unread: #16223a; --hover: #1b2740;
}

/* Display font (Space Grotesk) on headings — matches xrda3.com */
h1, h2, h3, .gm-list-title, .login-hero-title, .msg-title, .legal-head h2,
.legal-page-title, .login-card h1 { font-family: var(--font-display); letter-spacing: -0.01em; }
:root[data-theme="dark"] .sk { background: #2c2f34; }
:root[data-theme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.09), transparent); }

/* Google-style profile menu */
.gm-account { position: relative; display: flex; align-items: center; gap: 12px; }
.gm-avatar-btn { background: none; border: 0; cursor: pointer; padding: 2px; border-radius: 50%; }
.gm-avatar-btn:hover { background: var(--hover); }
.gm-avatar-lg { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 600; font-size: 0.95rem;
  background-size: cover; background-position: center; overflow: hidden; }
.gm-profile-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 280px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.18); overflow: hidden; }
.gm-profile-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.gm-profile-name { font-weight: 500; font-size: 0.92rem; word-break: break-all; }
.gm-profile-sub { color: var(--muted); font-size: 0.8rem; }
.gm-menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px;
  background: none; border: 0; text-align: left; color: var(--text); font-size: 0.9rem; cursor: pointer; }
.gm-menu-item:hover { background: var(--hover); }
.gm-menu-item i { width: 18px; text-align: center; color: var(--muted); }
.gm-menu-item.danger { color: var(--danger); } .gm-menu-item.danger i { color: var(--danger); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 0.9rem; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.92; background: var(--accent); }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.gm-icon-btn {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; padding: 8px 10px; border-radius: 8px; font-size: 0.95rem;
  display: inline-flex; align-items: center; gap: 6px;
}
.gm-icon-btn:hover { background: var(--hover); color: var(--text); }

/* ── App shell ─────────────────────────────────────────────────────── */
#app-shell { display: flex; flex-direction: column; height: 100vh; }

.gm-topbar {
  height: 60px; flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.gm-menu { display: none; border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.gm-logo { font-size: 1.25rem; font-weight: 500; display: flex; align-items: center; gap: 10px; cursor: pointer; white-space: nowrap; }
.gm-logo-mark { color: var(--accent); }
.gm-logo-img { height: 26px; display: block; }
:root[data-theme="dark"] .gm-logo-img { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .gm-logo-img { filter: brightness(0) invert(1); } }
.gm-topbar-email { display: inline-block; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.4; border-radius: 6px; padding: 2px 6px; white-space: nowrap; margin-left: 1px; }
@media (max-width: 600px) { .gm-topbar-email { display: inline-block; } }
.gm-search {
  flex: 1; max-width: 700px; display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-radius: 10px; padding: 0 16px; height: 46px;
  border: 1px solid transparent;
}
.gm-search:focus-within { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.gm-search-ico { color: var(--muted); }
.gm-search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 0.95rem; color: var(--text); }
.gm-search-clear { border: 0; background: none; color: var(--muted); cursor: pointer; }
.gm-account { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.gm-account-email { color: var(--muted); font-size: 0.9rem; }

.gm-body { flex: 1; display: flex; min-height: 0; }

.gm-sidebar { width: 256px; flex: none; padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; }

/* ── Storage card (bottom of sidebar) ──────────────────────────────────── */
.gm-storage-card { margin: auto 8px 8px; padding: 12px 14px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 14px; cursor: pointer; text-align: left;
  display: block; width: calc(100% - 16px); transition: background .15s, box-shadow .15s; }
.gm-storage-card:hover { background: var(--accent-soft); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.gm-storage-top { display: flex; align-items: center; gap: 9px; font-size: 0.85rem; color: var(--text); margin-bottom: 9px; }
.gm-storage-top > i:first-child { color: var(--accent); }
.gm-storage-label { font-weight: 500; }
.gm-storage-caret { margin-left: auto; font-size: 0.7rem; color: var(--muted); }
.gm-storage-track { height: 6px; border-radius: 999px; background: var(--row-border); overflow: hidden; }
.gm-storage-bar { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.gm-storage-bar.full { background: #d93025; }
.gm-storage-text { margin-top: 7px; font-size: 0.74rem; color: var(--muted); }

/* ── Message attachments ───────────────────────────────────────────────── */
/* Attachments: compact chip cards. In the reading view they live in the fixed
   bottom menu as a single horizontal row that scrolls sideways if it overflows. */
.att-wrap { margin-top: 20px; }
.att-head { display: flex; align-items: center; gap: 7px; font-size: 0.72rem; color: var(--muted);
  font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.att-head i { font-size: 0.8rem; }
.att-list { display: flex; flex-wrap: wrap; gap: 10px; }
.msg-foot-region .att-wrap { margin: 0 0 14px; }
.msg-foot-region .att-head { margin-bottom: 8px; }
.msg-foot-region .att-list { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.msg-foot-region .att-card { flex: 0 0 auto; }
.att-card { position: relative; display: flex; align-items: center; gap: 11px; width: 248px; max-width: 100%;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease; }
.att-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.att-ico { width: 38px; height: 38px; flex: none; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 1.05rem; }
.att-dl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; color: var(--text);
  text-decoration: none; }
.att-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; font-weight: 500; }
.att-dl:hover .att-name { text-decoration: underline; }
.att-size { font-size: 0.75rem; color: var(--muted); }
/* Download / Save icon buttons — appear on hover (always visible on touch) */
.att-actions { display: flex; align-items: center; gap: 2px; flex: none; opacity: 0; transition: opacity .14s ease; }
.att-card:hover .att-actions { opacity: 1; }
.att-act { width: 30px; height: 30px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; text-decoration: none; }
.att-act:hover { background: var(--hover); color: var(--accent); }
.att-save.saved { opacity: 1; color: #1e8e3e; }
.att-save:disabled { cursor: default; }
@media (hover: none) { .att-actions { opacity: 1; } }

/* ── Cloud storage (Google Drive) panel ────────────────────────────────── */
.cloud-panel { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.cloud-logo { width: 42px; height: 42px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 1.15rem; }
.cloud-info { flex: 1; min-width: 0; }
.cloud-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.cloud-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-btn { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px;
  border: 1px solid transparent; background: var(--accent); color: var(--accent-contrast); font: inherit; font-size: 0.86rem;
  font-weight: 600; cursor: pointer; transition: filter .14s ease; }
.cloud-btn:hover { filter: brightness(1.06); }
.cloud-btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.cloud-btn.ghost:hover { background: var(--hover); filter: none; }

/* ── Saved files list ──────────────────────────────────────────────────── */
.files-head-left { display: flex; align-items: center; gap: 8px; }
.files-sub { font-size: 0.8rem; color: var(--muted); }
.files-list { padding: 6px 18px 24px; }
.files-group { margin-bottom: 8px; }
.files-group-head { font-size: 0.72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin: 14px 2px 10px; }
.files-group-empty { font-size: 0.85rem; color: var(--muted); padding: 6px 2px 10px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 10px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.gm-icon-btn.danger:hover { color: #d93025; }
.gm-compose {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 26px 14px 20px; margin: 4px 8px 14px;
  border: 0; border-radius: 16px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.95rem; font-weight: 600;
  box-shadow: 0 1px 3px rgba(60,64,67,.15);
}
.gm-compose:hover { box-shadow: 0 2px 6px rgba(60,64,67,.25); }
.gm-folders { display: flex; flex-direction: column; }
.gm-folder {
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px 0 20px; height: 38px;
  border-radius: 0 20px 20px 0; color: var(--text); font-size: 0.9rem;
}
.gm-folder:hover { background: var(--hover); text-decoration: none; }
.gm-folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.gm-fi { width: 18px; text-align: center; }

.gm-main { flex: 1; min-width: 0; overflow-y: auto; background: var(--surface);
  border-top-left-radius: 0; border-left: 1px solid var(--border); }
.gm-list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 6px; }
.gm-list-title { margin: 0; font-size: 1.1rem; font-weight: 500; }

/* ── Filter bar ────────────────────────────────────────────────────── */
.gm-filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 2px 18px 10px; }
.gm-filter-chips { display: flex; gap: 6px; }
.gm-filter-chip { border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 0.82rem; padding: 5px 14px; border-radius: 999px;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.gm-filter-chip:hover { background: var(--hover, var(--accent-soft)); }
.gm-filter-chip.active { background: var(--accent-soft); color: var(--accent);
  border-color: transparent; font-weight: 500; }
.gm-filter-date-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 0.82rem; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; }
.gm-filter-date-btn:hover { background: var(--hover, var(--accent-soft)); }
.gm-filter-date-btn.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 500; }
.gm-fd-caret { font-size: 0.68rem; opacity: .7; }

/* ── Calendar popup ────────────────────────────────────────────────────── */
.cal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 400px; padding: 16px; box-shadow: 0 10px 44px rgba(0,0,0,.32); }
.cal-presets { display: flex; flex-wrap: nowrap; gap: 6px; margin-bottom: 14px; }
.cal-preset { border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 0.78rem; padding: 5px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
@media (max-width: 440px) { .cal-presets { flex-wrap: wrap; } }
.cal-preset:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-month { font-weight: 600; font-size: 0.95rem; }
.cal-nav { width: 32px; height: 32px; border-radius: 50%; border: 0; background: none; color: var(--text);
  cursor: pointer; font-size: 0.85rem; }
.cal-nav:hover { background: var(--hover, var(--accent-soft)); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: 38px; gap: 2px; }
.cal-dow { text-align: center; font-size: 0.7rem; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-cell { min-width: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; border-radius: 8px; cursor: pointer; color: var(--text); user-select: none; }
.cal-cell.empty { cursor: default; }
.cal-cell:not(.empty):not(.future):hover { background: var(--accent-soft); }
.cal-cell.future { color: var(--muted); opacity: .4; cursor: not-allowed; }
.cal-cell.today { outline: 1px solid var(--accent); }
.cal-cell.sel-mid { background: var(--accent-soft); border-radius: 0; }
.cal-cell.sel-end { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.cal-range { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 12px 0 4px; min-height: 1.1em; }

/* ── Load more ─────────────────────────────────────────────────────── */
.gm-list-more { display: flex; justify-content: center; padding: 10px 18px 22px; }
.gm-loadmore { border: 1px solid var(--border); background: var(--surface); color: var(--accent);
  font-size: 0.86rem; font-weight: 500; padding: 9px 22px; border-radius: 999px; cursor: pointer;
  transition: background .15s, box-shadow .15s; }
.gm-loadmore:hover { background: var(--accent-soft); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.gm-loadmore.loading { color: var(--muted); cursor: default; }

/* ── Message list (Gmail rows) ─────────────────────────────────────── */
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-row {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px; height: 46px; border-bottom: 1px solid var(--row-border);
  cursor: pointer;
}
.msg-row:hover { box-shadow: inset 1px 0 0 var(--border), inset -1px 0 0 var(--border), 0 1px 3px rgba(0,0,0,.08); z-index: 1; }
.msg-row.unread { background: var(--unread); }
.msg-row.unread .msg-from, .msg-row.unread .msg-subject { font-weight: 700; color: var(--text); }
.msg-star { width: 22px; flex: none; color: var(--muted); opacity: .55; cursor: pointer; text-align: center; }
.msg-star:hover { opacity: 1; }
.msg-star.on { color: var(--star); opacity: 1; }
.msg-from { width: 200px; min-width: 110px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg-subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg-date { color: var(--muted); font-size: 0.78rem; white-space: nowrap; flex: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.85rem; font-weight: 600; text-transform: uppercase;
}
.msg-row .avatar { width: 28px; height: 28px; font-size: 0.78rem; }
.gm-msg-actions { display: inline-flex; gap: 2px; margin-left: auto; }

/* ── Message & compose panes ───────────────────────────────────────── */
.gm-msg-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--row-border); }
.gm-compose-title { font-weight: 500; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px; }
.meta { color: var(--muted); font-size: 0.88rem; margin: 2px 0; }
.meta strong { color: var(--text); }
/* Reading view is flat like Gmail: no card box, no divider lines.
   It fills the pane as a column so the action bar + footer stay pinned while
   the body/attachments scroll in a fixed-height region in between. */
#message-view:not([hidden]) { height: 100%; display: flex; flex-direction: column; min-height: 0; }
#message-view .gm-msg-toolbar { flex: none; }
#message-card { border: 0; box-shadow: none; margin: 0; padding: 12px 24px 0;
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#message-card .msg-title,
#message-card .msg-head { flex: none; }
/* Body is a bounded, scrolling region marked only by a 4px accent bar on the
   left (denotes the content height) — no box around it. */
.msg-scroll { flex: 1 1 auto; min-height: 120px; overflow-y: auto; margin: 14px 0 0;
  padding: 2px 4px 2px 16px; border-radius: 2px;
  border-left: 4px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.msg-scroll::-webkit-scrollbar { width: 11px; }
.msg-scroll::-webkit-scrollbar-thumb { background: var(--row-border); border-radius: 8px; border: 3px solid var(--surface); }
.msg-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.msg-scroll { scrollbar-width: thin; scrollbar-color: var(--row-border) transparent; }
.msg-body { margin-top: 0; padding-top: 0; border-top: 0; }

/* Fixed bottom menu: attachments + action bar + footer, pinned under the box */
.msg-foot-region { flex: none; padding: 14px 0 16px; background: var(--surface); }
.msg-foot-region .msg-reply-bar { margin-top: 0; }
.msg-foot-region .msg-foot { margin-top: 14px; }
.msg-body iframe { display: block; width: 100%; min-height: 120px; border: 0; background: #fff; border-radius: 6px; }

/* Message-loading skeleton (replaces plain "Loading…") */
.msg-sk { padding: 2px 0; }
.sk-line { display: block; height: 13px; margin: 9px 0; border-radius: 6px; background: var(--row-border); position: relative; overflow: hidden; }
.sk-line::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: sksheen 1.2s infinite; }
@keyframes sksheen { 100% { transform: translateX(100%); } }
.msk-title { height: 22px; width: 55%; margin: 2px 0 22px; }
.msk-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.msk-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; margin: 0; }
.msk-head-lines { flex: 1; min-width: 0; }
.msk-head-lines .sk-line { margin: 6px 0; }
.msk-w45 { width: 45%; } .msk-w30 { width: 30%; } .msk-w85 { width: 85%; } .msk-w70 { width: 70%; }
.msk-body { margin-top: 10px; padding-top: 20px; border-top: 1px solid var(--border); }
:root[data-theme="dark"] .sk-line { background: #1f2b44; }
:root[data-theme="dark"] .sk-line::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sk-line { background: #1f2b44; }
  :root:not([data-theme="light"]) .sk-line::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
}

/* Presence status shown as a coloured ring around the profile avatar */
.gm-avatar-btn { position: relative; padding: 3px; }
.gm-status-dot { display: none; }
.gm-avatar-btn .gm-avatar-lg { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #94a3b8; transition: box-shadow .15s ease; }
.gm-avatar-btn.st-active  .gm-avatar-lg { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #16a34a; }
.gm-avatar-btn.st-busy    .gm-avatar-lg { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #dc2626; }
.gm-avatar-btn.st-away    .gm-avatar-lg { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #f59e0b; }
.gm-avatar-btn.st-offline .gm-avatar-lg { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #94a3b8; }

/* Status picker in the profile menu */
.gm-status-row { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.gm-status-opt { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 4px;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 0.8rem; cursor: pointer; }
.gm-status-opt:hover { background: var(--hover); }
.gm-status-opt.on { border-color: var(--border); background: var(--surface-2); color: var(--text); font-weight: 500; }
.gm-pip { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.gm-pip.active { background: #16a34a; } .gm-pip.busy { background: #dc2626; } .gm-pip.away { background: #f59e0b; }

/* Team presence panel (sidebar) */
.gm-team { margin: 8px 8px 0; padding: 10px 2px 4px; border-top: 1px solid var(--border); }
.gm-team-head { font-size: 0.72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 7px; padding: 0 8px 6px; }
.gm-team-head i { font-size: 0.85em; }
.gm-team-list { display: flex; flex-direction: column; gap: 1px; }
.gm-team-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.gm-team-row:hover { background: var(--hover); }
.gm-team-avwrap { position: relative; flex: none; }
.gm-team-av { width: 28px; height: 28px; font-size: 0.72rem; }
.gm-team-dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--surface); background: #94a3b8; }
.gm-team-dot.active { background: #16a34a; }
.gm-team-dot.busy { background: #dc2626; }
.gm-team-dot.away { background: #f59e0b; }
.gm-team-dot.offline { background: #94a3b8; }
.gm-team-name { font-size: 0.88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.gm-team-row.clickable { cursor: pointer; }
.gm-team-row.active { background: var(--accent-soft); }
.gm-team-badge { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-contrast); font-size: 0.7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; }

/* Team chat dock (Phase 2) — bottom-right conversation window */
.gm-chat { position: fixed; right: 20px; bottom: 20px; width: 320px; max-width: calc(100vw - 32px);
  height: 420px; max-height: calc(100vh - 100px); z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 0 0;
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.28); display: none; flex-direction: column; overflow: hidden; }
.gm-chat.open { display: flex; }
.gm-chat-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  background: var(--accent); color: var(--accent-contrast); }
.gm-chat-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
.gm-chat-dot.active { background: #22c55e; } .gm-chat-dot.busy { background: #ef4444; }
.gm-chat-dot.away { background: #f59e0b; } .gm-chat-dot.offline { background: #cbd5e1; }
.gm-chat-title { flex: 1 1 auto; font-weight: 700; font-size: 0.9rem; text-transform: capitalize;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-chat-x { border: 0; background: transparent; color: var(--accent-contrast); cursor: pointer;
  font-size: 1rem; opacity: 0.85; padding: 2px 4px; border-radius: 6px; }
.gm-chat-x:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }
.gm-chat-body { flex: 1 1 auto; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg); }
.gm-chat-loading { color: var(--muted); font-size: 0.82rem; text-align: center; margin: auto; }
.gm-msg { display: flex; flex-direction: column; max-width: 82%; }
.gm-msg.mine { align-self: flex-end; align-items: flex-end; }
.gm-msg.theirs { align-self: flex-start; align-items: flex-start; }
.gm-msg-bubble { padding: 7px 11px; border-radius: 14px; font-size: 0.88rem; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word; }
.gm-msg.mine .gm-msg-bubble { background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 4px; }
.gm-msg.theirs .gm-msg-bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.gm-msg-time { font-size: 0.66rem; color: var(--muted); margin-top: 2px; padding: 0 4px; }
.gm-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.gm-chat-input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px; font: inherit; font-size: 0.88rem; background: var(--bg); color: var(--text); }
.gm-chat-input:focus { outline: none; border-color: var(--accent); }
.gm-chat-send { flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--accent); color: var(--accent-contrast); display: inline-flex; align-items: center; justify-content: center; }
.gm-chat-send:hover { opacity: 0.92; }
pre.plain { white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 0; }

/* Reading view — Gmail-style sender header + reply pills */
.msg-title { margin: 0 0 18px; font-size: 1.35rem; font-weight: 400; color: var(--text); word-break: break-word; line-height: 1.3; }
.msg-head { display: flex; align-items: center; gap: 12px; }
.msg-head .avatar { width: 40px; height: 40px; font-size: 1rem; }
.msg-head-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-head-from { font-size: 0.92rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head-name { font-weight: 600; color: var(--text); }
.msg-head-addr { color: var(--muted); font-weight: 400; }
.msg-head-to { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head-date { font-size: 0.8rem; color: var(--muted); white-space: nowrap; flex: none; }

.msg-reply-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.reply-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 20px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border)); background: var(--surface);
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  cursor: pointer; transition: background .14s ease, box-shadow .14s ease; }
.reply-pill:hover { background: var(--hover); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.reply-pill i { color: var(--muted); }

/* Footer block that closes the reading view */
.msg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; margin-top: 28px; font-size: 0.76rem; color: var(--muted); }
.msg-foot-to, .msg-foot-brand { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.msg-foot-to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-foot i { color: var(--muted); opacity: .8; }

/* Delivery indicator — green check once it's in the mailbox */
.msg-foot-to.is-delivered { color: #1e8e3e; font-weight: 500; }
.msg-foot-to.is-delivered i { color: #1e8e3e; opacity: 1; }
.msg-foot-to.is-sent i { color: var(--muted); opacity: .9; }

/* "Secured by" — green with a gently pulsing shield */
.msg-foot-brand { color: #1e8e3e; font-weight: 500; }
.msg-foot-brand i { color: #1e8e3e; opacity: 1; animation: shieldPulse 2.6s ease-in-out infinite; }
@keyframes shieldPulse {
  0%, 100% { transform: scale(1); opacity: .8; }
  50%      { transform: scale(1.18); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .msg-foot-brand i { animation: none; } }

/* Hover / focus tooltip for both footer indicators */
.has-tip { position: relative; cursor: default; outline: none; }
.has-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 0;
  width: max-content; max-width: 280px; white-space: normal; text-align: left;
  background: #0f172a; color: #fff; font-size: 0.72rem; font-weight: 400; line-height: 1.45;
  padding: 9px 11px; border-radius: 9px; box-shadow: 0 8px 22px rgba(2, 6, 23, 0.28);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease; z-index: 30;
}
.has-tip::before {   /* little arrow */
  content: ""; position: absolute; bottom: calc(100% + 3px); left: 16px;
  border: 6px solid transparent; border-top-color: #0f172a;
  opacity: 0; transition: opacity .15s ease; z-index: 30;
}
.msg-foot-brand.has-tip::after { left: auto; right: 0; }
.msg-foot-brand.has-tip::before { left: auto; right: 16px; }
.has-tip:hover::after, .has-tip:focus-visible::after { opacity: 1; transform: translateY(0); }
.has-tip:hover::before, .has-tip:focus-visible::before { opacity: 1; }

/* List row hover quick-actions (date swaps to action icons on hover) */
.msg-row-actions { display: none; align-items: center; gap: 1px; flex: none; margin-left: 4px; }
.msg-row:hover .msg-row-actions { display: inline-flex; }
.msg-row:hover .msg-date { display: none; }
.msg-row-act { border: 0; background: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.msg-row-act:hover { background: var(--hover); color: var(--text); }
@media (hover: none) { .msg-row-actions { display: inline-flex; } .msg-row .msg-date { display: inline; } }
.status { color: var(--muted); padding: 8px 18px; }
.empty { list-style: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 14px; min-height: 58vh; padding: 40px 16px; }
.empty-icon { width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 2.3rem; }
.empty-title { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.empty-sub { font-size: 0.95rem; color: var(--muted); max-width: 340px; line-height: 1.5; }
.error { color: var(--danger); font-size: 0.9rem; margin: 8px 0; }

/* ── Gmail-style compose ───────────────────────────────────────────── */
.compose { padding: 0; overflow: hidden; }
.compose-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--row-border); }
.compose-prefix { color: var(--muted); font-size: 0.9rem; width: 54px; flex: none; }
.compose-input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 0.95rem; font-family: inherit; outline: none; padding: 2px 0; }

.rte-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px 12px; border-bottom: 1px solid var(--row-border); background: var(--bg); }
.rte-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.rte-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.rte-btn.active { background: var(--accent-soft); color: var(--accent); }
.rte-sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

.rte-editor { min-height: 260px; padding: 16px; outline: none; font-size: 0.95rem; line-height: 1.6; color: var(--text); overflow-wrap: break-word; }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rte-editor a { color: var(--accent); }

.attach-dropzone { margin: 0 16px 12px; padding: 16px; text-align: center; border: 1.5px dashed var(--border); border-radius: 8px; color: var(--muted); font-size: 0.88rem; transition: border-color .15s, background .15s; }
.attach-dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.attach-list { list-style: none; margin: 0 16px 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.attach-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg); font-size: 0.82rem; }
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.attach-chip .size { color: var(--muted); }
.attach-chip .rm { border: 0; background: none; color: var(--muted); cursor: pointer; line-height: 1; padding: 0; }
.attach-chip .rm:hover { color: var(--danger); }
.compose-footer { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--row-border); }
.compose-footer .spacer { flex: 1; }
.btn-icon { padding: 8px 10px; }
.attach-size { color: var(--muted); font-size: 0.82rem; }

/* ── Split login — features (left) · sign-in form (right) ─────────────── */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; padding: 40px 24px; overflow-x: hidden;
  background:
    radial-gradient(900px 520px at 12% 8%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
}
.login-split { display: grid; grid-template-columns: 1.05fr 420px; gap: 56px; align-items: center; width: 100%; min-width: 0; }

.login-hero { min-width: 0; }
.login-hero-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 600; color: var(--text); }
.login-hero-brand i { color: var(--accent); }
.login-hero-logo { height: 36px; width: auto; display: block; }
.login-card-head { margin: 0 0 8px; text-align: center; line-height: 1; }
.login-card-logo { height: 30px; width: auto; display: inline-block; }
:root[data-theme="dark"] .login-hero-logo, :root[data-theme="dark"] .login-card-logo { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-hero-logo,
  :root:not([data-theme="light"]) .login-card-logo { filter: brightness(0) invert(1); }
}
.login-hero-title { margin: 22px 0 12px; font-size: clamp(2rem, 1.2rem + 2.4vw, 2.95rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.08; }
.login-hero-sub { margin: 0 0 34px; color: var(--muted); font-size: 1.05rem; max-width: 440px; line-height: 1.5; }
.login-hero-sub strong { color: var(--text); font-weight: 600; }
.login-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.login-features li { display: flex; align-items: flex-start; gap: 14px; }
.lf-ico { width: 42px; height: 42px; flex: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); font-size: 1.05rem; }
.lf-text { display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem; color: var(--muted); line-height: 1.45; }
.lf-text strong { color: var(--text); font-size: 0.98rem; font-weight: 600; }

/* Container holds the split, centred; the footer sits at the bottom */
.login-container { width: 100%; max-width: 1020px; min-width: 0; margin: auto; display: flex; flex-direction: column; gap: 34px; }

/* Footer: powered-by (left) · legal links (right) */
.login-foot { width: 100%; max-width: 1020px; margin: 28px auto 0; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.login-foot a { color: var(--muted); text-decoration: none; }
.login-foot a:hover { color: var(--muted); text-decoration: underline; }  /* only underline on hover, no colour change */
.login-foot-brand { color: var(--muted); font-weight: 500; }
.login-foot-links { display: flex; gap: 20px; flex-wrap: wrap; }

/* ── Standalone legal / support pages ───────────────────────────────── */
.legal-page { max-width: 780px; margin: 0 auto; padding: 24px; min-height: 100dvh; display: flex; flex-direction: column; }
.legal-page-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 2px 22px; }
.legal-page-logo { height: 26px; width: auto; display: block; }
:root[data-theme="dark"] .legal-page-logo { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .legal-page-logo { filter: brightness(0) invert(1); } }
.legal-page-back { color: var(--muted); text-decoration: none; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 8px; }
.legal-page-back:hover { color: var(--accent); }
.legal-page-main { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 34px 38px; box-shadow: 0 1px 0 rgba(15,23,42,.04) inset, 0 6px 24px -10px rgba(15,23,42,.1); }
.legal-page-title { margin: 0 0 4px; font-size: 1.75rem; font-weight: 600; color: var(--text); }
.legal-page .login-foot { margin: 24px 0 8px; }

.legal-body { font-size: 0.94rem; line-height: 1.65; color: var(--text); }
.legal-body h3 { font-size: 1.02rem; font-weight: 600; margin: 24px 0 8px; font-family: var(--font-display); }
.legal-body p { margin: 0 0 13px; color: var(--muted); }
.legal-body p strong, .legal-body li strong { color: var(--text); font-weight: 600; }
.legal-body ul { margin: 0 0 13px; padding-left: 20px; color: var(--muted); }
.legal-body li { margin: 5px 0; }
.legal-body a { color: var(--accent); }
.legal-updated { font-size: 0.82rem; color: var(--dim); font-style: italic; margin: 0 0 18px; }
@media (max-width: 560px) { .legal-page { padding: 16px; } .legal-page-main { padding: 24px 20px; } }
@media (max-width: 560px) {
  .login-foot { flex-direction: column; gap: 10px; text-align: center; margin-top: 20px; }
  .login-foot-links { gap: 14px; justify-content: center; }
}

/* Security / feature cards — one horizontal scroll row, hidden scrollbar,
   each card a different soft pastel colour */
.login-cards { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 6px;
  scroll-snap-type: x proximity; scrollbar-width: none; -ms-overflow-style: none; }
.login-cards::-webkit-scrollbar { width: 0; height: 0; display: none; }
.login-card2 { --c: var(--accent); flex: 0 0 256px; scroll-snap-align: start;
  display: flex; align-items: flex-start; gap: 13px; padding: 18px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--c) 22%, var(--border));
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 16%, var(--surface)) 0%, var(--surface) 82%);
  box-shadow: 0 1px 2px rgba(60,64,67,.06); transition: transform .15s ease, box-shadow .15s ease; }
.login-card2:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(60,64,67,.12); }
.login-card2:nth-child(1) { --c: #1a73e8; }
.login-card2:nth-child(2) { --c: #0f9d58; }
.login-card2:nth-child(3) { --c: #a142f4; }
.login-card2:nth-child(4) { --c: #f29900; }
.login-card2:nth-child(5) { --c: #e8457b; }
.login-card2:nth-child(6) { --c: #00acc1; }
.lc-ico { width: 40px; height: 40px; flex: none; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 22%, var(--surface)); color: var(--c); font-size: 1rem; }
.lc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lc-body strong { font-size: 0.92rem; font-weight: 600; color: var(--text); }
.lc-body span { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }

.login-card {
  width: 100%; max-width: 420px; margin: 0; padding: 40px 40px 34px;
  border: 1px solid var(--border); border-radius: 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 7%, var(--surface)) 0%, var(--surface) 58%);
  box-shadow: 0 1px 2px rgba(60,64,67,.08), 0 10px 34px rgba(60,64,67,.12);
}
.login-card h1 { justify-content: center; font-size: 1.5rem; font-weight: 500; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.login-card h1 i { color: var(--accent); }
.login-card p.sub { text-align: center; margin: 0 0 28px; color: var(--muted); font-size: 0.92rem; }
.login-card .field { margin-bottom: 20px; }
.login-card .field label { font-size: 0.82rem; }
.login-card .input { height: 50px; border-radius: 8px; font-size: 1rem; padding: 0 14px; }
.login-card .pw-wrap .input { padding-right: 44px; }
.login-card .btn-block { height: 48px; border-radius: 26px; font-size: 1rem; font-weight: 500; margin-top: 10px; }
.login-hero-mail { display: inline-block; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.3; border-radius: 6px; padding: 3px 7px; }
.login-remember { display: flex; align-items: center; gap: 9px; margin: 2px 0 8px; cursor: pointer;
  font-size: 0.9rem; color: var(--muted); user-select: none; }
.login-remember input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; margin: 0; }

@media (max-width: 880px) {
  .login-container { max-width: 480px; gap: 24px; }
  .login-split { grid-template-columns: 1fr; gap: 26px; max-width: none; justify-items: stretch; }
  .login-hero { text-align: center; }
  .login-hero-brand { font-size: 1.35rem; }
  .login-hero-title { font-size: 1.85rem; margin: 16px 0 8px; }
  .login-hero-sub { margin: 0 auto; max-width: none; }
  .login-features { display: none; }   /* keep the form front-and-centre on phones */
}
@media (max-width: 480px) { .login-card { padding: 30px 22px 26px; } }

/* ── Sidebar folder counts (Gmail-style) ────────────────────────────── */
.gm-flabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-fcount { margin-left: auto; font-size: 0.75rem; color: var(--muted); font-weight: 400; min-width: 14px; text-align: right; }
.gm-folder.has-unread { font-weight: 700; color: var(--text); }
.gm-folder.has-unread .gm-fcount { color: var(--text); font-weight: 700; }
.gm-folder.active.has-unread, .gm-folder.active.has-unread .gm-fcount { color: var(--accent); }

/* Hide the browser's native search clear (we have our own) */
.gm-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.gm-search input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

/* ── Overlay popup (confirm / password) ─────────────────────────────── */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 80; }
.ov-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 420px; padding: 22px; box-shadow: 0 10px 44px rgba(0,0,0,.32); }
.ov-title { margin: 0 0 8px; font-size: 1.12rem; font-weight: 500; }
.ov-msg { margin: 0 0 16px; color: var(--muted); font-size: 0.92rem; line-height: 1.5; word-break: break-word; }
.ov-field { display: flex; gap: 8px; margin-bottom: 12px; }
.ov-field .input { flex: 1; }
.ov-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── Manage domain (admin) — cards, ring, mailbox cards ─────────────── */
.admin-wrap { padding: 20px 22px 36px; display: flex; flex-direction: column; gap: 22px; max-width: 920px; }
.admin-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.admin-card { flex: 1 1 210px; display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05); transition: box-shadow .15s ease, border-color .15s ease; }
.admin-card:hover { box-shadow: 0 4px 16px rgba(16,24,40,.08); }
.admin-card-ico { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex: none; }
.ico-blue { background: #e8f0fe; color: #1a73e8; } .ico-green { background: #e6f4ea; color: #188038; }
.admin-card-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-card-num { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.admin-card-sm { font-size: 1.05rem; word-break: break-all; }
.admin-card-lbl { color: var(--muted); font-size: 0.8rem; }
.admin-ring { flex: none; }
.admin-dns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

/* Animated doughnuts (Chart.js) with centered value */
.admin-chart { position: relative; width: 72px; height: 72px; flex: none; }
.admin-chart canvas { display: block; width: 72px !important; height: 72px !important; }
.admin-chart-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700; line-height: 1; color: var(--text); }
.admin-chart-sub { font-size: 0.6rem; font-weight: 600; color: var(--muted); margin-top: 2px; letter-spacing: .02em; }
.admin-usage-txt { font-size: 0.78rem; color: var(--muted); margin-top: 6px; display: inline-flex; align-items: center; gap: 5px; }

/* Cache / live freshness hint by the Refresh button */
.gm-list-head-actions { display: flex; align-items: center; gap: 12px; }
.admin-meta { font-size: 0.76rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.admin-meta i { font-size: 0.8em; }
@media (max-width: 560px) { .admin-meta { display: none; } }

.dns-badge { font-size: 0.66rem; padding: 2px 7px; border-radius: 10px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.dns-badge.on { background: #e6f4ea; color: #137333; } .dns-badge.off { background: #fce8e6; color: #c5221f; }

.admin-create-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.admin-create-card h3 { margin: 0 0 14px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.admin-create-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-create-row #ad-local { flex: 0 1 160px; } .admin-create-row #ad-pass { flex: 1 1 200px; }
.admin-at { color: var(--muted); }
.admin-mbx-title { margin: 4px 0 0; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.admin-mbx-title .count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.admin-mbx { display: flex; flex-direction: column; gap: 10px; }
.mbx-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; transition: border-color .15s ease, background .15s ease; }
.mbx-card:hover { border-color: var(--accent-soft); background: var(--hover); }
.mbx-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.mbx-card-email { font-size: 0.95rem; word-break: break-all; }
.mbx-card-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.admin-badge { align-self: flex-start; padding: 2px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 700; }
.admin-badge.on { background: #e6f4ea; color: #137333; } .admin-badge.off { background: #fce8e6; color: #c5221f; }
.icon-btn { padding: 7px 9px; }
.mbx-admin-tag { font-size: 0.74rem; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.mbx-admin-tag i { color: var(--star); }
.admin-empty { color: var(--muted); padding: 24px; text-align: center; }
:root[data-theme="dark"] .ico-blue { background: #1c2a40; color: #8ab4f8; }
:root[data-theme="dark"] .ico-green { background: #17311f; color: #81c995; }
:root[data-theme="dark"] .dns-badge.on, :root[data-theme="dark"] .admin-badge.on { background: #17311f; color: #81c995; }
:root[data-theme="dark"] .dns-badge.off, :root[data-theme="dark"] .admin-badge.off { background: #3b1f1d; color: #f28b82; }

@media (max-width: 760px) {
  .admin-card { flex: 1 1 100%; }
}
@media (max-width: 560px) {
  .admin-wrap { padding: 16px 14px 32px; gap: 18px; }
  .admin-cards { gap: 12px; }
  .admin-create-card { padding: 16px; }
  .admin-create-row { gap: 10px; }
  .admin-create-row #ad-local, .admin-create-row #ad-pass { flex: 1 1 100%; }
  .admin-create-row .btn { flex: 1 1 auto; justify-content: center; }
  .mbx-card-email { font-size: 0.9rem; }
}

/* ── Gmail-matching polish (Manage view only) ────────────────────────── */
/* Pill buttons, circular icon actions, a flat hover-row list and lighter
   surfaces — the airy, rounded language of real Gmail. Scoped to #admin-view
   so the inbox / compose UI is untouched. */
#admin-view .btn { border-radius: 999px; padding-left: 16px; padding-right: 16px; }
#admin-view .icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; justify-content: center; }
#admin-view .admin-card { border-color: var(--row-border); }
#admin-view .admin-create-card { border-color: var(--row-border); }
#admin-view .input { border-radius: 10px; }

/* Mailbox list: one rounded surface, flat rows, thin dividers, full-row hover */
#admin-view .admin-mbx { gap: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
#admin-view .mbx-card { border: 0; border-radius: 0; border-bottom: 1px solid var(--row-border); background: transparent; padding: 12px 16px; }
#admin-view .mbx-card:last-child { border-bottom: 0; }
#admin-view .mbx-card:hover { background: var(--hover); }
#admin-view .admin-empty { padding: 28px; }

/* ── Shimmer skeleton (list loading) — visible sweep ────────────────── */
.msg-row.skeleton { cursor: default; }
.msg-row.skeleton:hover { box-shadow: none; }
.sk { display: inline-block; height: 14px; border-radius: 7px; position: relative; overflow: hidden; background: #e2e5ea; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: sk-shimmer 1.15s infinite; }
.sk-star { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.sk-avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.sk-from { width: 170px; flex: none; }
.sk-subject { flex: 1; }
.sk-date { width: 46px; flex: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sk { background: #2c2f34; }
  :root:not([data-theme="light"]) .sk::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent); }
}
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
.field { display: block; margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.pw-wrap { position: relative; }
.pw-wrap .input { width: 100%; padding-right: 40px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 8px; font-size: 0.95rem; line-height: 1; }
.pw-toggle:hover { color: var(--accent); }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 0.95rem; font-family: inherit; }
.input:focus { outline: none; border-color: var(--accent); }

/* ── Admin panel ───────────────────────────────────────────────────── */
.admin-create { margin: 16px; }
.admin-create-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-create-row .input { flex: 0 1 200px; width: auto; }
.admin-at { color: var(--muted); }
.admin-table { width: calc(100% - 32px); margin: 0 16px 24px; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.admin-table th, .admin-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--row-border); font-size: 0.9rem; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table th { color: var(--muted); font-weight: 600; background: var(--bg); }
.admin-actions-col { width: 300px; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-badge { padding: 2px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 600; }
.admin-badge.on { background: #e6f4ea; color: #137333; }
.admin-badge.off { background: #fce8e6; color: #c5221f; }
.admin-empty { color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: #fce8e6; color: var(--danger); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .gm-menu { display: inline-flex; }
  .gm-account-email { display: none; }
  .gm-sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 260px; z-index: 20;
    background: var(--surface); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .2s;
  }
  .gm-sidebar.open { transform: translateX(0); }
  .gm-main { border-radius: 0; border-left: 0; }
  .msg-from { width: 130px; }
}

/* ── Outbox (scheduled / queued mail) ─────────────────────────────────────── */
.outbox-list { padding: 8px 12px; display: flex; flex-direction: column; gap: 10px; }
.outbox-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px;
}
.outbox-meta { min-width: 0; }
.outbox-subject { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outbox-to { color: var(--muted, #5f6368); font-size: 0.85rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outbox-when { color: var(--accent, #bf2c31); font-size: 0.8rem; margin-top: 4px; }
.outbox-actions { display: flex; gap: 8px; flex-shrink: 0; }
.compose-schedule { padding: 5px 8px; border: 1px solid var(--border, #dadce0); border-radius: 8px; font: inherit; }
.muted { color: var(--muted, #5f6368); }
