/* The companion's look: one column, phone first, thumb-reachable tabs at the
 * bottom, touch targets of 48 px at least, digits readable at arm's length.
 * Light by default (outdoors, next to an instrument), dark when the phone asks.
 * No web font and nothing fetched: Aptos where the system has it. */
:root {
  --blue: #215F9A; --lime: #C3CB2B;
  --bg: #f5f7fa; --card: #ffffff; --line: #d5dbe3; --text: #14202c; --muted: #56657a;
  --primary: #215F9A; --on-primary: #ffffff; --accent: #215F9A; --digits: #0f2f4f;
  --bad: #b3261e; --bad-bg: #fdecea; --good: #1e6b3a; --good-bg: #e8f5ec; --focus: #C3CB2B;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --card: #171c23; --line: #2c3440; --text: #e3e8ef; --muted: #9aa6b6;
    --primary: #3b7fc0; --on-primary: #ffffff; --accent: #C3CB2B; --digits: #C3CB2B;
    --bad: #ff8a80; --bad-bg: #2a1413; --good: #8fd6a6; --good-bg: #122017;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --card: #171c23; --line: #2c3440; --text: #e3e8ef; --muted: #9aa6b6;
  --primary: #3b7fc0; --on-primary: #ffffff; --accent: #C3CB2B; --digits: #C3CB2B;
  --bad: #ff8a80; --bad-bg: #2a1413; --good: #8fd6a6; --good-bg: #122017;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 640px; background: var(--bg); color: var(--text);
  font: 17px/1.5 Aptos, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom)) 16px;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
.top { padding: calc(12px + env(safe-area-inset-top)) 0 4px; }
h1 { font-size: 22px; margin: 0; color: var(--accent); }
h2 { font-size: 17px; margin: 0 0 6px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
/* Which browser, which storage, which key: true, and under "More". Only a
 * startup note - a stall, an error - earns a line in the holder's face. */
.ctx { margin: 0 0 8px; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.ctxrule { margin: 6px 0 0; font-size: 13px; color: var(--bad); }
.lead { font-size: 17px; }
.hint, .rule, .engine { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); font-weight: 400; }
.kicker { margin: 10px 0 2px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { white-space: pre-wrap; word-break: break-all; font-size: 13px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 8px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.card > h2:first-child { margin-top: 0; }
.card.warn { border-left: 4px solid var(--lime); }
h3 { font-size: 16px; margin: 18px 0 4px; }
/* The one line nobody may skim past: the backup string plus its passphrase
 * is the key itself. */
.warnline { border-left: 4px solid var(--bad); background: var(--bad-bg); color: var(--text);
  border-radius: 0 10px 10px 0; padding: 10px 12px; margin: 12px 0; font-size: 15px; }
.check { margin: 12px 0; }
.check label { display: flex; gap: 10px; align-items: flex-start; margin: 0; color: var(--text); font-size: 15px;
  min-height: 48px; padding: 6px 0; }
.check input[type="checkbox"] { width: 26px; height: 26px; min-height: 26px; flex: 0 0 auto; margin: 2px 0 0; }
pre.diag { font-size: 12px; max-height: 60vh; overflow: auto; word-break: break-word; }

/* Controls: 48 px at least, full width, readable */
button, .button, input, textarea {
  font: inherit; color: var(--text); border-radius: 10px; width: 100%; min-height: 48px;
}
input, textarea { background: var(--card); border: 1px solid var(--line); padding: 10px 12px; font-size: 18px; }
textarea { font-family: ui-monospace, monospace; font-size: 14px; min-height: 96px; }
label { display: block; margin: 12px 0 4px; font-size: 15px; color: var(--muted); }
button, .button {
  display: block; margin: 12px 0 0; padding: 12px 14px; cursor: pointer; text-align: center;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.secondary { background: transparent; color: var(--text); }
.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.big { min-height: 56px; font-size: 18px; }
button.link { display: inline; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; background: none;
  color: var(--primary); text-decoration: underline; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
details { margin: 14px 0; }
summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
[hidden] { display: none !important; }

/* Messages */
.msg { border-left: 4px solid; border-radius: 0 10px 10px 0; padding: 10px 12px; margin: 12px 0; white-space: pre-wrap; }
.msg.bad { border-color: var(--bad); background: var(--bad-bg); }
.msg.good { border-color: var(--good); background: var(--good-bg); }

/* The code to type: the largest thing on the screen, one line, grouped 5 + 5 */
.result { text-align: center; }
.digits {
  margin: 6px 0; color: var(--digits); white-space: nowrap;
  font: 700 clamp(34px, 12.5vw, 64px)/1.15 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.digits .gap { display: inline-block; width: .5em; }
.digits.expired { opacity: .35; text-decoration: line-through; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; text-align: left; margin: 10px 0; font-size: 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; word-break: break-all; }
.countdown { font-size: 18px; font-weight: 600; }
.countdown.late { color: var(--bad); }

/* My key */
.keyname { font-size: 24px; font-weight: 700; margin: 0; word-break: break-all; }
.fp { font: 700 28px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; margin: 0; }
canvas.qr { display: block; width: min(100%, 420px); height: auto; margin: 14px auto 0; background: #fff;
  image-rendering: pixelated; border-radius: 8px; }
.qrfull { position: fixed; inset: 0; z-index: 10; background: #fff; color: #000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 16px; }
.qrfull canvas.qr { width: min(96vw, 80vh); margin: 0; }
.qrfullname { font-size: 22px; font-weight: 700; margin: 12px 0 0; color: #000; }
.qrfull .primary { max-width: 420px; }

/* Camera */
.camera video { display: block; width: 100%; max-height: 60vh; object-fit: cover; border-radius: 12px;
  background: #000; margin: 14px 0 0; border: 3px solid var(--lime); }

/* Instruments */
.history { list-style: none; padding: 0; margin: 0; }
.history li { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.history .serial { font-weight: 700; font-size: 18px; word-break: break-all; }
.history .when { color: var(--muted); font-size: 14px; }

/* The one disclosure, closed by default: everything the flow does not need.
   There is no tab bar any more - the screen follows the state. */
#more { margin: 26px 0 0; border-top: 1px solid var(--line); }
#more > summary { font-size: 16px; min-height: 52px; color: var(--muted); }
#more[open] > summary { color: var(--primary); }
/* the secondary way out of the create card: small, and one tap away */
.aside { margin: 14px 0 0; }
.foot { color: var(--muted); font-size: 13px; margin: 20px 0 8px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* A control that reads as a link: the build line's refresh. */
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--link, #215F9A); text-decoration: underline; cursor: pointer; }
.linkish:focus-visible { outline: 3px solid var(--accent, #C3CB2B); outline-offset: 2px; }
