/* AppAlbania Mail — one stylesheet, no external fonts (CSP). Light + dark: follows prefers-color-scheme,
   or <html data-theme="light|dark"> (Settings -> Appearance; set before first paint by js/theme-boot.js). */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --surface-3: #e8ecf3;
  --text: #111827;
  --text-2: #374151;
  --muted: #5b6474;
  --faint: #8b94a6;
  --border: #e2e6ee;
  --border-soft: #edf0f5;
  --accent: #3b5bdb;
  --accent-hover: #3250c4;
  --accent-text: #ffffff;
  --accent-soft: #edf1fe;
  --accent-ring: rgba(59, 91, 219, .22);
  --row-hover: #f6f8fc;
  --row-active: #e8edfd;
  --row-selected: #f1f4fe;
  --row-unread: #fbfcff;
  --star: #e0a10b;
  --danger: #d0362c;
  --danger-bg: #fef3f2;
  --danger-text: #b42318;
  --ok: #12805c;
  --notice-bg: #f5f7fb;
  --notice-border: #e4e8f0;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, .09), 0 2px 6px rgba(17, 24, 39, .05);
  --shadow-lg: 0 24px 60px rgba(17, 24, 39, .16), 0 4px 14px rgba(17, 24, 39, .07);
  --toast-bg: #111827;
  --toast-text: #f9fafb;
  --tip-bg: #1f2533;
  --tip-text: #f5f7fb;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --logo-filter: none;
  --frame-border: 0;
  color-scheme: light;
}

/* dark: when the system is dark (unless Light was chosen), or when Dark was chosen */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #151821;
    --surface-2: #1b1f2a;
    --surface-3: #252b38;
    --text: #e8eaf0;
    --text-2: #c5cad6;
    --muted: #9aa3b5;
    --faint: #6c7589;
    --border: #262b37;
    --border-soft: #1e222c;
    --accent: #8ea6ff;
    --accent-hover: #a5b8ff;
    --accent-text: #0f1115;
    --accent-soft: rgba(142, 166, 255, .13);
    --accent-ring: rgba(142, 166, 255, .30);
    --row-hover: #191d27;
    --row-active: #20263a;
    --row-selected: #1b2131;
    --row-unread: #171b25;
    --star: #f5b83d;
    --danger: #ff6b61;
    --danger-bg: #2c1614;
    --danger-text: #ff9b92;
    --ok: #47cd89;
    --notice-bg: #1a1e28;
    --notice-border: #262b37;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .4);
    --toast-bg: #e8eaf0;
    --toast-text: #0f1115;
    --tip-bg: #e8eaf0;
    --tip-text: #111827;
    color-scheme: dark;
    --logo-filter: invert(1) hue-rotate(180deg) brightness(1.05);
    --frame-border: 1px solid var(--border);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #151821;
  --surface-2: #1b1f2a;
  --surface-3: #252b38;
  --text: #e8eaf0;
  --text-2: #c5cad6;
  --muted: #9aa3b5;
  --faint: #6c7589;
  --border: #262b37;
  --border-soft: #1e222c;
  --accent: #8ea6ff;
  --accent-hover: #a5b8ff;
  --accent-text: #0f1115;
  --accent-soft: rgba(142, 166, 255, .13);
  --accent-ring: rgba(142, 166, 255, .30);
  --row-hover: #191d27;
  --row-active: #20263a;
  --row-selected: #1b2131;
  --row-unread: #171b25;
  --star: #f5b83d;
  --danger: #ff6b61;
  --danger-bg: #2c1614;
  --danger-text: #ff9b92;
  --ok: #47cd89;
  --notice-bg: #1a1e28;
  --notice-border: #262b37;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .4);
  --toast-bg: #e8eaf0;
  --toast-text: #0f1115;
  --tip-bg: #e8eaf0;
  --tip-text: #111827;
  color-scheme: dark;
  --logo-filter: invert(1) hue-rotate(180deg) brightness(1.05);
  --frame-border: 1px solid var(--border);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
kbd {
  font: 600 11px/1 var(--mono); padding: 3px 5px; border-radius: 5px; min-width: 18px; display: inline-block; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text-2);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2);
  transition: background-color .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn:disabled { opacity: .45; cursor: default; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px; text-decoration: none;
  transition: background-color .12s, border-color .12s, filter .12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary .icon { width: 16px; height: 16px; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: inherit; }
.btn-link:hover { text-decoration: underline; }

/* tooltip bubble (js/tooltip.js): dark on light, light on dark */
.tip {
  position: fixed; z-index: 2000; display: flex; align-items: center; gap: 8px; max-width: 280px;
  padding: 5px 8px; border-radius: 7px; background: var(--tip-bg); color: var(--tip-text);
  font-size: 12.5px; font-weight: 500; line-height: 1.3; white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-md); opacity: 0; transform: translateY(2px); transition: opacity .1s, transform .1s;
}
.tip[data-side="bottom"] { transform: translateY(-2px); }
.tip.on { opacity: 1; transform: none; }
.tip kbd {
  font: 600 11px/1 var(--mono); min-width: 0; padding: 2px 5px; border-radius: 4px; border: 0;
  background: color-mix(in srgb, var(--tip-text) 18%, transparent); color: var(--tip-text);
}
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }

