/* befclips Mail — same design language as befclips.com:
   warm cream paper, forest-green ink, sage/lime/brick accents,
   Fraunces display + Inter body, hard offset shadows, pill buttons. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

/* Modernized befclips tokens — kept in sync with the workspace theme.css
   (soft layered shadows instead of hard offsets; light + dark). */
:root {
  --bg: #f7f0e6;
  --bg-alt: #efe7d8;
  --surface: #fffcf4;
  --surface-2: #f6efe1;
  --topbar-bg: rgba(255, 252, 244, 0.82);
  --ink: #1f2a1f;
  --ink-hover: #2c3b2d;
  --ink-70: rgba(29, 43, 31, 0.70);
  --ink-45: rgba(29, 43, 31, 0.45);
  --ink-25: rgba(29, 43, 31, 0.22);
  --ink-12: rgba(29, 43, 31, 0.12);
  --ink-06: rgba(29, 43, 31, 0.055);
  --text: #26332a;
  --text-dim: #55655a;
  --text-faint: #7c8a7e;
  --sage: #b9d9c4;
  --sage-soft: rgba(185, 217, 196, 0.35);
  --lime: #bfea4b;
  --lime-soft: rgba(191, 234, 75, 0.22);
  --lime-hover: #cbef63;
  --brick: #c53a20;
  --brick-soft: rgba(197, 58, 32, 0.10);
  --blue: #1e5bff;
  --amber: #b45309;
  --green-deep: #2e6b3f;
  --border: rgba(29, 43, 31, 0.14);
  --border-strong: rgba(29, 43, 31, 0.28);
  --ring: rgba(46, 107, 63, 0.40);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(31, 42, 31, 0.08), 0 1px 1px rgba(31, 42, 31, 0.04);
  --shadow: 0 4px 14px rgba(31, 42, 31, 0.10), 0 1px 3px rgba(31, 42, 31, 0.06);
  --shadow-lg: 0 18px 44px rgba(31, 42, 31, 0.18), 0 4px 12px rgba(31, 42, 31, 0.08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Georgia", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
}

:root[data-theme="dark"] {
  --bg: #16180f; --bg-alt: #1c1f14; --surface: #1f2218; --surface-2: #262a1d;
  --topbar-bg: rgba(31, 34, 24, 0.82);
  --ink: #edefe4; --ink-hover: #dfe3d2;
  --ink-70: rgba(237,239,228,0.70); --ink-45: rgba(237,239,228,0.42);
  --ink-25: rgba(237,239,228,0.22); --ink-12: rgba(237,239,228,0.12); --ink-06: rgba(237,239,228,0.06);
  --text: #e7e9dd; --text-dim: #b3bba7; --text-faint: #899279;
  --sage: #9ec7ad; --sage-soft: rgba(158,199,173,0.16);
  --lime: #c6ea5e; --lime-soft: rgba(198,234,94,0.15); --lime-hover: #d2f06e;
  --brick: #f0785c; --brick-soft: rgba(240,120,92,0.15);
  --blue: #7aa3ff; --amber: #e0a44a; --green-deep: #7fc496;
  --border: rgba(237,239,228,0.13); --border-strong: rgba(237,239,228,0.26);
  --ring: rgba(127,196,150,0.50);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.45);
  --shadow: 0 6px 20px rgba(0,0,0,0.48), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16180f; --bg-alt: #1c1f14; --surface: #1f2218; --surface-2: #262a1d;
    --topbar-bg: rgba(31, 34, 24, 0.82);
    --ink: #edefe4; --ink-hover: #dfe3d2;
    --ink-70: rgba(237,239,228,0.70); --ink-45: rgba(237,239,228,0.42);
    --ink-25: rgba(237,239,228,0.22); --ink-12: rgba(237,239,228,0.12); --ink-06: rgba(237,239,228,0.06);
    --text: #e7e9dd; --text-dim: #b3bba7; --text-faint: #899279;
    --sage: #9ec7ad; --sage-soft: rgba(158,199,173,0.16);
    --lime: #c6ea5e; --lime-soft: rgba(198,234,94,0.15); --lime-hover: #d2f06e;
    --brick: #f0785c; --brick-soft: rgba(240,120,92,0.15);
    --blue: #7aa3ff; --amber: #e0a44a; --green-deep: #7fc496;
    --border: rgba(237,239,228,0.13); --border-strong: rgba(237,239,228,0.26);
    --ring: rgba(127,196,150,0.50);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.45);
    --shadow: 0 6px 20px rgba(0,0,0,0.48), 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--ink-45) transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}
