:root {
  --ink: #f3e9de;
  --muted: rgba(243, 233, 222, 0.58);
  --line: rgba(243, 233, 222, 0.12);
  --glass: rgba(26, 21, 18, 0.72);
  --clay: #c47447;
  --good: #9fd1a6;
  --warn: #f0a37a;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1512; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
button, select, input { font: inherit; color: inherit; }
button, select {
  background: rgba(243, 233, 222, 0.07); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; cursor: pointer; font-size: 13px;
}
button:hover, select:hover { background: rgba(243, 233, 222, 0.14); }
select option { background: #2a221d; }
kbd {
  font: 10px/1 ui-monospace, Menlo, monospace; padding: 2px 4px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--muted); margin-left: 3px;
}
.primary { background: var(--clay); border-color: transparent; color: #fff; font-weight: 600; }
.primary:hover { background: #d4814f; }
.primary kbd { color: rgba(255, 255, 255, 0.8); border-color: rgba(255, 255, 255, 0.3); }

.brand { position: fixed; top: 16px; left: 20px; display: flex; align-items: baseline; gap: 14px; pointer-events: none; }
.brand button { pointer-events: auto; }
.wordmark { font: 600 22px/1 Georgia, "Times New Roman", serif; letter-spacing: -0.01em; }
.wordmark .dot { color: var(--clay); }
.tagline { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.ghost-button { background: none; border: none; color: var(--muted); padding: 2px 4px; }

#tools { position: fixed; left: 16px; top: 64px; display: flex; flex-direction: column; gap: 6px; width: 196px; }
.tool {
  display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; text-align: left;
  background: var(--glass); backdrop-filter: blur(8px); padding: 8px 10px;
}
.tool kbd { grid-row: span 2; align-self: center; margin: 0; }
.tool-name { font-weight: 600; font-size: 14px; }
.tool-hint { font-size: 11px; color: var(--muted); line-height: 1.3; }
.tool.active { border-color: var(--clay); background: rgba(196, 116, 71, 0.22); }
.tool.active kbd { color: var(--ink); border-color: var(--clay); }

.panel {
  position: fixed; right: 16px; top: 16px; width: 248px; padding: 12px;
  background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px;
  max-height: calc(100vh - 100px); overflow: auto;
}
.panel-title { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.panel-title:not(:first-child) { margin-top: 14px; }
#section { width: 100%; height: 230px; display: block; border-radius: 8px; background: rgba(0, 0, 0, 0.22); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 12px 0 0; }
.stats div { min-width: 0; }
.stats dt { font-size: 10.5px; color: var(--muted); }
.stats dd { margin: 1px 0 0; font: 13px ui-monospace, Menlo, monospace; white-space: nowrap; }
#stat-centre { color: var(--warn); }
#stat-centre.good { color: var(--good); }
#swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: flex; align-items: center; gap: 6px; padding: 5px 8px; font-size: 12px; }
.swatch span { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); }
.swatch.active { border-color: var(--ink); }
.export { display: flex; flex-direction: column; gap: 8px; }
.export label { font-size: 12px; color: var(--muted); }
.export input { width: 64px; background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; margin: 0 4px; }

.bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center;
  padding: 10px 14px; background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px;
  max-width: calc(100vw - 32px);
}
.group { display: flex; gap: 8px; align-items: center; }
.group[hidden] { display: none; }
.label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.readout { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); min-width: 96px; }
#gap-label { min-width: 40px; }
.wheel-button { min-width: 104px; }
.wheel-button.on { background: rgba(159, 209, 166, 0.18); border-color: rgba(159, 209, 166, 0.5); }
input[type=range] { accent-color: var(--clay); width: 110px; }
.water { width: 80px; height: 8px; background: rgba(0, 0, 0, 0.35); border-radius: 4px; overflow: hidden; }
#water-fill { height: 100%; background: #7fb4d6; transition: width 0.2s; }
#water-fill.dry { background: var(--warn); }

#toast {
  position: fixed; left: 50%; bottom: 132px; transform: translateX(-50%) translateY(6px);
  padding: 8px 14px; border-radius: 999px; background: rgba(26, 21, 18, 0.85); border: 1px solid var(--line);
  font-size: 13px; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

.help {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto;
  background: rgba(30, 24, 20, 0.94); border: 1px solid var(--line); border-radius: 16px; padding: 24px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.help[hidden] { display: none; }
.help h1 { font: 600 30px/1.1 Georgia, serif; margin: 0 0 10px; }
.help p, .help li { font-size: 14px; line-height: 1.55; color: rgba(243, 233, 222, 0.85); }
.help ol { padding-left: 20px; margin: 10px 0; }
.help li { margin-bottom: 6px; }
.help .small { font-size: 12.5px; color: var(--muted); }
.help .primary { margin-top: 6px; padding: 9px 18px; }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 40px; text-align: center; background: #1a1512; font-size: 16px; }
.fatal[hidden] { display: none; }

@media (max-width: 900px) {
  #tools { top: auto; bottom: 150px; width: auto; flex-direction: row; flex-wrap: wrap; right: 16px; }
  .tool { grid-template-columns: auto auto; }
  .tool-hint { display: none; }
  .panel { width: 200px; }
  #section { height: 150px; }
}
