/* Mission Control — phone-first, thumb-reachable, readable in sunlight on a train.
   Dark by default because that is when you are answering; light honoured if set. */

/* The [hidden] attribute must always win. Without this, an ID- or class-level
   `display` rule (e.g. #backup) outranks the browser default [hidden]{display:none}
   and the element leaks onto every screen — including sign-in. */
[hidden] { display: none !important; }

:root {
  --bg: #0f1420;
  --surface: #182031;
  --surface-2: #1f2941;
  --line: #2b3752;
  --text: #eef2fa;
  --muted: #97a3bd;
  --accent: #4f8cff;
  --danger: #ff5f56;
  --danger-dim: #4a1f22;
  --ok: #3ecf8e;
  --warn: #ffb545;
  --radius: 14px;
  --tap: 52px; /* minimum comfortable target on a moving train */
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --line: #d8dfec;
    --text: #131824;
    --muted: #5b678a;
    --danger-dim: #ffe9e7;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* --- top bar ------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.link {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.link.is-live { color: var(--ok); }
.link.is-stale { color: var(--warn); }

.icon-btn {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}
.icon-btn[aria-pressed="true"] { border-color: var(--accent); }

/* --- panes --------------------------------------------------------------- */

.pane { padding: 14px 12px 0; }
.pane h2 { margin: 4px 4px 12px; font-size: 15px; color: var(--muted); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.empty { text-align: center; padding: 18vh 20px; color: var(--muted); }
.empty-mark {
  font-size: 42px;
  margin: 0 0 8px;
  color: var(--ok);
}
.muted { color: var(--muted); font-size: 14px; }

/* --- request card -------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  animation: rise 220ms ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}

.card.is-pending { border-color: var(--warn); }
.card.is-detached { border-left: 3px solid var(--muted); }

/* The project chip is the most important thing on screen: with four sessions
   running, four questions saying "Deploy?" are useless without knowing who asks. */
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.age { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.question {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.context {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.context summary {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.context pre {
  margin: 0;
  padding: 0 12px 12px;
  max-height: 42vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}

/* --- answers ------------------------------------------------------------- */

.options { display: grid; gap: 8px; }

.opt {
  min-height: var(--tap);
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.opt:active { transform: scale(0.99); }

/* Consequential answers are deliberately awkward: visually separated, and they
   need a second tap. "No" halts a colleague; a mis-tap should not manage it. */
.opt.is-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}
.opt.is-danger.is-arming {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.opt-hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}

.free { display: grid; gap: 8px; }
.free textarea {
  width: 100%;
  min-height: 84px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.primary {
  min-height: var(--tap);
  padding: 12px 18px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}
.primary:disabled { opacity: 0.5; }

.ghost {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* --- the undo window ----------------------------------------------------- */

.sending {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--warn);
  border-radius: 11px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.sending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sending strong { font-size: 16px; }
.sending .secs { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.meter {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--warn);
  transition: width 200ms linear;
}

.undo-row { display: flex; gap: 8px; }
.undo-row .ghost { flex: 1; }

/* --- history ------------------------------------------------------------- */

.history .card { opacity: 0.9; }
.answered-as {
  margin: 0;
  font-size: 15px;
}
.answered-as b { color: var(--ok); }
.corrected {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--danger-dim);
  color: var(--text);
  font-size: 13px;
}

.error {
  margin: 8px 4px 0;
  color: var(--danger);
  font-size: 14px;
}

/* --- tabs ---------------------------------------------------------------- */

.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: var(--tap);
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--text); }

form { display: flex; gap: 8px; }
form input {
  flex: 1;
  min-height: var(--tap);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- auth screens -------------------------------------------------------- */

.auth { max-width: 460px; margin: 0 auto; }
.auth h2 { margin: 10px 4px 6px; font-size: 20px; color: var(--text); font-weight: 650; }
.auth > .muted { margin: 0 4px 16px; }

.stack { display: grid; gap: 12px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; padding-left: 2px; }
.field input {
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  width: 100%;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 2px;
  font-size: 15px;
  cursor: pointer;
}
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.as-link {
  display: block;
  text-align: center;
  text-decoration: none;
  line-height: calc(var(--tap) - 24px);
}

.centred { text-align: center; margin: 8px 0 16px; }

/* Secrets and backup codes: monospace, generously spaced, easy to read off a
   screen and type into an authenticator without transcription errors. */
.secret {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: 15px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  text-align: center;
}

#backup { display: grid; gap: 12px; }
.account-actions { margin-top: 18px; }
