/* Undertow editor. The look is a night-time nautical chart: ink-dark water, thin
   ruled lines, serif italics for names, small monospaced soundings for numbers.
   No web fonts, no images: everything is system type and drawn lines. */

:root {
  --ink: #06121b;
  --ink-2: #0a1b27;
  --ink-3: #0f2736;
  --rule: #1c4054;
  --rule-soft: #133041;
  --foam: #e8f0ea;
  --mist: #8eafbb;
  --dim: #5d7f8d;
  --brass: #d9b56b;
  --course: #ff7ab8;
  --warn: #f0a94a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 90% at 50% 35%, #0c2231 0%, var(--ink) 70%);
  color: var(--foam);
  font: 13px/1.4 var(--sans);
  overflow: hidden;
}

h2 {
  margin: 0 0 8px;
  font: italic 600 15px/1.2 var(--serif);
  letter-spacing: 0.01em;
  color: var(--foam);
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.hint {
  font: 400 11px/1.2 var(--sans);
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
}

button, select, input[type="text"], input[type="number"], input:not([type]) {
  font: inherit;
  color: var(--foam);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 9px;
  min-height: 26px;
}

button {
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  white-space: nowrap;
}

button:hover { border-color: var(--brass); color: var(--brass); }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible, .scrubber:focus-visible {
  outline: 1px solid var(--brass);
  outline-offset: 2px;
}

button.primary {
  border-color: var(--brass);
  color: var(--ink);
  background: var(--brass);
  font-weight: 600;
  min-width: 74px;
}
button.primary:hover { background: #efd08a; color: var(--ink); }
button.primary.on { background: transparent; color: var(--brass); }

button.quiet {
  border-style: dashed;
  color: var(--mist);
  width: 100%;
  margin-top: 6px;
}

select {
  background: var(--ink-2);
  padding-right: 4px;
}
select option { background: var(--ink-2); color: var(--foam); }

input[type="range"] {
  accent-color: var(--brass);
  height: 18px;
  min-width: 0;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mist);
  font: italic 12px var(--serif);
}

/* ---- top bar -------------------------------------------------------------- */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 3px 0 -2px var(--rule-soft);
  background: rgba(6, 18, 27, 0.7);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background:
    linear-gradient(var(--brass), var(--brass)) 50% 50% / 1px 100% no-repeat,
    linear-gradient(var(--brass), var(--brass)) 50% 50% / 100% 1px no-repeat,
    conic-gradient(from 45deg, transparent 0 25%, rgba(217, 181, 107, 0.35) 0 50%, transparent 0 75%, rgba(217, 181, 107, 0.35) 0);
}

.brand-name {
  font: italic 600 20px/1 var(--serif);
  letter-spacing: 0.02em;
}

.scene-name {
  border-color: transparent;
  border-bottom: 1px dotted var(--rule);
  border-radius: 0;
  color: var(--mist);
  font: italic 14px var(--serif);
  width: 128px;
  padding-left: 2px;
}
.scene-name:hover, .scene-name:focus { border-bottom-color: var(--brass); color: var(--foam); }

.transport, .keys, .files { display: flex; align-items: center; gap: 8px; }
.files { margin-left: auto; }

.readout {
  display: flex;
  gap: 12px;
  font: 12px var(--mono);
  color: var(--brass);
  min-width: 128px;
}

#volume { width: 64px; }

.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; color: var(--mist); }
.segmented button:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 3px 3px 0; }
.segmented button[aria-selected="true"] { color: var(--ink); background: var(--foam); border-color: var(--foam); }

/* ---- main deck ------------------------------------------------------------ */

.deck {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 270px;
  min-height: 0;
}

.panel {
  padding: 14px 14px 10px;
  overflow: auto;
  min-height: 0;
  background: rgba(8, 23, 33, 0.72);
}
.panel.moods { border-right: 1px solid var(--rule); }
.panel.state { border-left: 1px solid var(--rule); }
.panel h2:not(:first-child) { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule-soft); }

