:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --panel: #131418;
  --panel-raised: #191a1f;
  --hover: #1c1e24;
  --field: #0f1013;
  --line: #23252c;
  --line-strong: #31343c;
  --text: #ececef;
  --text-2: #a3a8b2;
  --text-3: #8f95a0;
  --accent: #7c9cff;
  --accent-hover: #93adff;
  --accent-text: #0b1020;
  --accent-soft: rgba(124, 156, 255, .14);
  --accent-ink: #9db4ff;
  --green: #4cc38a;
  --amber: #e2a64f;
  --red: #f0707a;
  --red-soft: rgba(240, 112, 122, .12);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --nav: 272px;
  --list: 400px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-raised: #fafbfc;
    --hover: #eef0f4;
    --field: #ffffff;
    --line: #e5e7eb;
    --line-strong: #d4d7dd;
    --text: #16181d;
    --text-2: #555b66;
    --text-3: #5f6570;
    --accent: #3d63f0;
    --accent-hover: #2f53dc;
    --accent-text: #ffffff;
    --accent-soft: rgba(61, 99, 240, .1);
    --accent-ink: #2645c4;
    --green: #157f4c;
    --amber: #8a5a0e;
    --red: #d63c49;
    --red-soft: rgba(214, 60, 73, .08);
    --shadow: 0 12px 32px rgba(20, 24, 33, .14);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }
h1, h2, h3 { margin: 0; }
pre { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"] { width: auto; min-width: auto; margin: 0; accent-color: var(--accent); }
.icon { display: block; flex: 0 0 auto; }
.mono { font-family: var(--mono); font-size: .92em; color: var(--text); }
.muted { color: var(--text-3); }
.note { margin: 0; color: var(--text-3); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Controls */
input { width: 100%; min-width: 0; height: 36px; padding: 0 12px; color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; outline: 0; background: var(--field); transition: border-color .12s, box-shadow .12s; }
input::placeholder { color: var(--text-3); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.button { height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 550; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.button.compact { height: 30px; gap: 6px; padding: 0 10px; font-size: 12.5px; }
.button.primary { color: var(--accent-text); background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.ghost { border-color: var(--line-strong); background: var(--panel); }
.button.ghost:hover { border-color: var(--text-3); background: var(--hover); }
.button.square { width: 36px; padding: 0; }
.button.ghost.square { color: var(--text-2); }
.button.ghost.square:hover { color: var(--text); }
.button.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); background: var(--red-soft); }
.button.danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); }
.icon-button { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0; color: var(--text-3); border: 0; border-radius: 50%; background: transparent; cursor: pointer; text-decoration: none; transition: color .12s, background .12s; }
.icon-button:hover { color: var(--text); background: var(--hover); }
.icon-button.danger:hover { color: var(--red); background: var(--red-soft); }
.icon-button.is-flashed { color: var(--green); }
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-actions form { margin: 0; }

/* App frame: a fixed-height window whose panes scroll on their own, like a mail client. */
.app-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.topbar { flex: 0 0 auto; }
.topbar-inner { height: 64px; display: grid; grid-template-columns: var(--nav) minmax(0, 1fr) auto; align-items: center; padding-right: 16px; }
.topbar form { margin: 0; }
.topbar-brand { display: flex; align-items: center; gap: 4px; padding-left: 20px; }
.nav-toggle { display: none; color: var(--text-2); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand img { border-radius: 7px; }
.inbox-search { position: relative; max-width: 720px; }
.inbox-search .icon { position: absolute; top: 50%; left: 16px; color: var(--text-3); transform: translateY(-50%); pointer-events: none; }
.inbox-search input { height: 44px; padding-left: 46px; border-color: transparent; border-radius: 999px; background: var(--panel); font-size: 14.5px; }
.inbox-search input:focus { border-color: var(--line-strong); box-shadow: var(--shadow); }
.topbar-side { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-left: 16px; }

.shell-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--nav) minmax(0, 1fr); }
.nav-backdrop { display: none; }

