:root {
  --bg: #15171c; --panel: #1f232b; --line: #343a46; --text: #e9ecf1; --muted: #9aa3b2;
  --accent: #4c8dff; --ok: #3ccf7a; --warn: #ffb347;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, sans-serif; }
header { padding: 20px 24px 0; }
h1 { margin: 0; font-size: 1.5rem; }
h2 { margin: 0 0 12px; font-size: 1.15rem; }
h3 { margin: 12px 0 4px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; padding: 20px 24px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; min-width: 0; }
.wide { grid-column: 1 / -1; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }

button, select { font: inherit; color: var(--text); background: #2b313c; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
kbd { font-size: 0.75rem; background: rgba(0,0,0,0.25); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
select { max-width: 220px; }

.camera-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
#camera { width: 100%; height: 100%; object-fit: contain; display: block; }
#camera-msg { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 20px;
  text-align: center; color: var(--muted); }
#camera-msg[hidden] { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: 0.85rem; position: relative; padding-left: 26px; }
.chip::before { content: ''; position: absolute; left: 8px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  border-radius: 3px; background: var(--c); border: 1px solid var(--muted); }
.chip.active { border-color: var(--accent); background: #24375a; }

.palette { display: flex; gap: 8px; margin-bottom: 14px; }
.swatch { width: 34px; height: 34px; padding: 0; border: 2px solid #000; }
.swatch.active { outline: 3px solid var(--accent); outline-offset: 2px; }

.net { display: grid; grid-template-columns: repeat(12, minmax(0, 30px)); grid-template-rows: repeat(9, 30px); gap: 2px; }
.sticker { padding: 0; border-radius: 4px; border: 1px solid #000; background: #3a3f4a; font-size: 0.7rem;
  font-weight: 700; color: rgba(0,0,0,0.55); }
.sticker.empty { background: repeating-linear-gradient(45deg, #2d323c, #2d323c 4px, #3a3f4a 4px, #3a3f4a 8px); }
.sticker.centre { cursor: default; opacity: 1; }
.sticker.edited { box-shadow: inset 0 0 0 2px rgba(0,0,0,0.6); }
#validation.ok { color: var(--ok); }
#validation.warn { color: var(--warn); }

.solve-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 800px) { .solve-grid { grid-template-columns: 1fr; } main { grid-template-columns: 1fr; padding: 16px; } }
#viewer { position: relative; height: 460px; border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, #2a3040, #15171c 75%); }
#viewer canvas { display: block; border-radius: 8px; }
#view-reset { position: absolute; top: 8px; right: 8px; z-index: 1; }
#current { min-height: 3.2em; font-size: 1.05rem; }
#current .big { display: inline-block; font-size: 2rem; font-weight: 800; margin-right: 10px; vertical-align: middle;
  min-width: 2.2em; text-align: center; background: #2b313c; border-radius: 8px; padding: 0 8px; }
.controls button { min-width: 44px; }
.speed { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); }
.moves { display: flex; flex-wrap: wrap; gap: 6px; }
.move { font-family: ui-monospace, monospace; font-weight: 700; min-width: 44px; }
.move.done { opacity: 0.4; }
.move.next { background: var(--accent); border-color: var(--accent); color: #fff; }

.segmented { display: inline-flex; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.segmented button.active { background: #24375a; color: var(--text); }
#auto-status { font-weight: 600; min-height: 1.5em; }
#auto-status.ok { color: var(--ok); }
.minis { display: flex; flex-wrap: wrap; gap: 10px; }
.mini { position: relative; display: grid; grid-template-columns: repeat(3, 18px); gap: 2px; padding: 3px;
  background: #000; border-radius: 5px; }
.mini span { width: 18px; height: 18px; border-radius: 2px; }
.mini.empty { width: 66px; height: 66px; background: transparent; border: 2px dashed var(--line); }
.mini em { position: absolute; right: -6px; bottom: -8px; font-style: normal; font-size: 0.7rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 5px; }
.sticker.fixed { outline: 2px dashed #fff; outline-offset: 1px; z-index: 1; }
.sticker.fixed.uncertain { outline-color: var(--warn); }
#layout-note:empty { display: none; }
