/* Mail Hub · Clear desk. Light and dark are equal themes; the page follows the device unless Appearance picks one.
   One violet accent marks the primary action and what is current. Every colour lives in the token blocks below, once
   per theme (a test enforces it), and every text token meets WCAG AA (4.5:1) on every surface in both themes.
   This file holds the tokens and the shared pieces (type, buttons, fields, chips, cards, tiles); each area has its
   own sheet: nav.css, mail.css, pane.css, pages.css. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Tokens. Light is the default; data-theme="dark" is dark; data-theme="system" follows the device.
   Two values differ from the design spec because they failed AA: light --primary-soft F0EDFF became F3F1FF (violet
   text on it was 4.48:1), and dark --primary 8B70FF became 9580FF (4.11:1 on its soft ground) with dark text on it
   (white on the dark violet was 3.6:1). */
:root {
  color-scheme: light;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 10px;
  --radius-card: 14px;
  --bg: #FFFFFF;
  --weak: #F5F4F2;
  --side: #F8F7F5;
  --line: #EAE7E4;
  --text: #0C0C14;
  --muted: #5C5958;
  --primary: #6D4AFF;
  --primary-soft: #F3F1FF;
  --on-primary: #FFFFFF;
  --danger: #C7243A;
  --danger-soft: #FDECEE;
  --warn: #9A5B00;
  --warn-soft: #FFF4E0;
  --ok: #127A5E;
  --ok-soft: #E3F6EF;
  --paper: #FFFFFF;
  --scrim: rgba(12, 12, 20, .32);
  --field-line: color-mix(in srgb, var(--muted) 70%, var(--bg));
  --c-conv: #2F55C8;
  --c-bill: #8F5B00;
  --c-sec: #B02525;
  --c-job: #6B43C4;
  --c-note: #4F5E7A;
  --c-news: #0A7483;
  --c-promo: #B3326A;
  --c-junk: #5C5958;
  --c-unsure: #8F5B00;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16141C;
  --weak: #211F2A;
  --side: #1B1922;
  --line: #2F2C3A;
  --text: #FFFFFF;
  --muted: #B4B1C2;
  --primary: #9580FF;
  --primary-soft: #2A2440;
  --on-primary: #16141C;
  --danger: #FF6B81;
  --danger-soft: #3A1E26;
  --warn: #FFB547;
  --warn-soft: #3A2D18;
  --ok: #4FD1A5;
  --ok-soft: #173329;
  --paper: #FFFFFF;
  --scrim: rgba(0, 0, 0, .55);
  --c-conv: #8FB4FF;
  --c-bill: #E8B04B;
  --c-sec: #FF7A7A;
  --c-job: #C3A6FF;
  --c-note: #A3B1C9;
  --c-news: #6FD3C8;
  --c-promo: #FF9BC4;
  --c-junk: #B4B1C2;
  --c-unsure: #E8B04B;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #16141C;
    --weak: #211F2A;
    --side: #1B1922;
    --line: #2F2C3A;
    --text: #FFFFFF;
    --muted: #B4B1C2;
    --primary: #9580FF;
    --primary-soft: #2A2440;
    --on-primary: #16141C;
    --danger: #FF6B81;
    --danger-soft: #3A1E26;
    --warn: #FFB547;
    --warn-soft: #3A2D18;
    --ok: #4FD1A5;
    --ok-soft: #173329;
    --paper: #FFFFFF;
    --scrim: rgba(0, 0, 0, .55);
    --c-conv: #8FB4FF;
    --c-bill: #E8B04B;
    --c-sec: #FF7A7A;
    --c-job: #C3A6FF;
    --c-note: #A3B1C9;
    --c-news: #6FD3C8;
    --c-promo: #FF9BC4;
    --c-junk: #B4B1C2;
    --c-unsure: #E8B04B;
  }
}

/* Account colours: pages set --acc-d and --acc-l inline; the theme picks one. */
[style*="--acc-d"] { --acc: var(--acc-l); }
:root[data-theme="dark"] [style*="--acc-d"] { --acc: var(--acc-d); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] [style*="--acc-d"] { --acc: var(--acc-d); }
}

/* elements */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
::selection { background: var(--primary-soft); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
a { color: var(--text); text-decoration-color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
/* Blazor focuses the page heading after navigation for screen readers; a heading is not a control, so no ring. */
h1:focus { outline: none; }
p { margin: 0; }
code, kbd { font-family: var(--mono); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* type: 26 px page titles, 15 px section heads, 13 px small print */
.page-title, .display { font: 700 26px/1.2 var(--sans); letter-spacing: -.01em; }
.page-title { margin: 2px 0 14px; }
.page-date { font-size: 13px; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 20px 0 6px; }
.section-head h2 { font: 600 15px/1.3 var(--sans); }
.section-head a, .section-head .link { font: 500 14px var(--sans); color: var(--primary); text-decoration: none; }
.label { font: 500 13px/1.2 var(--sans); color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* icons: <Icon> draws a 24 px grid, 2 px stroke; older inline SVGs use svg.icon */
svg.ic { display: block; flex: none; }
svg.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* buttons: weak by default, violet for the one primary action; 40 px tall */
.btn {
  min-height: 40px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px var(--sans);
  color: var(--text);
  background: var(--weak);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, var(--weak)); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 86%, var(--text)); color: var(--on-primary); }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--weak); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); background: none; border: 0; border-radius: var(--radius); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--weak); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; color: var(--primary); font: inherit; text-decoration: underline; }