/* Left navigation */
.nav { min-height: 0; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding: 6px 12px 24px; scrollbar-width: thin; }
.nav > * { min-width: 0; }
.nav > form { margin: 0; }
.inbox-create { display: grid; gap: 8px; }
.inbox-create form { min-width: 0; margin: 0; }
.inbox-create .button { width: 100%; height: 42px; justify-content: flex-start; border-radius: 10px; }
.mobile-inbox-create { display: none; }
.recent-inboxes[hidden] { display: none; }
.recent-inbox-list { min-width: 0; display: grid; gap: 2px; max-height: 272px; overflow-y: auto; scrollbar-width: thin; }
.recent-inbox { min-width: 0; display: flex; align-items: center; gap: 2px; padding-right: 4px; border-radius: 9px; }
.recent-inbox:hover, .recent-inbox:focus-within { background: var(--hover); }
.recent-inbox.active { background: var(--accent-soft); }
.recent-inbox-link { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 4px 8px 14px; text-decoration: none; }
.recent-inbox-link > .icon { color: var(--text-3); }
.recent-inbox.active .recent-inbox-link > .icon { color: var(--accent); }
.recent-inbox-label { min-width: 0; display: grid; gap: 1px; }
.recent-inbox-address { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 12.5px; }
.recent-inbox.active .recent-inbox-address { color: var(--text); }
.recent-inbox-time { color: var(--text-3); font-size: 11px; }
.recent-remove { width: 26px; height: 26px; }
.recent-clear { font-size: 11.5px; }
.recent-note { margin: 0; padding: 0 14px; color: var(--text-3); font-size: 11px; }
.recent-empty { margin: 0; padding: 4px 14px 8px; color: var(--text-3); font-size: 12px; }
@media (hover: hover) {
  .recent-remove { opacity: 0; }
  .recent-inbox:hover .recent-remove, .recent-inbox:focus-within .recent-remove { opacity: 1; }
}
.nav-links { display: grid; gap: 2px; }
.nav-item { min-width: 0; height: 36px; display: flex; align-items: center; gap: 14px; padding: 0 14px; color: var(--text-2); border-radius: 999px; text-decoration: none; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: var(--hover); }
.nav-item.active { color: var(--text); background: var(--accent-soft); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }
.nav-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.nav-heading { min-height: 30px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 0 14px; color: var(--text-3); font-size: 12px; }
.nav-heading h2 { color: var(--text-2); font-size: 13px; font-weight: 600; }
.nav-heading .good { color: var(--green); }
.nav-heading .warn { color: var(--amber); }
.nav-heading .bad { color: var(--red); }