/* ------------------------------------------------------------------ layout */

.app {
  display: grid;
  grid-template-columns: 240px 400px minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg); padding: 14px 10px 10px;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 12px; }
.sb-logo { display: inline-flex; align-items: center; }
.sb-logo img { height: 40px; width: auto; display: block; }
.sb-logo img, .auth-logo img { filter: var(--logo-filter); }
.sb-close { display: none; }

.compose-btn {
  display: flex; align-items: center; gap: 10px; height: 42px; margin: 0 4px 14px; padding: 0 16px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font-weight: 650; font-size: 14px; box-shadow: var(--shadow-sm);
  transition: background-color .12s, transform .06s;
}
.compose-btn:hover { background: var(--accent-hover); }
.compose-btn:active { transform: translateY(1px); }

.sb-scroll {
  flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px 18px; scrollbar-width: thin;
  /* subtle fade where the list runs under the footer */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 12px 8px; }
.nav-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 2px 10px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px;
  border: 0; border-radius: 8px; background: none; color: var(--text-2); text-decoration: none;
  font-size: 14px; text-align: left; white-space: nowrap;
  transition: background-color .1s, color .1s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent); }
.nav-item .icon { width: 17px; height: 17px; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12.5px; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; color: var(--text-2); }
.badge:empty { display: none; }
.badge.strong { font-weight: 700; color: var(--text); }
.nav-item.active .badge { color: var(--accent); }
.badge.muted { color: var(--muted); font-weight: 400; }

.acc-row { display: flex; align-items: center; }
.acc-toggle {
  width: 20px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--faint); padding: 0; border-radius: 6px;
}
.acc-toggle:hover { color: var(--text); }
.acc-toggle .icon { width: 14px; height: 14px; transition: transform .15s; }
.acc-toggle.open .icon { transform: rotate(90deg); }
.acc-item { padding-left: 6px; }
.acc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--acc, var(--faint)); flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc, #888) 22%, transparent); }
.acc-error {
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.folder-list { list-style: none; margin: 1px 0 6px; padding: 0; }
.folder-item { height: 30px; font-size: 13.5px; padding-left: calc(30px + var(--depth, 0) * 14px); }
.folder-item .icon { width: 15px; height: 15px; color: var(--faint); }
.folder-item.active .icon { color: var(--accent); }

.sb-foot { border-top: 1px solid var(--border); margin-top: 4px; padding: 8px 2px 0; display: flex; align-items: center; gap: 2px; flex: none; }
.sb-foot .logout-form { margin: 0 0 0 auto; display: flex; }
.sb-foot .icon-btn { color: var(--muted); }
.sb-foot .icon-btn.active { background: var(--accent-soft); color: var(--accent); }

.scrim { display: none; }

/* ------------------------------------------------------------------ list pane */

.list-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.list-head { position: relative; padding: 12px 14px 10px; border-bottom: 1px solid var(--border); }
.list-titlebar { display: flex; align-items: center; gap: 8px; height: 34px; margin-bottom: 10px; }
.list-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { flex: 1; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 2px; }
.menu-btn { display: none; margin-left: -6px; }
#refresh-btn.spinning .icon { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 9px; color: var(--muted);
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.search:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .icon { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font-size: 13.5px; height: 100%; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within .search-kbd { display: none; }

.bulk {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: 0 10px 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bulk-all { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; white-space: nowrap; margin-right: auto; }
.bulk-all input, .row-check { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.bulk-actions { display: flex; gap: 0; }
.bulk-actions .icon-btn { width: 32px; }

.list-scroll { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; }
.msg-list { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative; display: flex; align-items: flex-start; gap: 6px;
  padding: 10px 14px 11px 10px; border-bottom: 1px solid var(--border-soft);
  cursor: default; user-select: none; contain: layout style;
}
.row.unread { background: var(--row-unread); }
.row:hover { background: var(--row-hover); }
.row.selected { background: var(--row-selected); }
.row.active { background: var(--row-active); }
.row.active::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); pointer-events: none; }
.row .bar { position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--acc); }
.row:not(.unread) .bar { background: color-mix(in srgb, var(--acc) 70%, var(--surface)); }
/* account name tag (multi-account views only): small chip in the account colour, left of the subject */
.acc-chip { display: none; }
.app:not([data-badges="off"]) .acc-chip {
  display: inline-block; flex: none; max-width: 120px; padding: 1px 7px; border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; font-weight: 600; line-height: 16px; letter-spacing: .01em; background: var(--acc); color: var(--chip-fg, #fff);
}
/* vertical layout: a rotated pill in the left gutter (same colours); the checkbox sits to its right */
.acc-tag-v { display: none; }
.app[data-tag-style="vertical"] .acc-chip { display: none; }
.app[data-tag-style="vertical"]:not([data-badges="off"]) .acc-tag-v {
  display: block; position: absolute; left: 8px; top: 5px; bottom: 5px; width: 18px;
  transform: rotate(180deg); writing-mode: vertical-rl;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; box-sizing: border-box;
  border-radius: 999px; background: var(--acc); color: var(--chip-fg, #fff);
  font-size: 10px; font-weight: 600; line-height: 18px; letter-spacing: .01em; padding: 3px 0;
}
.app[data-tag-style="vertical"]:not([data-badges="off"]) .row:has(.acc-tag-v) { padding-left: 34px; }
.row:not(.unread) .acc-chip, .row:not(.unread) .acc-tag-v { opacity: .85; }
.tag-style-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; }
.tag-style-row .switch-hint { flex-basis: 100%; }
.seg.disabled { opacity: .5; }
.seg-btn:disabled { cursor: not-allowed; }
.row.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } }

