/* ─────────────────────────────────────────────────────────────────────────
   Vortex — the phone.

   The app is a door you stand at, not a dashboard. When something is waiting
   for you it takes the whole screen; when nothing is, the app is almost
   wordless. That is the difference between this and the desktop console, and
   it is structural rather than cosmetic.

   One rule about colour: it only ever means state. The chrome is monochrome,
   and orange / green / red mean waiting / live / failed. If you see colour,
   something is true.
   ───────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Archivo';
  src: url('/vortex/font/archivo-latin.woff2') format('woff2-variations');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: dark light;

  --ink0: #06111a;   /* page */
  --ink1: #0a1620;   /* the chamber */
  --ink2: #102636;   /* raised */
  --edge: #1b3446;
  --edge2: #143042;

  --text: #e9f1f5;
  --text2: #92a9b8;
  --text3: #5d7688;

  --wait: #ff8a3d;   /* something is waiting for you */
  --live: #3aa981;   /* a session is open */
  --fail: #e4483c;   /* it did not end */

  --face: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tab: 58px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --ink0: #eef2f4; --ink1: #ffffff; --ink2: #ffffff;
    --edge: #d2dde3; --edge2: #e2eaee;
    --text: #08151e; --text2: #47606f; --text3: #7b93a2;
    --wait: #b85a00; --live: #1c7a5b; --fail: #b5271c;
  }
}
:root[data-theme='light'] {
  --ink0: #eef2f4; --ink1: #ffffff; --ink2: #ffffff;
  --edge: #d2dde3; --edge2: #e2eaee;
  --text: #08151e; --text2: #47606f; --text3: #7b93a2;
  --wait: #b85a00; --live: #1c7a5b; --fail: #b5271c;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The browser's own [hidden] rule loses to any class that sets display.
   This is not defensive tidiness: a dead tab bar sat on the first screen
   because of exactly that. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink0);
  color: var(--text);
  font-family: var(--face);
  font-size: 16px;
  line-height: 1.45;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text2); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ─────────────────────── type scale ─────────────────────── */

.hero { font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.032em; margin: 0; text-wrap: balance; }
.title { font-size: 25px; line-height: 1.16; font-weight: 700; letter-spacing: -0.028em; margin: 0; text-wrap: balance; }
.lede { font-size: 16.5px; line-height: 1.44; color: var(--text2); margin: 10px 0 0; max-width: 30ch; }
.quiet { color: var(--text2); }
.faint { color: var(--text3); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ─────────────────────── the wizard ───────────────────────
   Full bleed. No header, no tabs, one question per screen. Progress is a rail,
   not a set of numbered markers — the steps have no meaning to count. */

.rail { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--edge2); z-index: 50; }
.rail i { display: block; height: 100%; background: var(--text); transition: width 0.42s cubic-bezier(0.2, 0.8, 0.2, 1); }

.step {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(58px, env(safe-area-inset-top)) 26px calc(26px + env(safe-area-inset-bottom));
}
.step > .body { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 7vh; }
.step > .foot { display: grid; gap: 10px; padding-top: 22px; }
.step .back {
  position: absolute; top: max(20px, env(safe-area-inset-top)); left: 18px;
  color: var(--text3); font-size: 15px; padding: 8px 10px;
}

/* The mark: a spiral drawn inward. Used once, large, on the opening screen. */
.mark { width: 96px; height: 96px; display: block; margin: 0 0 34px; }
.mark.sm { width: 26px; height: 26px; margin: 0; }

/* The biometric moment — the one place the design raises its voice. */
.sensor {
  width: 168px; height: 168px; margin: 6px auto 0; position: relative;
  display: grid; place-items: center;
}
.sensor svg { width: 100%; height: 100%; }
.sensor::after {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  border: 1px solid var(--edge); animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.06); opacity: 0.35; } }
.sensor.done::after { animation: none; border-color: var(--live); }

/* ─────────────────────── inputs ─────────────────────── */

.field {
  width: 100%; background: transparent; color: var(--text);
  border: 0; border-bottom: 1.5px solid var(--edge);
  padding: 12px 2px; font-size: 21px; font-weight: 600; letter-spacing: -0.02em;
}
.field::placeholder { color: var(--text3); font-weight: 400; }
.field:focus { outline: none; border-bottom-color: var(--text); }
.field-note { font-size: 13.5px; color: var(--text3); margin: 10px 0 0; }

