/* InboxChute app stylesheet. Light and dark follow the browser. */
:root {
  color-scheme: light dark;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --fg: #1d2330;
  --muted: #5d6675;
  --line: #e2dfd8;
  --line-strong: #cfcac0;
  --accent: #2346a8;
  --accent-hover: #1b3887;
  --accent-soft: #e8edfb;
  --accent-fg: #ffffff;
  --ok: #1d7a46;
  --ok-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf1d8;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --shadow: 0 1px 2px rgba(29, 35, 48, 0.06), 0 1px 1px rgba(29, 35, 48, 0.04);
  --radius: 10px;
  --focus: 0 0 0 3px rgba(35, 70, 168, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1e26;
    --fg: #e8eaee;
    --muted: #9aa3b2;
    --line: #2a303b;
    --line-strong: #3a414e;
    --accent: #8aa8ff;
    --accent-hover: #a9c0ff;
    --accent-soft: #1f2a47;
    --accent-fg: #0f1320;
    --ok: #5cc98b;
    --ok-soft: #15301f;
    --warn: #e5b45a;
    --warn-soft: #33270f;
    --bad: #ff8a80;
    --bad-soft: #3a1714;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --focus: 0 0 0 3px rgba(138, 168, 255, 0.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
h1 { font-size: 1.75rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; margin-top: 2rem; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.85rem; }
code { font: 0.875em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--accent-soft); padding: 0.1em 0.35em; border-radius: 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 64rem; margin: 0 auto; padding: 0.7rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--fg); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { color: var(--fg); }
.brand svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 8px; font-size: 0.95rem; }
.nav a:hover { color: var(--fg); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--fg); background: var(--accent-soft); font-weight: 600; }
.topbar-inner > form { margin: 0 0 0 auto; }
/* The phone menu (src/web/shell.ts topbar): hidden on wide screens, where the navigation sits in the bar. */
.menu { display: none; }

/* Page */
.page { max-width: 64rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page-narrow { max-width: 40rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head > * { min-width: 0; }
.page-head p { margin: 0.25rem 0 0; color: var(--muted); }

/* In-page links at the top of a long page (src/web/responsive.ts, jumpNav) */
.jump { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.25rem; }
.jump a { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.25rem 0.85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--fg); text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.jump a:hover { border-color: var(--accent); color: var(--accent); }
[id] { scroll-margin-top: 1rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.35rem; margin-bottom: 1rem; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.card-head h3 { margin: 0; overflow-wrap: anywhere; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr)); }
.card-danger { border-color: var(--bad); }

/* Tabs: one switcher style for every per-mailbox page */
.tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0 0 1.25rem; padding: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); width: fit-content; max-width: 100%; }
.tabs a { color: var(--muted); text-decoration: none; padding: 0.35rem 0.8rem; border-radius: 7px; font-size: 0.9rem; font-weight: 500; overflow-wrap: anywhere; }
.tabs a:hover { color: var(--fg); background: var(--bg); }
.tabs a[aria-current="page"] { color: var(--accent-fg); background: var(--accent); font-weight: 600; }

/* Stat tiles */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; }
.stat-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin: 0.15rem 0; }
.stat-note { font-size: 0.8rem; color: var(--muted); }

/* Compact controls */
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0 0 0.75rem; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; min-width: 11rem; }
.btn-sm, button.btn-sm { font-size: 0.85rem; padding: 0.3rem 0.7rem; }
.card-foot { border-top: 1px solid var(--line); margin-top: 0.9rem; padding-top: 0.75rem; display: flex; gap: 0.25rem 1rem; flex-wrap: wrap; align-items: center; }
.card-foot a, .card-foot button { font-size: 0.875rem; }
.link-danger { color: var(--bad); }
.link-danger:hover { color: var(--bad); }

