/* ThaiDrive - Gestaltung angelehnt an thailaendische Wegweiser: Blau mit weissem Innenrand,
   zweisprachig Thai/Englisch, Warnschild-Gelb fuer die Pruefung. */

:root {
  --blue: #0F4C9A;          /* Wegweiser-Blau (Kopfleisten) */
  --blue-deep: #0A3670;
  --accent: #1459B8;        /* interaktive Elemente */
  --yellow: #FFC72C;        /* Warnschild */
  --sign-ink: #1A1A1A;
  --bg: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #F3F6FA;
  --ink: #0F2036;
  --muted: #55657A;
  --line: #D3DAE4;
  --frame: #D5DAE0;         /* neutrale Flaeche hinter Bildern (manche Schilder sind transparent) */
  --sel-bg: #E1ECFA;
  --ok: #137A3E;
  --ok-bg: #E2F3E8;
  --bad: #C32A21;
  --bad-bg: #FCE7E5;
  --shadow: 0 1px 2px rgba(15, 32, 54, .06), 0 4px 14px rgba(15, 32, 54, .05);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Thonburi", "Sukhumvit Set", "Noto Sans Thai", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Thonburi", "Sukhumvit Set", "Noto Sans Thai", "Segoe UI", Roboto, sans-serif;
  --font-th: "Thonburi", "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", -apple-system, sans-serif;
  --tabh: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #0B2F63;
    --blue-deep: #071F44;
    --accent: #6AA8FF;
    --bg: #0D1620;
    --surface: #16222F;
    --surface-2: #1D2B3A;
    --ink: #E6EDF5;
    --muted: #9DB0C6;
    --line: #2B3B4D;
    --frame: #46505C;
    --sel-bg: #17304F;
    --ok: #4CD07D;
    --ok-bg: #11301F;
    --bad: #FF7B72;
    --bad-bg: #3A1816;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font: 17px/1.4 var(--font);
  color: var(--ink);
  background: var(--bg);
  touch-action: manipulation;           /* kein Doppeltipp-Zoom */
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.ic { width: 24px; height: 24px; flex: none; display: block; }
.th, :lang(th) { font-family: var(--font-th); line-height: 1.55; }

#app { min-height: 100vh; min-height: 100dvh; }
#view {
  max-width: 720px; margin: 0 auto; outline: none;
  padding: 16px 16px calc(var(--tabh) + 24px + env(safe-area-inset-bottom));
}
body[data-run="1"] #view { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body[data-run="1"] #tabs { display: none; }

