/*
 * ChatHub inbox: tokens and base. Style: »framed sheet« (docs/design/inbox-v2.md, 3).
 * The chrome (rail) is one tinted frame; the work sits on a sheet with a 1px edge and no shadow.
 * Colour budget: the sites carry the chroma (one swatch each), the accent marks Claude and focus,
 * and status colours appear only on a state that needs action. Every text pair is at least 4.5:1.
 *
 * Files: application.css (this: tokens, base, buttons, fields), inbox.css (the desk and the phone),
 * screens.css (settings, sign-in, the original-mail dialog).
 */

:root {
  /* Surfaces */
  --frame: #F1F3F4;
  --sheet: #FFFFFF;
  --raised: #F6F7F8;
  --active: #E9ECEE;
  --border: #E4E7EA;
  --rule: #EEF0F2;
  --control: #CBD0D5;
  --field-edge: #8C9299;

  /* Text */
  --ink: #131416;
  --ink-2: #3A3E44;
  --muted: #5B6168;
  --faint: #656B71;

  /* Actions and meaning */
  --primary: #1D2024;
  --on-primary: #FFFFFF;
  --accent: #1B6C80;
  --accent-soft: #E6F1F4;
  --positive: #1E7B4F;
  --negative: #C4242A;
  --negative-soft: #FFEDEA;
  --negative-ink: #831C1E;
  --warning: #B4580A;
  --warning-soft: #FFF4E5;
  --note: #FFF7DB;
  --note-edge: #EBCB6B;
  --note-ink: #6B4A00;

  /* Messages */
  --bubble-theirs: #F1F3F5;
  --bubble-mine: #1D2024;
  --on-mine: #FFFFFF;

  /* Type: one face. */
  --font: "Mona Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-msg: 15px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --lh: 1.45;

  /* Shape and space (4px base) */
  --radius-sheet: 14px;
  --radius-card: 10px;
  --radius-control: 8px;
  --radius-bubble: 16px;
  --radius-chip: 6px;
  --sheet-inset: 8px;
  --rail-w: 220px;
  --list-w: 360px;
  --panel-w: 300px;
  --row-h: 76px;
  --control-h: 32px;
  --tap: 44px;
  --pad: 16px;
  --pad-lg: 24px;

  --focus: 0 0 0 2px var(--sheet), 0 0 0 4px var(--accent);
  --float: 0 12px 32px -12px rgb(19 20 22 / .28), 0 2px 6px rgb(19 20 22 / .06);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Dark: true neutrals, lightness steps for elevation, colour only on meaning. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --frame: #0B0B0C; --sheet: #141516; --raised: #1B1C1E; --active: #242628;
    --border: #26282B; --rule: #1E2022; --control: #3D4045; --field-edge: #6E747B;
    --ink: #F2F3F4; --ink-2: #C9CCD0; --muted: #A9AEB4; --faint: #8E949A;
    --primary: #F2F3F4; --on-primary: #111214;
    --accent: #5CB8CE; --accent-soft: #15292E;
    --positive: #5BC48E; --negative: #F07A7F; --negative-soft: #2C1A1C; --negative-ink: #F5A3A6;
    --warning: #E8A25A; --warning-soft: #2A1E10;
    --note: #2A2410; --note-edge: #6B5A1E; --note-ink: #F1D27A;
    --bubble-theirs: #222427; --bubble-mine: #E6E8EA; --on-mine: #111214;
    --float: 0 16px 40px -12px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .swatch { background: var(--site-d, var(--muted)); }
}
:root[data-theme="dark"] {
  --frame: #0B0B0C; --sheet: #141516; --raised: #1B1C1E; --active: #242628;
  --border: #26282B; --rule: #1E2022; --control: #3D4045; --field-edge: #6E747B;
  --ink: #F2F3F4; --ink-2: #C9CCD0; --muted: #A9AEB4; --faint: #8E949A;
  --primary: #F2F3F4; --on-primary: #111214;
  --accent: #5CB8CE; --accent-soft: #15292E;
  --positive: #5BC48E; --negative: #F07A7F; --negative-soft: #2C1A1C; --negative-ink: #F5A3A6;
  --warning: #E8A25A; --warning-soft: #2A1E10;
  --note: #2A2410; --note-edge: #6B5A1E; --note-ink: #F1D27A;
  --bubble-theirs: #222427; --bubble-mine: #E6E8EA; --on-mine: #111214;
  --float: 0 16px 40px -12px rgb(0 0 0 / .7);
  color-scheme: dark;
}
:root[data-theme="dark"] .swatch { background: var(--site-d, var(--muted)); }