.check { position: relative; width: 22px; height: 20px; flex: none; display: flex; align-items: center; justify-content: center; }
.row-check { opacity: 0; transition: opacity .1s; }
.row:hover .row-check, .selecting .row-check, .row.selected .row-check, .row-check:focus-visible { opacity: 1; }
.row.unread .check::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); pointer-events: none;
  transition: opacity .1s;
}
.row.unread:hover .check::after, .selecting .row.unread .check::after { opacity: 0; }

.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 6px; height: 21px; }
.from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--text-2); font-weight: 500; }
.row.unread .from { color: var(--text); font-weight: 700; }
.row-flag { width: 14px; height: 14px; color: var(--faint); }
.date { flex: none; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.row.unread .date { color: var(--accent); font-weight: 650; }
.row-sub { display: flex; align-items: center; gap: 6px; height: 21px; margin-top: 1px; }
.subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; color: var(--text-2); font-weight: 400; }
.row.unread .subject { color: var(--text); font-weight: 700; }
.snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.45; color: var(--muted); margin-top: 1px; }
.star-btn {
  width: 24px; height: 22px; margin-right: -4px; padding: 0; border: 0; background: none; color: var(--faint);
  display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; opacity: 0; flex: none;
  transition: opacity .1s, color .1s;
}
.star-btn .icon { width: 16px; height: 16px; }
.row:hover .star-btn, .star-btn.on, .star-btn:focus-visible { opacity: 1; }
.star-btn:hover { color: var(--star); }
.star-btn.on { color: var(--star); }

.row.skeleton { pointer-events: none; }
.sk { height: 10px; border-radius: 5px; background: var(--surface-3); margin: 5px 0 9px 26px; animation: pulse 1.2s ease-in-out infinite; }
.sk-a { width: 45%; } .sk-b { width: 75%; } .sk-c { width: 90%; margin-bottom: 2px; }
@keyframes pulse { 50% { opacity: .5; } }