h1, h2, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: var(--ink); }

/* focus visibility (accessibility) */
:focus-visible { outline: 3px solid var(--green-deep); outline-offset: 2px; border-radius: 4px; }

svg.icon {
  width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
}

/* ---------- buttons ---------- */
button, .btn {
  font-family: var(--font); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: box-shadow .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { box-shadow: var(--shadow); border-color: var(--ink-45); }
button:active, .btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
button.primary, .btn.primary { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
button.ghost { background: transparent; box-shadow: none; border-color: transparent; }
button.ghost:hover { background: var(--ink-06); box-shadow: none; transform: none; }
button.icon-btn { min-width: 44px; padding: 0 10px; }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

/* ---------- inputs ---------- */
label.field { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-70); }
input[type=text], input[type=email], input[type=password], input.text {
  width: 100%; min-height: 44px; padding: 10px 14px; font-family: var(--font); font-size: 15px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
input::placeholder { color: var(--ink-45); }

.card {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ===================================================================
   LOGIN
   =================================================================== */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-4); }
.login-card { width: 100%; max-width: 400px; padding: 32px 30px; }
.login-brand {
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  display: flex; align-items: center; gap: 11px; margin-bottom: 4px;
}
.login-brand::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%;
  background: var(--lime); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
}
.login-sub { color: var(--ink-45); font-size: 14px; margin-bottom: 26px; }
.login-card .row { margin-bottom: 18px; }
.pw-wrap { position: relative; }
.pw-wrap button.reveal {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 34px; min-width: 34px; padding: 0 8px; box-shadow: none; border-color: transparent; background: transparent;
}
.pw-wrap button.reveal:hover { background: var(--ink-06); transform: translateY(-50%); box-shadow: none; }
.form-error {
  display: none; background: var(--brick-soft); color: var(--brick);
  border: 1.5px solid var(--brick); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}
.form-error.show { display: block; }
.login-card button[type=submit] { width: 100%; }

/* ===================================================================
   APP SHELL
   =================================================================== */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; border-bottom: 1px solid var(--border-strong);
  background: var(--topbar-bg); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50; gap: 12px;
}
header.topbar .brand {
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  display: flex; align-items: center; gap: 10px;
}
header.topbar .brand::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  background: var(--lime); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm);
}
header.topbar .spacer { flex: 1; }
header.topbar .who-badge {
  font-size: 13px; font-weight: 600; color: var(--ink-70);
  background: var(--sage-soft); border: 1.5px solid var(--ink-25);
  border-radius: 999px; padding: 5px 13px;
}

main.mail-app {
  display: grid;
  grid-template-columns: 210px minmax(300px, 400px) 1fr;
  gap: var(--sp-3); align-items: start;
  padding: var(--sp-4) var(--sp-5); max-width: 1500px; margin: 0 auto;
}
.pane { min-width: 0; }

/* ---------- toolbar ---------- */
.list-toolbar { display: flex; gap: var(--sp-2); align-items: center; padding: 10px 12px; border-bottom: 1.5px solid var(--ink-12); }
.list-toolbar input { min-height: 38px; box-shadow: none; }
.folder-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; }