.chart-wrap { position: relative; min-width: 0; min-height: 0; }
#chart { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

.course, .now {
  position: absolute;
  left: 22px;
  pointer-events: none;
  font: 12px/1.5 var(--mono);
  color: var(--mist);
  text-shadow: 0 0 6px var(--ink), 0 0 2px var(--ink);
}
.now { top: 18px; }
.now b { font: italic 600 26px/1.1 var(--serif); color: var(--foam); display: block; }
.now .roman { color: var(--brass); }
.course { bottom: 18px; max-width: 70%; }
.course .path { color: var(--course); }
.course .relaxed { color: var(--warn); }

/* ---- moods ---------------------------------------------------------------- */

.mood-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.mood-list li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}
.mood-list li:hover { border-color: var(--rule); }
.mood-list li[aria-selected="true"] { border-color: var(--swatch); background: color-mix(in srgb, var(--swatch) 12%, transparent); }
.mood-list .swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px var(--ink), 0 0 0 3px var(--swatch); }
.mood-list .name { font: italic 600 15px var(--serif); }
.mood-list .count { font: 11px var(--mono); color: var(--dim); }
.mood-list .live { color: var(--brass); }

.mood-editor { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule-soft); display: grid; gap: 7px; }

.field {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--mist);
  font: italic 12px var(--serif);
}
.field > span { white-space: nowrap; }
.field input, .field select { width: 100%; font: 12px var(--sans); font-style: normal; }
.field input[type="color"] { padding: 0; height: 24px; border: 1px solid var(--rule); background: none; }
.field .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.field .pair.with-unit { grid-template-columns: minmax(0, 1fr) auto; }
.field .unit { font: 11px var(--mono); color: var(--dim); align-self: center; }

.region {
  font: 12px/1.5 var(--mono);
  color: var(--foam);
  padding: 6px 8px;
  border: 1px dotted var(--rule);
  border-radius: 3px;
  min-height: 30px;
}
.region small { color: var(--dim); font-family: var(--sans); }
.region .home { color: var(--brass); }

