/* Paperflow — warm paper surfaces, deep evergreen accent, light and dark. */
:root {
  color-scheme: light dark;
  --bg: #f5f3ec;
  --bg-2: #efece3;
  --surface: #fffefb;
  --raised: #ffffff;
  --sunken: #f0eee6;
  --hover: #f3f1ea;
  --ink: #18201c;
  --ink-2: #47524c;
  --muted: #7b837e;
  --line: #e6e2d7;
  --line-2: #d6d1c4;
  --accent: #1f5442;
  --accent-2: #2a6b55;
  --accent-ink: #ffffff;
  --accent-bg: #e4efe8;
  --accent-line: #bcd6c7;
  --amber: #93570c;
  --amber-bg: #fcf0db;
  --amber-line: #f0d4a6;
  --red: #b2382a;
  --red-bg: #fbe6e2;
  --red-line: #f0c3bb;
  --blue: #2f5f8f;
  --blue-bg: #e5eef7;
  --violet: #6a4a9a;
  --violet-bg: #efe9f7;
  --gold: #c99a52;
  --story: #173d33;
  --story-2: #0f2c25;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgb(24 32 28 / 6%);
  --shadow: 0 1px 2px rgb(24 32 28 / 5%), 0 6px 20px rgb(24 32 28 / 6%);
  --shadow-lg: 0 24px 70px rgb(12 20 16 / 22%), 0 2px 8px rgb(12 20 16 / 8%);
  --ring: 0 0 0 3px rgb(42 107 85 / 18%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Source Serif Pro", Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --bg-2: #151a17;
    --surface: #181d1a;
    --raised: #1d2320;
    --sunken: #141815;
    --hover: #212824;
    --ink: #e9ece8;
    --ink-2: #b7c0ba;
    --muted: #87918b;
    --line: #2a312d;
    --line-2: #39423d;
    --accent: #5fb38f;
    --accent-2: #7cc6a5;
    --accent-ink: #0d1d16;
    --accent-bg: #1c2f27;
    --accent-line: #2f4d40;
    --amber: #e5b066;
    --amber-bg: #2f2516;
    --amber-line: #4d3a1d;
    --red: #f08f80;
    --red-bg: #361d1a;
    --red-line: #5a2c26;
    --blue: #8fb6e0;
    --blue-bg: #1a2633;
    --violet: #bba3e3;
    --violet-bg: #251f33;
    --story: #102a23;
    --story-2: #0a1c17;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    --shadow-lg: 0 24px 70px rgb(0 0 0 / 55%);
    --ring: 0 0 0 3px rgb(95 179 143 / 25%);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--accent-2); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 12px; margin-top: 14px; }
