/* FlashPass UI. Layout and tokens follow the Claude Design mockups (design/README.md).
   The CSP forbids inline styles, so every visual variant is a class here. */
:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #15171c;
  --muted: #585d69;
  --line: #dedcd4;
  --field: #fbfaf7;
  --accent: #4338ca;
  --on-accent: #ffffff;
  --accent-soft: #eeedfb;
  --ring: rgba(67, 56, 202, .28);
  --danger: #b42318;
  --on-danger: #ffffff;
  --danger-soft: #fdecea;
  --danger-line: #edb4ab;
  --warn: #8a4b00;
  --warn-soft: #fff3dc;
  --ok: #146c43;
  --ok-soft: #e5f3eb;
  --dis-bg: #e7e5df;
  --dis-ink: #55596a;
  --backdrop: rgba(8, 10, 14, .56);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --card: #171a21;
    --ink: #ecedf1;
    --muted: #a2a7b3;
    --line: #2e3340;
    --field: #11141a;
    --accent: #8e88ff;
    --on-accent: #0e1014;
    --accent-soft: #25234a;
    --ring: rgba(142, 136, 255, .35);
    --danger: #ff8f80;
    --on-danger: #1a0b0a;
    --danger-soft: #3a1d1b;
    --danger-line: #6b302b;
    --warn: #f4b860;
    --warn-soft: #33270f;
    --ok: #72d6a0;
    --ok-soft: #13291e;
    --dis-bg: #242833;
    --dis-ink: #a2a7b3;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); }