/* ── Base ──────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--frame);
  color: var(--ink);
  font: 400 var(--fs-md)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* No tabular figures: Mona Sans draws a slashed zero in tnum, which reads as »Ø« in Danish. */
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-control); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); }

.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; background: var(--site-l, var(--muted)); }
.swatch--sm { width: 8px; height: 8px; border-radius: 2px; }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 12px;
  border-radius: var(--radius-control); border: 1px solid var(--control);
  background: var(--sheet); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 550; white-space: nowrap; text-decoration: none;
  line-height: 1;
}
.btn:hover { background: var(--raised); }
.btn--primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn--primary:hover { background: color-mix(in srgb, var(--primary) 86%, var(--sheet)); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--quiet:hover { background: var(--raised); }
.btn--danger { color: var(--negative); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--block { width: 100%; }
.btn--lg { height: 40px; padding: 0 16px; font-size: var(--fs-md); }
.btn[disabled], .btn[aria-disabled="true"] { color: var(--faint); background: var(--raised); border-color: var(--border); cursor: not-allowed; }
.btn--primary[disabled] { color: var(--faint); }
form.button_to { display: contents; }
.kbd { font: 500 11px/1 var(--font); color: var(--faint); border: 1px solid var(--border); border-radius: 4px; padding: 2px 4px; min-width: 16px; text-align: center; }
.btn--primary .kbd { color: color-mix(in srgb, var(--on-primary) 70%, transparent); border-color: color-mix(in srgb, var(--on-primary) 30%, transparent); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-size: var(--fs-sm); font-weight: 550; text-decoration: none; cursor: pointer; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

.avatar {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; overflow: hidden;
  background: var(--active); color: var(--ink-2);
  font: 600 9.5px/1 var(--font); letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--md { width: 28px; height: 28px; font-size: 11px; }
.avatar--claude { background: var(--accent-soft); color: var(--accent); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; flex: none; white-space: nowrap;
  height: 20px; padding: 0 7px; border-radius: var(--radius-chip);
  font-size: var(--fs-xs); font-weight: 550;
  background: var(--active); color: var(--ink-2);
}
.tag--accent { background: var(--accent-soft); color: var(--accent); }
.tag--negative { background: var(--negative-soft); color: var(--negative-ink); }
.tag--warning { background: var(--warning-soft); color: var(--warning); }
.tag--positive { background: color-mix(in srgb, var(--positive) 14%, var(--sheet)); color: var(--positive); }
.tag--note { background: var(--note); color: var(--note-ink); }

/* ── Fields (settings, sign-in, forms) ─────────────────────────────── */

.field { display: grid; gap: 6px; }
.field-label { font-size: var(--fs-sm); font-weight: 550; color: var(--ink-2); }
.field-hint { font-size: var(--fs-sm); color: var(--muted); }
.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--field-edge); border-radius: var(--radius-control);
  background: var(--sheet); color: var(--ink); font-size: var(--fs-md);
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: var(--focus); }
textarea.input { resize: vertical; line-height: var(--lh); }
select.input { padding-right: 32px; }
.input--small { min-height: var(--control-h); padding: 4px 8px; font-size: var(--fs-sm); width: auto; }
.input--code { font-size: 24px; letter-spacing: .3em; text-align: center; }
.check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.stack { display: grid; gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

@media (max-width: 760px) {
  .input { font-size: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .linkish { transition: background-color .12s ease, color .12s ease; }
}
