/* Design tokens: "Neutral + navy". Pure neutrals, deep navy accent.
   Dark values follow the OS preference, or Settings' theme override. */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #14171c;
  --muted: #5f6673;
  --border: #e3e6eb;
  --accent: #1e3a8a;
  --accent-text: #ffffff;
  --accent-tint: #dfe6f7; /* selected rows: a soft navy wash */
  --alert-bg: #fdecec;
  --alert-text: #9b1c1c;
  --notice-bg: #eef2fb;
  --notice-text: #1e3a8a;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --radius: 6px;
  --gutter: 16px;
  --header-height: 54px;
  color-scheme: light dark;
}

/* Dark: follows the OS unless Settings forces a theme (<html data-theme>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --accent: #93b4ff;
    --accent-text: #0f1115;
    --accent-tint: #1d2740;
    --alert-bg: #3a1517;
    --alert-text: #f8b4b4;
    --notice-bg: #18213a;
    --notice-text: #c7d6ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --text: #e7e9ee;
  --muted: #9aa1ad;
  --border: #2a2f38;
  --accent: #93b4ff;
  --accent-text: #0f1115;
  --accent-tint: #1d2740;
  --alert-bg: #3a1517;
  --alert-text: #f8b4b4;
  --notice-bg: #18213a;
  --notice-text: #c7d6ff;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-sans);
}

h1 { font: 700 1.6rem/1.2 var(--font-serif); margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.site-header {
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--gutter);
  border-bottom: 2px solid var(--text);
  background: var(--surface);
}
.brand { font: 700 1.25rem var(--font-serif); color: var(--text); text-decoration: none; letter-spacing: .02em; }
.site-nav { display: flex; align-items: center; gap: 16px; }
.site-nav form { margin: 0; }

.site-main { max-width: 72rem; margin: 0 auto; padding: 24px var(--gutter); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px;
}
.card-narrow { max-width: 28rem; margin: 0 auto; }

.form { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
/* Submit buttons keep their natural width (a column flex box would stretch
   them), except on the narrow sign-in style cards where a full-width button suits. */
.form > input[type=submit], .form > .button { align-self: flex-start; min-width: 6rem; margin-top: 8px; }
.card-narrow .form > input[type=submit], .card-narrow .form > .button { align-self: stretch; }
.form label { font-weight: 600; font-size: .9rem; }
.form input[type=email], .form input[type=password], .form input[type=text] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); min-height: 44px; width: 100%;
}
/* One visible focus ring for everything keyboard-reachable. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.skip-link { position: absolute; left: 8px; top: -100px; z-index: 20; padding: 8px 14px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }

.button, .form input[type=submit] {
  display: inline-block; font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--radius);
  padding: 10px 16px; min-height: 44px; cursor: pointer; margin: 0;
}
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.flash-alert { background: var(--alert-bg); color: var(--alert-text); }
.flash-notice { background: var(--notice-bg); color: var(--notice-text); }
.errors { background: var(--alert-bg); color: var(--alert-text); border-radius: var(--radius); padding: 10px 14px 10px 32px; margin: 0; }

.qr { max-width: 16rem; margin: 16px auto; background: #fff; padding: 8px; border-radius: var(--radius); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: block; word-break: break-all; margin-top: 8px; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-codes code { font-size: 1.05rem; }

.button-quiet { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 6px 12px; min-height: 36px; font-weight: 500; }
.button-quiet.is-on { color: var(--accent); border-color: var(--accent); }
.button-danger { color: var(--alert-text); }
.button:disabled { opacity: .4; cursor: default; }
.form select { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); min-height: 44px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