.optional { color: var(--muted); font-weight: 400; }
.cap { text-transform: capitalize; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logo { width: 26px; height: 26px; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-sheet { fill: none; stroke: var(--surface); stroke-width: 4; }
.logo-line { stroke: var(--gold); stroke-width: 3; }
@media (prefers-color-scheme: dark) {
  .logo-bg { fill: #1f5442; }
  .logo-sheet { stroke: #f4f2e9; }
}

/* Form controls */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  background: var(--raised);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: var(--ring); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.row-end { justify-content: flex-end; }
.reveal { position: relative; }
.reveal input { padding-right: 56px; }
.reveal .link { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; }
.error { color: var(--red); background: var(--red-bg); border: 1px solid var(--red-line); border-radius: var(--radius-sm); padding: 9px 12px; margin-top: 12px; font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--raised); box-shadow: var(--shadow-sm);
  font-weight: 600; font-size: 13px; white-space: nowrap; color: var(--ink);
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--line-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn .i { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgb(15 40 30 / 25%), inset 0 1px 0 rgb(255 255 255 / 12%); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; }
.btn-small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-wide { width: 100%; height: 44px; margin-top: 20px; font-size: 14px; }
.btn-big { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 10px; }
.link { color: var(--accent-2); font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }
.danger, .btn.danger { color: var(--red); }
#sync-button.spinning .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -0.015em; color: var(--ink); text-decoration: none; }
.brand-light { color: #fff; }
.brand-light .logo-bg { fill: rgb(255 255 255 / 12%); }
.brand-light .logo-sheet { stroke: #fff; }

/* Auth */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-story {
  position: relative; overflow: hidden;
  background:
    radial-gradient(70% 55% at 10% 0%, rgb(255 255 255 / 8%), transparent 70%),
    radial-gradient(60% 50% at 100% 100%, rgb(201 154 82 / 14%), transparent 70%),
    linear-gradient(160deg, var(--story), var(--story-2));
  color: #e6eee9; padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-story::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: linear-gradient(rgb(255 255 255 / 3%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 3%) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(80% 70% at 30% 40%, #000, transparent);
}
.auth-story > * { position: relative; z-index: 1; }
.auth-pitch { max-width: 540px; }
.auth-pitch h1 { font-family: var(--serif); font-weight: 500; font-size: 44px; line-height: 1.08; color: #fff; letter-spacing: -0.02em; }
.auth-pitch > p { margin-top: 18px; font-size: 16.5px; color: #c3d3ca; max-width: 46ch; }
.auth-sample {
  margin-top: 34px; max-width: 450px; background: #fffefb; color: #18201c; border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 28px 60px rgb(0 0 0 / 35%), 0 0 0 1px rgb(255 255 255 / 6%); transform: rotate(-1.2deg);
  --line: #e6e2d7; --line-2: #d6d1c4; --sunken: #f0eee6; --muted: #7b837e; --ink-2: #47524c; --ink: #18201c;
  --accent: #1f5442; --accent-bg: #e4efe8; --amber: #93570c; --amber-bg: #fcf0db;
}
.sample-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sample-envelope { flex: none; width: 46px; height: 32px; border-radius: 4px; border: 1px solid var(--line-2); background: linear-gradient(155deg, transparent 49%, var(--line-2) 50%, transparent 51%) top / 100% 60% no-repeat, linear-gradient(25deg, transparent 49%, var(--line-2) 50%, transparent 51%) top / 100% 60% no-repeat, var(--sunken); }
.sample-from { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.sample-from small { color: var(--muted); font-size: 12px; }
.sample-from strong { font-weight: 600; }
.sample-steps { list-style: none; counter-reset: s; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; font-size: 13px; color: var(--ink-2); }
.sample-steps li { counter-increment: s; display: flex; align-items: center; gap: 10px; }
.sample-steps li::before { content: counter(s); flex: none; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); font-size: 11px; font-weight: 700; }
.sample-steps b { color: var(--ink); font-weight: 600; }
.sample-steps em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600; color: var(--amber); background: var(--amber-bg); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.auth-sample .chip-action { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
@media (max-height: 860px) { .auth-sample { display: none; } }
.how { list-style: none; counter-reset: how; padding: 0; margin: 38px 0 0; display: grid; gap: 18px; }
.how li { counter-increment: how; display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; }
.how li::before { content: counter(how); grid-row: span 2; width: 28px; height: 28px; border-radius: 9px; background: rgb(255 255 255 / 8%); border: 1px solid rgb(255 255 255 / 16%); display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; }
.how strong { color: #fff; font-weight: 600; }
.how span { color: #a9beb3; }
.auth-fine { color: #8fa89b; font-size: 13px; }
.auth-panel { display: grid; place-items: center; align-content: center; gap: 0; padding: 40px 24px; background: var(--bg); }
.auth-form { width: 100%; max-width: 372px; }
.auth-form h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -0.015em; }
.auth-form > p.muted { margin: 6px 0 12px; }
.auth-switch { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.auth-form input { height: 44px; }
.auth-form input:focus-visible { outline: none; }
.auth-form .reveal input { padding-right: 60px; }
.field-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.field-hint.ok { color: var(--accent-2); }
.field-hint.ok::before { content: "✓ "; font-weight: 700; }
.auth-accounts h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -0.015em; margin-bottom: 14px; }
.account-list { display: grid; gap: 8px; }
.auth-accounts .account-option { border: 1px solid var(--line); background: var(--raised); padding: 11px 12px; box-shadow: var(--shadow-sm); }
.auth-accounts .account-option:hover { border-color: var(--accent-line); background: var(--raised); }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 22px 0 6px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* App shell */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px 14px; border-right: 1px solid var(--line); background: var(--bg-2); }
.sidebar > .brand { padding: 2px 10px 20px; }
.nav-label { padding: 14px 12px 6px; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.nav { display: grid; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 8px; text-align: left; color: var(--ink-2); font-weight: 500; text-decoration: none; transition: background 0.1s, color 0.1s; }
.nav-item > span { flex: 1; min-width: 0; }
.nav-item .i { color: var(--muted); }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--raised); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.nav-item.active .i { color: var(--accent); }
.nav-item b { font-weight: 600; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 20px; text-align: center; }
.nav-item b.count-hot:not(:empty) { background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 1px 7px; }
.nav-item b.count-hot:is(:empty) { display: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.dot-on { background: #3a9a6b; box-shadow: 0 0 0 3px rgb(58 154 107 / 18%); }

.main { min-width: 0; padding: 32px 44px 64px; max-width: 1120px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }
.search { position: relative; display: flex; align-items: center; margin: 0; }
.search .i { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search input { width: 260px; height: 36px; padding-left: 34px; padding-right: 30px; border-radius: 9px; font-weight: 400; }
.search kbd { position: absolute; right: 9px; font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; line-height: 17px; pointer-events: none; }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }
.banner { display: flex; gap: 8px; align-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.banner-warn { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.foot { font-size: 12px; margin-top: 18px; text-align: center; }

/* Overview */
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat-icon { grid-row: span 2; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); }
.stat-icon .i { width: 18px; height: 18px; }
.stat b { font-size: 22px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat > span:last-child { color: var(--muted); font-size: 12.5px; }
.stat.late .stat-icon { background: var(--red-bg); color: var(--red); }
.stat.late b { color: var(--red); }
.stat.soon .stat-icon { background: var(--amber-bg); color: var(--amber); }
.stat:not(.late):not(.soon):not(:first-child) .stat-icon { background: var(--sunken); color: var(--muted); }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.panel-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-bg); color: var(--accent); margin-bottom: 14px; flex: none; }
.panel-icon .i { width: 20px; height: 20px; }
.connect { display: grid; grid-template-columns: 1fr 360px; gap: 44px; }
.connect h2 { font-family: var(--serif); font-weight: 500; font-size: 23px; letter-spacing: -0.01em; margin-bottom: 8px; }
.connect-copy p { color: var(--ink-2); margin-bottom: 12px; max-width: 48ch; }
.connect-copy a { font-weight: 600; text-decoration: none; }
.connect-copy a:hover { text-decoration: underline; }
.connect-form label:first-child { margin-top: 0; }
.connect-form .muted { font-size: 12.5px; margin-top: 6px; }
#notification-save { margin-top: 16px; }
.connected-line { display: flex; gap: 9px; align-items: center; font-weight: 650; font-size: 15px; }
#connected-summary { background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 18px; align-self: start; }
#disconnect { margin-top: 18px; display: block; font-weight: 500; }

/* Mail list */
.mail-list { display: grid; gap: 26px; }
.mail-list:empty { display: none; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 0 4px 10px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.group-head span { font-weight: 600; color: var(--muted); background: var(--sunken); border: 1px solid var(--line); border-radius: 9px; padding: 0 7px; letter-spacing: 0; font-size: 11px; line-height: 17px; }
.group-rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.mail-row { position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 18px; align-items: center; width: 100%; padding: 16px 20px 16px 18px; text-align: left; border-bottom: 1px solid var(--line); transition: background 0.1s; }
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: var(--hover); }
.mail-row:focus-visible { outline-offset: -2px; }
.mail-row::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.mail-row.tone-late::before { background: var(--red); }
.mail-row.tone-soon::before { background: var(--amber); }
.mail-row.is-pending .mail-title { color: var(--muted); font-weight: 500; }
.thumb { display: block; width: 76px; height: 52px; border-radius: 6px; background: var(--sunken); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mail-main { min-width: 0; display: grid; gap: 1px; }
.mail-meta { display: flex; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.mail-meta strong { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-meta span { white-space: nowrap; }
.mail-meta span::before { content: "·"; margin-right: 8px; }
.mail-title { font-weight: 620; font-size: 15px; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-summary { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.due { display: grid; justify-items: end; gap: 1px; text-align: right; white-space: nowrap; padding-left: 8px; }
.due b { font-size: 13px; font-weight: 650; }
.due small { font-size: 12px; color: var(--muted); }
.due-late b { color: var(--red); }
.due-soon b { color: var(--amber); }
.due-later b { color: var(--ink-2); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .i { width: 12px; height: 12px; stroke-width: 2.2; }
.chip-action { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.chip-done { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }
.chip-high { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.chip-quiet { background: transparent; color: var(--muted); }
.chip-ask { background: var(--violet-bg); color: var(--violet); border-color: transparent; }
.chip-wait::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.due-chip.due-late { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.due-chip.due-soon { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
@keyframes pulse { 50% { opacity: 0.25; } }

.empty { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 64px 20px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h3 { font-family: var(--serif); font-weight: 500; font-size: 21px; }
.empty-icon { display: none; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); margin-bottom: 8px; }
.empty-icon .i { width: 22px; height: 22px; stroke-width: 2.2; }
.empty-good .empty-icon { display: grid; }
.empty-pad { margin: 24px; }

/* Dialogs */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgb(14 20 17 / 42%); backdrop-filter: blur(2px); }
dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 9px; color: var(--muted); display: grid; place-items: center; z-index: 3; }
.close .i { width: 18px; height: 18px; }
.close:hover { background: var(--hover); color: var(--ink); }
.modal { width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border-radius: 16px; padding: 28px; }
.modal-wide { width: min(780px, calc(100vw - 32px)); }
.modal-narrow { width: min(420px, calc(100vw - 32px)); }
.modal h2 { font-family: var(--serif); font-weight: 500; font-size: 25px; letter-spacing: -0.015em; margin-bottom: 6px; padding-right: 34px; }
.sheet { width: min(1200px, calc(100vw - 32px)); height: calc(100vh - 48px); max-height: none; border-radius: 16px; overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet > div { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-doc { width: min(960px, calc(100vw - 32px)); }

/* Slide-over for a single piece of mail */
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(1180px, calc(100vw - 72px)); height: 100vh; max-width: none; max-height: none; border-radius: 18px 0 0 18px; border-left: 1px solid var(--line); }
.drawer[open] { animation: slide 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* Segmented control */
.segmented { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-top: 14px; }
.segmented button { padding: 6px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.segmented button:hover:not(:disabled) { color: var(--ink); }
.segmented button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 10%), 0 0 0 1px var(--line); }
#kind-switch + #method-switch:not([hidden]) { margin-left: 8px; }

/* Vault */
.vault { display: grid; gap: 16px; }
.vault .vault-group { margin: 0; padding: 24px 26px 12px; }
.vault-group-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.vault-group-head > div { flex: 1; }
.vault-group-head .panel-icon { margin: 0; }
.vault-group-head h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; letter-spacing: -0.01em; }
.vault-group-head p { font-size: 13px; margin-top: 2px; }
.vault-item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.vault-glyph { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); color: var(--ink-2); }
.vault-item strong { display: block; font-weight: 600; }
.vault-item small { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.vault-item .row { margin: 0; gap: 4px; }
.vault-empty { color: var(--muted); font-size: 13px; padding: 18px 0 16px; border-top: 1px solid var(--line); }

/* Detail */
.detail-head { display: flex; align-items: center; gap: 18px; padding: 22px 70px 20px 28px; border-bottom: 1px solid var(--line); background: var(--surface); }
.thumb-lg { width: 92px; height: 64px; flex: none; border-radius: 8px; }
.detail-title { flex: 1; min-width: 0; }
.detail-head .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-head h2 { font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.18; letter-spacing: -0.015em; }
.detail-head .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-head .meta strong { color: var(--ink-2); font-weight: 600; }
.detail-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); grid-template-rows: minmax(0, 1fr); }
.detail-cols > section { overflow-y: auto; }
.detail-plan { display: flex; flex-direction: column; background: var(--surface); }
.plan-scroll { flex: 1; padding: 22px 32px 32px; }
.detail-source { padding: 22px 26px 40px; background: var(--bg-2); border-left: 1px solid var(--line); }
.detail-source h3, .detail-plan h3.label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin: 24px 0 8px; }
.detail-source p { color: var(--ink-2); }
.quote { border-left: 3px solid var(--gold); padding: 4px 0 4px 12px; margin: 8px 0; color: var(--ink-2); font-family: var(--serif); font-size: 14.5px; font-style: italic; }
.bullets { margin: 0; padding-left: 18px; color: var(--ink-2); }
.bullets li { margin: 3px 0; }
details { margin-top: 14px; }
summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
summary:hover { color: var(--ink); }
.source-text { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; max-height: 320px; overflow: auto; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; margin-top: 10px; color: var(--ink-2); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.preview { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.preview .segmented { margin: 0; }
.preview .segmented button { padding: 4px 10px; font-size: 12px; }
#inline-document img { display: block; width: 100%; max-height: 300px; object-fit: contain; background: var(--sunken); }
#inline-document iframe { display: block; width: 100%; height: 440px; border: 0; background: var(--sunken); }
#document-body { padding: 56px 16px 16px; }
#document-body img { display: block; max-width: 100%; max-height: calc(100vh - 140px); margin: 0 auto; }
#document-body iframe { width: 100%; height: calc(100vh - 140px); border: 0; }

/* Plan */
.plan-state { display: grid; justify-items: start; gap: 6px; margin: 24px 32px 0; padding: 22px; border-radius: var(--radius); background: var(--sunken); border: 1px solid var(--line); }
.plan-state > .i { width: 22px; height: 22px; color: var(--amber); margin-bottom: 4px; }
.plan-state-quiet > .i { color: var(--muted); }
.plan-state h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; }
.detail-plan > .plan-section, .detail-plan > .generated { margin-left: 32px; margin-right: 32px; }
.stepper { display: flex; gap: 0; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 11px; background: var(--sunken); padding: 3px; }
.stepper a { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.stepper a:hover { color: var(--ink); }
.stepper a span { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-2); font-size: 11px; color: var(--ink-2); }
.stepper a span .i { width: 12px; height: 12px; stroke-width: 2.6; }
.stepper a.done { color: var(--accent); }
.stepper a.done span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stepper a.current { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 8%), 0 0 0 1px var(--line); }
.stepper a.current span { border-color: var(--amber); color: var(--amber); }
.plan-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.plan-facts div { background: var(--surface); padding: 10px 14px; }
.plan-facts dt { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.plan-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 13.5px; }
.plan-section { margin-top: 30px; }
.plan-section > h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.plan-section > h3 small { font-family: var(--sans); font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.plan-section > p.muted { margin-bottom: 14px; font-size: 13px; }

.steps { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 0; }
.steps > li { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding-bottom: 20px; }
.steps > li::after { content: ""; position: absolute; left: 16.5px; top: 38px; bottom: 4px; width: 1.5px; background: var(--line); border-radius: 1px; }
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.step-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--sunken); border: 1px solid var(--line); color: var(--ink-2); }
.step-sign_in .step-icon, .step-retrieve_document .step-icon { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.step-pay .step-icon { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.step-submit .step-icon { background: var(--violet-bg); color: var(--violet); border-color: transparent; }
.step-confirm .step-icon { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.step-body { min-width: 0; padding: 1px 0 0; }
.step-kind { font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.step-kind span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.steps h4 { font-size: 15px; font-weight: 650; margin: 1px 0 4px; letter-spacing: -0.005em; }
.steps p { color: var(--ink-2); }
.done-when { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; color: var(--ink-2); margin-top: 8px; padding: 7px 10px; background: var(--sunken); border-radius: 8px; }
.done-when .i { width: 14px; height: 14px; margin-top: 2px; color: var(--accent); stroke-width: 2.4; }
.done-when b { color: var(--ink); font-weight: 600; }
.step-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }

.inputs { display: grid; gap: 10px; }
.input-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.input-card:not(.ok) { border-color: var(--amber-line); }
.input-card.ok { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-bg) 35%, var(--surface)); }
.input-top { display: flex; gap: 12px; align-items: flex-start; }
.input-top > div { flex: 1; min-width: 0; }
.input-glyph { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--amber-bg); color: var(--amber); }
.input-card.ok .input-glyph { background: var(--accent-bg); color: var(--accent); }
.input-top strong { font-weight: 650; }
.input-card p { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.input-env { font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.input-pick { display: flex; gap: 8px; margin: 12px 0 0 44px; }
.input-pick select { flex: 1; height: 34px; padding: 4px 10px; }
.input-using { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 0 44px; font-size: 13px; }
.input-using > span:first-child { display: flex; align-items: center; gap: 6px; color: var(--ink-2); min-width: 0; flex-wrap: wrap; }
.input-using > span:first-child .i { color: var(--accent); width: 14px; height: 14px; stroke-width: 2.4; }
.input-using small { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.input-using .row { margin: 0; gap: 2px; flex-wrap: nowrap; }

.handoff { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 20px; padding: 16px 32px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.handoff-copy { flex: 1; min-width: 0; }
.handoff strong { font-weight: 650; }
.handoff p { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.handoff .handoff-missing { display: flex; align-items: center; gap: 6px; color: var(--amber); font-weight: 500; margin-top: 4px; }
.handoff-missing .i { width: 14px; height: 14px; }

.sources a { display: block; padding: 12px 14px; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); transition: border-color 0.12s, background 0.12s; }
.sources a:hover { border-color: var(--accent-line); background: var(--hover); }
.source-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.source-top .i { color: var(--muted); width: 14px; height: 14px; }
.sources strong { font-weight: 600; }
.sources p { color: var(--ink-2); font-size: 13px; }
.sources small { color: var(--accent-2); font-size: 12px; font-weight: 500; }

.feedback { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); }
.feedback summary { list-style: none; display: flex; align-items: center; gap: 8px; }
.feedback summary::-webkit-details-marker { display: none; }
.feedback summary::before { content: ""; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
.feedback[open] summary::before { transform: rotate(45deg); }
.feedback textarea { margin-top: 12px; background: var(--raised); }
.history { margin-top: 12px; display: grid; gap: 8px; }
.history article { font-size: 13px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.history article p { margin: 6px 0 2px; color: var(--ink-2); }
.history small { color: var(--muted); }
.fine-inline { color: var(--muted); font-size: 12px; }
.generated { color: var(--muted); font-size: 12px; margin-top: 26px; }

.prompt { font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--sunken); border: 1px solid var(--line); margin-top: 14px; height: 360px; }
#handoff-warning { margin: 12px 0 0; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
.admin-grid h3 { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.card-top { display: flex; justify-content: space-between; gap: 10px; }
.card p { color: var(--ink-2); margin: 6px 0; }
.card small { color: var(--muted); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 13px; margin-top: 8px; }
.compare h4 { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.compare ol { padding-left: 18px; margin: 6px 0 0; }
.suggestion { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 11px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 100; max-width: calc(100vw - 32px); animation: rise 0.18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Account switcher */
.account { position: relative; margin-top: auto; padding: 10px 0 0; border-top: 1px solid var(--line); display: block; }
.account-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left; }
.account-button:hover, .account-button[aria-expanded="true"] { background: var(--hover); }
.account-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--ink); }
.chev { width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-135deg); margin: 3px 4px 0; }
.account-button[aria-expanded="true"] .chev { transform: rotate(45deg); margin-top: -3px; }
.account-button.has-others .avatar { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px var(--amber); }
.avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #fff; background: hsl(var(--hue, 158) 38% 36%); }
.hue-0 { --hue: 158; } .hue-1 { --hue: 28; } .hue-2 { --hue: 210; } .hue-3 { --hue: 340; }
.hue-4 { --hue: 265; } .hue-5 { --hue: 48; } .hue-6 { --hue: 190; } .hue-7 { --hue: 0; }
.account-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); min-width: 260px; background: var(--raised); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; animation: pop 0.12s ease-out; }
.account-menu-list { max-height: 320px; overflow-y: auto; }
.account-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; text-align: left; }
.account-option:hover { background: var(--hover); }
.account-option-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-option.current .account-option-email { font-weight: 650; }
.account-option .count { background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 700; line-height: 20px; }
.account-option .check { color: var(--accent); font-weight: 700; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; font-size: 13px; color: var(--ink-2); }
.menu-item:hover { background: var(--hover); color: var(--ink); }

/* Sidebar focus: keep the ring inside the item so it lines up with the active highlight. */
.nav-item:focus-visible, .account-button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.nav-item.active:focus-visible { outline: none; }

/* Responsive */
@media (max-width: 1100px) {
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .detail-cols { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; overflow-y: auto; }
  .detail-cols > section { overflow: visible; }
  .detail-source { border-left: 0; border-top: 1px solid var(--line); }
  .connect, .admin-grid { grid-template-columns: 1fr; gap: 20px; }
  .drawer { width: 100vw; border-radius: 0; border-left: 0; }
}
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-story { padding: 24px 24px 28px; gap: 18px; }
  .auth-pitch h1 { font-size: 28px; }
  .auth-pitch > p { font-size: 14.5px; margin-top: 10px; }
  .auth-story .how, .auth-sample, .auth-fine { display: none; }
  .auth-panel { place-items: start center; padding: 28px 24px 40px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 56px 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); gap: 6px 8px; background: color-mix(in srgb, var(--bg-2) 92%, transparent); backdrop-filter: blur(10px); }
  .sidebar > .brand { padding: 0 6px 0 0; font-size: 19px; }
  .sidebar > .brand .logo { width: 22px; height: 22px; }
  .nav-label { display: none; }
  .nav { display: flex; min-width: 0; max-width: 100%; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav-secondary { margin: 0; padding: 0; border: 0; }
  .nav-item { width: auto; white-space: nowrap; padding: 6px 9px; gap: 6px; }
  .nav-item .i { display: none; }
  .main { padding: 20px 16px 48px; }
  .page-head h1 { font-size: 26px; }
  .page-actions { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .search kbd { display: none; }
  .overview { gap: 8px; margin-bottom: 20px; }
  .stat { padding: 10px 12px; column-gap: 10px; }
  .stat-icon { width: 30px; height: 30px; border-radius: 8px; }
  .stat b { font-size: 18px; }
  .mail-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 13px 14px 13px 16px; align-items: start; }
  .mail-row .thumb { display: none; }
  .mail-title, .mail-summary { white-space: normal; }
  .mail-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .due small { display: none; }
  .due b { font-size: 12px; }
  .detail-head { padding: 16px 56px 16px 16px; flex-wrap: wrap; gap: 12px; }
  .detail-head .thumb-lg { display: none; }
  .detail-head h2 { font-size: 22px; }
  .plan-scroll { padding: 18px 16px 28px; }
  .plan-state, .detail-plan > .plan-section, .detail-plan > .generated { margin-left: 16px; margin-right: 16px; }
  .stepper a { font-size: 11.5px; padding: 6px 4px; gap: 5px; }
  .stepper a span { display: none; }
  .detail-source { padding: 18px 16px 32px; }
  .input-pick, .input-using { margin-left: 0; }
  .input-pick { flex-direction: column; }
  .input-env { display: none; }
  .handoff { padding: 12px 16px; gap: 12px; }
  .handoff p:not(.handoff-missing) { display: none; }
  .sheet { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  #inline-document iframe { height: 300px; }
  #inline-document img { max-height: 220px; }
  .account { position: absolute; top: 9px; right: 12px; margin: 0; padding: 0; border: 0; }
  .account-button { padding: 4px; }
  .account-email, .chev { display: none; }
  .account-menu { left: auto; right: 0; bottom: auto; top: calc(100% + 6px); width: min(320px, calc(100vw - 24px)); }
}
@media (max-width: 560px) {
  .vault-group-head { flex-wrap: wrap; }
  .vault-group-head .btn { width: 100%; }
  .vault .vault-group { padding: 20px 18px 10px; }
  .panel { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