/* fields */
form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label { font: 500 13px var(--sans); color: var(--muted); }
.input {
  min-height: 44px; width: 100%;
  background: var(--bg);
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  color: var(--text);
  font: 16px var(--sans);
  padding: 0 12px;
}
.input.code { font: 500 18px var(--mono); letter-spacing: .3em; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--primary); }
.input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.input.invalid { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.check input { accent-color: var(--primary); width: 18px; height: 18px; }
.validation-message, .form-error { color: var(--danger); font-size: 13px; }
.form-error { margin: 10px 0 0; }
.validation-errors { margin: 0; padding-left: 18px; color: var(--danger); font-size: 13px; }

/* messages */
.alert { border: 1px solid var(--line); border-radius: var(--radius); background: var(--weak); padding: 10px 12px; font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.alert strong { color: var(--text); }
.alert.danger { border-color: var(--danger); color: var(--text); background: var(--danger-soft); }
.alert.success { border-color: var(--ok); background: var(--ok-soft); color: var(--text); }
.alert.warning { border-color: var(--warn); background: var(--warn-soft); color: var(--text); }
.toast { margin-top: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--ok-soft); color: var(--text); font-size: 14px; }
.empty { max-width: 560px; margin: 12vh auto 0; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); padding: 28px 28px 26px; display: grid; gap: 12px; }
.empty h1 { font-size: 22px; }
.empty p { color: var(--muted); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }

/* status chips (the mock's "waiting 2 days", "bill · €7.14", "verified") */
.status-pill { display: inline-flex; align-items: center; gap: 4px; font: 600 12px/1.5 var(--sans); padding: 2px 9px; border-radius: 99px; white-space: nowrap; background: var(--weak); color: var(--muted); }
.status-pill.danger { background: var(--danger-soft); color: var(--danger); }
.status-pill.warn { background: var(--warn-soft); color: var(--warn); }
.status-pill.ok { background: var(--ok-soft); color: var(--ok); }
.status-pill.primary { background: var(--primary-soft); color: var(--primary); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: var(--on-primary); font: 600 12px/1 var(--sans); font-variant-numeric: tabular-nums; }

/* filter chips (All · People · Money ...): the active one is inverted */
.filter-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filter-chip { flex: none; min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 99px; background: var(--weak); color: var(--text); font: 500 14px var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none; }
.filter-chip[aria-pressed="true"], .filter-chip[aria-current="page"] { background: var(--text); color: var(--bg); }

/* tiles: three count buttons above the list; pressed shows the violet ring */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; align-content: start; min-height: 76px; padding: 12px 10px; border: 1.5px solid transparent; border-radius: var(--radius-card); background: var(--weak); color: var(--text); text-align: left; text-decoration: none; font: inherit; cursor: pointer; }
.tile b { font: 700 24px/1 var(--sans); color: var(--text); font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; line-height: 1.25; color: var(--muted); }
.tile.hot b { color: var(--primary); }
.tile[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }

/* cards: one per thing that needs Tim */
.card { display: grid; gap: 6px; margin: 10px 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.card p { font-size: 15px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: 6px; }
.card-actions .btn.primary { flex: 1; }

/* link lists: the More and Automation rows (label left, value and chevron right) */
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list a, .link-list .link-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 15px; text-decoration: none; }
.link-list a:hover { color: var(--primary); }
.link-list .meta { font-size: 14px; color: var(--muted); }
.link-list form { display: block; }
.link-list button.link-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }

/* tags: the account short label, a category, a flag, the AI mark */
.tag { font: 600 12px var(--sans); letter-spacing: .02em; border: 1px solid transparent; border-radius: 6px; color: color-mix(in srgb, var(--acc, var(--text)) 80%, var(--text)); background: color-mix(in srgb, var(--acc, transparent) 15%, transparent); padding: 2px 6px; text-align: center; min-width: 52px; }
.ctag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--cc) 14%, transparent); color: color-mix(in srgb, var(--cc) 80%, var(--text)); font: 500 12px var(--sans); white-space: nowrap; --cc: var(--muted); }
.ctag .ci { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ctag[data-c="conversation"] { --cc: var(--c-conv); }
.ctag[data-c="bill"] { --cc: var(--c-bill); }
.ctag[data-c="security"] { --cc: var(--c-sec); }
.ctag[data-c="job"] { --cc: var(--c-job); }
.ctag[data-c="notification"] { --cc: var(--c-note); }
.ctag[data-c="newsletter"] { --cc: var(--c-news); }
.ctag[data-c="promotion"] { --cc: var(--c-promo); }
.ctag[data-c="junk"] { --cc: var(--c-junk); }
.ctag[data-c="unsure"] { --cc: var(--c-unsure); }
/* Red is reserved: it says "this one waits on you", never "this is a category". */
.flag { font: 500 12px/1.5 var(--sans); padding: 0 7px; border-radius: 99px; background: var(--weak); color: var(--muted); }
.flag.hot { background: var(--primary-soft); color: var(--primary); }
.flag.warn { background: var(--danger-soft); color: var(--danger); }
/* Marks text the AI wrote from the mail itself (SEC-3): quiet, but always there. */
.ai-mark { display: inline-block; font: 600 10px/1.5 var(--sans); letter-spacing: .04em; padding: 0 4px; margin-right: 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); vertical-align: 1px; }
.addr { display: flex; align-items: center; gap: 8px; font: 500 14px var(--sans); overflow-wrap: anywhere; }
.when { font: 13px var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.when.hot { color: var(--primary); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; flex: none;
  font: 700 15px var(--sans);
}

/* Phones: small buttons still get a 40 px tap target. */
@media (max-width: 899px) {
  .btn.small { min-height: 40px; }
}

#blazor-error-ui {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: var(--danger-soft); border-top: 1px solid var(--danger);
  padding: 10px 16px; color: var(--text);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }
