/* DI Ladder visual system. Tokens on :root, dark by default, light under prefers-color-scheme: light.
   Spacing on a 4/8px scale, one accent, tabular numerals for every number, status colors always paired with words/signs. */
:root {
  color-scheme: dark;
  --bg: #0e131c;
  --bg-2: #161d2a;
  --bg-3: #1f2838;
  --line: #28334a;
  --text: #eaeff7;
  --text-2: #9eabbf;
  --text-3: #6f7b90;
  --accent: #4f8cff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(79, 140, 255, 0.16);
  --green: #3ccf8e;
  --green-soft: rgba(60, 207, 142, 0.16);
  --red: #ff6d6d;
  --red-soft: rgba(255, 109, 109, 0.16);
  --amber: #f6b73c;
  --amber-soft: rgba(246, 183, 60, 0.18);
  --gray: #8e98aa;
  --gray-soft: rgba(142, 152, 170, 0.18);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 22px; --fs-2xl: 36px;
  --radius: 14px; --radius-sm: 10px;
  --top-h: 52px; --tab-h: 64px; --gutter: 16px;
  --top-gap: 8px; /* clear space under the status bar; iOS softens content that sits right against it */
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5fa;
    --bg-2: #ffffff;
    --bg-3: #eaeef5;
    --line: #dfe4ee;
    --text: #0f1626;
    --text-2: #56627a;
    --text-3: #8791a5;
    --accent: #2f6fe6;
    --accent-soft: rgba(47, 111, 230, 0.12);
    --green: #1d9a62;
    --green-soft: rgba(29, 154, 98, 0.12);
    --red: #d64545;
    --red-soft: rgba(214, 69, 69, 0.12);
    --amber: #b87a0b;
    --amber-soft: rgba(184, 122, 11, 0.14);
    --gray: #6f7a8e;
    --gray-soft: rgba(111, 122, 142, 0.14);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  /* Pinned to the four screen edges: on an iPhone Home Screen app with a translucent status bar, 100vh/100dvh come up
     short by the status bar's height, which left an empty strip under the tab bar. */
  margin: 0; position: fixed; inset: 0; width: auto; height: auto; overflow-x: hidden; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: var(--fs-md)/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.num, .big, .kpi-v, .row-v, .row-t, .tot-v { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* top bar */
.top {
  /* Home Screen mode draws the page under the status bar (black-translucent); the header pads itself below it. */
  height: calc(var(--top-h) + env(safe-area-inset-top) + var(--top-gap)); flex: 0 0 auto;
  padding: calc(env(safe-area-inset-top) + var(--top-gap)) calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; left: 4px; right: 4px; height: 2px; background: #fff; border-radius: 1px; }
.brand-mark::before { top: 5px; } .brand-mark::after { top: 11px; }
.top-right { display: flex; align-items: center; gap: var(--sp-2); }
.net { font-size: var(--fs-xs); font-weight: 600; color: var(--amber); background: var(--amber-soft); padding: 3px 8px; border-radius: 999px; }

.badge { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; }
.badge-paper { color: var(--accent); background: var(--accent-soft); }
.badge-live { color: #fff; background: var(--red); }
.badge-halted { color: var(--amber); background: var(--amber-soft); }
.badge-killed { color: var(--gray); background: var(--gray-soft); border-color: var(--gray); }

/* main view */
.view { flex: 1 1 auto; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: var(--sp-3) var(--gutter) var(--sp-4); }
.view.home { padding-top: var(--sp-1); padding-bottom: var(--sp-2); } /* Home never scrolls: its top padding pays for the status-bar gap */
.h { display: flex; align-items: baseline; justify-content: space-between; margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.h:first-child { margin-top: var(--sp-1); }
.h .count { color: var(--text-3); font-weight: 600; text-transform: none; letter-spacing: 0; }
.sub { color: var(--text-2); font-size: var(--fs-sm); }
.muted { color: var(--text-3); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-3) var(--sp-4); }
.empty { color: var(--text-2); font-size: var(--fs-sm); padding: var(--sp-4); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); margin: var(--sp-2) 0; }
.skeleton { min-height: 120px; }

/* home */
.hero { padding: var(--sp-2) 0 var(--sp-3); }
.hero .label { font-size: var(--fs-sm); color: var(--text-2); display: flex; justify-content: space-between; }
.big { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin: 2px 0; }
.delta { font-size: var(--fs-sm); font-weight: 600; }
.delta .since { color: var(--text-3); font-weight: 500; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.kpi { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); min-height: 68px; box-shadow: var(--shadow); }
.kpi-l { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-v { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.kpi-s { font-size: var(--fs-xs); color: var(--text-3); }
.spark { margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.spark svg { display: block; width: 100%; height: 92px; }
.spark .axis { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-fill { fill: var(--accent); opacity: 0.12; }
.spark-dot { fill: var(--accent); stroke: var(--bg-2); stroke-width: 2; }
.spark-lbl { font: 600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--text); font-variant-numeric: tabular-nums; }
.spark-base { stroke: var(--line); stroke-dasharray: 3 3; }
.lastrun { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-4); min-height: 44px; }
.lastrun .st { font-weight: 600; }
.status-ok { color: var(--green); } .status-failed, .status-halted { color: var(--red); } .status-running { color: var(--amber); }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: var(--fs-sm); padding: 8px 0 8px 12px; min-height: 44px; }
.today { margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-4) var(--sp-3); }
.today .h { margin: var(--sp-1) 0 var(--sp-1); }
.act { display: flex; gap: var(--sp-2); align-items: baseline; padding: 5px 0; font-size: var(--fs-sm); border-top: 1px solid var(--line); }
.act:first-of-type { border-top: 0; }
.act .msg { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
/* Home shows a one-line summary of each action; the full reason is one tap away in Timeline, so the screen never scrolls.
   The halted and killed cards are the exception: their reason is the one line that matters, so it is never clipped (S5 fix 1). */
.today:not(.halt):not(.killed) .act .msg { -webkit-line-clamp: 1; }
.halt .act .msg, .killed .act .msg { display: block; overflow: visible; -webkit-line-clamp: unset; }
.chip { flex: 0 0 auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 6px; background: var(--gray-soft); color: var(--text-2); }
.chip-place { background: var(--accent-soft); color: var(--accent); }
.chip-fill { background: var(--green-soft); color: var(--green); }
.chip-cancel { background: var(--amber-soft); color: var(--amber); }
.chip-decline, .chip-error, .chip-reconcile_mismatch, .chip-halt { background: var(--red-soft); color: var(--red); }
.chip-resume { background: var(--green-soft); color: var(--green); }
.chip-intent { background: transparent; color: var(--text-3); border: 1px solid var(--line); }
.more { font-size: var(--fs-xs); color: var(--accent); font-weight: 600; padding-top: 4px; }
.flowform { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-2); }
.flowform input { flex: 1; min-width: 0; }
.halt { border-color: var(--amber); }
.halt .h { color: var(--amber); }
.killed { border-color: var(--gray); }
.killed .h { color: var(--text); }
.mode-reason { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--amber); line-height: 1.35; }
.btn-danger { color: var(--red); border-color: var(--red); background: var(--red-soft); }

/* lists */
.row { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-2) var(--sp-4); background: var(--bg-2); border: 1px solid var(--line); border-top-width: 0; }
.list .row:first-child { border-top-width: 1px; border-radius: var(--radius) var(--radius) 0 0; }
.list .row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.list .row:only-child { border-radius: var(--radius); }
.row-main { flex: 1; min-width: 0; }
.row-t { font-weight: 600; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-s { font-size: var(--fs-xs); color: var(--text-2); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.row-side { text-align: right; flex: 0 0 auto; }
.row-v { font-weight: 700; font-size: var(--fs-md); }
.row-vs { font-size: var(--fs-xs); color: var(--text-2); }
.flag { display: inline-block; margin-left: 6px; vertical-align: 1px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); }
.row[data-backfill="1"] { border-left: 3px solid var(--amber); }
.totals { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-2); }
.tot-l { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.tot-v { font-weight: 700; font-size: var(--fs-lg); }
.bar { height: 6px; border-radius: 3px; background: var(--bg-3); margin-top: var(--sp-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* timeline */
.run { margin-bottom: var(--sp-2); padding: 0; overflow: hidden; }
.run-h { display: flex; align-items: center; gap: var(--sp-2); min-height: 48px; padding: var(--sp-2) var(--sp-4); width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.run-h .d { font-weight: 700; }
.run-h .k { color: var(--text-2); font-size: var(--fs-sm); }
.run-h .sum { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.run-h .chev { width: 18px; height: 18px; color: var(--text-3); transition: transform 0.15s; }
.run[data-open="0"] .chev { transform: rotate(-90deg); }
.run[data-open="0"] .ev { display: none; }
.ev { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.ev .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ev[data-phase="intent"] { padding: 3px var(--sp-4) 6px; font-size: var(--fs-xs); color: var(--text-3); border-top: 0; align-items: center; }
.ev[data-phase="intent"] .msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev[data-phase="intent"] .chip { font-size: 10px; padding: 1px 5px; }
.ev[data-phase="intent"] + .ev { border-top: 1px solid var(--line); }
.run-h .d, .report .d { white-space: nowrap; }
.report .k { flex: 1; min-width: 0; }
.sentinel { text-align: center; color: var(--text-3); font-size: var(--fs-xs); padding: var(--sp-4); }

/* forms */
textarea, input[type="text"], input[type="date"], input[type="number"] {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; min-height: 44px;
  font-size: 16px; /* under 16px, iOS Safari zooms the page on focus and leaves it zoomed */
  max-width: 100%; min-width: 0; display: block;
}
/* iOS renders a date input at its own intrinsic width, ignoring width: 100%, so it pokes past the card edge. */
input[type="date"] { -webkit-appearance: none; appearance: none; height: 44px; line-height: 22px; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.flowform input { display: inline-block; }
textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; line-height: 1.35; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: var(--sp-3); }
.field label { display: block; font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.btn { min-height: 44px; padding: 0 var(--sp-4); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-3); font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.55; }
.actions { display: flex; gap: var(--sp-2); }
.actions .btn { flex: 1; }
.report { padding: 0; margin-bottom: var(--sp-2); overflow: hidden; }
.report pre { margin: 0; padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-xs); line-height: 1.4; color: var(--text-2); max-height: 300px; overflow: auto; -webkit-overflow-scrolling: touch; }
.report[data-open="0"] pre { display: none; }

/* DI screen: notifications */
.note { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.4; margin: var(--sp-2) 0 0; }
.note b { color: var(--text); font-weight: 600; }
.subrow { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-2) var(--sp-4); background: var(--bg-2); border: 1px solid var(--line); border-top-width: 0; }
.list .subrow:first-child { border-top-width: 1px; border-radius: var(--radius) var(--radius) 0 0; }
.list .subrow:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.list .subrow:only-child { border-radius: var(--radius); }
.subrow[data-enabled="0"] .row-t { color: var(--text-3); }
.switch { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; padding: 0 2px; background: none; border: 0; color: var(--text-2); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; }
.switch i { display: block; width: 44px; height: 26px; border-radius: 13px; background: var(--bg-3); border: 1px solid var(--line); position: relative; transition: background 0.15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-3); transition: transform 0.15s, background 0.15s; }
.switch[aria-checked="true"] i { background: var(--green); border-color: var(--green); }
.switch[aria-checked="true"] i::after { transform: translateX(18px); background: #fff; }
.notif { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.notif:first-child { border-top: 0; }
.notif .nt { font-weight: 600; }
.notif .nb { font-size: var(--fs-xs); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif .nm { flex: 1; min-width: 0; }
.notif .ns { flex: 0 0 auto; text-align: right; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.notif .ns.sent { color: var(--green); } .notif .ns.failed { color: var(--red); } .notif .ns.skipped { color: var(--text-3); }
.notif .nw { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: none; letter-spacing: 0; }
.log { padding: 0; overflow: hidden; }
.rowbtns { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.rowbtns .btn { flex: 1; }

/* scorecard */
.sc-top { padding: var(--sp-3) var(--sp-4); }
.sc-tally { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.sc-tally .kpi-v { font-size: var(--fs-lg); }
/* S5 fix 3: each tally label stays on one line so the three values share a baseline. */
.sc-tally .kpi-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-pnl { margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.sc-pnl svg { display: block; width: 100%; height: 110px; }
.sc-legend { display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--text-2); margin-top: 4px; }
.sc-legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.sc-legend .di i { background: var(--amber); } .sc-legend .ag i { background: var(--accent); }
.pnl-di { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pnl-ag { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pnl-lbl { font: 600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; fill: var(--text); font-variant-numeric: tabular-nums; }
.pnl-base { stroke: var(--line); stroke-dasharray: 3 3; }
.sc-day { margin-bottom: var(--sp-2); padding: 0; overflow: hidden; }
.sc-day .run-h .k { flex: 1; min-width: 0; }
.sc-hdr, .sc-row { display: grid; grid-template-columns: 1fr 1fr 88px; gap: var(--sp-2); align-items: center; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.sc-hdr { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 6px; padding-bottom: 4px; }
.sc-row .c { min-width: 0; }
.sc-row .c .p { font-weight: 600; white-space: nowrap; }
.sc-row .c .s { font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.sc-row .c.none { color: var(--text-3); font-size: var(--fs-xs); }
.sc-row .f { text-align: right; }
.sc-flag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: var(--amber-soft); color: var(--amber); max-width: 88px; white-space: normal; line-height: 1.2; text-align: center; }
.sc-flag.agree { background: var(--green-soft); color: var(--green); }
.sc-sum { padding: var(--sp-2) var(--sp-4) var(--sp-3); border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-2); line-height: 1.45; }
.sc-sum b { color: var(--text); font-weight: 600; }
.sc-day[data-open="0"] .sc-hdr, .sc-day[data-open="0"] .sc-row, .sc-day[data-open="0"] .sc-sum { display: none; }
.sc-day[data-open="0"] .chev { transform: rotate(-90deg); }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--accent); font-weight: 600; font-size: var(--fs-sm); }

/* tabs */
.tabs {
  flex: 0 0 auto; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg-2); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px; color: var(--text-3); font-size: 11px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab[aria-current="page"] { color: var(--accent); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }

/* PIN screen */
.pin { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom)); z-index: 10; }
.pin-card { width: 100%; max-width: 340px; text-align: center; }
.pin-mark { width: 64px; height: 64px; margin: 0 auto var(--sp-4); border-radius: 18px; background: var(--accent); position: relative; }
.pin-mark::before, .pin-mark::after { content: ""; position: absolute; left: 16px; right: 16px; height: 5px; border-radius: 3px; background: #fff; }
.pin-mark::before { top: 20px; } .pin-mark::after { top: 39px; }
.pin-title { margin: 0; font-size: var(--fs-xl); font-weight: 700; }
.pin-sub { margin: var(--sp-1) 0 var(--sp-5); color: var(--text-2); }
.pin-field { position: relative; height: 56px; margin-bottom: var(--sp-2); }
.pin-dots { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text-3); display: block; transition: background 0.1s, border-color 0.1s, transform 0.1s; }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
/* The real input sits invisibly over the dots: tapping the dots opens the numeric keypad, the dots show progress. */
.pin-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.01; color: transparent; caret-color: transparent; text-align: center; font-size: var(--fs-xl); }
.pin-field:focus-within .pin-dots i:not(.on) { border-color: var(--text-2); }
.pin-error { min-height: 20px; margin: var(--sp-2) 0 var(--sp-3); color: var(--red); font-size: var(--fs-sm); font-weight: 600; }
.pin form .btn { width: 100%; }
.shake { animation: shake 0.4s; }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }

@media (min-width: 520px) {
  body { align-items: center; }
  .top, .view, .tabs { width: 100%; max-width: 480px; }
}