/* Facts */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0 0 1rem; font-size: 0.925rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill-bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pill-info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* Banners */
.banner { border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.banner p:last-child { margin-bottom: 0; }
.banner-warn { background: var(--warn-soft); color: var(--fg); border-color: var(--warn); }
.banner-bad { background: var(--bad-soft); color: var(--fg); border-color: var(--bad); }
.banner-ok { background: var(--ok-soft); color: var(--fg); border-color: var(--ok); }
.banner-info { background: var(--accent-soft); color: var(--fg); border-color: var(--accent); }

/* Buttons and forms */
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; font: inherit; font-size: 0.95rem; font-weight: 600; padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover, button:hover { border-color: var(--muted); color: var(--fg); }
.btn-primary, button.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover, button.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn-danger, button.btn-danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover, button.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-quiet, button.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover, button.btn-quiet:hover { color: var(--fg); background: var(--bg); border-color: transparent; }
.btn-lg { font-size: 1.05rem; padding: 0.7rem 1.35rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
label { display: block; font-weight: 600; font-size: 0.925rem; margin-bottom: 0.3rem; }
input[type="email"], input[type="text"], select, textarea { font: inherit; width: 100%; max-width: 28rem; padding: 0.5rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field { margin-bottom: 1rem; }
textarea { max-width: 40rem; min-height: 6rem; resize: vertical; line-height: 1.5; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
label.check input { flex: none; margin: 0; accent-color: var(--accent); }
fieldset { border: none; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-weight: 600; font-size: 0.925rem; margin-bottom: 0.3rem; padding: 0; }
.hint { font-size: 0.85rem; color: var(--muted); font-weight: 400; margin-top: 0.25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
th, td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td form { margin: 0; }
td { overflow-wrap: break-word; }

/* Long model-facing wording, collapsed to its first sentence (src/web/responsive.ts, collapsedWording) */
.wording-lead { margin: 0; }
.wording details { margin-top: 0.3rem; }
.wording details p { margin: 0; }
.wording:has(> details[open]) > .wording-lead { display: none; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.875rem; }
summary:hover { color: var(--accent-hover); }
details[open] > summary { margin-bottom: 0.4rem; }

/*
 * Stacked tables (table.stack). Below 40rem every row is a card: the header row is hidden, each cell names its column from
 * data-label, a first cell with no label is the card's heading, and a .cell-inline cell (a count, a date, a pill) sits on the same
 * line as what comes before it. On wider screens a stacked table is an ordinary table.
 */
@media (max-width: 40rem) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.45rem 0.9rem; margin: 0 0 0.75rem; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
  table.stack tr:last-child { margin-bottom: 0; }
  table.stack td, table.stack tr:last-child td { flex: 1 1 100%; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  table.stack td:first-child:not([data-label]) { flex: 1 1 auto; font-weight: 650; }
  table.stack td:first-child:not([data-label]) :is(.small, p, div) { font-weight: 400; }
  table.stack td.cell-inline { flex: 0 1 auto; }
  table.stack td.cell-inline > p { display: inline; margin: 0 0 0 0.4rem; }
  table.stack td:empty { display: none; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 0.1rem; color: var(--muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
  table.stack td.cell-inline[data-label]::before { display: inline; margin: 0 0.4rem 0 0; }
  table.stack td .actions, table.stack td > form { margin-top: 0.15rem; }
  .table-wrap:has(> table.stack) { overflow-x: visible; }
}

/* Steps (first run) */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.75rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: none; }
.steps li::before { counter-increment: step; content: counter(step); width: 1.75rem; height: 1.75rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; background: var(--bg); border: 1px solid var(--line-strong); color: var(--muted); }
.steps li.done::before { content: "\2713"; background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.now::before { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.steps h3 { margin: 0.15rem 0 0.2rem; }
.steps p { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.925rem; }

/* Landing */
.hero { max-width: 44rem; margin: 0 auto; padding: 4.5rem 1.25rem 2rem; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 1rem; }
.hero .lead { font-size: 1.15rem; color: var(--muted); margin-bottom: 2rem; }
.hero .actions { justify-content: center; }
.features { max-width: 52rem; margin: 0 auto; padding: 1rem 1.25rem 4rem; display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.features .card h3 { margin-bottom: 0.35rem; }
.features .card p { color: var(--muted); font-size: 0.95rem; }
.footer { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

/* Stand-alone message pages (errors, approvals) */
.notice { max-width: 34rem; margin: 4rem auto; padding: 0 1.25rem; }

@media (max-width: 40rem) {
  .topbar-inner { gap: 0.5rem 0.75rem; padding: 0.5rem 1rem; flex-wrap: nowrap; }
  .topbar-inner > .nav, .topbar-inner > form { display: none; }
  .menu { display: block; position: relative; margin-left: auto; }
  .menu > summary { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.4rem 0.85rem; list-style: none; cursor: pointer; color: var(--fg); font-weight: 600; border: 1px solid var(--line); border-radius: 8px; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu > summary svg { width: 1.25rem; height: 1.25rem; }
  .menu[open] > summary { background: var(--bg); }
  .menu-list { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20; display: flex; flex-direction: column; min-width: 15rem; padding: 0.4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28); }
  .menu-list a { display: flex; align-items: center; min-height: 2.75rem; padding: 0.5rem 0.85rem; border-radius: 8px; color: var(--fg); text-decoration: none; }
  .menu-list a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
  .menu-list form { margin: 0.3rem 0 0; padding-top: 0.3rem; border-top: 1px solid var(--line); }
  .menu-list form button { width: 100%; min-height: 2.75rem; justify-content: flex-start; text-align: left; }
  .nav { order: 3; flex-basis: 100%; gap: 0.25rem; }
  .nav a, .topbar form button { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.4rem 0.75rem; }
  .page { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.5rem; }
  h2 { margin-top: 1.75rem; }
  .card { padding: 1rem; }
  .page-head { margin-bottom: 1rem; }
  .btn, button { min-height: 2.5rem; }
  summary { display: flex; align-items: center; min-height: 2.5rem; }
  .tabs { width: auto; }
  .tabs a { display: inline-flex; align-items: center; min-height: 2.25rem; }
  input[type="email"], input[type="text"], select, textarea { max-width: 100%; }
  .inline-form select { min-width: 0; flex: 1 1 10rem; }
  form > button[type="submit"].btn-primary, .page-head > .btn { width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { margin-top: 0.4rem; }
  .features { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}
