:root {
  --bg: #fbfbfa;
  --fg: #16181d;
  --muted: #5c6370;
  --line: #e2e2df;
  --panel: #ffffff;
  --accent: #1f4ed8;
  --ok: #17663a;
  --warn: #8a5300;
  --bad: #97231f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e9eaec;
    --muted: #9aa1ad;
    --line: #2a2e36;
    --panel: #1b1e24;
    --accent: #7fa5ff;
    --ok: #62c48c;
    --warn: #e0a84a;
    --bad: #f08a86;
  }
}

* { box-sizing: border-box; }

/* hidden means hidden. A class that sets display (.inline-form is flex)
   would otherwise win over the attribute, and a form hidden because the
   role or the installation cannot use it would be drawn anyway. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

header, main, footer { max-width: 60rem; margin: 0 auto; padding: 0 1rem; }
header { padding-top: 2.5rem; padding-bottom: 1rem; }
h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.02em; }
/* The name and the language switch share a line, and wrap under each
   other rather than push the page wider on a phone. */
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; }
.lang-switch { display: flex; gap: 0.25rem; flex-shrink: 0; }
.lang-switch button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tagline { color: var(--muted); margin: 0.4rem 0 0; max-width: 42rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1rem 0;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--muted); }
input {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.55rem 0.7rem;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
small { color: var(--muted); font-size: 0.8rem; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
button {
  font: inherit; padding: 0.55rem 1rem; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid transparent;
}
button.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
button.danger { background: var(--bad); color: var(--bg); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
dt { color: var(--muted); font-size: 0.85rem; }
dd { margin: 0; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; font-size: 0.92rem; }
/* Every table sits in one of these: a table wider than a phone scrolls
   inside itself instead of widening the page. */
.table-wrap { overflow-x: auto; max-width: 100%; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

.note { color: var(--muted); font-size: 0.88rem; }
.error { color: var(--bad); font-size: 0.9rem; margin-top: 0.6rem; }
.loading { color: var(--muted); }

.pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 99px; font-size: 0.78rem; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: currentColor; }
.pill.bad { color: var(--bad); border-color: currentColor; }
.pill.unknown { color: var(--muted); border-color: currentColor; }
.pill.warn { color: var(--warn); border-color: currentColor; }
.guide { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 1rem 0; }
.guide > summary { cursor: pointer; }
.guide-step { border-top: 1px solid var(--line); padding: 0.5rem 0; margin-top: 0; }
.guide-step.next { border-left: 3px solid var(--accent); padding-left: 0.6rem; }
.guide-step > summary { cursor: pointer; color: var(--fg); }
.guide-step[open] > summary { margin-bottom: 0.5rem; }
.guide-checks, .guide-suggestions { list-style: none; padding: 0; margin: 0.4rem 0; }
.guide-checks li, .guide-suggestions li { display: flex; gap: 0.5rem; align-items: baseline; margin: 0.25rem 0; }
.guide-checks small, .guide-suggestions small { display: block; }
.check { flex: none; width: 1.2rem; text-align: center; font-weight: 600; }
.check.pass { color: var(--ok); }
.check.warn { color: var(--warn); }
.check.fail { color: var(--bad); }

.drift-counts { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; margin: 0.5rem 0; font-size: 0.9rem; }
.drift-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.drift-list li { border-top: 1px solid var(--line); padding: 0.55rem 0; min-width: 0; }
.drift-list p { margin: 0.25rem 0; overflow-wrap: anywhere; }
.drift-head { display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; align-items: baseline; }

footer { padding: 2rem 1rem 3rem; color: var(--muted); font-size: 0.85rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }

@media (max-width: 30rem) {
  dl { grid-template-columns: 1fr; }
}

/* --- panel heads, tabs, and the two kinds of absence --------------------- */

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
}
.panel-head h2 { margin-bottom: 0.5rem; min-width: 0; overflow-wrap: anywhere; }
.panel-head select { min-width: 0; }

h3 {
  font-size: 0.92rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 1.5rem 0 0.5rem;
}
h4 { font-size: 0.85rem; color: var(--muted); margin: 1.25rem 0 0.25rem; }

button.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
button.link {
  background: none; border: none; color: var(--accent);
  padding: 0; font: inherit; text-decoration: underline; cursor: pointer;
}

/* "not decided" and "unknown" (in any language) must never look like a value. */
.muted { color: var(--muted); font-style: italic; }
.number { font-variant-numeric: tabular-nums; }
.bad-text { color: var(--bad); }

.evidence { color: var(--muted); font-size: 0.85rem; }

details { margin-top: 1rem; }
summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
details[open] summary { margin-bottom: 0.75rem; }

.color-row { display: flex; align-items: center; gap: 0.5rem; }
.color-row input { flex: 1; }
.swatch {
  width: 2rem; height: 2rem; flex: none; border-radius: 6px;
  border: 1px solid var(--line);
}
.swatch.empty {
  background: repeating-linear-gradient(
    45deg, transparent, transparent 4px, var(--line) 4px, var(--line) 8px);
}

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 0.5rem 0.8rem; border-radius: 0; cursor: pointer;
}
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }

pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.6rem 0.75rem; overflow-x: auto; font-size: 0.82rem; margin: 0.5rem 0 0;
}

#system-pending { margin-top: 0.75rem; font-size: 0.88rem; }

