/* ---------------------------------------------------------------------
 * 1. Font
 * ------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  src: url('/assets/inter-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------------
 * 2. Tokens (copied literally from styles-landing.ts — keep in sync)
 * ------------------------------------------------------------------- */
:root {
  --bg:#ffffff;
  --ink:#0f1222;
  --muted:#5c6072;
  --border:#e8e9ef;
  --accent:#5e6aff;
  --accent-2:#b053f0;
  --signal:#c9660b;
  --ok:#22a06b;
  --code-bg:#f7f8fb;
  --dark-bg:#0b0c10;
}

/* ---------------------------------------------------------------------
 * 3. Reset / base
 * ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 'Inter', ui-sans-serif, system-ui, sans-serif;
}

code, pre, kbd { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

img, svg { display: block; max-width: 100%; }

a { color: var(--accent); }

ul { list-style: none; margin: 0; padding: 0; }

main { display: block; }

hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ---------------------------------------------------------------------
 * 4. Typography
 * ------------------------------------------------------------------- */
h1, h2, h3 { margin: 0 0 .75rem; letter-spacing: -.01em; }

.page-title {
  font-size: clamp(1.9rem, 3.2vw, 2.5rem);
  font-weight: 780;
  letter-spacing: -.02em;
  line-height: 1.12;
  margin: .25rem 0 1rem;
}

.section-title {
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 1rem;
}

.eyebrow {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  /* --ink, not --accent: see styles-landing.ts for the same contrast note. */
  color: var(--ink);
  margin: 0 0 .6rem;
}

.lede { color: var(--muted); max-width: 62ch; margin: 0; }

/* Reserved contract primitive for future pages — keep in sync with consumers. */
.muted { color: var(--muted); }

/* ---------------------------------------------------------------------
 * 5. Layout primitives
 * ------------------------------------------------------------------- */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------------------------------------------
 * 6. Site nav / footer
 * ------------------------------------------------------------------- */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  /* Longhand only: .site-nav is always combined with .container in markup
     (class="site-nav container"), which sets padding: 0 24px (0 16px at
     <=480px, 0 12px at <=360px) for the side gutters. A padding shorthand
     here — even "22px 0" — would win the cascade (same specificity,
     declared later) and zero out those sides. Same reasoning applies to
     .site-footer below. */
  padding-top: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.wordmark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}

.nav-links { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }

.nav-links a:not(.btn):not(.btn-outline) {
  color: var(--ink);
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-links a:not(.btn):not(.btn-outline):hover { color: var(--accent); }

/* The header's "Log out" is a POST form, not a link (see the navExtra
   comment on LayoutOptions in render.ts for why) — reset to look and
   behave like the other nav items, focus-visible included. */
.nav-links form { margin: 0; }
.nav-form-btn {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: .92rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.nav-form-btn:hover, .nav-form-btn:focus-visible { color: var(--accent); }

.site-footer {
  /* Longhand only — see the .site-nav comment above: .site-footer always
     carries .container too (class="site-footer container"). */
  padding-top: 40px;
  padding-bottom: 56px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: .85rem;
  color: var(--muted);
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--ink); }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }

/* ---------------------------------------------------------------------
 * 7. Buttons (same direction-B choice as the landing page: dark ink fill,
 * never white text on --accent — see styles-landing.ts for the contrast
 * rationale).
 * ------------------------------------------------------------------- */
.btn, .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: .7em 1.2em;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn { background: var(--ink); color: #fff; }
.btn:hover, .btn:focus-visible { background: #232741; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover, .btn-outline:focus-visible { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------------
 * 8. Cards
 * ------------------------------------------------------------------- */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 28px;
  box-shadow: 0 1px 2px rgb(15 18 34/.04), 0 8px 24px rgb(15 18 34/.06);
}

/* ---------------------------------------------------------------------
 * 9. Forms
 * ------------------------------------------------------------------- */
.form-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .4rem;
  margin: 0 0 1rem;
}
.form-row label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}

