:root {
  --bg: #0b1620;
  --panel: #12222f;
  --panel-2: #1a2f40;
  --line: #24405a;
  --text: #e8f0f6;
  --muted: #8ea6ba;
  --accent: #ffd23f;
  --accent-text: #1b1400;
  --danger: #ff4d4f;
  --deck: #0b2233;
  --water-a: #1179b5;
  --water-b: #0a4f80;
}
/* Licht thema met veel contrast, voor een buitenbad in de zon */
:root[data-theme="light"] {
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel-2: #e3ebf2;
  --line: #b9c8d6;
  --text: #0b1620;
  --muted: #4a6075;
  --accent: #0b5cd6;
  --accent-text: #ffffff;
  --deck: #d5dee6;
  --water-a: #1a8fd0;
  --water-b: #0d6aa8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

body {
  display: grid;
  grid-template-columns: 1fr 168px;
  grid-template-rows: 64px 1fr 84px;
  height: 100dvh;
}

/* --- kopbalk --- */
header { grid-column: 1 / 3; display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.name { flex: 1; min-width: 0; font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.dirty::after { content: " •"; color: var(--accent); }
select { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; padding: 0 10px; }
.seg { display: flex; background: var(--bg); border-radius: 14px; padding: 4px; }
.seg button { min-width: 72px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-text); }

/* --- knoppen --- */
.tool { min-width: 48px; min-height: 48px; border: 0; border-radius: 14px; background: var(--panel-2);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px; }
.tool svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.tool:active { transform: scale(.96); }
.tool.wide { flex-direction: row; gap: 8px; font-size: 14px; padding: 0 14px; }
.tool.primary { background: var(--accent); color: var(--accent-text); }
.tool[aria-busy="true"] { opacity: .6; }
.tool.rec { color: #ff4d4f; }
.tool.rec[aria-pressed="true"] { background: #ff4d4f; color: #fff; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 6px rgba(255, 77, 79, .35); } }
/* Tijdens opnemen: rode rand om het veld, zodat je ziet dat elke beweging telt */
body.recording main { box-shadow: inset 0 0 0 4px #ff4d4f; }
@media (prefers-reduced-motion: reduce) { .tool.rec[aria-pressed="true"] { animation: none; } }

/* --- veld --- */
main { position: relative; min-width: 0; min-height: 0; padding: 6px; overflow: hidden; }
/* De deck-rechthoek is bewust groter dan het veld; buiten de SVG niets tonen */
svg.board { width: 100%; height: 100%; display: block; overflow: hidden; }
svg.board .deck { fill: var(--deck); }
svg.board .water-a { stop-color: var(--water-a); }
svg.board .water-b { stop-color: var(--water-b); }
svg.board .piece { cursor: grab; }
svg.board .piece.lift { filter: drop-shadow(0 0.25px 0.35px rgba(0,0,0,.6)) brightness(1.08); cursor: grabbing; }
svg.board[data-tool="swim"], svg.board[data-tool="pass"] { cursor: crosshair; }
svg.board[data-tool="erase"] .drawing, svg.board[data-tool="erase"] .piece { cursor: pointer; }

/* --- gereedschap rechts --- */
.dock { grid-column: 2; grid-row: 2; background: var(--panel); border-left: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(2, 72px); grid-auto-rows: 68px; gap: 8px; padding: 10px; align-content: start; overflow-y: auto; }
.dock .tool { min-height: 68px; }
.dock hr { grid-column: 1 / 3; width: 100%; border: 0; border-top: 1px solid var(--line); margin: 0; align-self: center; }

/* --- tijdlijn --- */
footer { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--panel); border-top: 1px solid var(--line); }
.steps { display: flex; gap: 8px; flex: 1; overflow-x: auto; padding: 4px 0; }
.chip { min-width: 56px; min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel-2); font-weight: 800; font-size: 18px; }
.chip.on { border-color: var(--accent); color: var(--accent); }

/* --- lade met tactieken --- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 10; }
.drawer { position: fixed; left: 0; top: 0; bottom: 0; width: 360px; max-width: 90vw; background: var(--panel);
  border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .18s; z-index: 11;
  display: flex; flex-direction: column; }
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
body.drawer-open .drawer { transform: none; }
.drawer .list { flex: 1; overflow-y: auto; padding: 8px; }
.drawer h4 { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.row { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.row:hover { background: var(--panel-2); }
.row .open { flex: 1; min-height: 52px; border: 0; background: transparent; text-align: left; padding: 6px 10px; border-radius: 12px; }
.row .open small { display: block; color: var(--muted); font-size: 12px; }
.row .tool { background: transparent; min-width: 44px; min-height: 44px; }
.row.on { box-shadow: inset 3px 0 0 var(--accent); background: var(--panel-2); }
.drawer .foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.empty { color: var(--muted); font-size: 14px; padding: 4px 10px; }

/* --- dialoog --- */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 18px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h3 { margin: 0 0 12px; }
dialog p { margin: 0 0 12px; color: var(--muted); }
dialog input { width: 100%; min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 12px; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .actions button { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; }
dialog .actions .ok { background: var(--accent); color: var(--accent-text); border-color: transparent; }
dialog .actions .ok.danger { background: var(--danger); color: #fff; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 700; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }

/* Telefoon of smal scherm: gereedschap onder het veld */
@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px 1fr auto 76px; }
  header { grid-column: 1; gap: 6px; padding: 0 6px; }
  header select { max-width: 92px; }
  .seg button { min-width: 50px; }
  .tool.wide { padding: 0 10px; }
  footer { gap: 4px; padding: 0 6px; }
  .dock { grid-column: 1; grid-row: 3; grid-template-columns: repeat(auto-fill, 56px); grid-auto-rows: 56px; border-left: 0; border-top: 1px solid var(--line); }
  .dock .tool { min-height: 56px; }
  .dock hr { display: none; }
  footer { grid-column: 1; }
  .hide-sm { display: none; }
}
