:root {
  --bg: #12151a; --panel: #1b2028; --panel2: #262e39; --text: #e9edf2; --muted: #9eabb9; --line: #34404d;
  --ok: #3ddc84; --okbg: #153c2a; --fail: #ff6b6b; --failbg: #4a2125; --skip: #f0c14b; --skipbg: #43391b;
  --accent: #6ab4ff; --accentbg: #17304d; --mark: rgba(255, 196, 60, .38); --markres: rgba(160, 170, 180, .25);
  --onaccent: #06121f; --fs: 20px; --vvh: 100dvh;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8; --panel: #ffffff; --panel2: #e9edf2; --text: #15202b; --muted: #55657a; --line: #cbd3dd;
    --ok: #0f7a41; --okbg: #dcf4e6; --fail: #c62323; --failbg: #fde3e3; --skip: #7d5a00; --skipbg: #fbeec4;
    --accent: #0b62c4; --accentbg: #dbeafc; --mark: rgba(255, 190, 40, .5); --markres: rgba(120, 130, 140, .25);
    --onaccent: #ffffff;
  }
}
html[data-size="s"] { --fs: 17px; }
html[data-size="m"] { --fs: 21px; }
html[data-size="l"] { --fs: 26px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.4 system-ui, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.muted { color: var(--muted); } .small { font-size: .75em; } .spacer { flex: 1; }

.btn { min-height: 56px; min-width: 56px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel2); user-select: none; -webkit-user-select: none; }
.btn:active { filter: brightness(1.2); }
.btn:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--onaccent); font-weight: 700; }
.btn.on { background: var(--accentbg); border-color: var(--accent); }

#top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 2px solid var(--line); padding: 8px 12px; }
.row1, .row2 { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; }
.row2 { margin-top: 8px; }
.pick { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.sizes { display: flex; gap: 4px; }
.sz { padding: 0; width: 56px; font-weight: 700; font-size: 16px; } .sz.m { font-size: 21px; } .sz.l { font-size: 27px; }
.sz[aria-pressed="true"] { background: var(--accentbg); border-color: var(--accent); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); } .dot.wait { background: var(--skip); }
.bar { flex: 1; height: 22px; border-radius: 11px; background: var(--panel2); overflow: hidden; display: flex; border: 2px solid var(--line); min-width: 60px; }
.bar i { display: block; height: 100%; width: 0; transition: width .25s; }
.bar .ok { background: var(--ok); } .bar .fail { background: var(--fail); } .bar .skip { background: var(--skip); }
.prog { font-weight: 600; white-space: nowrap; font-size: .85em; }

