:root {
  --bg: #0f141c;
  --panel: #171e2a;
  --panel2: #1f2836;
  --line: #2c3748;
  --text: #e6ebf2;
  --muted: #8d99ab;
  --accent: #ffc83d;
  --accent2: #5b8ff0;
  --danger: #e4605c;

  /* board (paper) */
  --board-bg: #ffffff;
  --ink: #15181d;
  --user-ink: #1f5fbf;
  --xmark-ink: #6a55c8;
  --note-ink: #8a4b08;
  --extra-fill: rgba(105, 118, 140, .2);
  --yy-shade: rgba(70, 80, 98, .42);
  --yy-ring: #7d8899;
  --grid-thin: #9aa3b0;
  --grid-thick: #15181d;
  --hl-peer: rgba(91, 143, 240, 0.10);
  --hl-same: rgba(255, 200, 61, 0.35);
  --hl-king: rgba(182, 124, 240, 0.22);
  --hl-knight: rgba(240, 122, 180, 0.22);
  --hl-diag: rgba(157, 180, 255, 0.25);
  --hl-digit: rgba(255, 211, 77, 0.55);
  --hl-digit-stroke: #e0a800;
  --sel-fill: rgba(255, 200, 61, 0.22);
  --sel-stroke: #f0a400;
  --cage: #2d3440;
  --cage-text: #15181d;
  --fog: rgba(73, 81, 96, 0.92);
  --mark-fill: #d5d9e0;
  --diag: rgba(91, 143, 240, 0.12);
  --pen-mark: #5b6472;
  --hint: rgba(56, 189, 248, 0.22);
  --hint-stroke: #0ea5e9;
  --hint-elim: #e0352f;
  --hint-link: #f08c00;
  --diag-stroke: rgba(91, 143, 240, 0.35);


  /* surfaces and text shared by both themes */
  --inset: #0f141c; --hover-bg: #263043; --hover-line: #46546b; --text2: #c7cfdb;
  --link: #8fb5ff; --link-hover-bg: #1b2638; --ok: #7fdc8f;
  --bad-bg: #3a1c1c; --bad-line: #7c2d2d; --bad-text: #ffb3b0; --warn-bg: #2b2412; --warn-line: #6b5420; --warn-text: #ffd98a;
  --toast-bg: #222b39; --hint-bg: #10263a; --hint-line: #1f6f9c; --hint-title: #7dd3fc; --hint-link: #8fd0ff; --hint-note-bg: #0f2233; --hint-note: #b9d8ee;

  --ax-x: #e5533d; --ax-y: #3fae4a; --ax-z: #5b8ff0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 11px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover { border-color: var(--hover-line); background: var(--hover-bg); }
button.primary { background: #c9921a; border-color: #e0a92c; color: #111; font-weight: 600; }
button.primary:hover { background: #e0a92c; }
button.danger:hover { border-color: var(--danger); color: var(--bad-text); }
select, input, textarea { background: var(--inset); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
input[type=range] { padding: 0; accent-color: var(--accent); vertical-align: middle; width: 100px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.logo { background: linear-gradient(135deg, var(--ax-x), var(--ax-z)); color: #fff; padding: 0 5px; border-radius: 5px; margin-right: 1px; }
.ptitle { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.ptitle #pTitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.ptitle #pMeta { font-size: 12px; }
.timer { font-variant-numeric: tabular-nums; background: var(--panel2); padding: 4px 10px; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }
.timer.paused { color: var(--muted); text-decoration: line-through; }
.spacer { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); background: var(--panel2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #111; font-weight: 600; }
.seg.small button { padding: 4px 8px; font-size: 13px; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; padding: 8px 4px; }

/* ---------- main layout ---------- */
.app {
  flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, auto) 300px;
}
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-height: 0; min-width: 0; }
.pane3d { display: flex; flex-direction: column; overflow: hidden; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.bar.wrap { flex-wrap: wrap; row-gap: 6px; }
.bar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.view3d { position: relative; flex: 1; min-height: 200px; background: #141a24; }
.view3d canvas { display: block; touch-action: none; cursor: grab; }
.view3d canvas:active { cursor: grabbing; }
.tip3d { position: absolute; pointer-events: none; color: #e6ebf2; background: rgba(10, 14, 22, .92); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; }
.digitfilter { flex-wrap: wrap; gap: 5px; border-top: 1px solid var(--line); }
.digitfilter button { width: 32px; padding: 4px 0; font-weight: 700; }
.digitfilter button.on { background: #ffd34d; color: #111; }

.pane2d { display: flex; flex-direction: column; align-items: center; padding: 10px; overflow: auto; }
.slicenav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.slicenav .idx button { width: 30px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.ax-x { color: var(--ax-x); } .ax-y { color: var(--ax-y); } .ax-z { color: var(--ax-z); }
.seg button.on .ax-x, .seg button.on .ax-y, .seg button.on .ax-z { color: #111; }
.sliceTitle { margin: 6px 0 2px; color: var(--muted); font-size: 13px; }
.sliceTitle b { color: var(--text); }
.linkbtn { background: none; border: 1px solid var(--line); border-radius: 12px; padding: 1px 9px; margin-left: 8px; font-size: 12px; color: var(--link); }
.linkbtn:hover { border-color: var(--link); background: var(--link-hover-bg); }
.boardwrap { display: flex; gap: 8px; align-items: stretch; }
.board { width: min(calc(100vh - 290px), 46vw); min-width: 300px; aspect-ratio: 1; }
.board-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.depth { width: calc(min(calc(100vh - 290px), 46vw) * 0.152); min-width: 48px; }
.depth-svg { width: 100%; display: block; cursor: pointer; user-select: none; }
.board-svg text, .depth-svg text { font-family: system-ui, "Segoe UI", sans-serif; }
.d-given { font-size: 66px; text-anchor: middle; fill: var(--ink); font-weight: 500; }
.d-user { font-size: 66px; text-anchor: middle; fill: var(--user-ink); }
.d-given.bad, .d-user.bad { fill: #d93636; }
.d-trial { font-size: 66px; text-anchor: middle; fill: #7b4fd6; font-style: italic; }
.d-trial.bad { fill: #d93636; }
.d-user.locked { fill: #17834a; font-weight: 600; }
.toast button { margin-left: 12px; padding: 3px 10px; }
.d-user.wrong { fill: #d93636; text-decoration: underline; }
.d-center { text-anchor: middle; fill: var(--user-ink); }
.d-corner { font-size: 24px; text-anchor: middle; fill: var(--user-ink); }
.d-center .xmark, .d-corner.xmark { fill: var(--xmark-ink); font-style: italic; }
.d-center .bad, .d-corner.bad { fill: #e0352f; text-decoration: line-through; font-weight: 700; }
.axis-label { font-size: 26px; text-anchor: middle; font-weight: 700; }
.cage-sum { font-size: 22px; font-weight: 600; }
.xv { fill: #15181d; } .xv.bad { fill: #d93636; }
.pathhint { margin-top: 6px; font-size: 13px; background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 5px 10px; border-radius: 6px; color: var(--warn-text); }

.thumbs { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; margin-top: 10px; width: 100%; max-width: 760px; }
.thumb { padding: 3px; display: flex; flex-direction: column; align-items: center; background: var(--panel2); position: relative; }
.thumb canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 3px; }
.thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.thumb-label { font-size: 11px; font-weight: 700; }
.thumb-count { font-size: 10px; color: var(--muted); }

/* ---------- controls ---------- */
.controls { padding: 12px; overflow-y: auto; overflow-x: hidden; }
.controls select, .controls input { max-width: 100%; }
.rulectl > * { min-width: 0; }
.controls h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.controls h3:first-child { margin-top: 0; }
.row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.row > button { flex: 1; }
.row.end { justify-content: flex-end; }
.row.end > button { flex: 0 0 auto; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.keypad button { aspect-ratio: 1.35; font-size: 24px; font-weight: 600; position: relative; }
.keypad.corner button { font-size: 15px; align-items: flex-start; }
.keypad.center button { font-size: 15px; }
.keypad.color { grid-template-columns: repeat(4, 1fr); }
.keypad.color button { font-size: 12px; color: #111; text-shadow: 0 0 3px #fff; }
.keypad .kbd { position: absolute; left: 6px; top: 3px; font-size: 10px; color: var(--muted); }
.keypad.color .kbd { color: #333; }
.keypad.pen button { aspect-ratio: auto; font-size: 13px; font-weight: 500; }
.palrow { grid-column: 1 / -1; }
.palhead { display: flex; align-items: center; gap: 6px; margin: 2px 0 2px; font-size: 13px; }
.palhead span { flex: 1; text-align: center; font-weight: 600; }
.palhead em { display: block; font-style: normal; font-weight: 400; font-size: 11px; color: var(--ok); }
.keypad .palhead button { aspect-ratio: auto; font-size: 13px; padding: 4px 10px; color: var(--text); text-shadow: none; }
.pentools { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; }
.pentools button { padding: 8px 2px; }
.pentools button.on { background: var(--accent); color: #111; font-weight: 600; }
.pencolors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 8px; }
.pencolors button { height: 24px; padding: 0; border-radius: 5px; }
.pencolors button.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.penhelp { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.keypad.pen .penhelp button { font-size: 12px; }
.palette-edit { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.palette-edit input[type=color] { width: 100%; height: 30px; padding: 0; border: 1px solid var(--line); background: none; }
.palette-edit .wide { grid-column: span 2; }

.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.tools button { padding: 6px 4px; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tools button.on { background: var(--accent); color: #111; font-weight: 600; }
.tools .sw { width: 30px; height: 10px; border-radius: 5px; }
.toolpanel { margin-top: 8px; background: var(--panel2); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.toolpanel:empty { display: none; }
.toolpanel p { margin: 0 0 6px; color: var(--muted); }
.fld { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.fld input, .fld textarea { color: var(--text); resize: vertical; }
.chkgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.lockrow { align-items: center; color: var(--ok); font-size: 13px; }
.lockrow > button { flex: 0 0 auto; margin-left: auto; }
.optrow { margin-top: 8px; color: var(--muted); }
.fld-inline { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.rulectl { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 13px; }
.rulectl .full { grid-column: 1 / -1; }
.rulectl select { padding: 2px 4px; font-size: 12px; }
.rulectl label.sel { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.rulewarn { grid-column: 1 / -1; font-size: 12px; border-radius: 6px; padding: 4px 8px; }
.rulewarn.bad { background: var(--bad-bg); color: var(--bad-text); }
.rulewarn.warn { background: var(--warn-bg); color: var(--warn-text); }
.status { font-size: 13px; margin-top: 6px; min-height: 1em; }
.status.ok { color: var(--ok); } .status.bad { color: var(--bad-text); }
.klist { display: flex; flex-direction: column; gap: 3px; max-height: 260px; overflow-y: auto; }
.krow { display: flex; align-items: center; gap: 6px; background: var(--panel2); border-radius: 6px; padding: 3px 6px; font-size: 12px; cursor: pointer; border: 1px solid transparent; }
.krow.on { border-color: var(--accent); }
.krow .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.krow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.krow input { width: 46px; padding: 1px 4px; }
.krow button { padding: 0 6px; font-size: 12px; }
.about { white-space: pre-wrap; font-size: 13px; color: var(--text2); margin: 0 0 8px; line-height: 1.5; }
#dlgIntro .about { font-size: 14px; }
.rules { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text2); }
.rules li { margin-bottom: 4px; }

/* ---------- dialogs ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 94vw; max-height: 92vh; }
.dlg { max-width: 560px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg { padding: 18px 20px; }
.dlg.wide { width: min(860px, 94vw); max-width: none; }
.dlg.center { text-align: center; min-width: 280px; }
.dlg h2 { margin: 0 0 12px; font-size: 19px; }
.dlg fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.dlg legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.vgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 14px; }
.vgrid label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.vgrid input { width: 64px; }
.dlg textarea, .dlg #shareUrl { width: 100%; flex: 1; }
#shareCode { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
#shareSize { margin-left: auto; font-size: 12px; }
.progress { height: 10px; background: var(--inset); border-radius: 6px; overflow: hidden; width: 340px; max-width: 80vw; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.filebtn { display: inline-flex; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 11px; cursor: pointer; }
.filebtn input { display: none; }
.helpgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; font-size: 13px; }
.helpgrid h4 { margin: 10px 0 4px; }
.helpgrid ul { padding-left: 18px; margin: 0; }
.helpgrid li { margin-bottom: 3px; }
kbd { background: var(--inset); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; font-family: ui-monospace, monospace; }
.badge-demo { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: #d7a6f2; color: #111; text-align: center; font-weight: 800; line-height: 18px; border: 1px solid #333; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--toast-bg); border: 1px solid var(--line); padding: 9px 16px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); z-index: 50; }

#btnBig3d.on { background: var(--accent); color: #111; }
.app.big3d { grid-template-columns: minmax(300px, 1.7fr) minmax(300px, auto) 300px; }
.app.big3d .board { width: min(calc(100vh - 290px), 30vw); }
.app.big3d .depth { width: calc(min(calc(100vh - 290px), 30vw) * 0.152); }
.app.big3d .thumbs { max-width: 480px; }

/* ---------- hints / step solver ---------- */
.small { font-size: 12px; margin: 0 0 4px; }
.hintbox { margin-top: 10px; background: var(--hint-bg); border: 1px solid var(--hint-line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.hintbox .tech { font-weight: 700; color: var(--hint-title); margin-bottom: 4px; }
.hintbox ol { margin: 6px 0; padding-left: 18px; color: var(--text2); }
.hintbox ol li { margin-bottom: 4px; }
.hintbox .final { color: var(--text); margin-top: 4px; }
.hintbox .row { margin-top: 8px; }
.hintbox ul.why { margin: 6px 0; padding-left: 18px; color: var(--text2); }
.hintbox ul.why li { margin-bottom: 4px; }
.hintbox ul.why a { color: var(--hint-link); text-decoration: none; }
.hintbox ul.why a:hover { text-decoration: underline; }
.hintbox .note { margin-top: 6px; padding: 6px 8px; background: var(--hint-note-bg); border-radius: 6px; color: var(--hint-note); font-size: 12px; }
.hintbox.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.hintbox.bad .tech { color: var(--bad-text); }
.hintbox.ok .tech { color: var(--ok); }

/* ---------- rule illustrations ---------- */
a.ex, .ex { color: var(--link); font-size: 12px; text-decoration: none; white-space: nowrap; }
a.ex:hover { text-decoration: underline; }
.rule-body { max-height: 70vh; overflow-y: auto; font-size: 14px; }
.rule-body p { margin: 0 0 10px; color: var(--text2); }
.rule-figwrap { display: flex; justify-content: center; background: var(--inset); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.rule-fig { max-width: 100%; max-height: 260px; }
.rule-fig text { font-family: system-ui, "Segoe UI", sans-serif; }
.rule-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.rule-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; background: var(--inset); }
.rule-card .rule-fig { height: 90px; width: 100%; }
.rule-card span { font-size: 13px; }

/* single-slice (2D) puzzles */
.app.flat { grid-template-columns: minmax(420px, auto) 300px; justify-content: center; }
.app.flat .pane3d, .app.flat .depth, .app.flat .thumbs, .app.flat #axisSeg, .app.flat #slPrev, .app.flat #slNext, .app.flat #idxSeg { display: none !important; }
.app.flat .board { width: min(calc(100vh - 170px), 60vw); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .app { flex: none; grid-template-columns: minmax(0, 1fr) 290px; grid-template-rows: minmax(360px, 46vh) auto; }
  body { overflow: auto; }
  .pane3d { grid-column: 1 / -1; }
  .pane2d { overflow: visible; }
  .controls { overflow: visible; }
  .board { width: min(calc(100vh - 200px), calc((100vw - 380px) / 1.16)); min-width: 0; }
  .depth { width: calc(min(calc(100vh - 200px), calc((100vw - 380px) / 1.16)) * 0.152); min-width: 0; }
  .app.big3d { grid-template-columns: minmax(0, 1fr) 290px; }
  .app.big3d .board { width: min(calc(100vh - 200px), calc((100vw - 380px) / 1.16)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; padding: 8px; }
  .bar { flex-wrap: wrap; }
  .board { width: calc(100vw - 100px); min-width: 0; }
  .depth { width: calc((100vw - 100px) * 0.152); }
  .thumbs { grid-template-columns: repeat(5, 1fr); }
  .helpgrid { grid-template-columns: 1fr; }
  .ptitle #pTitle { max-width: 50vw; }
}

/* ---------- front page ---------- */
.brand { background: none; border: 0; padding: 0 2px; color: var(--text); }
.brand:hover { background: none; border: 0; opacity: .85; }
body.home main.app, body.home .ptitle, body.home .timer, body.home #modeSeg, body.home #btnShare, body.home #btnExport, body.home #btnNew { display: none !important; }
.home { flex: 1; overflow-y: auto; --d-easy: #3fae4a; --d-medium: #5b8ff0; --d-hard: #f08c00; --d-extreme: #e4605c; }
.home-inner { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; display: flex; flex-direction: column; gap: 22px; }
.home h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.3px; }
.home h2 { margin: 0 0 4px; font-size: 18px; }
.home a { color: var(--accent2); }
.home-hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.home-logo { width: 104px; height: 104px; flex: none; }
.home-logo line { stroke: var(--text); stroke-opacity: .55; stroke-width: .8; }
.home-logo text { fill: var(--text); font-size: 10px; font-weight: 700; text-anchor: middle; }
.home-pitch { flex: 1 1 340px; min-width: 0; }
.home-pitch p { margin: 0; max-width: 62ch; font-size: 15px; }
.continue-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 18px; min-width: 220px; max-width: 320px;
  border: 1px solid var(--accent); background: linear-gradient(135deg, rgba(255, 200, 61, .14), rgba(255, 200, 61, .04)); border-radius: 12px; text-align: left; }
.continue-card:hover { background: rgba(255, 200, 61, .2); border-color: var(--accent); }
.cc-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent); font-weight: 700; }
.cc-title { font-weight: 600; font-size: 16px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-meta { font-size: 12px; }

.home-quick { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.home-quick > p { margin: 0 0 4px; }
.qrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qlabel { width: 78px; color: var(--muted); font-size: 13px; }
.home-quick .seg { flex-wrap: wrap; }
.home-quick .seg button { padding: 7px 14px; }
.home-quick .seg button small { color: var(--muted); margin-left: 4px; font-size: 11px; }
.seg button.on small { color: inherit; opacity: .75; }
.qnote { margin: 2px 0 0; font-size: 13px; min-height: 1.4em; }
.home-quick .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.home-quick .row > button { flex: 0 0 auto; }
button.big { padding: 9px 22px; font-size: 15px; }

.home-lists { display: flex; flex-direction: column; gap: 14px; }
.home-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.home-tabs [data-tab] { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 12px; font-size: 16px; font-weight: 600; color: var(--muted); margin-bottom: -1px; }
.home-tabs [data-tab]:hover { color: var(--text); background: none; }
.home-tabs [data-tab].on { color: var(--text); border-bottom-color: var(--accent); }
.home-tabs .count { font-size: 12px; font-weight: 500; background: var(--panel2); border-radius: 10px; padding: 1px 7px; margin-left: 4px; color: var(--muted); }
.home-tabs .spacer { flex: 1; }
.home-tabs #libFilter { margin-bottom: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.pcard { display: flex; gap: 12px; text-align: left; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--dc, var(--line)); transition: transform .12s, border-color .12s, background .12s; }
.pcard:hover { transform: translateY(-2px); background: var(--panel2); border-color: var(--hover-line); border-left-color: var(--dc); }
.pcard.current { box-shadow: 0 0 0 1px var(--accent); }
.pcard.d-easy { --dc: var(--d-easy); } .pcard.d-medium { --dc: var(--d-medium); } .pcard.d-hard { --dc: var(--d-hard); } .pcard.d-extreme { --dc: var(--d-extreme); }
.pc-ic { width: 60px; height: 60px; flex: none; border-radius: 10px; background: var(--inset); display: grid; place-items: center; }
.pc-ic .ic { width: 54px; height: 54px; }
.pc-ic .ic line { stroke: var(--dc); }
.pc-ic .ic polygon { fill: var(--dc); fill-opacity: .14; }
.pc-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pc-title { font-weight: 650; font-size: 15.5px; }
.pc-meta { font-size: 12.5px; color: var(--muted); }
.pc-meta .diff { color: var(--dc); font-weight: 600; text-transform: capitalize; }
.pc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-chips span { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); }
.pc-chips span.plain { color: var(--muted); }
.pc-desc { font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st { font-size: 12px; font-weight: 600; margin-top: 2px; }
.st.new { color: var(--muted); font-weight: 500; }
.st.prog { color: var(--accent); }
.st.done { color: var(--d-easy); }
.empty { grid-column: 1 / -1; padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.empty h3 { margin: 0 0 6px; }
.empty p { max-width: 62ch; margin: 0 auto; }
.home-import { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.home-import input { flex: 1 1 260px; min-width: 0; }
@media (max-width: 640px) {
  .home-inner { padding: 14px 16px 30px; }
  .home h1 { font-size: 22px; }
  .home-logo { width: 72px; height: 72px; }
  .qlabel { width: 100%; }
  .continue-card { max-width: none; width: 100%; }
}

/* ---------- light theme: the same layout on paper-white panels ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f5; --panel: #ffffff; --panel2: #f1f4f8; --line: #d3dae4; --text: #1b2230; --muted: #5b6676;
  --accent: #f2b318; --accent2: #2f6fd8; --danger: #c93c38;
  --inset: #f6f8fb; --hover-bg: #e4e9f0; --hover-line: #aeb9c8; --text2: #364152;
  --link: #2a62c9; --link-hover-bg: #e6eefc; --ok: #1d8a3a;
  --bad-bg: #fde6e4; --bad-line: #e8a29c; --bad-text: #b3261e; --warn-bg: #fff4d6; --warn-line: #e6c56c; --warn-text: #7a5600;
  --toast-bg: #ffffff; --hint-bg: #eaf5fd; --hint-line: #93c9ea; --hint-title: #0b6aa2; --hint-link: #0b6aa2; --hint-note-bg: #d9ecf8; --hint-note: #23506f;
  --grid-thin: #a9b1bd;
}
:root[data-theme="light"] button.primary { background: #f2b318; border-color: #d99b06; }
:root[data-theme="light"] button.primary:hover { background: #f7c43d; }
:root[data-theme="light"] .topbar, :root[data-theme="light"] .pane { box-shadow: 0 1px 3px rgba(20, 30, 50, .06); }
:root[data-theme="light"] .toast { box-shadow: 0 8px 30px rgba(20, 30, 50, .18); }
:root[data-theme="light"] dialog::backdrop { background: rgba(20, 30, 50, .35); }

/* layer buttons: a small picture of what each layer writes */
#layerSeg button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px 4px; font-size: 12.5px; }
.lic { width: 24px; height: 24px; flex: none; }
.lic-cell { fill: var(--board-bg); stroke: var(--grid-thin); stroke-width: 1.2; }
.lic text { font-family: system-ui, sans-serif; text-anchor: middle; fill: var(--user-ink); }
.lic-big { font-size: 16px; font-weight: 600; }
.lic-sm { font-size: 7.5px; font-weight: 600; }
.lic-pen { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
#layerSeg button.on .lic-cell { stroke: #111; }
/* keypad: keys that are not digits of this puzzle are pencil-mark placeholders */
.keypad button.xkey { font-style: italic; color: var(--muted); }
.keypad button.dim { opacity: .4; }
.keypad.letters button { aspect-ratio: 1.5; font-size: 18px; padding: 0; min-width: 0; }
.keypad.c3 button.zero { grid-column: 2; }
:root[data-theme="light"] .cc-label { color: #a06b00; }

/* ---------- floating panels: line pop-out, stats ---------- */
.floatpanel { position: fixed; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); max-width: calc(100vw - 32px); }
.fp-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; }
.fp-title { font-weight: 650; }
.fp-head .spacer { flex: 1; }
.fp-btn { padding: 2px 8px; font-size: 13px; }
.linepop { left: 50%; bottom: 18px; transform: translateX(-50%); }
.lp-strip { overflow-x: auto; padding: 10px 12px 4px; }
.lp-strip svg { display: block; max-width: none; }
.lp-coord { font-size: 17px; text-anchor: middle; fill: var(--muted); }
.lp-jump { font-size: 20px; fill: var(--accent2); }
.lp-foot { padding: 0 12px 9px; font-size: 12.5px; }
.statspanel { right: 18px; top: 70px; width: 360px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; }
.st-body { overflow-y: auto; padding: 10px 12px 12px; font-size: 13px; }
.st-body h4 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.st-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.st-bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--inset); border: 1px solid var(--line); overflow: hidden; vertical-align: middle; flex: none; }
.st-bar > span { display: block; height: 100%; background: var(--accent2); }
.st-bar.ok > span { background: #3fae4a; } .st-bar.bad > span { background: var(--danger); }
.st-digits { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; }
.st-digit { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px 6px; }
.st-digit .g { font-size: 18px; font-weight: 700; }
.st-digit .n { font-size: 11px; color: var(--muted); }
.st-digit .st-bar { width: 80%; }
.st-digit.done { border-color: #3fae4a; } .st-digit.done .g { color: #3fae4a; }
.st-digit.over { border-color: var(--danger); }
.st-digit.on { box-shadow: 0 0 0 2px var(--accent); }
.st-groups div { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.st-groups div .st-bar { margin-left: auto; }
.st-type { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; margin-top: 4px; }
.st-type .spacer { flex: 1; }
.st-type .caret { width: 10px; color: var(--muted); }
.st-badn { color: var(--danger); font-weight: 600; }
.st-list { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 0 3px 16px; }
.st-clue { font-size: 12px; padding: 2px 7px; }
.st-clue.done { border-color: #3fae4a; } .st-clue.bad { border-color: var(--danger); color: var(--bad-text); }
.st-warn { color: var(--bad-text); margin: 10px 0 0; }
:root[data-theme="light"] .floatpanel { box-shadow: 0 12px 40px rgba(20, 30, 50, .18); }

.d-note { text-anchor: middle; fill: var(--note-ink); font-style: italic; font-weight: 500; pointer-events: none; }
.notebox { display: flex; flex-direction: column; gap: 6px; }
.notebox input { width: 100%; font-size: 15px; padding: 7px 9px; }
.notebox p { margin: 0; font-size: 12.5px; color: var(--muted); }
.lic text.lic-note { font-size: 6.5px; font-style: italic; fill: var(--note-ink); font-weight: 600; }
:root[data-theme="light"] .view3d { background: #e9edf3; }
:root[data-theme="light"] .tip3d { color: var(--text); background: rgba(255, 255, 255, .95); }

.storagebox p { margin: 0 0 8px; font-size: 13px; }
.home-foot { font-size: 12.5px; margin: 4px 0 -4px; }
.seg.multi button.on::before { content: '✓ '; }
.qhint { font-size: 12px; }
.st.lock { color: var(--muted); font-weight: 500; }
.pcard.locked { opacity: .6; }
.pcard.locked:hover { transform: none; }

/* brand: isometric cube mark + "Layer" light / "Sudoku" bold */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.brandmark { width: 30px; height: auto; flex: none; }
.brandword { font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.bw-light { font-weight: 400; }
.conflictnote { color: var(--bad-text); font-size: 12.5px; margin-top: 2px; }
.d-corner.other { fill: var(--muted); font-weight: 500; }

/* beta marking */
.beta { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 1px; color: #7a4d00; background: #ffd56b; border-radius: 5px; padding: 1px 6px; line-height: 1.5; vertical-align: middle; margin-left: 6px; }
.beta-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px; border: 1px solid #f2c94c; background: linear-gradient(135deg, rgba(255, 213, 107, .25), rgba(255, 213, 107, .08)); }
.beta-banner .beta { margin-left: 0; font-size: 12px; padding: 3px 8px; }
.bb-text { flex: 1 1 360px; font-size: 14px; }
.bb-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; background: #5865f2; color: #fff !important; text-decoration: none; font-weight: 600; padding: 8px 14px; border-radius: 8px; }
.bb-btn:hover { background: #4752c4; }