/* --- token editors -------------------------------------------------------- */
.tokens h5 { margin: 1.1rem 0 0.2rem; font-size: 0.95rem; }
.tokens table { font-size: 0.86rem; }
.tokens th { white-space: nowrap; }
.tokens td { padding: 0.2rem 0.3rem; vertical-align: middle; }
.tokens input, .tokens select { width: 100%; min-width: 4rem; padding: 0.25rem 0.4rem; font-size: 0.86rem; }
.tokens input.narrow { min-width: 3.5rem; max-width: 5.5rem; }
.tokens input.wide { min-width: 12rem; }
.tokens .swatch { width: 1.2rem; height: 1.2rem; vertical-align: middle; margin-left: 0.3rem; }
.tokens .row-remove { padding: 0.15rem 0.5rem; font-size: 0.8rem; }
.tokens .row-add { margin-top: 0.4rem; }
.tokens .backgrounds label { display: inline-flex; align-items: center; gap: 0.2rem; margin-right: 0.5rem; font-size: 0.8rem; white-space: nowrap; }
.tokens .backgrounds input { width: auto; min-width: 0; }

.inline-form { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 12rem; }
.token-once { background: var(--panel, #f6f7f9); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0.5rem 0; word-break: break-all; }
.token-once code { font-size: 0.95rem; }

/* --- the identity view ----------------------------------------------------- */
select {
  max-width: 100%;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.6rem; margin-top: 0.25rem;
}
.identity .panel-head h2 { text-transform: none; letter-spacing: -0.01em; font-size: 1.5rem; color: var(--fg); }
.identity-line { color: var(--muted); font-size: 0.88rem; margin: 1rem 0 0; }
.identity-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

.id-logos { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; }
.id-logo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.id-logo .stage { display: flex; align-items: center; justify-content: center; min-height: 9rem; padding: 1.5rem; }
.id-logo .stage.light { background: #ffffff; }
.id-logo .stage.dark { background: #16181d; }
.id-logo .stage img { max-width: 100%; max-height: 6rem; }
.id-logo .caption { padding: 0.5rem 0.75rem; font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
.id-logo .caption strong { color: var(--fg); font-weight: 600; }

.id-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.id-color .chip { height: 5rem; border-radius: 10px; border: 1px solid var(--line); }
.id-color .caption { font-size: 0.82rem; margin-top: 0.35rem; }
.id-color .caption strong { display: block; }
.id-color .caption span { color: var(--muted); display: block; }

.id-type { display: grid; gap: 0.5rem; }
.id-type .sample { font-size: 1.7rem; line-height: 1.2; }
.id-type .caption { font-size: 0.82rem; color: var(--muted); }

.id-spacing { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.id-spacing .step { text-align: center; font-size: 0.78rem; color: var(--muted); }
.id-spacing .bar { background: var(--accent); opacity: 0.6; border-radius: 3px; margin: 0 auto 0.25rem; }

.id-tone { font-size: 1.15rem; line-height: 1.5; margin: 0; padding-left: 1rem; border-left: 3px solid var(--line); }
.id-rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.id-rules li { display: flex; gap: 0.6rem; align-items: baseline; font-size: 0.95rem; }
.id-rules .pill { flex: none; }

.identity h3 { margin-top: 1.75rem; }
#brand-manage { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
#brand-manage > summary { font-size: 0.95rem; }

/* A field that cannot be sent says why, beside it. */
input.invalid { border-color: var(--bad); outline-color: var(--bad); }
.field-error:not([hidden]) { display: block; color: var(--bad); font-size: 0.8rem; margin-top: 0.15rem; }

/* Text people typed — notes, names, reasons, codes — may hold a word longer
   than a phone is wide. It breaks rather than widening the page. Inside
   tables only the prose cells break, so a narrow screen does not chop
   every word; the table scrolls instead. */
p, li, dd, blockquote, summary, .note, .error, .caption, .identity-line,
.prose, .evidence, .token-once { overflow-wrap: anywhere; }
td code { overflow-wrap: normal; }
td .prose, td.prose, td .evidence, td.evidence { overflow-wrap: anywhere; }

/* An older version, read-only: framed so it is not mistaken for the form. */
.version-view { border: 1px dashed var(--line); border-radius: 10px; padding: 0.75rem 1rem; margin-top: 1rem; }
.version-view h4 { margin: 0; }
.row-actions { white-space: nowrap; }

/* The enrolment QR code. Dark on white in both colour schemes: a scanner
   reads contrast, and an inverted code is one many apps refuse. */
.qr { max-width: 16rem; margin: 0.75rem 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-light { fill: #ffffff; }
.qr-dark { fill: #000000; }

/* Recovery codes: two columns on a phone, each code whole. */
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.3rem 1rem; padding-left: 1.5rem; }
.recovery-codes code { font-size: 0.95rem; white-space: nowrap; }

/* A checkbox beside its sentence, not a full-width block. */
.check-label { display: flex; gap: 0.5rem; align-items: baseline; color: var(--fg); }
.check-label input { display: inline-block; width: auto; margin: 0; flex: none; }

/* A newer version of the terms waiting for the signed-in person. Framed in
   the accent, not in red: nothing is wrong, something is asked. */
.banner { border: 1px solid var(--accent); border-left-width: 4px; border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0 0 1rem; }
.banner p { margin: 0 0 0.5rem; overflow-wrap: anywhere; }
/* The button names the version; on a 390 px phone it wraps, not overflows. */
.banner button { max-width: 100%; white-space: normal; text-align: left; }

/* The publish gate in the release preview: what blocks, then what is left
   undecided. */
.gate-blocking, .gate-gaps { margin: 0.25rem 0 0.75rem 1.2rem; padding: 0; }
.gate-blocking li, .gate-gaps li { margin: 0.2rem 0; }