.list-foot { min-height: 1px; }
.list-loading { display: flex; justify-content: center; padding: 18px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.list-end { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; }
.load-more { display: flex; margin: 16px auto; }
.list-empty { text-align: center; padding: 64px 24px; color: var(--text-2); }
.list-empty .icon { width: 36px; height: 36px; color: var(--faint); stroke-width: 1.4; }
.list-empty p { margin: 10px 0 0; }
.list-error { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 24px; color: var(--danger-text); }

/* ------------------------------------------------------------------ reader */

.reader-pane { position: relative; min-width: 0; min-height: 0; background: var(--surface); display: flex; flex-direction: column; }
.reader-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.reader-empty .icon { width: 44px; height: 44px; stroke-width: 1.2; color: var(--faint); }
.reader-empty p { margin: 10px 0 0; }
.reader { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.reader-toolbar {
  display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 14px; flex: none;
  border-bottom: 1px solid var(--border);
}
.reader-toolbar .back-btn { display: none; }
.tb-group { display: flex; gap: 2px; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; flex: none; }
.reader-toolbar .starred { color: var(--star); }
.reader-toolbar .tb-group:last-child { margin-left: auto; }

.reader-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.reader-top { padding: 24px 28px 14px; flex: none; }
.reader-subject { font-size: 23px; line-height: 1.28; font-weight: 700; letter-spacing: -.022em; margin: 0 0 18px; overflow-wrap: anywhere; color: var(--text); }
.sender { display: flex; align-items: flex-start; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; letter-spacing: .02em; color: #fff;
  background: var(--acc, var(--faint));
}
.sender-main { flex: 1; min-width: 0; }
.sender-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.sender-name { font-weight: 600; font-size: 15px; color: var(--text); }
.sender-email { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.sender-to { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.sender-to .acc-dot { width: 7px; height: 7px; box-shadow: none; }
.reader-date { flex: none; font-size: 14px; color: var(--muted); padding-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
/* "details": a plain link, no box; the focus ring only for keyboard focus */
.rcpt summary { cursor: pointer; color: var(--accent); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 2px; border-radius: 4px; padding: 0 2px; }
.rcpt summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.rcpt summary:focus { outline: none; }
.rcpt summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rcpt summary::-webkit-details-marker { display: none; }
.rcpt summary::marker { content: ""; }
.rcpt-body { margin-top: 8px; padding: 10px 12px; background: var(--notice-bg); border: 1px solid var(--notice-border); border-radius: 8px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; flex-basis: 100%; }
.rcpt-body b { font-weight: 600; color: var(--text); }
.rcpt[open] { flex-basis: 100%; }

.notice {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 8px 8px 8px 12px; min-height: 40px;
  border-radius: 10px; background: var(--notice-bg); border: 1px solid var(--notice-border); color: var(--text-2); font-size: 13.5px;
}
.notice .icon { width: 16px; height: 16px; color: var(--muted); }
.notice .btn-link { padding: 5px 10px; border-radius: 7px; }
.notice .btn-link:hover { background: var(--accent-soft); text-decoration: none; }
.notice span { flex: 1; }
.notice-error { background: var(--danger-bg); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice-error .icon { color: var(--danger-text); }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip-att {
  position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; overflow: hidden;
  transition: border-color .12s, background-color .12s;
}
a.chip-att:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip-att .icon { width: 16px; height: 16px; color: var(--muted); }
.att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 500; }
.att-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.att-action { opacity: .7; }

.body-wrap { flex: 1 0 60vh; display: flex; padding: 4px 16px 16px; min-height: 60vh; position: relative; }
/* a frame still loading sits invisibly over the skeleton (or the previous frame) and takes its place on load */
.body-frame.pending { position: absolute; inset: 0; visibility: hidden; }
.body-wrap.loading::before { content: ""; flex: 1; margin: 12px 4px; border-radius: 8px; background: linear-gradient(var(--surface-2), var(--surface-2)) 0 0 / 70% 10px no-repeat, linear-gradient(var(--surface-2), var(--surface-2)) 0 26px / 90% 10px no-repeat, linear-gradient(var(--surface-2), var(--surface-2)) 0 52px / 55% 10px no-repeat; animation: pulse 1.2s ease-in-out infinite; }
.body-frame { flex: 1; width: 100%; border: var(--frame-border); background: #fff; border-radius: 8px; display: block; }

/* ------------------------------------------------------------------ settings */

.app[data-view="settings"] .list-pane, .app[data-view="settings"] .reader-pane { display: none; }
.settings-pane {
  grid-column: 2 / -1; grid-row: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--border);
}
.st-head { flex: none; padding: 12px 24px 0; border-bottom: 1px solid var(--border); }
.st-titlebar { display: flex; align-items: center; gap: 8px; height: 34px; margin-bottom: 8px; }
.st-title { flex: 1; font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.st-back .icon { width: 15px; height: 15px; }
.st-tabs { display: flex; gap: 4px; margin-bottom: -1px; overflow-x: auto; scrollbar-width: none; }
.st-tab {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; flex: none;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px;
  border-bottom: 2px solid transparent; transition: color .12s, border-color .12s;
}
.st-tab .icon { width: 16px; height: 16px; }
.st-tab:hover { color: var(--text); }
.st-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.st-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; background: var(--bg); }
.st-body { max-width: 780px; margin: 0 auto; padding: 24px 24px 64px; }
.st-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.st-section-head h2 { font-size: 20px; letter-spacing: -.015em; margin: 0 0 4px; }
.st-section-head p { margin: 0; font-size: 13.5px; }
.st-section-head .btn { flex: none; }
.st-empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; }
.st-empty .icon { width: 32px; height: 32px; stroke-width: 1.4; color: var(--faint); }
.st-empty p { margin: 8px 0 0; }

.st-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.card-icon .icon { width: 16px; height: 16px; }
.card-title { font-size: 15px; font-weight: 650; margin: 0; flex: 1; }
.card-sub { margin: 4px 0 14px; }
.card-text { margin: 0 0 14px; color: var(--text-2); font-size: 13.5px; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 650; flex: none; }
.pill-on { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill-off { background: var(--surface-2); color: var(--muted); }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.field.required .field-hint { color: var(--danger-text); font-weight: 500; }
.field.required .input { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.input {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 14px; outline: none; min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
select.input { padding-right: 8px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }
.input.mono, .code-input { font-family: var(--mono); letter-spacing: .12em; }
.code-input { max-width: 180px; font-size: 18px; height: 44px; text-align: center; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 0 12px; }
.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions.start { justify-content: flex-start; }
.form-error { margin: 0 0 14px; padding: 9px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger-text); font-size: 13px; overflow-wrap: anywhere; }
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-danger-ghost { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.notice.notice-inline { margin: 0 0 14px; }

/* account cards */
.acc-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.acc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s, opacity .15s; }
.acc-card.open { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); box-shadow: var(--shadow-md); }
.acc-card.dragging { opacity: .45; }
.acc-card-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 6px; min-height: 64px; }
.drag-handle { width: 26px; height: 36px; color: var(--faint); cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle[hidden] + .acc-swatch { margin-left: 8px; }
.acc-swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--acc); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 22%, transparent); }
.acc-card-title { flex: 1; min-width: 0; }
.acc-name-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.acc-name { font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 60%; }
.acc-email { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.acc-status { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.acc-status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.acc-status.ok .status-dot { background: var(--ok); }
.acc-status.err { color: var(--danger-text); font-weight: 500; }
.acc-status .icon { width: 14px; height: 14px; }
.acc-card-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.acc-card-actions .icon-btn { width: 30px; height: 30px; }
.acc-card-actions .icon-btn .icon { width: 16px; height: 16px; }
.acc-card-actions .btn { margin-left: 4px; }
.acc-edit .icon { transition: transform .15s; }
.acc-card.open .acc-edit .icon { transform: rotate(180deg); }
.acc-card-body { border-top: 1px solid var(--border-soft); padding: 4px 20px 18px 42px; }
.acc-sub { padding: 16px 0 0; }
.acc-sub + .acc-sub { border-top: 1px solid var(--border-soft); margin-top: 16px; }
.acc-sub h3 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }
.acc-form { margin: 0; }
.acc-danger { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.acc-danger p { margin: 0; flex: 1; min-width: 200px; }

.acc-sub h3.acc-sub-gap { margin-top: 14px; }
.tag-text-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: transparent; color: var(--text-2); padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--row-hover); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.acc-chip-preview {
  display: inline-block; max-width: 160px; padding: 1px 7px; border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; font-weight: 600; line-height: 16px; letter-spacing: .01em; background: var(--acc); color: var(--chip-fg, #fff);
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; background: var(--sw); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .1s, box-shadow .12s;
}
.swatch-btn:hover { transform: scale(1.08); }
.swatch-btn .icon { width: 15px; height: 15px; stroke-width: 2.6; opacity: 0; }
.swatch-btn.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.swatch-btn.on .icon { opacity: 1; }

.sig-box { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.sig-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sig-toolbar { background: var(--surface-2); padding: 3px 6px; }
.sig-editor { min-height: 96px; max-height: 280px; overflow-y: auto; padding: 10px 12px; outline: none; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.sig-editor p { margin: 0 0 .4em; }
.sig-editor blockquote { margin: .4em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.sig-editor img { max-width: 100%; height: auto; }
.sig-editor img.remote-img { display: inline-block; min-width: 60px; min-height: 24px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 4px; }
.sig-editor a { color: var(--accent); }

.acc-server summary, .acc-special summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  padding: 4px 0; border-radius: 6px;
}
.acc-server summary::-webkit-details-marker, .acc-special summary::-webkit-details-marker { display: none; }
.acc-server summary .icon, .acc-special summary .icon { width: 16px; height: 16px; color: var(--muted); }
.acc-server summary .summary-chevron, .acc-special summary .summary-chevron { margin-left: auto; transition: transform .15s; }
.acc-server[open] summary, .acc-special[open] summary { margin-bottom: 12px; }
.acc-server[open] summary .summary-chevron, .acc-special[open] summary .summary-chevron { transform: rotate(180deg); }
.acc-server summary:hover, .acc-special summary:hover { color: var(--text); }
.acc-special > .field-hint { margin: 0 0 12px; }
.special-grid { gap: 0 16px; }

.add-form { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--shadow-md); }
.custom-server { padding: 14px 14px 2px; margin-bottom: 14px; border-radius: 10px; background: var(--surface-2); }
.custom-server .input { background: var(--surface); }
.custom-server .field-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 2fa */
.twofa-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px 28px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.step-title { margin: 0 0 10px; font-weight: 600; font-size: 13.5px; }
.qr-box { width: 212px; height: 212px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 7px; }
.qr { width: 196px; height: 196px; image-rendering: pixelated; display: block; }
.secret-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.secret {
  font: 600 14px/1.4 var(--mono); letter-spacing: .06em; padding: 7px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); user-select: all; overflow-wrap: anywhere; min-width: 0;
}
.twofa-confirm { margin-top: 18px; }
.twofa-confirm .notice { margin: 0 0 14px; }

/* sessions */
.sessions { list-style: none; margin: 0; padding: 0; }
.session { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.session-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.session.current .session-icon { background: var(--accent-soft); color: var(--accent); }
.session-main { flex: 1; min-width: 0; }
.session-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta { overflow-wrap: anywhere; }

/* appearance: theme cards with a miniature of the app (fixed colours per theme, not the current one) */
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 10px 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.theme-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-name { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 4px; }
.theme-radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; display: grid; place-items: center; }
.theme-card.on .theme-radio { border-color: var(--accent); }
.theme-card.on .theme-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.theme-hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
.tp { --tp-bg: #f3f5f9; --tp-side: #eef1f6; --tp-surface: #fff; --tp-line: #cfd6e2; --tp-accent: #3b5bdb; --tp-on: #e7ecfc; --tp-paper: #fff;
  display: grid; grid-template-columns: 26% 34% 1fr; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid #dde2ea; background: var(--tp-bg); }
.tp-dark { --tp-bg: #0f1115; --tp-side: #12151b; --tp-surface: #151821; --tp-line: #2e3442; --tp-accent: #8ea6ff; --tp-on: #1f2740; --tp-paper: #f4f5f7; border-color: #262b36; }
.tp-split { display: grid; }
.tp-split > .tp { grid-area: 1 / 1; }
.tp-split > .tp-dark { clip-path: polygon(62% 0, 100% 0, 100% 100%, 38% 100%); }
.tp-side, .tp-list, .tp-read { display: flex; flex-direction: column; gap: 5px; padding: 8px 6px; }
.tp-side { background: var(--tp-side); }
.tp-list { background: var(--tp-surface); border-left: 1px solid var(--tp-line); border-right: 1px solid var(--tp-line); padding: 6px 0; gap: 0; }
.tp-read { background: var(--tp-surface); }
.tp-btn { height: 9px; border-radius: 4px; background: var(--tp-accent); }
.tp-line { height: 4px; border-radius: 2px; background: var(--tp-line); width: 80%; }
.tp-line.short { width: 55%; }
.tp-row { display: flex; flex-direction: column; gap: 4px; padding: 5px 6px; }
.tp-row.on { background: var(--tp-on); box-shadow: inset 2px 0 0 var(--tp-accent); }
.tp-paper { flex: 1; border-radius: 3px; background: var(--tp-paper); border: 1px solid var(--tp-line); }
@media (max-width: 699px) { .theme-cards { grid-template-columns: 1fr; } .tp { height: 72px; } }

/* about */
.about-logo { height: 44px; width: auto; display: block; margin: 2px 0 16px; }
.about-logo { filter: var(--logo-filter); }
.about-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0 0 16px; font-size: 13.5px; }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; overflow-wrap: anywhere; }
.about-version { font-family: var(--mono); font-weight: 600; }

.modal-form .field { margin-bottom: 12px; }
.modal-form .cd-msg { margin-bottom: 14px; }
.modal-form .form-error { margin-top: 2px; }

/* ------------------------------------------------------------------ popovers / menus / modal */

.popover {
  position: fixed; z-index: 60; min-width: 200px; max-width: min(320px, calc(100vw - 16px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md);
  padding: 5px; animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu { display: flex; flex-direction: column; }
.menu-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; padding-left: calc(10px + var(--depth, 0) * 12px);
  border: 0; border-radius: 6px; background: none; text-align: left; font-size: 13.5px; color: var(--text); white-space: nowrap;
}
.menu-item span { overflow: hidden; text-overflow: ellipsis; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.picker { width: 260px; }
.picker-filter { width: 100%; height: 32px; padding: 0 10px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); outline: none; }
.picker-filter:focus { border-color: var(--accent); }
.picker-list { max-height: 320px; overflow-y: auto; }

.modal-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, .35); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 720px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 18px 22px 22px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head h2 { flex: 1; font-size: 16px; margin: 0; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px 24px; }
.help-grid h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 8px; }
.help-grid dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin: 0; align-items: center; }
.help-grid dt { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.help-grid dd { margin: 0; color: var(--text-2); font-size: 13px; }
.kbd-sep { color: var(--muted); font-size: 11px; }
.modal-confirm { max-width: 420px; padding: 22px 22px 18px; }
.cd-title { font-size: 16px; margin: 0 0 6px; }
.cd-msg { margin: 0 0 20px; color: var(--text-2); }
.cd-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }

/* ------------------------------------------------------------------ toasts */

.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--shadow-md); font-size: 13.5px; font-weight: 500;
  animation: toast-in .18s ease-out; max-width: 100%;
}
.toast .icon { width: 16px; height: 16px; color: #f97066; }
.toast-text { overflow-wrap: anywhere; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.toast-action { border: 0; background: none; color: #93b4ff; font-weight: 700; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ composer */

.composer {
  position: fixed; z-index: 70; right: 24px; bottom: 0; width: 560px; height: 560px; max-height: calc(100dvh - 24px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px 12px 0 0; box-shadow: var(--shadow-lg); overflow: hidden;
  opacity: 0; transform: translateY(16px); transition: opacity .16s ease-out, transform .16s ease-out;
}
.composer.in { opacity: 1; transform: none; }
.composer.closing { opacity: .6; pointer-events: none; }
.composer.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, calc(100vw - 48px)); height: calc(100dvh - 64px); border-radius: 12px; }
.c-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex: none; }
.c-title { flex: 1; min-width: 0; font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-head-actions { display: flex; }
.c-head .icon-btn { width: 30px; height: 30px; }
.c-fields { flex: none; padding: 0 16px; }
.c-row { display: flex; align-items: center; gap: 10px; min-height: 40px; border-bottom: 1px solid var(--border-soft); }
.c-row > label { width: 44px; flex: none; color: var(--muted); font-size: 13px; }
.c-from { flex: 1; min-width: 0; height: 32px; border: 0; background: none; outline: none; font-size: 13.5px; padding: 0; }
.c-subject { flex: 1; min-width: 0; height: 40px; border: 0; background: none; outline: none; font-size: 14px; font-weight: 600; }
.cc-toggles { display: flex; gap: 10px; flex: none; font-size: 13px; }
.cc-toggles .btn-link { color: var(--muted); font-weight: 500; }
.cc-toggles .btn-link:hover { color: var(--accent); }

.chip-field { position: relative; flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 0; min-height: 40px; cursor: text; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; height: 26px; max-width: 100%; padding: 0 2px 0 9px;
  border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.invalid { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger-text); }
.chip-x { width: 20px; height: 20px; border: 0; background: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); padding: 0; }
.chip-x:hover { background: var(--surface-3); color: var(--text); }
.chip-x .icon { width: 12px; height: 12px; stroke-width: 2.2; }
.chip-text { flex: 1; min-width: 120px; height: 28px; border: 0; background: none; outline: none; font-size: 13.5px; }
.suggest {
  position: absolute; left: -8px; right: 0; top: calc(100% - 2px); z-index: 5; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 4px;
}
.suggest-item { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.suggest-item.hi { background: var(--accent-soft); }
.sg-name { font-size: 13.5px; font-weight: 600; }
.sg-email { font-size: 12px; color: var(--muted); }

.c-toolbar { display: flex; align-items: center; gap: 1px; padding: 4px 10px; border-bottom: 1px solid var(--border-soft); flex: none; flex-wrap: wrap; position: relative; }
.c-toolbar .icon-btn { width: 30px; height: 30px; }
.c-toolbar .icon { width: 16px; height: 16px; }
.c-toolbar .tb-sep { margin: 0 5px; height: 18px; }
.link-bar { position: absolute; inset: 3px 8px; display: flex; align-items: center; gap: 6px; background: var(--surface); }
.link-bar input { flex: 1; height: 30px; padding: 0 10px; border: 1px solid var(--accent); border-radius: 7px; background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.c-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.c-editor { flex: 1; padding: 14px 16px; outline: none; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; min-height: 120px; }
.c-editor p { margin: 0 0 .6em; }
.c-editor blockquote { margin: .4em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-2); }
.c-editor img { max-width: 100%; height: auto; }
.c-editor img.remote-img { display: inline-block; min-width: 60px; min-height: 24px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 4px; }
.c-editor a { color: var(--accent); }
.am-signature { color: var(--text-2); }
.am-signature:empty { display: none; }
.c-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.c-atts:empty { display: none; }
.c-atts .chip-att { height: 34px; padding-right: 4px; }
.c-atts .chip-att.fixed { padding-right: 10px; background: var(--surface-2); }
.att-x { width: 24px; height: 24px; }
.att-x .icon { width: 13px; height: 13px; }
.att-progress { position: absolute; left: 0; bottom: 0; height: 2px; width: var(--p, 0%); background: var(--accent); transition: width .15s; }
.chip-att:not(.uploading) .att-progress { display: none; }
.chip-att.failed { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-bg); }
.chip-att.failed .att-size { color: var(--danger-text); font-weight: 600; }

.c-error { flex: none; margin: 0 16px 8px; padding: 8px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger-text); font-size: 13px; overflow-wrap: anywhere; }
.c-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px 16px; border-top: 1px solid var(--border-soft); flex: none; }
.c-send { height: 36px; padding: 0 16px; border-radius: 9px; }
.is-sending .c-send { opacity: .7; }
.c-status { font-size: 12.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
.drop-hint {
  position: absolute; inset: 44px 0 0; display: none; align-items: center; justify-content: center; gap: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 2px dashed var(--accent); border-radius: 0 0 10px 10px;
  color: var(--accent); font-weight: 650; pointer-events: none;
}
.composer.dragging .drop-hint { display: flex; }

/* ------------------------------------------------------------------ auth pages */

.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
body:has(.auth) { overflow: auto; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow-md);
}
.auth-logo { font-size: 20px; font-weight: 700; text-align: center; letter-spacing: .2px; margin-bottom: 8px; }
.auth-logo img { height: 56px; width: auto; display: block; margin: 0 auto 6px; }
.auth-title { font-size: 15px; font-weight: 600; text-align: center; color: var(--muted); margin: 0 0 20px; }
.auth-error { background: var(--danger-bg); color: var(--danger-text); border-radius: 8px; padding: 10px 12px; margin: 0 0 16px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.auth-form input[type=email], .auth-form input[type=password], .auth-form input[type=text] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px;
}
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-form button {
  margin-top: 18px; font: inherit; font-weight: 650; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 9px; padding: 11px 14px;
}
.auth-form button:hover { background: var(--accent-hover); }