main { max-width: 1200px; margin: 0 auto; padding: 12px 12px 120px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.cltitle { font-size: 1.3em; margin: 6px 0 4px; } .build { margin: 0 0 10px; }
details.intro { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 4px 14px; margin-bottom: 12px; }
details.intro summary { min-height: 56px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.sechead { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 10px; text-align: left; background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; margin: 14px 0 8px; padding: 0 14px; font-weight: 700; }
.sechead .chev { transition: transform .15s; } .sechead[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.sechead .cnt { margin-left: auto; font-weight: 500; color: var(--muted); }
.info { background: var(--panel); border: 2px dashed var(--line); border-radius: 14px; padding: 10px 14px; color: var(--muted); }

.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; background: var(--panel); border: 2px solid var(--line); border-left-width: 8px; border-radius: 14px; padding: 8px 10px; margin-bottom: 8px; }
.item.ok { border-left-color: var(--ok); background: linear-gradient(90deg, var(--okbg), var(--panel) 40%); }
.item.fail { border-left-color: var(--fail); background: linear-gradient(90deg, var(--failbg), var(--panel) 40%); }
.item.skip { border-left-color: var(--skip); background: linear-gradient(90deg, var(--skipbg), var(--panel) 40%); }
.item.flash { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 5px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.itemtext { text-align: left; background: none; border: 0; min-height: 56px; padding: 6px 4px; border-radius: 10px; width: 100%; }
.itemtext .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: .7em; color: var(--muted); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; border: 2px solid var(--line); font-size: .85em; font-weight: 600; color: var(--text); }
.badge.warn { border-color: var(--fail); color: var(--fail); } .badge.steps { border-color: var(--accent); color: var(--accent); }
.btns { display: flex; gap: 8px; }
.sbtn { min-height: 60px; min-width: 116px; border-radius: 14px; border: 3px solid var(--line); background: var(--panel2); font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; justify-content: center; gap: 8px; user-select: none; -webkit-user-select: none; }
.sbtn .ic { font-size: 1.25em; line-height: 1; }
.sbtn.ok { border-color: var(--ok); color: var(--ok); } .sbtn.fail { border-color: var(--fail); color: var(--fail); } .sbtn.skip { border-color: var(--skip); color: var(--skip); }
.sbtn.ok[aria-pressed="true"] { background: var(--ok); color: var(--onaccent); }
.sbtn.fail[aria-pressed="true"] { background: var(--fail); color: #fff; }
.sbtn.skip[aria-pressed="true"] { background: var(--skip); color: #1b1500; }
.sbtn:disabled { opacity: .4; }
@media (max-width: 820px) { .item { grid-template-columns: 1fr; } .btns .sbtn { flex: 1; min-width: 0; } }
@media (max-width: 560px) { .row1 { flex-wrap: wrap; } .prog { font-size: .7em; } }

.fbbox { margin-top: 22px; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; }
textarea, input[type="text"], input[type="password"], input:not([type]) { width: 100%; background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 12px; min-height: 56px; }
textarea { resize: vertical; min-height: 120px; }
.removed .item { opacity: .75; }

/* menus / dialogs / toast */
.menu { position: fixed; z-index: 30; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .55); padding: 70px 12px 12px; overflow: auto; }
.menu .card { max-width: 760px; margin: 0 auto; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 10px; }
.menu .entry { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 64px; text-align: left; margin-bottom: 6px; }
.menu .entry.cur { border-color: var(--accent); }
.menu h3 { margin: 10px 6px 6px; font-size: .8em; color: var(--muted); text-transform: uppercase; }
.dialogwrap { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 12px 12px; }
.dialog { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 18px; width: min(520px, 100%); display: grid; gap: 12px; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 600; max-width: 90vw; }
.toast.bad { background: var(--fail); color: #fff; }

/* detail view */
.detail { position: fixed; z-index: 40; left: 0; right: 0; top: 0; height: var(--vvh); background: var(--bg); display: flex; flex-direction: column; }
.dhead { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 2px solid var(--line); }
.dhead .pos { flex: 1; text-align: center; font-weight: 600; }
.dscroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 140px; }
.dinner { max-width: 960px; margin: 0 auto; display: grid; gap: 16px; }
.dtitle { font-size: 1.25em; font-weight: 700; }
.dbtns { display: flex; gap: 10px; } .dbtns .sbtn { flex: 1; min-height: 72px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.card h3 { font-size: .85em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; letter-spacing: .04em; }
.ann { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.ann .blk { margin: 4px 0; padding: 4px 0; } .ann .blk.q { border-left: 4px solid var(--line); padding-left: 12px; color: var(--muted); }
.ann .blk.ul, .ann .blk.ol { display: flex; gap: 10px; padding-left: 4px; }
.ann .blk.ul::before { content: "\2022"; flex: none; } .ann .blk.ol::before { content: attr(data-num) "."; flex: none; min-width: 1.6em; font-weight: 700; color: var(--accent); }
.ann .blk.h { font-weight: 700; }
.ann code, .info code, .itemtext code { background: var(--panel2); border-radius: 6px; padding: 0 6px; font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.ann.picking .blk { cursor: crosshair; }
mark { color: inherit; border-radius: 4px; cursor: pointer; background: var(--mark); box-shadow: 0 2px 0 var(--skip); }
mark.res { background: var(--markres); box-shadow: none; }
mark.sel { background: var(--accentbg); box-shadow: 0 2px 0 var(--accent); outline: 2px solid var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { min-height: 56px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--line); background: var(--panel2); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--onaccent); }
.prompt { font-weight: 800; font-size: 1.1em; margin-bottom: 8px; } .prompt.fail { color: var(--fail); }
.noteitem { border-top: 1px solid var(--line); padding: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.annitem { display: block; width: 100%; text-align: left; min-height: 56px; margin-bottom: 8px; background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.annitem.res { opacity: .65; } .annitem q { color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actionbar { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 14px; max-width: 960px; margin: 0 auto; background: var(--panel); border: 3px solid var(--accent); border-radius: 16px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); }
.actionbar .qprev { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.popup { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; max-height: 82%; overflow-y: auto; background: var(--panel); border-top: 4px solid var(--accent); border-radius: 18px 18px 0 0; padding: 14px; box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); }
.popup .inner { max-width: 960px; margin: 0 auto; display: grid; gap: 10px; }
.quote { border-left: 5px solid var(--skip); padding: 4px 12px; color: var(--muted); max-height: 5.5em; overflow: auto; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; flex-wrap: wrap; } .row > * { flex: 1; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; }
body.login main { width: min(420px, 92vw); padding: 0; }
body.login form { display: grid; gap: 14px; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 20px; }
body.login h1 { margin-bottom: 14px; text-align: center; }
body.login button { min-height: 60px; border-radius: 14px; border: 0; background: var(--accent); color: var(--onaccent); font-weight: 700; }
.err { color: var(--fail); font-weight: 600; margin: 0; }

.ann .blk .t { min-width: 0; overflow-wrap: anywhere; }
.infohead { font-size: .95em; margin: 18px 4px 6px; color: var(--muted); }
.card .row { margin-top: 12px; }
.detail.withpop .dscroll { padding-bottom: 60vh; }