.health { display: grid; gap: 8px; margin: 0 4px 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.health-overview { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 12.5px; }
.health-overview strong { color: var(--text); font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.health.error .health-overview strong, .health-error { color: var(--red); }
.health-error { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.policy summary { color: var(--text-3); font-size: 12px; cursor: pointer; list-style: none; }
.policy summary::-webkit-details-marker { display: none; }
.policy summary .link { margin-left: 4px; color: var(--accent); }
.policy[open] summary .link { display: none; }
.policy-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 6px; margin: 10px 0 8px; }
.policy-form .button { grid-column: 1 / -1; }
.policy-field { min-width: 0; display: grid; gap: 4px; color: var(--text-3); font-size: 11.5px; }
.suffix-field { position: relative; display: block; }
.suffix-field input { height: 30px; padding: 0 26px 0 8px; font: 12px var(--mono); }
.suffix-field > span { position: absolute; top: 50%; right: 7px; color: var(--text-3); font-size: 11px; transform: translateY(-50%); pointer-events: none; }

.domain-filter-bar { padding: 0 4px 2px; }
.domain-filter { height: 32px; border-radius: 999px; font-size: 13px; }
.domain-list { display: grid; gap: 1px; }
.domain-row { min-height: 36px; display: flex; align-items: center; gap: 12px; padding: 2px 4px 2px 16px; border-radius: 999px; }
.domain-row[hidden] { display: none; }
.domain-row:hover { background: var(--hover); }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.status-dot.off { background: var(--text-3); box-shadow: none; }
.status-dot.cooldown { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); }
.domain-text { min-width: 0; flex: 1; display: grid; }
.domain-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.domain-row:hover .domain-text strong { color: var(--text); }
.domain-row.is-off .domain-text strong { color: var(--text-3); }
.wild { color: var(--text-3); }
.domain-status { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 11.5px; }
.domain-state { color: var(--text-3); }
.domain-health { color: var(--text-3); font-variant-numeric: tabular-nums; }
.domain-health.good { color: var(--green); }
.domain-health.warn { color: var(--amber); }
.domain-health.bad { color: var(--red); }
.domain-row .row-actions { gap: 0; }
.domain-row .icon-button { width: 28px; height: 28px; }
@media (hover: hover) {
  .domain-row .row-actions { opacity: 0; transition: opacity .12s; }
  .domain-row:hover .row-actions, .domain-row:focus-within .row-actions { opacity: 1; }
}
.panel-empty { margin: 0; padding: 8px 16px; color: var(--text-3); font-size: 13px; }
.add-domain { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 6px; padding: 0 4px; }
.add-domain input { height: 34px; border-radius: 999px; font-size: 13px; }
.add-domain .button { height: 34px; border-radius: 999px; }
.add-domain-note { padding: 0 16px; }

.link-button { padding: 0; color: var(--accent); border: 0; background: none; cursor: pointer; font: inherit; }
.link-button:hover { text-decoration: underline; }

/* Setup drawer, sliding in from the right. */
.drawer { position: fixed; z-index: 55; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg); box-shadow: var(--shadow); visibility: hidden; transform: translateX(100%); transition: transform .2s ease, visibility 0s linear .2s; }
.setup-open .drawer { visibility: visible; transform: none; transition: transform .2s ease; }
.drawer-backdrop { display: none; position: fixed; z-index: 54; inset: 0; background: rgba(0, 0, 0, .45); }
.setup-open .drawer-backdrop { display: block; }
.drawer-head { height: 64px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; font-weight: 600; }
.drawer-body { flex: 1; min-height: 0; display: grid; align-content: start; gap: 12px; overflow-y: auto; padding: 16px; scrollbar-width: thin; }
.disclosure > summary .icon { transition: transform .15s; }
.disclosure[open] > summary .icon { transform: rotate(180deg); }
.setup-section { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.setup-section h3 { font-size: 13px; font-weight: 600; }
.setup-section > h3 { margin-bottom: 4px; }
.setup-section p { margin: 0 0 10px; color: var(--text-2); font-size: 12.5px; }
.setup-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.setup-section-head form { margin: 0; }
.copy-field { display: flex; align-items: center; gap: 4px; padding: 2px 2px 2px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.copy-field code { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: 12px/1.5 var(--mono); }
.copy-field .icon-button { width: 28px; height: 28px; border-radius: 6px; }
.status-list { display: grid; gap: 4px; margin-top: 10px; }
.status-list:empty { display: none; }
.status-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 10px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
.status-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12px/1.4 var(--mono); }
.status-list small { grid-column: 1 / -1; color: var(--red); overflow-wrap: anywhere; }
.state { display: flex; align-items: center; gap: 6px; color: var(--green); }
.state i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state.off { color: var(--text-3); }
.purchase-panel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.domain-search-action { display: flex; align-items: center; gap: 6px; }
.domain-search-action input { width: 54px; height: 30px; padding: 0 8px; font-size: 12.5px; }
.purchase-form { margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.purchase-toolbar, .purchase-submit { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; color: var(--text-3); font-size: 12px; }
.purchase-toolbar { border-bottom: 1px solid var(--line); }
.purchase-toolbar label { display: flex; align-items: center; gap: 7px; color: var(--text); cursor: pointer; }
.purchase-options label { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.purchase-options label:hover { background: var(--hover); }
.purchase-options strong { overflow: hidden; text-overflow: ellipsis; font: 400 12px/1.4 var(--mono); }
.purchase-options span { color: var(--text-3); font-size: 11.5px; }
.purchase-submit { flex-wrap: wrap; }
.purchase-submit strong { color: var(--text); }

/* Workspace: the message list and the reading pane share one card. */
.workspace { min-height: 0; display: grid; grid-template-columns: var(--list) minmax(0, 1fr); margin: 0 16px 16px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.google-workspace { grid-template-columns: minmax(0, 1fr); }
.google-workspace .list-pane { min-width: 0; border-right: 0; }
.list-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.list-head { display: grid; gap: 4px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.address-line { min-width: 0; display: flex; align-items: center; gap: 10px; }
.google-workspace .address-line { flex-wrap: wrap; justify-content: space-between; }
.inbox-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.inbox-actions form { margin: 0; }
.address-line .address { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 16px/1.4 var(--mono); }
.mailbox-meta { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-3); font-size: 12px; }
.mailbox-meta.is-error { color: var(--red); }
.mailbox-note { margin: 0; color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.live-dot { position: relative; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--green); }
.live-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--green); animation: pulse 2s ease-out infinite; }
@keyframes pulse { from { opacity: .6; transform: scale(1); } to { opacity: 0; transform: scale(2.6); } }

.message-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.message-row { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background .1s; }
.row-link { position: absolute; inset: 0; }
.row-link:focus-visible { outline-offset: -2px; }
.message-row:hover { background: var(--hover); }
.message-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.message-text { min-width: 0; flex: 1; display: grid; gap: 1px; }
.message-line { min-width: 0; display: flex; align-items: center; gap: 6px; }
.message-from { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.message-clip { color: var(--text-3); }
.message-time { margin-left: auto; padding-left: 10px; flex: 0 0 auto; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.message-subject, .message-snippet, .message-to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-subject { min-width: 0; color: var(--text); font-size: 13.5px; }
.code-chip { position: relative; z-index: 1; height: 22px; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; margin-left: auto; padding: 0 8px; color: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; background: var(--accent-soft); cursor: pointer; font: 600 12px/1 var(--mono); letter-spacing: .04em; }
.code-chip:hover { border-color: var(--accent); }
/* Google inbox rows come from Gmail's web feed; the body expands in place. */
.message-row.google { cursor: pointer; }
.message-row.google.is-open .message-snippet { display: none; }
.google-toggle { min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.google-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.google-body { max-width: 76ch; margin: 12px 0 0; padding: 16px 0 4px; border-top: 1px solid var(--line); color: var(--text-2); font: inherit; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.google-status { margin: 0; padding: 16px; color: var(--text-3); font-size: 13px; }
.google-status.is-error { color: var(--red); overflow-wrap: anywhere; }

/* The detected code, large, between the reader's header and the body. */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 28px 0 80px; padding: 12px 12px 12px 16px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 12px; background: var(--accent-soft); }
.code-box div { display: grid; }
.code-box small { color: var(--text-2); font-size: 12px; }
.code-box strong { font: 600 24px/1.25 var(--mono); letter-spacing: .12em; }
.message-subject.is-empty { color: var(--text-3); font-style: italic; }
.message-snippet { color: var(--text-3); font-size: 13px; }
.message-to { color: var(--text-3); font-size: 12px; }
.message-to span { font-family: var(--mono); font-size: 11.5px; }

.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; font-size: 14px; font-weight: 650; }
.avatar.large { width: 40px; height: 40px; font-size: 16px; }
.tone-0 { color: #7c9cff; background: rgba(124, 156, 255, .16); }
.tone-1 { color: #4cc38a; background: rgba(76, 195, 138, .16); }
.tone-2 { color: #e2a64f; background: rgba(226, 166, 79, .16); }
.tone-3 { color: #e879b5; background: rgba(232, 121, 181, .16); }
.tone-4 { color: #40b8d0; background: rgba(64, 184, 208, .16); }
.tone-5 { color: #b18cf6; background: rgba(177, 140, 246, .16); }
@media (prefers-color-scheme: light) {
  .tone-0 { color: #3554d1; } .tone-1 { color: #17804f; } .tone-2 { color: #a36312; }
  .tone-3 { color: #b53c80; } .tone-4 { color: #13809a; } .tone-5 { color: #7448cc; }
}

.empty, .reader-empty { display: grid; justify-items: center; align-content: center; gap: 4px; padding: 56px 24px; text-align: center; }
.empty strong, .reader-empty strong { font-weight: 600; }
.empty > span:not(.empty-icon), .reader-empty > span:not(.empty-icon) { color: var(--text-3); font-size: 13px; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 8px; color: var(--text-2); border-radius: 12px; background: var(--hover); }

/* Reading pane */
.reader-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.reader-empty { flex: 1; }
.reader-toolbar { height: 52px; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.reader-back { display: none; }
.reader-toolbar .row-actions { margin-left: auto; }
.view-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--field); }
.view-switch button { height: 26px; padding: 0 12px; color: var(--text-2); border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 550; }
.view-switch button:hover { color: var(--text); }
.view-switch button[aria-pressed="true"] { color: var(--text); background: var(--hover); box-shadow: 0 0 0 1px var(--line-strong); }
.reader-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.letter-head { padding: 22px 28px 0; }
.letter-head h1:focus:not(:focus-visible) { outline: none; }
.letter-head h1 { font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -.015em; overflow-wrap: anywhere; }
.letter-from { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; }
.letter-people { min-width: 0; flex: 1; display: grid; gap: 1px; }
.letter-sender { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.letter-sender strong { font-weight: 600; }
.letter-sender span, .letter-to { color: var(--text-3); font-size: 13px; overflow-wrap: anywhere; }
.letter-to a { color: var(--text-2); font-family: var(--mono); font-size: 12.5px; text-decoration: none; }
.letter-to a:hover { color: var(--accent); text-decoration: underline; }
.letter-from time { flex: 0 0 auto; padding-top: 2px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.letter-body { padding: 22px 28px 24px 80px; }
.letter-body pre { max-width: 72ch; white-space: pre-wrap; overflow-wrap: anywhere; font: 14.5px/1.65 var(--sans); }
.letter-body p { margin: 0; }
.letter-body[hidden], .letter-rendered[hidden] { display: none; }
/* The email keeps its own light design in a white frame, like a mail client in dark mode. */
.letter-rendered { display: grid; gap: 10px; padding: 18px 28px 24px; }
.email-frame { width: 100%; height: 320px; display: block; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.remote-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 12px; color: var(--text-2); border: 1px solid var(--line); border-radius: 10px; background: var(--panel-raised); font-size: 12.5px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 28px 24px 80px; }
.attachment { max-width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 10px; text-decoration: none; }
.attachment:hover { border-color: var(--text-3); background: var(--hover); }
.attachment span { min-width: 0; display: grid; }
.attachment strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 13px; font-weight: 550; }
.attachment small { color: var(--text-3); font-size: 11.5px; }
.reader-extras { display: grid; gap: 8px; padding: 16px 28px 28px; border-top: 1px solid var(--line); }
.reader-extras .note { margin-bottom: 4px; }
.disclosure { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 550; list-style: none; }
.disclosure > summary:hover { background: var(--hover); }
.disclosure > summary::-webkit-details-marker { display: none; }
.facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 16px; margin: 0; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; color: var(--text-2); }
.source { max-height: 480px; overflow: auto; padding: 12px; color: var(--text-2); border-top: 1px solid var(--line); background: var(--field); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.65 var(--mono); }

/* Toasts */
.flash-stack { position: fixed; z-index: 60; right: 20px; bottom: 20px; width: min(400px, calc(100% - 40px)); display: grid; gap: 8px; }
.alert { position: relative; padding: 11px 14px; border: 1px solid; border-radius: 10px; font-size: 13px; transition: opacity .2s, transform .2s; }
.flash-stack .alert { box-shadow: var(--shadow); background-color: var(--panel); }
.alert.is-hiding { opacity: 0; transform: translateY(6px); }
.alert.success { color: var(--text); border-color: color-mix(in srgb, var(--green) 45%, var(--line)); background-image: linear-gradient(color-mix(in srgb, var(--green) 10%, transparent), color-mix(in srgb, var(--green) 10%, transparent)); }
.alert.error { padding-right: 40px; color: var(--text); border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background-image: linear-gradient(var(--red-soft), var(--red-soft)); }
.alert-close { position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; display: grid; place-items: center; color: var(--text-2); border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.alert-close:hover { color: var(--text); background: var(--hover); }

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 12px; }
.login-card { width: min(380px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.login-card img { border-radius: 10px; }
.login-card h1 { margin-top: 18px; font-size: 20px; font-weight: 650; letter-spacing: -.015em; }
.login-card > p { margin: 4px 0 0; font-size: 13px; }
.login-card .alert { margin-top: 18px; }
.login-form { display: grid; gap: 14px; margin-top: 22px; }
.login-form label { display: grid; gap: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.login-form input { height: 40px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 64px; }
.reveal { position: absolute; top: 6px; right: 6px; height: 28px; padding: 0 10px; color: var(--text-3); border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 12px; }
.reveal:hover { color: var(--text); background: var(--hover); }
.login-submit { width: 100%; height: 40px; margin-top: 4px; }

/* Below this width the navigation becomes a drawer behind the menu button. */
@media (max-width: 1180px) {
  :root { --list: 360px; }
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 0 12px 0 8px; }
  .topbar-brand { padding-left: 0; }
  .nav-toggle { display: inline-flex; }
  .sidebar-inbox-create { display: none; }
  .mobile-inbox-create { display: flex; flex: 0 0 auto; padding: 0 12px 10px; }
  .mobile-inbox-create form { flex: 1; }
  .mobile-inbox-create .button { height: 36px; justify-content: center; }
  .shell-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace { margin: 0 12px 12px; }
  .nav { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(var(--nav), 85vw); padding-top: 16px; background: var(--bg); box-shadow: var(--shadow); visibility: hidden; transform: translateX(-105%); transition: transform .2s ease, visibility 0s linear .2s; }
  .nav-open .nav { visibility: visible; transform: none; transition: transform .2s ease; }
  .nav-backdrop { position: fixed; z-index: 45; inset: 0; background: rgba(0, 0, 0, .45); }
  .nav-open .nav-backdrop { display: block; }
}

/* Phones: the list and the open message take turns filling the screen. */
@media (max-width: 760px) {
  .brand { display: none; }
  .topbar-inner { height: 56px; gap: 8px; }
  .inbox-search input { height: 40px; }
  .workspace { grid-template-columns: minmax(0, 1fr); margin: 0 8px 8px; border-radius: 12px; }
  .list-pane { border-right: 0; }
  .reader-pane { display: none; }
  .has-message .list-pane { display: none; }
  .has-message .reader-pane { display: flex; }
  .reader-back { display: inline-flex; }
  .letter-head { padding: 18px 16px 0; }
  .letter-from { flex-wrap: wrap; }
  .letter-from time { flex-basis: 100%; padding-left: 52px; }
  .letter-body { padding: 18px 16px 22px; }
  .letter-rendered { padding: 16px 12px 20px; }
  .code-box { margin: 16px 16px 0; }
  .attachments { padding: 0 16px 20px; }
  .reader-extras { padding: 14px 16px 20px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .flash-stack { right: 12px; bottom: 12px; width: calc(100% - 24px); }
  .login-card { padding: 24px; }
}

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