:root {
  --bar: #16213a; --bar2: #22304f; --ink: #1c2333; --muted: #6b7489; --line: #e3e7ef; --bg: #eef1f6;
  --pri: #1f9d55; --pri-h: #188a45; --acc: #5b47d6; --gold: #d4af37;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.4 -apple-system, "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); overscroll-behavior-y: none; }
button { font: inherit; border: 0; cursor: pointer; border-radius: 12px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--st)) 14px 10px;
  background: var(--bar); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { display: block; font-size: 18px; }
.brand small { display: block; font-size: 12px; color: #9fb0d0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd { background: var(--bar2); color: #dfe6f5; padding: 8px 12px; font-size: 14px; font-weight: 600; border: 1px solid #3a4b72; }
.upd.new { background: var(--pri); color: #fff; border-color: #34c172; animation: glow 1.3s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(52,193,114,0); } 0%, 100% { box-shadow: 0 0 0 0 rgba(52,193,114,.7); } }
.view { padding: 14px 14px calc(24px + var(--sb)); max-width: 720px; margin: 0 auto; }
.banner { background: #e7f6ec; color: #17663a; padding: 12px 14px; border-radius: 14px; font-size: 14.5px; margin-bottom: 12px; }
.banner.warn { background: #fff7e0; color: #7a5a00; }
.take { display: grid; gap: 10px; margin: 6px 0 18px; }
.take .big { display: flex; align-items: center; justify-content: center; gap: 12px; height: 92px; border-radius: 18px; background: var(--bar);
  color: #fff; font-size: 21px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px rgba(22,33,58,.25); }
.take .big .ic { font-size: 30px; }
.take .small { text-align: center; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); font-weight: 600; color: var(--bar2); cursor: pointer; }
h2 { font-size: 17px; margin: 8px 0 10px; }
h2 span { color: var(--muted); font-weight: 500; }
.pages, .recent { background: #fff; border-radius: 18px; padding: 14px; border: 1px solid var(--line); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pg { position: relative; background: #f3f5f9; border-radius: 10px; padding: 5px; border: 1px solid var(--line); }
.pg img { display: block; width: 100%; aspect-ratio: .72; object-fit: contain; background: #fff; border-radius: 4px; }
.pg .n { position: absolute; left: 7px; top: 7px; background: var(--bar); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.pg.busy::after { content: 'Cleaning…'; position: absolute; inset: 5px; display: grid; place-items: center; background: rgba(255,255,255,.75); font-size: 12px; font-weight: 700; color: var(--muted); border-radius: 4px; }
.lbl { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
.inp { width: 100%; height: 46px; border: 1px solid #d7dce7; border-radius: 12px; padding: 0 12px; font: inherit; font-size: 16px; background: #fff; }
.acts { display: flex; gap: 10px; margin-top: 14px; }
.pri { background: var(--pri); color: #fff; font-weight: 700; padding: 14px 18px; font-size: 17px; flex: 1; }
.pri:disabled { opacity: .5; }
.sec { background: #eef1f6; color: var(--ink); font-weight: 600; padding: 12px 14px; }
.danger { background: #fdecec !important; color: #b4281d !important; }
.link { background: none; color: var(--acc); font-weight: 600; padding: 4px 6px; }
.note { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }
.note.ok { color: #17663a; }
.note.err { color: #b4281d; }
.rh { display: flex; align-items: center; justify-content: space-between; }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { color: var(--muted); font-size: 12.5px; }
.item button { padding: 9px 12px; font-size: 14px; font-weight: 600; background: #eef1f6; color: var(--ink); }
.item button.pri { background: var(--acc); color: #fff; flex: none; font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0; }
.ver { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 0 0; }

/* full-screen steps */
.view.full { position: fixed; inset: 0; z-index: 10; max-width: none; padding: 0; display: flex; flex-direction: column; background: #0f1422; color: #fff; }
.view.full .bar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--st)) 12px 10px; }
.view.full .bar b { flex: 1; text-align: center; font-size: 16px; }
.view.full .bar .spacer { width: 84px; }
.view.full .bar.bottom { padding: 10px 12px calc(12px + var(--sb)); }
.view.full .sec { background: #22304f; color: #fff; }
.view.full .pri.wide { flex: 1; }
.round { width: 52px; height: 50px; padding: 0 !important; font-size: 22px; flex: none; }
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.stage canvas { max-width: calc(100% - 24px); max-height: calc(100% - 12px); display: block; }
.stage svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.hint { text-align: center; font-size: 13.5px; color: #b9c5de; margin: 6px 16px 0; }
.chips { display: flex; gap: 8px; padding: 10px 12px 0; overflow-x: auto; }
.chips button { flex: none; padding: 10px 14px; border-radius: 20px; background: #22304f; color: #dfe6f5; font-weight: 600; font-size: 14.5px; }
.chips button.on { background: #fff; color: #16213a; }
.busy { position: absolute; inset: 0; display: none; place-items: center; align-content: center; gap: 10px; background: rgba(15,20,34,.55); font-weight: 600; }
.busy.on { display: grid; }
.busy i, .spin { width: 36px; height: 36px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: r .9s linear infinite; display: block; margin: 0 auto; }
@keyframes r { to { transform: rotate(360deg); } }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(10,15,28,.5); display: flex; align-items: flex-end; }
.sheet .card { width: 100%; background: #fff; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + var(--sb)); display: grid; gap: 8px; }
.sheet .card b { font-size: 16px; margin-bottom: 4px; }
.sheet .card button { padding: 15px; background: #f3f5f9; color: var(--ink); font-weight: 600; font-size: 16px; }
.veil { position: fixed; inset: 0; z-index: 30; background: rgba(10,15,28,.6); display: grid; place-items: center; padding: 20px; }
.veil .card { background: #fff; border-radius: 18px; padding: 22px; width: min(360px, 100%); text-align: center; }
.veil .spin { border-color: #dfe5f0; border-top-color: var(--acc); margin-bottom: 12px; }
.veil p { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.pbar { height: 6px; background: #edf0f6; border-radius: 4px; overflow: hidden; margin-top: 14px; }
.pbar i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .2s; }
.toast { position: fixed; left: 14px; right: 14px; bottom: calc(18px + var(--sb)); z-index: 40; background: #16213a; color: #fff; padding: 14px 16px;
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 15px; display: flex; gap: 10px; align-items: center; }
.toast span { flex: 1; }
.toast button { background: #fff; color: #16213a; font-weight: 700; padding: 9px 12px; font-size: 14px; }
.toast.err { background: #8f1d14; }
.view.full .bar.bottom .grow { flex: 1; white-space: nowrap; }
.view.full .bar.bottom .pri { flex: 1; white-space: nowrap; }
.chips { justify-content: center; }