.pin {
  width: 100%; text-align: center; letter-spacing: 0.5em; text-indent: 0.5em;
  font-size: 26px; font-weight: 700; padding: 14px 0;
  background: transparent; border: 0; border-bottom: 1.5px solid var(--edge); color: var(--text);
}
.pin:focus { outline: none; border-bottom-color: var(--wait); }

/* ─────────────────────── actions ─────────────────────── */

.act {
  display: block; width: 100%; min-height: 56px; border-radius: 15px;
  font-size: 17px; font-weight: 650; letter-spacing: -0.015em;
  background: var(--text); color: var(--ink0);
  transition: transform 0.12s ease;
}
.act:active { transform: scale(0.982); }
.act[disabled] { opacity: 0.4; }
.act.allow { background: var(--live); color: #04150f; }
.act.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--edge); }
.act.deny { background: transparent; color: var(--fail); box-shadow: inset 0 0 0 1.5px var(--fail); }
.act.small { min-height: 46px; font-size: 15px; border-radius: 12px; }
.act.text { background: none; box-shadow: none; color: var(--text3); font-weight: 500; font-size: 15px; min-height: 44px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─────────────────────── the chamber ───────────────────────
   An approval is not a card in a list. It is the screen. */

.chamber {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: max(26px, env(safe-area-inset-top)) 24px calc(22px + env(safe-area-inset-bottom));
  background: var(--ink1);
  animation: arrive 0.34s cubic-bezier(0.16, 0.9, 0.24, 1);
}
@keyframes arrive { from { opacity: 0; transform: translateY(14px); } }
.chamber .who { font-size: 15px; color: var(--text2); margin: 0 0 14px; }
.chamber .who b { color: var(--text); font-weight: 650; }
.chamber .body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.chamber .foot { display: grid; gap: 10px; }

/* Facts: hanging rows on hairlines, not boxes. */
.facts { margin: 26px 0 0; border-top: 1px solid var(--edge2); }
.fact {
  display: grid; grid-template-columns: 74px 1fr; gap: 14px; align-items: baseline;
  padding: 13px 0; border-bottom: 1px solid var(--edge2);
}
.fact dt { color: var(--text3); font-size: 14.5px; margin: 0; }
.fact dd { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -0.015em; }
.fact dd small { display: block; font-size: 13.5px; font-weight: 400; color: var(--text3); margin-top: 2px; letter-spacing: 0; }

/* The proof required, as a filled ladder plus the word. Shape carries it. */
.proof { display: inline-flex; align-items: center; gap: 9px; }
.proof .rungs { display: flex; align-items: flex-end; gap: 3px; height: 15px; }
.proof .rungs i { width: 5px; border-radius: 1px; background: var(--edge); }
.proof .rungs i:nth-child(1) { height: 6px; }
.proof .rungs i:nth-child(2) { height: 10.5px; }
.proof .rungs i:nth-child(3) { height: 15px; }
.proof .rungs i.on { background: currentColor; }
.proof.p1 { color: var(--text2); } .proof.p2 { color: var(--text); } .proof.p3 { color: var(--live); }

.raise { color: var(--text3); font-size: 14.5px; padding: 12px 0; text-align: left; }
.raise-open { display: grid; gap: 8px; padding: 4px 0 8px; }
.raise-open button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--edge); font-size: 15.5px;
}
.raise-open button[aria-pressed='true'] { box-shadow: inset 0 0 0 1.5px var(--text); }
.raise-open button[disabled] { opacity: 0.35; }

/* ─────────────────────── home, when nothing is waiting ─────────────────────── */

.top {
  display: flex; align-items: center; gap: 10px;
  padding: max(18px, env(safe-area-inset-top)) 22px 4px;
}
.top .name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; color: var(--text3); border-radius: 11px; }

main { padding: 0 22px calc(var(--tab) + 30px); }

.calm { padding: 34px 0 26px; }