/* ------------------------------------------------------------------ medium (tablet): drawer sidebar, two panes */

@media (max-width: 1099px) {
  .app { grid-template-columns: 360px minmax(0, 1fr); }
  .list-pane { grid-column: 1; grid-row: 1; }
  .reader-pane { grid-column: 2; grid-row: 1; }
  .settings-pane { grid-column: 1 / -1; border-left: 0; }
  /* the full sidebar (accounts and their folders) slides in over the panes */
  .sidebar {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    padding: 14px 12px 12px; transform: translateX(-102%); transition: transform .2s ease-out, visibility 0s .2s;
    background: var(--surface); visibility: hidden;
  }
  .app[data-drawer="open"] .sidebar { transform: none; box-shadow: var(--shadow-lg); visibility: visible; transition: transform .2s ease-out; }
  .app[data-drawer="open"] .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .4); animation: fade .15s; }
  .sb-head { justify-content: space-between; padding: 0 4px 12px; }
  .sb-logo img { height: 38px; width: auto; }
  .sb-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
}

/* ------------------------------------------------------------------ small: one pane at a time */

@media (max-width: 699px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav-item { height: 38px; font-size: 14.5px; }
  .folder-item { height: 34px; }

  .list-pane, .reader-pane { grid-column: 1; grid-row: 1; border: 0; }
  .app[data-pane="list"] .reader-pane { display: none; }
  .app[data-pane="reader"] .list-pane { display: none; }
  .list-head { padding: 10px 16px; }
  .row { padding: 11px 16px 12px 10px; }
  .row-check { opacity: 1; }
  .row.unread .check::after { opacity: 0; }
  .star-btn { opacity: 1; }
  .star-btn:not(.on) { color: var(--border); }
  .reader-toolbar { padding: 0 8px; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .reader-toolbar .back-btn { display: inline-flex; }
  .reader-toolbar .tb-sep { margin: 0 2px; }
  .reader-toolbar .icon-btn { width: 36px; height: 40px; }
  .reader-top { padding: 16px 16px 10px; }
  .reader-subject { font-size: 19px; margin-bottom: 14px; }
  .sender { flex-wrap: wrap; }
  .reader-date { width: 100%; padding-left: 52px; margin-top: -4px; }
  .body-wrap { padding: 0 0 0; }
  .body-frame { border-radius: 0; }
  .att-name { max-width: 180px; }

  .composer, .composer.max {
    right: 0; bottom: 0; left: 0; top: 0; width: auto; height: auto; max-height: none; border-radius: 0; border: 0; transform: none;
  }
  .composer { transform: translateY(24px); }
  .composer.in { transform: none; }
  .c-head .icon-btn[title="Maximize"], .c-head .icon-btn[title="Restore size"] { display: none; }
  .c-fields { padding: 0 16px; }
  .toasts { bottom: 16px; }

  .settings-pane { grid-column: 1; border: 0; }
  .st-head { padding: 10px 16px 0; }
  .st-back span { display: none; }
  .st-back { width: 34px; padding: 0; }
  .st-tab { padding: 0 10px; }
  .st-body { padding: 16px 16px 48px; }
  .st-section-head { flex-wrap: wrap; }
  .st-card { padding: 16px; }
  .acc-card-head { flex-wrap: wrap; padding: 10px 12px 10px 4px; gap: 8px 10px; }
  .acc-card-actions { width: 100%; padding-left: 36px; }
  .acc-card-actions .acc-edit { margin-left: auto; }
  .acc-name-line { flex-wrap: wrap; gap: 0 8px; }
  .acc-name { max-width: 100%; }
  .acc-card-body { padding: 4px 16px 16px; }
  .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr) 88px; }
  .twofa-setup { grid-template-columns: minmax(0, 1fr); }
  .qr-box { margin: 0 auto; }
}

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

/* settings switch */
.switch-row { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.switch-title { font-weight: 600; font-size: 14px; }
.switch-hint { font-size: 13px; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--border); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s; }
.switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(16px); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }
