/* Page layout and controls. Colours and fonts come from the theme's
   stylesheet (themes/*.css), which sets the variables used here. */
:root { font: 14px/1.45 var(--ui-font, system-ui, sans-serif); background:var(--page); color:var(--text) }
* { box-sizing:border-box }
body { margin:0; height:100vh; display:flex; flex-direction:column }
.bar { display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; padding:6px 10px; background:var(--panel); border-bottom:1px solid var(--line) }
.brand { font-weight:800; margin-right:8px }
.spacer { flex:1 }
button, .button { font:inherit; color:var(--text); background:var(--button); border:1px solid var(--button-edge); border-radius:5px; padding:3px 9px; cursor:pointer }
button:hover, .button:hover { border-color:var(--edge) }
button:disabled { opacity:.45; cursor:default }
button.active { background:var(--edge); color:var(--page) }
select { font:inherit; color:var(--text); background:var(--button); border:1px solid var(--button-edge); border-radius:5px; padding:2px 5px }
input { font:inherit; color:var(--text); background:var(--input); border:1px solid var(--button-edge); border-radius:4px; padding:2px 5px }
.field { display:inline-flex; gap:5px; align-items:center; color:var(--muted) }
nav { display:flex; gap:4px }
.levels { display:inline-flex; gap:4px; align-items:center; margin-right:10px }
.zoom { display:inline-block; min-width:3.5em; text-align:center }
.level { display:inline-block; min-width:6em; text-align:center; border:1px solid var(--button-edge); border-radius:5px; padding:2px 8px }
.hint { color:var(--note); font-size:.85rem }
.layout { flex:1; display:grid; grid-template-columns:180px minmax(0,1fr) 420px; min-height:0 }
#palette { overflow:auto; padding:8px; border-right:1px solid var(--line); background:var(--panel) }
#palette h3 { font-size:.8rem; color:var(--muted); margin:10px 0 4px; text-transform:uppercase; letter-spacing:.05em }
#palette button { display:block; width:100%; text-align:left; margin:2px 0; font:600 12px ui-monospace,monospace }
main { display:flex; flex-direction:column; min-width:0; min-height:0 }
.board { flex:1; overflow:auto; background:var(--board) }
.board svg { display:block; color:var(--text); user-select:none }
.board.placing svg { cursor:crosshair }
.side { overflow:auto; padding:8px 10px; border-left:1px solid var(--line) }
.side h2 { font-size:.95rem; margin:6px 0 }
pre { margin:0; padding:10px; border:1px solid var(--line); border-radius:6px; background:var(--panel); overflow:auto; font-size:.75rem; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere }
.problems { margin:0; padding-left:18px; font-size:.85rem; color:var(--bad) }
.problems button.goto { all:unset; cursor:pointer; text-decoration:underline dotted; vertical-align:top }
.problems code { font:.95em ui-monospace,monospace }
.problems button.goto:hover { text-decoration:underline }
.wire-fault { fill:none; stroke:var(--bad); stroke-width:3; stroke-dasharray:7 4; pointer-events:none }
.wire-fault.selected { stroke-width:6 }
.socket-highlight { fill:none; stroke:#f5b400; stroke-width:3; pointer-events:none; animation:pulse 1.2s ease-in-out 3 }
@keyframes pulse { 50% { stroke-opacity:.25 } }
.landing { fill:#f5b40014; stroke:#f5b400; stroke-width:2.5; stroke-dasharray:8 5; pointer-events:none }
.problems li.ok, .problems li.unfinished { list-style:none; margin-left:-18px }
.problems li.ok { color:var(--belt) }
.problems li.unfinished, .problems li.gap { color:var(--note) }
.problems button.goto:focus-visible { outline:1px solid currentColor; outline-offset:2px }

/* Campaign: level menu, intro and outro dialogs, level panel. */
[hidden] { display:none !important }
.tools-group { display:inline-flex; gap:6px; align-items:center }
.level-title { font-weight:700; color:var(--note) }
.level-intro { margin:0 0 8px; font-size:.9rem; color:var(--muted) }
.dialog code, .level-intro code { font:.9em ui-monospace,monospace; background:var(--input); padding:0 3px; border-radius:3px }
.overlay { position:fixed; inset:0; background:rgba(10,14,11,.7); display:flex; align-items:center; justify-content:center; z-index:10 }
.dialog { background:var(--panel); border:1px solid var(--edge); border-radius:8px; padding:16px 20px; max-width:560px; max-height:85vh; overflow:auto }
.dialog h2 { margin:0 0 8px; font-size:1.1rem }
.dialog p { margin:0 0 12px; white-space:pre-wrap }
.dialog .buttons { display:flex; gap:8px; justify-content:flex-end; margin-top:10px }
.menu { max-width:760px; width:90vw; display:flex; flex-direction:column; overflow:hidden }
#chapters { overflow:auto; min-height:0 }
#menu-lead { margin:0 0 4px }
.menu .buttons .primary, .dialog .buttons .primary { border-color:var(--note); font-weight:600 }
.menu h3 { margin:12px 0 2px; font-size:.95rem }
.menu .chapter-intro { margin:0 0 6px; font-size:.85rem; color:var(--muted) }
.menu ol { margin:0; padding:0; list-style:none; display:flex; flex-wrap:wrap; gap:4px }
.menu li button { font-size:.8rem }
.menu li button.solved { border-color:var(--belt); color:var(--belt) }
.menu li button.next { border-color:var(--note) }

/* Header extras: theme and outside links, kept quiet beside the actions. */
.quiet { margin-left:4px; gap:10px; color:var(--muted) }
.quiet a { color:var(--muted); text-decoration:none }
.quiet a:hover { color:var(--text); text-decoration:underline }
/* A level without palette entries gives the board the palette's column. */
#palette:empty { display:none }
.layout:has(> #palette:empty) { grid-template-columns:minmax(0,1fr) 420px }