/* ---------- folders ---------- */
.folder-list { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.folder {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; background: none; color: var(--ink-70);
  font-weight: 600; font-size: 14px; text-align: left; cursor: pointer;
  transition: background .15s ease;
}
.folder:hover { background: var(--ink-06); }
.folder.active { background: var(--surface); border-color: var(--ink); box-shadow: var(--shadow-sm); color: var(--ink); }
.folder .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count {
  font-size: 12px; font-weight: 700; min-width: 22px; text-align: center;
  background: var(--lime); color: var(--ink); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 1px 7px;
}
.folder .count.zero { display: none; }
.folder.intro-folder { color: var(--ink); font-family: var(--font-display); font-weight: 600; }
.folder.intro-folder .icon { color: var(--brick); }
.folder.intro-folder.active { background: var(--sage); border-color: var(--ink); }
.folder-divider { height: 1.5px; background: var(--ink-06); margin: 8px 6px; }

/* ---------- message list (FIXED two-row grid) ---------- */
.msg-list { display: flex; flex-direction: column; max-height: calc(100dvh - 190px); overflow-y: auto; }
.msg-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-rows: auto auto;
  /* Spacing on the 4/8 rhythm. row-gap was 5px against 1.3/1.35 line-heights,
     which put the sender and subject almost on top of each other — the two
     lines read as one block instead of two fields. 6px still separates them
     cleanly because the line-heights below are doing the real work. */
  column-gap: 12px; row-gap: 6px;
  width: 100%; padding: 12px 16px; text-align: left; cursor: pointer;
  /* A 1.5px rule at every row turned the list into a dense ladder; 1px reads
     as a separator without competing with the text. */
  background: none; border: 0; border-bottom: 1px solid var(--ink-12);
  border-radius: 0; box-shadow: none; min-height: 0;
  /* .msg-list is a capped flex column, so rows are flex items. Without this
     they inherit flex-shrink:1 and, once the list overflows, the browser
     compresses every row instead of scrolling — with min-height:0 removing the
     min-content floor, the sender and subject collapse onto each other and
     bleed into the next row. Only visible once the inbox is taller than the
     cap, which is why a handful of messages looked fine. */
  flex: 0 0 auto;
  /* button's base rule sets align/justify-content:center; harmless for the
     inline-flex default but wrong for a grid container. */
  justify-content: stretch; align-items: center;
  transition: background .12s ease;
}
.msg-row:hover { background: var(--ink-06); transform: none; box-shadow: none; }
.msg-row.active { background: var(--sage-soft); }
.msg-row .dot { grid-row: 1 / span 2; align-self: start; margin-top: 7px; width: 9px; height: 9px; border-radius: 50%; background: transparent; }
.msg-row.unseen .dot { background: var(--brick); }
.msg-row .who { grid-column: 2; grid-row: 1; font-weight: 700; font-size: 14px; line-height: 1.45; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.seen .who { font-weight: 500; color: var(--ink-70); }
.msg-row .right { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
/* ink-45 measures 2.67:1 on the light surface — under the 4.5:1 AA floor for
   the timestamp and the 3:1 floor for the status glyphs. ink-70 is 5.51:1
   light / 7.47:1 dark. */
.msg-row .right svg { width: 14px; height: 14px; color: var(--ink-70); }
.msg-row .when { font-size: 12px; color: var(--ink-70); font-variant-numeric: tabular-nums; }
.msg-row .subj { grid-column: 2 / 4; grid-row: 2; font-size: 14px; line-height: 1.5; color: var(--ink-70); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.unseen .subj { color: var(--ink); }

/* ---------- reader ---------- */
.reader { padding: 22px 24px; min-height: calc(100dvh - 160px); }
.reader-top { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.reader-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.reader-actions .icon-btn { min-width: 40px; padding: 0 8px; color: var(--ink-70); }
.reader-actions .icon-btn:hover { color: var(--ink); }
.reader-actions .icon-btn.danger:hover { background: var(--brick); color: #fff; }
.reader-actions .icon-btn svg { width: 18px; height: 18px; }
.reader-head { border-bottom: 1.5px solid var(--ink-12); padding-bottom: 16px; margin-bottom: 16px; }
.reader-head h2 { font-size: 22px; margin-bottom: 10px; line-height: 1.3; }
.reader-meta { font-size: 13px; color: var(--ink-70); display: flex; flex-direction: column; gap: 3px; }
.reader-meta .addr { font-weight: 700; color: var(--ink); }
.reader-meta .when { color: var(--ink-45); font-variant-numeric: tabular-nums; }
.reader-body { font-size: 14.5px; line-height: 1.65; }
.reader-body pre.plain { white-space: pre-wrap; word-break: break-word; font-family: var(--font); margin: 0; }
iframe.html-body { width: 100%; min-height: 46vh; border: 1.5px solid var(--ink-12); background: #fff; border-radius: var(--radius-sm); }
.privacy-note { font-size: 12px; color: var(--ink-45); margin-top: 12px; display: flex; align-items: center; gap: 6px; }
.attach-strip { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 18px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px; background: var(--surface); color: var(--ink-70);
}
.attach-chip svg { width: 14px; height: 14px; }
button.attach-chip { cursor: pointer; font-family: inherit; }
button.attach-chip.clean:hover { background: var(--sage, #b9d9c4); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
button.attach-chip.clean:active { transform: translate(2px, 2px); box-shadow: none; }
.attach-chip.infected { border-color: var(--brick, #c53a20); color: var(--brick, #c53a20); background: color-mix(in srgb, var(--brick, #c53a20) 8%, var(--surface)); cursor: not-allowed; }
.attach-chip.unknown { border-style: dashed; color: var(--ink-45); cursor: not-allowed; }
.attach-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; margin-left: 2px; }
.attach-badge svg { width: 11px; height: 11px; }
.attach-badge.ok { background: var(--lime, #bfea4b); color: var(--ink); }
.attach-badge.bad { background: var(--brick, #c53a20); color: #fff; }
.attach-badge.warn { background: var(--ink-12); color: var(--ink-70); }

/* ---------- time menu (schedule / snooze) ---------- */
.pop-menu {
  position: absolute; z-index: 1200; min-width: 230px;
  background: var(--surface, #fffdf7); border: 1px solid var(--border-strong); border-radius: var(--radius-sm, 12px);
  box-shadow: 5px 5px 0 var(--ink); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.pop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; text-align: left; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: none; border: none; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.pop-item:hover { background: var(--sage, #b9d9c4); }
.pop-hint { font-size: 11px; font-weight: 600; color: var(--ink-45); }
.pop-item:hover .pop-hint { color: var(--ink-70); }
.pop-custom { display: flex; gap: 6px; padding: 8px 8px 4px; border-top: 1.5px solid var(--ink-12); margin-top: 4px; }
.pop-dt {
  flex: 1; min-width: 0; font-family: inherit; font-size: 12px; color: var(--ink);
  border: 1.5px solid var(--ink-12); border-radius: 8px; padding: 5px 7px; background: var(--surface);
}
.pop-set {
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--ink);
  background: var(--lime, #bfea4b); border: 1px solid var(--border-strong); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.pop-set:active { transform: translateY(1px); }
#composeSchedule { display: inline-flex; align-items: center; gap: 6px; }
#composeSchedule svg { width: 15px; height: 15px; }

/* mobile back button (hidden on desktop) */
.mobile-back { display: none; }

/* ---------- states ---------- */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 20px; color: var(--ink-45); text-align: center; min-height: 40vh;
}
.state svg { width: 30px; height: 30px; }
.state.err { color: var(--brick); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 11px 18px;
  background: var(--ink); color: var(--surface); border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 100; box-shadow: var(--shadow);
}
.toast.error { background: var(--brick); }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1000px) {
  main.mail-app { grid-template-columns: 170px 1fr; }
  .pane.reader-pane { display: none; }
  main.mail-app.reading .pane.list-pane { display: none; }
  main.mail-app.reading .pane.folders-pane { display: none; }
  main.mail-app.reading .pane.reader-pane { display: block; grid-column: 1 / -1; }
  .mobile-back { display: inline-flex; margin-bottom: 12px; }
}
@media (max-width: 640px) {
  main.mail-app { grid-template-columns: 1fr; padding: var(--sp-3); }
  main.mail-app .pane.folders-pane { display: none; }
  main.mail-app.folders .pane.folders-pane { display: block; }
  main.mail-app.folders .pane.list-pane { display: none; }
  header.topbar { padding: 12px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------- compose */
.compose-btn { display: inline-flex; align-items: center; gap: 8px; margin-left: 18px; }
.compose-btn svg { width: 17px; height: 17px; }

.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(29, 43, 31, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; overflow-y: auto;
}
.modal-scrim[hidden] { display: none; }
.compose-card { width: 100%; max-width: 640px; padding: 0; overflow: hidden; }
.compose-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1.5px solid var(--ink-12);
}
.compose-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; flex: 1; }
.compose-form { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.compose-form .field { display: flex; align-items: center; gap: 12px; margin: 0; }
.compose-form .field > span {
  width: 62px; flex: none; text-align: right;
  font-weight: 600; font-size: 13px; color: var(--ink-70);
}
.compose-form .field input { flex: 1; }
.compose-form textarea {
  width: 100%; resize: vertical; min-height: 200px; line-height: 1.6;
  font-family: var(--font); font-size: 14.5px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 12px 14px;
}
.compose-foot { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.compose-foot .primary { display: inline-flex; align-items: center; gap: 7px; }
.compose-foot .primary svg { width: 16px; height: 16px; }
.compose-status { font-size: 13px; font-weight: 600; color: var(--brick); }

@media (max-width: 640px) {
  .compose-btn span { display: none; }
  .compose-form .field { flex-direction: column; align-items: stretch; gap: 5px; }
  .compose-form .field > span { width: auto; text-align: left; }
}

/* ---- canned templates (compose toolbar) */
.compose-tools {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1.5px solid var(--ink-12);
}
.tmpl-label { font-weight: 600; font-size: 13px; color: var(--ink-70); }
.tmpl-picker {
  min-height: 38px; padding: 6px 12px; font-family: var(--font); font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: 999px; box-shadow: var(--shadow-sm); cursor: pointer;
}
.tmpl-del { min-width: 38px; padding: 0 9px; color: var(--brick); }
.tmpl-del svg { width: 16px; height: 16px; }
.tmpl-save { font-size: 13px; }
@media (max-width: 640px) {
  .tmpl-label { display: none; }
  .tmpl-picker { max-width: 150px; }
}

/* ---- masked aliases modal */
.masks-card { width: 100%; max-width: 620px; padding: 0; overflow: hidden; }
.masks-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.masks-intro { font-size: 13px; color: var(--ink-70); margin: 0; line-height: 1.55; }
.mask-form { display: flex; gap: 8px; flex-wrap: wrap; }
.mask-form input { flex: 1; min-width: 140px; }
.mask-form .primary { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.mask-form .primary svg { width: 16px; height: 16px; }
.masks-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.mask-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  background: var(--surface);
  flex: none;  /* .masks-list is a capped flex column — see .msg-row. */
}
.mask-row.off { opacity: 0.62; background: var(--bg-alt); }
.mask-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mask-addr {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  min-height: 32px; padding: 3px 10px; font-size: 13.5px; font-weight: 700;
  border-radius: 999px; border: 1.5px solid var(--ink-12); background: var(--sage-soft); box-shadow: none;
  max-width: 100%;
}
.mask-addr span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mask-addr:hover { border-color: var(--ink); transform: none; box-shadow: var(--shadow-sm); }
.mask-addr svg { width: 14px; height: 14px; flex: none; }
.mask-meta { font-size: 12px; color: var(--ink-70); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mask-status {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
}
.mask-row.on .mask-status { background: var(--lime); }
.mask-row.off .mask-status { background: transparent; color: var(--ink-70); }
.mask-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.mask-toggle { font-size: 13px; min-height: 38px; padding: 0 14px; }
.mask-del { min-width: 38px; padding: 0 9px; }
.mask-del svg { width: 16px; height: 16px; }
@media (max-width: 640px) {
  #btnMasks span, #btnLogout span { display: none; }
  .mask-row { flex-wrap: wrap; }
}

/* ===================================================================
   Modernization add-ons — modal primitives (ui.js), theme toggle,
   form rows, empty states. Kept in sync with the workspace theme.css.
   =================================================================== */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-70); }
.form-row textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; font-family: var(--font); font-size: 15px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); resize: vertical;
}

.theme-toggle { min-height: 36px; min-width: 36px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: transparent; box-shadow: none; color: var(--text-dim); }
.theme-toggle:hover { background: var(--ink-06); border-color: var(--border); box-shadow: none; color: var(--ink); transform: none; }
.theme-toggle .icon { width: 18px; height: 18px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 20, 12, 0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; animation: overlay-in 0.15s ease; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 460px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modal-in 0.2s cubic-bezier(0.2,0.7,0.3,1); }
@keyframes modal-in { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 0; }
.modal-head h3 { font-family: var(--font-display); font-size: 19px; margin: 0; text-transform: none; letter-spacing: -0.01em; color: var(--ink); }
.modal-head .modal-x { min-height: 32px; min-width: 32px; padding: 0; border-radius: 8px; border: none; background: transparent; box-shadow: none; color: var(--text-faint); }
.modal-head .modal-x:hover { background: var(--ink-06); color: var(--ink); box-shadow: none; transform: none; }
.modal-body { padding: 14px 20px; }
.modal-body p.modal-msg { margin: 2px 0 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 20px 18px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 44px 22px; color: var(--text-faint); font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-state .empty-icon { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-dim); margin-bottom: 8px; }
.empty-state .empty-icon svg.icon { width: 22px; height: 22px; }
.empty-state .big { font-family: var(--font-display); font-size: 18px; color: var(--text-dim); margin-bottom: 2px; }
.empty-state .sub { max-width: 300px; }
.empty-state .cta { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