.ic {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.logo-bg { fill: var(--accent); }
.logo-bolt { fill: var(--on-accent); }

/* Shell */
.hdr { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.lang { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.lang button {
  min-width: 44px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.wrap { flex: 1; width: 100%; max-width: 600px; margin: 0 auto; padding: 4px 16px 0; }
.foot { margin: 0; padding: 20px 16px 28px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* Card and text */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
.sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-col { display: flex; flex-direction: column; gap: 14px; }
.lbl { display: block; font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.meta { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.center { text-align: center; }
.strong { font-weight: 600; color: var(--ink); }

/* Fields */
.field {
  display: block;
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--field);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
}
.field.mono { font-family: var(--mono); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.field.bad, .field.bad:focus { border-color: var(--danger); }
.field.bad:focus { box-shadow: 0 0 0 4px var(--danger-soft); }
.field::placeholder { color: var(--muted); }
textarea.field { resize: vertical; min-height: 120px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-field { font-size: 14px; }
.pin-big { font-size: 28px; font-weight: 600; letter-spacing: .2em; padding: 10px 14px; }
.sel { position: relative; }
.sel select { appearance: none; -webkit-appearance: none; min-height: 48px; padding-right: 42px; }
.sel .ic { position: absolute; right: 14px; top: 14px; pointer-events: none; color: var(--muted); }
.sel select:disabled { color: var(--dis-ink); }
.form { display: flex; flex-direction: column; gap: 20px; margin-top: 24px; }
.form-pin { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 20px; }

/* Byte counter */
.counter { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.counter .mono { white-space: nowrap; }
.counter.warn .meta { color: var(--warn); font-weight: 600; }
.counter.over .meta { color: var(--danger); font-weight: 600; }
.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar-counter { margin-top: 10px; }
.bar-counter.warn i { background: var(--warn); }
.bar-counter.over i { background: var(--danger); }
.bar-indeterminate i { width: 40%; animation: fpslide 1.2s ease-in-out infinite; }
@keyframes fpslide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); background: transparent; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn:disabled { background: var(--dis-bg); border-color: var(--dis-bg); color: var(--dis-ink); cursor: default; }
.btn.wide, .btn.wide-sm { width: 100%; }
.btn:focus-visible, .lang button:focus-visible, .brand:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.btn .i-done, .btn.copied .i-copy { display: none; }
.btn.copied .i-done { display: inline; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.spin {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: fpspin .8s linear infinite;
}
@keyframes fpspin { to { transform: rotate(360deg); } }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--ink); }
.alert.info .ic { color: var(--accent); }
.alert .ic { margin-top: 1px; }
.alert-col { flex-direction: column; gap: 4px; }
.alert-col .alert-main { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.alert-col .alert-extra { padding-left: 28px; }

/* Skeleton (C0) */
.sk { background: var(--line); border-radius: 8px; animation: fppulse 1.4s ease-in-out infinite; }
@keyframes fppulse { 50% { opacity: .45; } }
.sk-stack { display: flex; flex-direction: column; gap: 12px; }
.sk-title { height: 28px; width: 82%; }
.sk-line { height: 14px; width: 100%; margin-top: 8px; }
.sk-line-2 { height: 14px; width: 70%; }
.sk-label { height: 14px; width: 30%; margin-top: 16px; }
.sk-area { height: 120px; border-radius: 12px; }
.sk-input { height: 48px; border-radius: 12px; }
.sk-btn { height: 48px; border-radius: 12px; margin-top: 16px; }
.loading-note { margin-top: 16px; }
.loading-row { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 0; }

/* Steps under the card */
.steps { display: grid; gap: 12px; margin: 20px 4px 0; padding: 0; list-style: none; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.steps .ic { color: var(--accent); }

/* Badges */
.icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.icon-badge.ok { background: var(--ok-soft); color: var(--ok); }
.icon-badge.danger { background: var(--danger-soft); color: var(--danger); }
.icon-badge.big { width: 64px; height: 64px; border-radius: 20px; }

/* Result channels (R1/R4) */
.chan { border: 1.5px solid var(--line); border-radius: 16px; padding: 16px; background: var(--field); }
.chan-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.chan-name { display: flex; align-items: center; gap: 10px; }
.chan-name .lbl { margin: 0; }
.chan-body { display: flex; flex-direction: column; gap: 8px; }
.chan-body .field { min-width: 0; }
.chan.off { opacity: .6; }
.chan.off .num { background: var(--muted); }
.chan.off .via, .chan.off .tag { display: none; }
.num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.via { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.split {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 6px 0;
}
.split::before, .split::after { content: ""; flex: 1; border-top: 1.5px dashed var(--line); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
  font-weight: 600;
}
.result-actions { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Segmented PIN (V1/V3): one transparent input over the boxes */
.pin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pin-head .lbl { margin: 0; }
.attempts { display: flex; align-items: center; gap: 8px; }
.seg { position: relative; display: flex; gap: 8px; justify-content: center; }
.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font-size: 16px;
  cursor: text;
}
.box {
  flex: 0 1 42px;
  min-width: 0;
  height: 56px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
}
.seg.long { gap: 4px; }
.seg.long .box { height: 48px; font-size: 20px; border-radius: 10px; }
.box.cur { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.seg.bad .box { border-color: var(--danger); }
.seg.bad .box.cur { box-shadow: 0 0 0 4px var(--danger-soft); }
.pips { display: flex; gap: 6px; }
.pip { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.pip.used { background: var(--danger); }

/* Revealed secret (S1) */
.secret-wrap { position: relative; }
.secret-text { resize: none; min-height: 116px; }
.blurred { filter: blur(7px); user-select: none; }
.veil { display: none; }
.blurred ~ .veil { display: flex; position: absolute; inset: 0; align-items: center; justify-content: center; pointer-events: none; }
.veil > span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* Terminal error (E1–E7) */
.card.error { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; padding: 36px 24px 28px; }
.card.error .sub { margin: 0; }
.card.error .btn { margin-top: 8px; }

/* Delete confirmation (R3): bottom sheet on phones, centred on wider screens */
.dialog {
  width: calc(100% - 32px);
  max-width: 440px;
  margin: auto auto 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 20px 20px;
  background: var(--card);
  color: var(--ink);
}
.dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.dialog::backdrop { background: var(--backdrop); }
.dialog .h1 { font-size: 21px; }
.dialog .sub { margin: 0; }
.dialog .btn-col { margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 2.4s; }
  .sk { animation: none; }
  .bar-indeterminate i { animation: none; width: 100%; opacity: .5; }
}

@media (min-width: 640px) {
  .hdr { padding: 20px 40px; }
  .wrap { padding: 24px 16px 0; }
  .card { padding: 32px; }
  .h1 { font-size: 28px; }
  .form { margin-top: 28px; }
  textarea#secret { min-height: 128px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .steps.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 28px; }
  .steps.wide li { flex-direction: column; gap: 8px; }
  .chan-body { flex-direction: row; }
  .chan-body .field { flex: 1; }
  .tag { margin-top: 10px; }
  .btn.wide-sm { width: auto; }
  .result-actions { flex-direction: row-reverse; justify-content: space-between; gap: 12px; padding-top: 18px; }
  .dialog { margin: auto; }
  .dialog .btn-col { flex-direction: row-reverse; }
  .dialog .btn-col .btn { flex: 1; }
}