/* ---------- Kopfleisten ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue); color: #fff;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.bar-in { max-width: 720px; margin: 0 auto; min-height: 56px; display: flex; align-items: center; gap: 8px; }
.bar h1 { font: 800 22px/1.1 var(--font-head); letter-spacing: -.01em; flex: 1; min-width: 0; }
.bar .grow { flex: 1; min-width: 0; }
.bar .qpos { font: 700 17px/1.1 var(--font-head); }
.bar .timer { font: 800 20px/1 var(--font-head); font-variant-numeric: tabular-nums; padding: 8px 12px; border-radius: 999px; background: rgba(255,255,255,.14); min-width: 76px; text-align: center; }
.bar .timer.warn { background: var(--yellow); color: var(--sign-ink); }
.bar .icon-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: #fff; display: grid; place-items: center; margin-left: -10px; }
.bar .icon-btn:active { background: rgba(255,255,255,.16); }
.progress-line { height: 4px; background: rgba(255,255,255,.22); }
.progress-line i { display: block; height: 100%; background: var(--yellow); transition: width .25s; }

/* Sprachumschalter: 44 px Tippflaeche, kleinere sichtbare Pille */
.seg { display: flex; flex: none; }
.seg button {
  min-width: 44px; min-height: 44px; padding: 0 2px; border: 0; background: none; color: rgba(255,255,255,.86);
  font: 700 14px/1 var(--font-head); display: grid; place-items: center;
}
.seg button span { display: block; padding: 8px 11px; border-radius: 999px; }
.seg button[aria-pressed="true"] { color: var(--sign-ink); }
.seg button[aria-pressed="true"] span { background: var(--yellow); }
.langcycle { min-width: 52px; min-height: 44px; border: 0; background: none; color: #fff; font: 700 14px/1 var(--font-head); }
.langcycle span { display: inline-block; padding: 8px 11px; border-radius: 999px; background: var(--yellow); color: var(--sign-ink); }

/* ---------- Startseite: Wegweiser-Schild ---------- */
.hero { background: var(--blue); color: #fff; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left)); }
.hero-in { max-width: 720px; margin: 0 auto; }
.hero-top { display: flex; justify-content: flex-end; min-height: 48px; align-items: center; }
.sign {
  border-radius: 20px; box-shadow: inset 0 0 0 2.5px #fff;
  padding: 22px 22px 20px; margin-top: 2px;
}
.sign h1 { font: 800 34px/1.05 var(--font-head); letter-spacing: -.02em; }
.sign .th-title { font: 600 19px/1.4 var(--font-th); margin-top: 6px; opacity: .95; }
.sign .sub { margin-top: 12px; font-size: 15px; opacity: .88; }
.offline { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.offline .row { display: flex; align-items: center; gap: 8px; }
.offline .dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; flex: none; }
.offline .dot .ic { width: 12px; height: 12px; stroke-width: 3.2; }
.offline.ready .dot { background: var(--yellow); color: var(--sign-ink); }
.offline .meter { height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.offline .meter i { display: block; height: 100%; background: var(--yellow); transition: width .2s; }
.offline .copybtn { align-self: flex-start; min-height: 44px; margin-top: 4px; font-size: 16px; }
.offline .offurl { display: block; font: 500 13px/1.45 ui-monospace, Menlo, monospace; word-break: break-all; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.15); user-select: all; -webkit-user-select: all; }
.offline .offurl[hidden] { display: none; }

/* ---------- allgemeine Bausteine ---------- */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.stack > * { min-width: 0; }
.section-title { font: 800 20px/1.2 var(--font-head); margin: 26px 2px 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.card h2 { font: 800 19px/1.25 var(--font-head); margin-bottom: 6px; }
.card p { color: var(--muted); font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 2px solid transparent;
  font: 700 17px/1 var(--font-head); text-align: center; user-select: none; -webkit-user-select: none;
}
.btn .ic { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.yellow { background: var(--yellow); color: var(--sign-ink); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.outline-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn:active:not([disabled]) { transform: scale(.98); }
@media (prefers-color-scheme: dark) { .btn.primary { color: #06223F; } .btn.danger { color: #2A0B09; } }

/* Hinweis-Karte "Add to Home Screen" */
.hint { border-left: 6px solid var(--yellow); display: grid; gap: 6px; position: relative; padding-right: 54px; }
.hint .x { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.hint ol { margin: 4px 0 0; padding-left: 20px; color: var(--ink); font-size: 16px; }
.hint li { margin: 2px 0; }
.hint .ic { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }

/* Modus-Kacheln */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; min-height: 96px; padding: 14px 14px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); position: relative;
}
.tile .ic { width: 26px; height: 26px; color: var(--accent); margin-bottom: 6px; }
.tile b { font: 800 18px/1.2 var(--font-head); }
.tile span { font-size: 14px; color: var(--muted); }
.tile:active { transform: scale(.98); }
.tile .count { position: absolute; top: 12px; right: 12px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--bad-bg); color: var(--bad); font: 800 15px/28px var(--font-head); text-align: center; }
.tile.exam {
  grid-column: 1 / -1; background: var(--yellow); color: var(--sign-ink); border: 0;
  box-shadow: inset 0 0 0 3px var(--sign-ink); padding: 18px 18px 16px; min-height: 0;
}
.tile.exam .ic { color: var(--sign-ink); }
.tile.exam b { font-size: 24px; }
.tile.exam span { color: #3A3318; font-size: 15px; }

/* Kapitel-Zeilen */
.chap {
  display: grid; gap: 8px; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 10px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.chap .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chap .name { font-weight: 700; }
.chap .meta { font-size: 14px; color: var(--muted); white-space: nowrap; }
.chap[disabled] { opacity: .55; }
.bar3 { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line); }
.bar3 i:nth-child(1) { background: var(--ok); }
.bar3 i:nth-child(2) { background: var(--bad); }

/* ---------- Fragen ---------- */
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.qcard + .qcard { margin-top: 14px; }
.qhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.qnum { font: 800 15px/1 var(--font-head); color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 7px; border-radius: 999px; font: 700 13px/1.4 var(--font-head); }
.badge .ic { width: 14px; height: 14px; stroke-width: 3; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.qimg { position: relative; margin: 0 0 14px; background: var(--frame); border-radius: 14px; overflow: hidden; }
.imgbtn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; position: relative; }
.qimg img { display: block; width: 100%; height: auto; max-height: min(38vh, 400px); object-fit: contain; }
.zbadge { position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.zbadge .ic { width: 20px; height: 20px; }

.qtext { font: 700 20px/1.35 var(--font-head); margin-bottom: 14px; }
.qtext .th, .ctext .th { font-family: var(--font-th); }
.qtext .en { display: block; }
.th.sub { display: block; font-size: .8em; font-weight: 500; color: var(--muted); margin-top: 3px; }
.qtext .th.sub { font-size: 16px; font-weight: 600; }

.choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; min-height: 58px; padding: 12px 12px 12px 14px; margin: 0 0 10px;
  text-align: left; background: var(--surface); color: var(--ink); border: 2px solid var(--line); border-radius: 14px;
  font-size: 17px; line-height: 1.35; user-select: none; -webkit-user-select: none;
}
.choice:last-child { margin-bottom: 0; }
/* Antwort mit Bild */
.cw { position: relative; margin: 0 0 10px; }
.cw:last-child { margin-bottom: 0; }
.cw .choice { margin: 0; }
.choice.has-img { flex-wrap: wrap; }
/* Bild laeuft bis an den Rand der Antwortflaeche (hebt Innenabstand 14/12 px auf) */
.choice .cimg { order: 9; flex: 0 0 calc(100% + 26px); display: block; margin: 6px -12px -12px -14px; background: var(--frame); border-radius: 0 0 12px 12px; overflow: hidden; }
.choice .cimg img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: contain; }
.choice.has-img .ctext:empty { display: block; }
.czoom { position: absolute; right: 2px; bottom: 2px; width: 44px; height: 44px; border: 0; background: none; padding: 0; display: grid; place-items: center; color: #fff; }
.czoom::before { content: ""; position: absolute; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.6); }
.czoom .ic { position: relative; width: 20px; height: 20px; }
button.choice:active { background: var(--surface-2); }
.choice .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 800 15px/1 var(--font-head); background: var(--surface-2); border: 1.5px solid var(--line); margin-top: 1px; }
.choice .ctext { flex: 1; min-width: 0; }
.choice .ctext .en, .choice .ctext .th { display: block; }
.choice .ctag { display: block; margin-top: 4px; font: 700 13px/1.3 var(--font-head); }
.choice .mark { flex: none; width: 26px; height: 26px; margin-top: 2px; }
.choice .mark .ic { width: 26px; height: 26px; stroke-width: 3; }
.choice.sel { border-color: var(--accent); background: var(--sel-bg); }
.choice.sel .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice.ok { border-color: var(--ok); background: var(--ok-bg); }
.choice.ok .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.ok .ctag, .choice.ok .mark { color: var(--ok); }
.choice.bad { border-color: var(--bad); background: var(--bad-bg); }
.choice.bad .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice.bad .ctag, .choice.bad .mark { color: var(--bad); }
@media (prefers-color-scheme: dark) {
  .choice.sel .letter { color: #06223F; }
  .choice.ok .letter, .choice.bad .letter { color: #0D1620; }
}

/* Aktionsleiste unten (Pruefung / Uebung) */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.actionbar-in { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.actionbar .btn { flex: none; }
.actionbar .btn.primary, .actionbar .btn.yellow { flex: 1; }
.actionbar .mid { flex: 1; }
.fb { flex: 1; display: flex; align-items: center; gap: 8px; font: 800 18px/1.2 var(--font-head); min-width: 0; }
.fb .ic { width: 26px; height: 26px; stroke-width: 3; }
.fb.ok { color: var(--ok); }
.fb.bad { color: var(--bad); }
.fb.idle { color: var(--muted); font-weight: 600; font-size: 16px; }

/* ---------- Tab-Leiste ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-in { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab { min-height: var(--tabh); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font: 700 11.5px/1 var(--font-head); position: relative; }
.tab .ic { width: 25px; height: 25px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--yellow); }

/* ---------- Schalter, Optionszeilen ---------- */
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px; margin-bottom: 8px; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
}
.opt .grow { flex: 1; min-width: 0; }
.opt .name { font-weight: 700; display: block; }
.opt .meta { font-size: 14px; color: var(--muted); }
.opt .radio { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: #fff; }
.opt .radio .ic { width: 16px; height: 16px; stroke-width: 3.4; opacity: 0; }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--sel-bg); }
.opt[aria-checked="true"] .radio { background: var(--accent); border-color: var(--accent); }
.opt[aria-checked="true"] .radio .ic { opacity: 1; }
.opt[disabled] { opacity: .5; }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.opt[aria-checked="true"] .switch { background: var(--accent); }
.opt[aria-checked="true"] .switch::after { transform: translateX(20px); }
.opt.sw[aria-checked="true"] { background: var(--surface); border-color: var(--line); }

/* ---------- Katalog ---------- */
.search { position: relative; margin-bottom: 12px; }
.search input {
  width: 100%; height: 50px; padding: 0 48px 0 46px; font-size: 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--surface); outline: none; -webkit-appearance: none; appearance: none;
}
.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search .ic.lead { position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; color: var(--muted); pointer-events: none; }
.search .clear { position: absolute; right: 2px; top: 3px; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 2px solid var(--line); background: var(--surface); font: 700 15px/1 var(--font-head); white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { color: #06223F; } }
.cat-card { content-visibility: auto; contain-intrinsic-size: auto 620px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font: 800 18px/1.3 var(--font-head); margin-bottom: 4px; }

/* ---------- Ergebnis ---------- */
.result { border-radius: 20px; padding: 22px 20px; text-align: center; background: var(--surface); box-shadow: inset 0 0 0 3px var(--c); color: var(--ink); --c: var(--line); }
.result.pass { --c: var(--ok); background: var(--ok-bg); }
.result.fail { --c: var(--bad); background: var(--bad-bg); }
.result .verdict { display: inline-flex; align-items: center; gap: 8px; font: 800 26px/1.1 var(--font-head); color: var(--c); }
.result .verdict .ic { width: 32px; height: 32px; stroke-width: 3.2; }
.result .score { font: 800 56px/1.05 var(--font-head); margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
.result .score small { font-size: 28px; color: var(--muted); font-weight: 700; }
.result .facts { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 15px; margin-top: 8px; }
.result .note { margin-top: 10px; font-size: 15px; font-weight: 600; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btnrow .btn { flex: 1; }

/* ---------- Statistik ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; text-align: center; }
.kpi b { display: block; font: 800 26px/1.1 var(--font-head); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted); }
.hist {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 8px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.hist .sc { font: 800 20px/1.1 var(--font-head); font-variant-numeric: tabular-nums; min-width: 78px; }
.hist .when { flex: 1; font-size: 14px; color: var(--muted); min-width: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Overlays ---------- */
.scrim { position: fixed; inset: 0; z-index: 100; background: rgba(6, 14, 24, .55); display: flex; align-items: flex-end; justify-content: center; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.dlg, .sheet { width: 100%; max-width: 480px; background: var(--surface); border-radius: 22px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.dlg h2, .sheet h2 { font: 800 21px/1.25 var(--font-head); margin-bottom: 6px; }
.dlg p { color: var(--muted); margin-bottom: 18px; }
.dlg-btns { display: flex; gap: 10px; }
.dlg-btns .btn { flex: 1; }
@media (min-width: 560px) { .scrim { align-items: center; } }
.sheet { max-height: calc(100dvh - 40px); overflow-y: auto; max-width: 560px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; margin: 14px 0; }
.cell {
  position: relative; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface);
  font: 800 16px/1 var(--font-head); font-variant-numeric: tabular-nums;
}
.cell.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.cell.done::after { content: "\2713"; position: absolute; top: 2px; right: 5px; font-size: 11px; font-weight: 900; }
.cell.cur { box-shadow: 0 0 0 3px var(--yellow); }
@media (prefers-color-scheme: dark) { .cell.done { color: #06223F; } }
.sheet .legend { margin: 0 0 14px; }
.sheet .legend .l-done { background: var(--accent); }
.sheet .legend .l-open { background: var(--surface); border: 2px solid var(--line); width: 12px; height: 12px; }

.zoom { position: fixed; inset: 0; z-index: 120; background: #20272F; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.zoom img { width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 50%; will-change: transform; -webkit-user-drag: none; pointer-events: none; }
.zoom .close {
  position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; touch-action: manipulation;
}
.zoom .zh { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,.8); pointer-events: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 110; bottom: calc(96px + env(safe-area-inset-bottom));
  max-width: min(92vw, 460px); display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--sign-ink); color: #fff; border-radius: 14px; font-size: 15px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.toast button { border: 0; background: none; color: var(--yellow); font: 800 15px var(--font-head); min-height: 44px; padding: 0 6px; }

@media (min-width: 700px) {
  .sign h1 { font-size: 42px; }
  .qimg img { max-height: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
