/*
 * HQ server pages (sign-in, mailbox, composer, preview, Settings): the v4 tokens (docs/V3-DESIGN.md §5): black,
 * white, grey and silver only, the same values as the screens. The old token names stay; the four label colours are
 * now shades (labels are told apart by text and icon). Light by default; dark when the device asks for it, unless the
 * noli_theme cookie set [data-theme] on <html>. Opaque surfaces (forms read best without glass), motion ≤ 200 ms.
 */
@font-face { font-family: 'Instrument Serif'; src: url('/fonts/InstrumentSerif-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Schibsted Grotesk'; src: url('/fonts/SchibstedGrotesk-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Schibsted Grotesk'; src: url('/fonts/SchibstedGrotesk-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Schibsted Grotesk'; src: url('/fonts/SchibstedGrotesk-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #F4F4F5; --surface: #FFFFFF; --surface-raised: #FFFFFF; --border: #E4E4E7; --border-strong: #71717A;
  --text: #0A0A0B; --text-muted: #52525B; --accent: #0A0A0B; --accent-hover: #27272A; --on-accent: #FAFAFA; --focus: #0A0A0B;
  --alert: #0A0A0B; --alert-tint: #E4E4E7; --action: #0A0A0B; --action-tint: #FFFFFF;
  --blocked: #3F3F46; --blocked-tint: #D4D4D8; --done: #0A0A0B; --done-tint: #C9CBD1;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --radius: 12px; --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --ease: cubic-bezier(0.2, 0, 0, 1); --fast: 150ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0B; --surface: #161618; --surface-raised: #1C1C1F; --border: #27272A; --border-strong: #71717A;
    --text: #FAFAFA; --text-muted: #A1A1AA; --accent: #FAFAFA; --accent-hover: #E4E4E7; --on-accent: #0A0A0B; --focus: #FAFAFA;
    --alert: #FAFAFA; --alert-tint: #27272A; --action: #FAFAFA; --action-tint: #161618;
    --blocked: #D4D4D8; --blocked-tint: #3F3F46; --done: #FAFAFA; --done-tint: #3F3F46;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0B; --surface: #161618; --surface-raised: #1C1C1F; --border: #27272A; --border-strong: #71717A;
  --text: #FAFAFA; --text-muted: #A1A1AA; --accent: #FAFAFA; --accent-hover: #E4E4E7; --on-accent: #0A0A0B; --focus: #FAFAFA;
  --alert: #FAFAFA; --alert-tint: #27272A; --action: #FAFAFA; --action-tint: #161618;
  --blocked: #D4D4D8; --blocked-tint: #3F3F46; --done: #FAFAFA; --done-tint: #3F3F46;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--sans); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font: 400 clamp(2rem, 1.5rem + 2vw, 2.75rem)/1.1 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: 0.875rem; overflow-wrap: anywhere; }
.quiet { color: var(--text-muted); }
.block { display: block; }
.lede { color: var(--text-muted); max-width: 65ch; }
.skip { position: absolute; left: var(--space-3); top: -48px; padding: var(--space-2) var(--space-3); background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: var(--radius); z-index: 10; }
.skip:focus { top: var(--space-3); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain > li { padding: var(--space-2) 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
ul.plain > li:first-child { border-top: 0; }

/* ---------- logo: the file that fits the theme, in black or white only (v4) ---------- */
.logo { display: inline-flex; }
.logo img { display: block; height: auto; max-width: 100%; filter: brightness(0); }
.logo .logo-linen { filter: brightness(0) invert(1); }
.logo-noli img, .logo-noli .logo-linen { filter: none; } /* the studio's «A medida» files already are ink and lino: never recoloured */
.logo-linen { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-ink { display: none !important; } :root:not([data-theme="light"]) .logo-linen { display: block !important; } }
:root[data-theme="dark"] .logo-ink { display: none !important; }
:root[data-theme="dark"] .logo-linen { display: block !important; }

/* ---------- shell ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); padding: var(--space-3) var(--space-4); background: var(--surface); border-bottom: 1px solid var(--border); }
.top-home { display: inline-flex; padding: var(--space-1); }
.top-nav { flex: 1 1 auto; min-width: 0; }
.top-nav ul { display: flex; flex-wrap: wrap; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.top-nav a, .top-account a, .link-button { display: inline-block; min-height: 44px; padding: 10px var(--space-3); border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.top-nav a:hover, .top-account a:hover, .link-button:hover { background: var(--surface-raised); color: var(--text); }
.top-nav a[aria-current="page"], .top-account a[aria-current="page"] { background: var(--surface-raised); box-shadow: inset 0 -2px 0 var(--accent); }
.top-account { display: flex; align-items: center; gap: var(--space-1); }
.link-button { background: none; border: 0; font: inherit; cursor: pointer; }
.banner { margin: 0; padding: var(--space-2) var(--space-4); background: var(--action-tint); color: var(--text); font-weight: 500; }
main { display: block; max-width: 1120px; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); }
main:focus { outline: none; }
.head { margin-bottom: var(--space-5); }
.crumb { color: var(--text-muted); }
.grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); min-width: 0; box-shadow: 0 1px 0 var(--border); }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid > .compose, .grid > .confirm, .grid > .checks, #inbox-threads, #thread, #people, #secrets { grid-column: 1 / -1; } }

/* ---------- the four labels and tags ---------- */
.label { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; vertical-align: 1px; }
.label-mark { font-weight: 700; }
.label-alert { color: var(--alert); background: var(--alert-tint); }
.label-action { color: var(--action); background: var(--action-tint); }
.label-blocked { color: var(--blocked); background: var(--blocked-tint); }
.label-done { color: var(--done); background: var(--done-tint); }
.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* ---------- messages ---------- */
.flash, .notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-raised); max-width: 75ch; }
.flash-ok, .notice-done { border-color: var(--done); background: var(--done-tint); }
.flash-error { border-color: var(--alert); background: var(--alert-tint); }
.empty { color: var(--text-muted); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 10px var(--space-4); border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-raised); color: var(--text); font: 500 1rem/1.2 var(--sans); text-decoration: none; cursor: pointer; transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.btn:hover { border-color: var(--text); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { color: var(--alert); border-color: var(--alert); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-small { min-height: 36px; padding: 6px var(--space-3); font-size: 0.875rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-google { background: var(--surface-raised); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.stack { display: grid; gap: var(--space-3); }
form.inline { display: inline; }
.field { display: grid; gap: var(--space-1); min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.field-help { font-size: 0.875rem; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="search"], select, textarea, .rte { width: 100%; min-height: 44px; padding: 10px var(--space-3); border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-raised); color: var(--text); font: 400 1rem/1.5 var(--sans); }
textarea, .rte { min-height: 12rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: 0; min-width: 0; }
legend { padding: 0 var(--space-1); font-weight: 600; }
label.check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; margin-right: var(--space-4); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); }
.rte-bar { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mailbox, preview ---------- */
.thread > p { margin: 0; }
.timeline { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); }
.msg { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); overflow-wrap: anywhere; }
.msg-in { border-left: 3px solid var(--accent); }
dl.kv { display: grid; gap: var(--space-3); margin: 0; }
dl.kv > div { display: grid; gap: var(--space-1); }
dl.kv dt { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.preview { white-space: pre-wrap; overflow-wrap: anywhere; font: 400 0.9375rem/1.5 var(--mono); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; padding: var(--space-3); margin: 0; }
.mail-preview { background: #FFFFFF; color: #1C1B19; border: 1px solid var(--border); border-radius: 10px; padding: var(--space-4); overflow-wrap: anywhere; }
.mail-preview a { color: #0B5E8E; }
.mail-preview img { max-width: 100%; height: auto; }
.checklist > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.sendrow { margin-top: var(--space-4); align-items: flex-start; }

/* ---------- Settings ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; vertical-align: top; padding: var(--space-2) var(--space-2); border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.table th { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
@media (max-width: 640px) { .table thead { display: none; } .table tr { display: grid; padding: var(--space-2) 0; border-top: 1px solid var(--border); } .table td { border: 0; padding: 2px 0; } }

/* ---------- sign-in ---------- */
body.bare main { max-width: 34rem; padding-top: clamp(var(--space-5), 10vh, 96px); }
.signin { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-6) var(--space-5); box-shadow: 0 1px 0 var(--border); }
.signin-logo { margin-bottom: var(--space-5); }
.steps { padding-left: 1.25rem; display: grid; gap: var(--space-2); }
.usercode { font: 700 1.5rem/1 var(--mono); letter-spacing: 0.1em; }

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