/* Numbers on a rule, not boxes on a grid. */
.tally { display: flex; border-top: 1px solid var(--edge2); border-bottom: 1px solid var(--edge2); }
.tally > div { flex: 1; padding: 15px 0; }
.tally > div + div { border-left: 1px solid var(--edge2); padding-left: 16px; }
.tally .v { font-size: 27px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.tally .l { font-size: 13.5px; color: var(--text3); margin-top: 5px; }
.tally .v.wait { color: var(--wait); }
.tally .v.live { color: var(--live); }
.tally .v.fail { color: var(--fail); }

.h { font-size: 14.5px; color: var(--text3); margin: 30px 0 8px; }

/* A live session: the remaining time is the message; the rule below drains. */
.session { padding: 16px 0; border-bottom: 1px solid var(--edge2); }
.session .what { font-size: 17.5px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 3px; }
.session .sub { font-size: 14px; color: var(--text2); }
.session .drain { height: 2px; background: var(--edge2); margin: 13px 0 9px; overflow: hidden; }
.session .drain i { display: block; height: 100%; background: var(--live); transition: width 1s linear; }
.session .drain.late i { background: var(--wait); }
.session .clock { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--text2); }
.session .clock b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Failed teardown. The one place the app shouts, and it shouts in words. */
.stillive {
  margin: 18px 0 4px; padding: 18px 18px 16px; border-radius: 4px;
  background: color-mix(in srgb, var(--fail) 13%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--fail);
}
.stillive .h1 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--fail); margin: 0 0 6px; }
.stillive p { margin: 0 0 14px; font-size: 15px; }

/* Log: time hangs in the margin, the sentence carries the meaning. */
.entry { display: grid; grid-template-columns: 46px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--edge2); }
.entry:last-child { border-bottom: 0; }
.entry .t { font-size: 13.5px; color: var(--text3); font-variant-numeric: tabular-nums; padding-top: 2px; }
.entry .s { font-size: 15.5px; line-height: 1.4; }
.entry .s b { font-weight: 650; }
.entry .v { font-size: 14px; margin-top: 3px; color: var(--text2); }
.entry .v.ok { color: var(--live); }
.entry .v.fail { color: var(--fail); font-weight: 650; }
.entry .v.refused { color: var(--wait); }

/* Vault rows and agents. Lists, not cards. */
.rowitem { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--edge2); width: 100%; text-align: left; }
.rowitem .g { flex: 1; min-width: 0; }
.rowitem .g b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -0.018em; }
.rowitem .g span { font-size: 14px; color: var(--text2); }
.rowitem .chev { color: var(--text3); }

.switch { appearance: none; width: 48px; height: 29px; border-radius: 15px; background: var(--edge2); box-shadow: inset 0 0 0 1px var(--edge); position: relative; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: var(--text3); transition: 0.16s; }
.switch:checked { background: color-mix(in srgb, var(--live) 34%, transparent); }
.switch:checked::after { left: 24px; background: var(--live); }

.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--edge2); }
.setrow .g b { display: block; font-size: 16px; font-weight: 600; }
.setrow .g span { font-size: 13.5px; color: var(--text3); }
.setrow select { background: transparent; border: 0; color: var(--text); font-size: 16px; font-weight: 600; text-align: right; }

/* History of a secret: the node's shape is the state. */
.hist { list-style: none; margin: 14px 0 0; padding: 0 0 0 22px; position: relative; }
.hist::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 1px; background: var(--edge2); }
.hist li { position: relative; padding: 9px 0; font-size: 15px; }
.hist li::before { content: ''; position: absolute; left: -22px; top: 15px; width: 9px; height: 9px; background: var(--ink0); box-shadow: 0 0 0 1.5px var(--edge); }
.hist li.current::before { border-radius: 50%; background: var(--live); box-shadow: 0 0 0 1.5px var(--live); }
.hist li.superseded::before { border-radius: 50%; }
.hist li.pending::before { transform: rotate(45deg); box-shadow: 0 0 0 1.5px var(--wait); }
.hist li.failed::before { background: var(--fail); box-shadow: 0 0 0 1.5px var(--fail); }
.hist li .st { font-weight: 700; }
.hist li.current .st { color: var(--live); }
.hist li.failed .st { color: var(--fail); }
.hist li.pending .st { color: var(--wait); }
.hist li.superseded .st { color: var(--text3); }
.hist li .when { color: var(--text3); font-size: 13.5px; }