.input {
  font: inherit;
  font-size: .95rem;
  width: 100%;
  padding: .65em .8em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.input::placeholder { color: var(--muted); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------
 * 10. Tables — 1px --border rules, roomy cells
 * ------------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 0 0 1.5rem; }
.table caption { text-align: left; margin-bottom: .6rem; font-size: .8rem; color: var(--muted); }
.table th,
.table td {
  text-align: left;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.table thead th {
  background: var(--code-bg);
  color: var(--muted);
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table code { font-size: .9em; }

@media (max-width: 640px) {
  .table { display: block; overflow-x: auto; }
}

/* ---------------------------------------------------------------------
 * 11. Flash messages
 * ------------------------------------------------------------------- */
.flash {
  padding: .85rem 1.1rem;
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--ink);
  font-size: .92rem;
}

/* Dedicated error red, not a design token: --signal is reserved for data
   extracted from mail, and every other token has a different, unrelated
   job — so a one-off color is the correct choice here, same spirit as the
   literal #232741 button-hover shade in styles-landing.ts. */
/* Reserved contract primitive for future pages — keep in sync with consumers. */
.flash-error {
  border-left-color: #b3261e;
  background: rgb(179 38 30/.06);
}

/* ---------------------------------------------------------------------
 * 12. Badges
 * ------------------------------------------------------------------- */
.badge-ok, .badge-muted, .badge-signal {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
/* Tinted, not filled — same AA rationale as the landing page's .badge:
   solid --ok fill with white text falls short of the 4.5:1 body-text
   target at this size/weight, a soft tint with --ink text does not. */
/* Reserved contract primitives for future pages — keep in sync with consumers. */
.badge-ok { background: rgba(34, 160, 107, .14); color: var(--ink); }
.badge-muted { background: var(--code-bg); color: var(--muted); border: 1px solid var(--border); }
/* Mailbox-list OTP indicator. --signal colors the tint/border only, not
   the text: at this badge's ~12px bold size, --signal text on the tint
   composites to ~3.3:1, short of the 4.5:1 normal-text AA target (it is
   not "large text" at this size) — same failure mode the .badge-ok
   comment above already accounts for, same fix: --ink text, tinted
   background as the color cue. Reserved for values extracted from mail,
   per the file-level note. */
.badge-signal { background: rgba(201, 102, 11, .14); color: var(--ink); border: 1px solid rgba(201, 102, 11, .3); }

/* ---------------------------------------------------------------------
 * 13. Kbd
 * ------------------------------------------------------------------- */
/* Reserved contract primitive for future pages — keep in sync with consumers. */
.kbd {
  display: inline-block;
  padding: .1em .45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--ink);
  font-size: .85em;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------
 * 14. Code blocks (replaces the old system's .snippet)
 * ------------------------------------------------------------------- */
.code-block {
  margin: .9rem 0 1.4rem;
  padding: 1rem 1.2rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .85rem;
  line-height: 1.7;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Reserved for OTP codes/verification links extracted from mail — see the
   file-level note above. Not a general-purpose highlight color.
   Sized up to clear the 18px+ bold "large text" AA threshold, same fix
   styles-landing.ts's own .tok-signal/.tok-ok use: at .code-block's
   ~.85rem body size, --signal text on --code-bg is only ~3.7:1, short of
   the 4.5:1 normal-text target. Chosen over a tint+ink badge treatment
   (see .badge-signal above) because these are inline highlights inside a
   line of body text ("Codes: ..."), not a standalone chip — sizing up
   keeps them reading as emphasized text in place, matching the landing
   page's identical token. */
.tok-signal { color: var(--signal); font-weight: 700; font-size: 1.2rem; }

/* ---------------------------------------------------------------------
 * 15. Docs page
 * ------------------------------------------------------------------- */
.docs-intro { padding: 2.75rem 0 .5rem; }

.docs-toc {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin: 1.5rem 0 0;
}
.docs-toc a { font-size: .88rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.docs-toc a:hover, .docs-toc a:focus-visible { color: var(--accent); }

.docs-section {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 1.25rem;
}
.docs-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.75rem 0 .6rem;
  scroll-margin-top: 1.25rem;
}
.docs-section h3 .method { color: var(--muted); font-weight: 500; margin-right: .4em; }

/* ---------------------------------------------------------------------
 * 16. Cabinet / mailbox shared sections (consumed by Task R2)
 * ------------------------------------------------------------------- */
.cabinet-intro { padding: 2.75rem 0 .5rem; }
.cabinet-section { padding: 2.25rem 0; border-top: 1px solid var(--border); }
.cabinet-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.cabinet-actions form { margin: 0; }

/* Mailbox list: filter form, per-row OTP indicator, prev/next pager. */
.mailbox-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin: 1.5rem 0; }
.mailbox-filters .form-row { margin: 0; min-width: 160px; }

.mailbox-pager { display: flex; justify-content: space-between; margin: 0 0 2rem; font-size: .9rem; }
.mailbox-pager a { color: var(--ink); font-weight: 600; text-decoration: none; }
.mailbox-pager a:hover, .mailbox-pager a:focus-visible { color: var(--accent); }
.mailbox-pager span { color: var(--muted); }

/* Mailbox detail: metadata rows, extracted-data section (code-block +
   .tok-signal below), attachment list, the message-body iframe. */
.mailbox-meta { padding: 1.1rem 0; border-top: 1px solid var(--border); }
.mailbox-meta .eyebrow { margin: 0 0 .2rem; }
.meta-line { margin: 0 0 1rem; color: var(--ink); word-break: break-word; }
.mailbox-attachments { display: flex; flex-direction: column; gap: .5rem; }
.mailbox-frame {
  display: block;
  width: 100%;
  min-height: 420px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.auth-section { padding: 3rem 0; max-width: 60ch; margin: 0 auto; }
.auth-form { display: flex; flex-direction: column; align-items: flex-start; gap: 1rem; margin-top: 1.5rem; }

.not-found { padding: 3rem 0; max-width: 60ch; }

/* ---------------------------------------------------------------------
 * 17. Focus
 * ------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
 * 18. Responsive
 * ------------------------------------------------------------------- */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .site-nav { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .card { padding: 20px; }
}

@media (max-width: 360px) {
  .container { padding: 0 12px; }
}

/* ---------------------------------------------------------------------
 * 19. Reduced motion: kill every animation/transition above
 * ------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