button.danger { color: #e98b7c; border-color: #5a2f2b; }
button.danger:hover { color: #ffb3a6; border-color: #e98b7c; }

/* ---- state ---------------------------------------------------------------- */

.pad {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: grab;
  touch-action: none;
}

.sliders { display: grid; gap: 6px; margin-top: 10px; }
.slider-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 34px 18px;
  align-items: center;
  gap: 6px;
}
.slider-row input[type="text"] {
  border-color: transparent;
  border-bottom: 1px dotted var(--rule);
  border-radius: 0;
  padding: 2px;
  font: italic 13px var(--serif);
  min-height: 22px;
  width: 100%;
}
.slider-row output { font: 12px var(--mono); color: var(--brass); text-align: right; }
.slider-row button { padding: 0; min-height: 18px; border: 0; color: var(--dim); font-style: normal; }

.gauge {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 34px 18px;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.gauge-label { font: italic 13px var(--serif); color: var(--mist); padding-left: 2px; }
.gauge-track { height: 6px; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.gauge-fill { height: 100%; width: 0; background: linear-gradient(90deg, #3d93a3, #d9b56b 60%, #ee5d4d); }
.gauge-value { font: 12px var(--mono); color: var(--brass); text-align: right; }

.passage { display: grid; gap: 7px; }

/* ---- timeline ------------------------------------------------------------- */

.log {
  border-top: 1px solid var(--rule);
  box-shadow: 0 -3px 0 -2px var(--rule-soft);
  padding: 10px 16px 12px;
  background: rgba(6, 18, 27, 0.8);
  min-width: 0;
}
.log-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.log-head h2 { margin-bottom: 6px; }

.logline {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 74px;
  overflow: hidden;
  justify-content: flex-end;
  border-bottom: 1px solid var(--rule-soft);
  mask-image: linear-gradient(90deg, transparent, #000 12%);
}
.logline:empty::after {
  content: "Press Play. Every chord the music visits is logged here, with the shape of the move that reached it.";
  align-self: center;
  margin: 0 auto;
  font: italic 13px var(--serif);
  color: var(--dim);
}

.entry {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 2px;
  border-bottom: 3px solid var(--swatch, var(--rule));
  color: var(--mist);
  cursor: default;
}
.entry .glyph { color: var(--mist); }
.entry .name { font: italic 600 16px/1.1 var(--serif); color: var(--foam); white-space: nowrap; }
.entry .sub { font: 11px/1.3 var(--mono); color: var(--dim); white-space: nowrap; }
.entry.transit .name { color: var(--course); }
.entry.arrival .glyph, .entry.transit .glyph { color: var(--course); }
.entry.now { background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--swatch) 22%, transparent)); }
.entry.now .name { color: #fff; }
.entry.ahead { opacity: 0.45; border-bottom-style: dotted; }

.scrub { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; margin-top: 10px; }
.scrubber { position: relative; height: 30px; cursor: ew-resize; touch-action: none; }
.scrubber .track { position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 2px; }
.scrubber .stop {
  position: absolute; top: 9px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--swatch); box-shadow: 0 0 0 2px var(--ink);
}
.scrubber .stop span {
  position: absolute; top: 13px; left: 50%; transform: translateX(-50%);
  font: italic 11px var(--serif); color: var(--mist); white-space: nowrap;
}
.scrubber .stop:first-child span { left: 0; transform: none; }
.scrubber .stop:last-of-type span { left: auto; right: 0; transform: none; }
.scrubber .handle {
  position: absolute; top: 1px; width: 2px; height: 28px; margin-left: -1px; background: var(--foam);
}
.scrubber .handle::before {
  content: ""; position: absolute; left: -5px; top: 9px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--foam); background: var(--ink);
}

.route { display: flex; align-items: center; gap: 4px; font: italic 12px var(--serif); color: var(--dim); min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.route .chip {
  border: 1px solid var(--swatch); color: var(--swatch); border-radius: 10px; padding: 0 8px; min-height: 20px;
  font: italic 12px var(--serif); background: transparent;
}
.route .chip:hover { text-decoration: line-through; }
.route select { min-height: 20px; padding: 0 4px; font-size: 12px; border-style: dashed; color: var(--mist); }

/* ---- floating bits -------------------------------------------------------- */

.tip {
  position: fixed;
  z-index: 10;
  max-width: 300px;
  padding: 8px 11px;
  background: #f1ead6;
  color: #1c2a33;
  border-radius: 2px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px #c9b98a inset;
  font: 12px/1.45 var(--sans);
  pointer-events: none;
}
.tip b { font: italic 600 15px var(--serif); display: block; }
.tip i { font-family: var(--serif); }
.tip .glyph { float: right; margin: 0 0 4px 10px; color: #1c2a33; }
.tip small { color: #5c6a70; display: block; margin-top: 3px; font-family: var(--mono); font-size: 11px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  z-index: 11;
  max-width: min(640px, 90vw);
  padding: 9px 14px;
  background: #2a1512;
  border: 1px solid #e98b7c;
  color: #ffd9d2;
  border-radius: 3px;
  font: 13px var(--sans);
}
.toast.ok { background: #10291f; border-color: #5ec8b5; color: #d4f3ec; }

@media (max-width: 1100px) {
  .deck { grid-template-columns: 210px minmax(0, 1fr) 230px; }
  .hint { display: none; }
}

/* Narrow screens: one column that scrolls, chart first. */
@media (max-width: 820px) {
  html, body { height: auto; }
  body { display: block; overflow: auto; }
  .deck { grid-template-columns: 1fr; }
  .chart-wrap { height: 86vw; min-height: 320px; order: -1; }
  .panel { overflow: visible; }
  .panel.moods, .panel.state { border: 0; border-top: 1px solid var(--rule); }
  .files { margin-left: 0; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