/* The recovery words are a printed artifact, so they get no radius and a face
   built for transcription. */
/* Four groups on a grid: a line of text would break mid-group, and these get
   copied onto paper by hand. */
.words {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 8px 0 0;
  background: var(--edge); box-shadow: 0 0 0 1px var(--edge);
}
.words span {
  background: var(--ink2); padding: 18px 6px; text-align: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 21px; font-weight: 600; letter-spacing: 0.1em;
}
.code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 27px; font-weight: 700; letter-spacing: 0.16em; text-align: center;
  padding: 18px 10px; background: var(--ink2); box-shadow: inset 0 0 0 1px var(--edge);
}

/* ─────────────────────── tabs ─────────────────────── */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: var(--tab); padding-bottom: env(safe-area-inset-bottom, 0);
  background: color-mix(in srgb, var(--ink0) 90%, transparent);
  border-top: 1px solid var(--edge2);
  backdrop-filter: blur(16px);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text3); font-size: 11px; font-weight: 500; position: relative; }
.tabs button svg { width: 21px; height: 21px; }
.tabs button[aria-current='true'] { color: var(--text); font-weight: 650; }
.tabs button[aria-current='true']::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 2px; background: var(--text); }
.tabs .n { position: absolute; top: 7px; right: calc(50% - 20px); min-width: 8px; height: 8px; border-radius: 4px; background: var(--wait); }

/* ─────────────────────── sheet, notice ─────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, #000 62%, transparent); display: flex; align-items: flex-end; }
:where(dialog).sheet { margin: 0; border: 0; padding: 0; width: 100%; height: 100%; max-width: none; max-height: none; color: inherit; overflow: hidden; }
dialog.sheet::backdrop { background: transparent; }
.sheet .panel {
  width: 100%; max-height: 92dvh; overflow-y: auto; background: var(--ink1);
  border-radius: 24px 24px 0 0; box-shadow: 0 -1px 0 var(--edge);
  padding: 26px 24px calc(24px + env(safe-area-inset-bottom));
  animation: rise 0.26s cubic-bezier(0.16, 0.9, 0.24, 1);
}
@keyframes rise { from { transform: translateY(26px); opacity: 0.5; } }

.notice {
  position: fixed; left: 14px; right: 14px; top: max(12px, env(safe-area-inset-top)); z-index: 90;
  background: var(--ink2); box-shadow: 0 0 0 1px var(--edge), 0 14px 34px rgba(0, 0, 0, 0.4);
  border-radius: 14px; padding: 14px 16px; font-size: 15px; line-height: 1.35;
  animation: drop 0.22s cubic-bezier(0.16, 0.9, 0.24, 1);
}
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }
.notice.bad { box-shadow: inset 3px 0 0 var(--fail), 0 0 0 1px var(--edge), 0 14px 34px rgba(0, 0, 0, 0.4); }
.notice.ok { box-shadow: inset 3px 0 0 var(--live), 0 0 0 1px var(--edge), 0 14px 34px rgba(0, 0, 0, 0.4); }

.empty { padding: 40px 0; }
.empty b { display: block; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.empty span { font-size: 15px; color: var(--text2); }

/* On a big screen the phone app stays a phone: it does not sprawl into the
   console's job. */
@media (min-width: 620px) {
  body { background: #050d13; }
  .app { max-width: 420px; margin: 0 auto; min-height: 100dvh; background: var(--ink0); box-shadow: 0 0 0 1px var(--edge2); }
  .tabs { max-width: 420px; left: 50%; transform: translateX(-50%); }
  .notice { max-width: 392px; left: 50%; transform: translateX(-50%); }
}

.layout-link { color: var(--text2); font-size: 13px; text-decoration: none; white-space: nowrap; }
.layout-link:hover { text-decoration: underline; }

/* The same five-column bar, on the phone stylesheet: scaled labels must wrap inside their column
   rather than widen the page (WCAG 1.4.4). Unchanged at the default text size. */
.tabs{height:auto;min-height:var(--tab)}
.tabs button{min-width:0;overflow-wrap:anywhere;text-align:center}
