/* ============ LISTEN — hyperrealistic synth machine + web-ish chrome ============ */
:root {
  --bg: #e9edf3;
  --bg-grad: radial-gradient(1100px 640px at 78% -8%, #f8faff 0%, #e9edf3 58%);
  --panel: #ffffff;
  --panel-2: #f4f6fa;
  --line: #d8dfea;
  --line-soft: #e6ebf3;
  --text: #1a2130;
  --text-dim: #4f5b74;
  --text-faint: #8792a8;
  --accent: #4f6bff;
  --accent-2: #7c5bff;
  --pink: #ec4899;
  --green: #10b981;
  --amber: #f59e0b;
  /* machine palette */
  --m-face: #22262e;
  --m-face-2: #2a2f39;
  --m-edge: #14171d;
  --m-label: #aeb6c6;
  --m-label-faint: #6b7384;
  --m-screw: #4a5160;
  --wood-1: #6b4a2f;
  --wood-2: #4c331f;
  --led-on: #4ade80;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(26, 33, 48, 0.10);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg-grad) fixed; color: var(--text);
  font-family: var(--font); min-height: 100vh;
}

/* ================= WEB-ISH TOP BAR ================= */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 18px; background: rgba(255,255,255,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: 3px; font-weight: 800; }
.tagline { font-size: 11.5px; color: var(--text-dim); margin-left: 2px; }
.topbar-status { display: flex; align-items: center; gap: 8px; }

.listen-indicator {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-family: var(--mono); color: var(--text-faint);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  background: var(--panel); transition: all .2s ease;
}
.listen-indicator .ear { filter: grayscale(1); opacity: .45; transition: all .2s ease; }
.listen-indicator.active { color: var(--pink); border-color: rgba(236,72,153,.5); box-shadow: 0 0 12px rgba(236,72,153,.3); }
.listen-indicator.active .ear { filter: none; opacity: 1; animation: earPulse .6s ease; }
@keyframes earPulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.2);} }

.badge { font-size: 10.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-dim); font-family: var(--mono); white-space: nowrap; background: var(--panel); }
.badge-ok { color: var(--green); border-color: rgba(16,185,129,.4); }
.badge-dim { color: var(--text-faint); }

.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; transition: all .15s ease; box-shadow: 0 1px 2px rgba(26,33,48,.05); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); color: #fff; }
.btn-mini { padding: 3px 9px; font-size: 11px; }

/* ================= WEB-ISH: WHAT THE AGENT HEARS (top, padded) ================= */
.hearing-panel {
  max-width: 1180px; margin: 16px auto 22px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .3s ease, border-color .3s ease;
  box-sizing: border-box;
}
/* wrapper that keeps ALL top-level blocks the same width as the machine */
.hearing-panel, .takes-bar { width: calc(100% - 28px); }
.hearing-panel.listening { border-color: rgba(236,72,153,.6); box-shadow: 0 0 0 3px rgba(236,72,153,.16), var(--shadow); }
.hearing-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.hearing-head h2 { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.ear-big { font-size: 18px; }
.hearing-head-right { display: flex; align-items: center; gap: 10px; }
.hearing-sub { font-size: 11px; color: var(--text-faint); }
.hearing-body { display: flex; gap: 16px; align-items: center; }
.hearing-ring { flex-shrink: 0; background: #0d1526; border: 1px solid var(--line); border-radius: 50%; }
.hearing { flex: 1; min-width: 0; }
.hearing .dim { font-size: 12px; color: var(--text-faint); }
.hearing .dim code { color: var(--accent); font-family: var(--mono); font-size: 11px; }
.hear-summary { font-size: 17px; font-weight: 700; color: var(--pink); margin-bottom: 7px; }
.hear-diff { font-size: 11px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--line-soft); border-left: 3px solid var(--accent-2); padding: 5px 10px; border-radius: 6px; margin-bottom: 9px; }
.hd-who { font-weight: 700; color: var(--text); margin-right: 6px; }
.hear-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (max-width: 760px) { .hear-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 460px) { .hear-grid { grid-template-columns: 1fr 1fr; } }
.hear-stat { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 9px; }
.hs-label { font-size: 8.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--text-faint); }
.hs-big { font-size: 13.5px; font-weight: 700; color: var(--text); margin: 1px 0; }
.hs-small { font-size: 9.5px; font-family: var(--mono); color: var(--accent); }

/* ================= HYPERREALISTIC MACHINE ================= */
.machine-wrap { max-width: 1180px; margin: 0 auto; padding: 0 14px 8px; }
.machine {
  display: flex; align-items: stretch;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(26,33,48,.35), 0 4px 14px rgba(26,33,48,.2);
  border: 1px solid var(--m-edge);
  overflow: hidden;
  background: var(--m-face);
}
/* wooden end cheeks */
.cheek {
  width: 20px; flex-shrink: 0;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.14) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2));
  box-shadow: inset 0 0 10px rgba(0,0,0,.4);
}
.machine-face {
  flex: 1; padding: 12px 14px 14px;
  background:
    radial-gradient(120% 140% at 50% 0%, var(--m-face-2) 0%, var(--m-face) 60%);
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
/* corner screws on the faceplate */
.machine-face::before, .machine-face::after,
.faceplate-top::before, .faceplate-top::after {
  content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6a7284, var(--m-screw) 60%, #20242c);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
}
.machine-face::before { top: 6px; left: 6px; }
.machine-face::after { top: 6px; right: 6px; }
.faceplate-top::before { bottom: 6px; left: 6px; }
.faceplate-top::after { bottom: 6px; right: 6px; }
.faceplate-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.brand-plate { display: flex; flex-direction: column; }
.mp-name { font-size: 16px; font-weight: 800; letter-spacing: 2px; color: #e8ecf4; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.mp-sub { font-size: 9px; letter-spacing: 1px; color: var(--m-label-faint); text-transform: uppercase; }

.vis-block { display: flex; gap: 8px; }
.vis { width: 185px; height: 70px; background: #05080f; border: 1px solid #000; border-radius: 6px; display: block; box-shadow: inset 0 2px 8px rgba(0,0,0,.8); }

/* ---------- control surface: zero wasted space ---------- */
.rack { display: flex; flex-wrap: wrap; gap: 8px; }
.module {
  background: linear-gradient(180deg, #2b303b, #242932);
  border: 1px solid #171b22; border-radius: 8px;
  padding: 7px 9px 8px; flex: 1 1 auto; min-width: 148px;
  display: flex; gap: 11px; flex-wrap: wrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 2px 5px rgba(0,0,0,.3);
}
.module-group { display: flex; flex-direction: column; }
.module-title { font-size: 8px; letter-spacing: 1.2px; color: var(--m-label-faint); margin-bottom: 5px; font-weight: 800; text-transform: uppercase; }
.module-knobs { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

/* ---------- hyperrealistic knobs ---------- */
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 50px; }
.knob {
  width: 38px; height: 38px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #5a6274 0%, #3a4150 45%, #23272f 100%);
  border: 2px solid #12151b;
  box-shadow:
    0 3px 6px rgba(0,0,0,.55),
    inset 0 1px 1px rgba(255,255,255,.22),
    inset 0 -3px 6px rgba(0,0,0,.4);
  position: relative; cursor: ns-resize; touch-action: none; outline-offset: 2px;
}
.knob:focus { outline: 2px solid var(--accent); }
.knob-indicator { position: absolute; inset: 0; border-radius: 50%; transition: transform .05s linear; }
.knob-indicator::after {
  content: ""; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 3px; height: 11px; background: #fff; border-radius: 2px;
  box-shadow: 0 0 4px rgba(255,255,255,.9), 0 1px 2px rgba(0,0,0,.4);
}
.knob-label { font-size: 8px; color: var(--m-label); letter-spacing: .2px; text-align: center; }
.knob-value { font-size: 8px; font-family: var(--mono); color: #cfe0ff; background: #05080f; border: 1px solid #000; padding: 0 5px; border-radius: 3px; min-width: 36px; text-align: center; box-shadow: inset 0 1px 3px rgba(0,0,0,.7); }

.select { font: inherit; background: #12151b; color: #dfe6f2; border: 1px solid #000; border-radius: 5px; padding: 4px 6px; font-size: 10px; cursor: pointer; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }

/* ---------- keyboard ---------- */
.keybed {
  background: #12151b; border: 1px solid #000; border-radius: 8px; padding: 7px 7px 9px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6);
}
.keyboard { display: flex; gap: 2px; user-select: none; overflow-x: auto; }
.key { flex: 1; min-width: 30px; height: 88px; border: 1px solid #b9c2d4; cursor: pointer; font-size: 8px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; border-radius: 0 0 4px 4px; transition: all .04s ease; position: relative; }
.key span { pointer-events: none; }
.key.white { background: linear-gradient(#ffffff, #e8ecf4); color: #93a0b8; box-shadow: 0 2px 3px rgba(0,0,0,.3); }
.key.black { background: linear-gradient(#39415a, #1c2233); color: #a8b4cc; height: 54px; flex: .62; min-width: 21px; margin: 0 -12px; z-index: 2; border-color: #000; box-shadow: 0 3px 5px rgba(0,0,0,.5); }
.key.active { background: linear-gradient(var(--accent), var(--accent-2)) !important; color: #fff !important; transform: translateY(2px); box-shadow: 0 1px 2px rgba(0,0,0,.3) !important; }

/* ---------- keymap strip: engraved into the machine (no gap above) ---------- */
.keymap-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(180deg, #1a1e26, #15181f);
  border: 1px solid #000; border-radius: 6px;
  padding: 6px 12px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.04);
}
.km-group { display: flex; align-items: center; gap: 8px; }
.km-label { font-family: var(--mono); font-size: 7.5px; letter-spacing: 1.5px; color: var(--m-label-faint); font-weight: 700; }
.km-keys { display: flex; gap: 3px; align-items: center; }
.km-keys kbd {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #3d4453, #2b303c);
  border: 1px solid #12151b; border-radius: 3px;
  color: #d5dbe8;
  box-shadow: 0 1px 2px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.12);
}
.km-sym { font-size: 9px; color: var(--m-label-faint); margin: 0 1px; }
.km-sep { width: 1px; height: 16px; background: #000; box-shadow: 1px 0 0 rgba(255,255,255,.05); }
.km-agent .km-note { font-size: 9.5px; color: var(--m-label); font-style: italic; }

/* ---------- simple mode (web-ish, inside machine area) ---------- */
.simple-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.simple-intro { margin: 0 0 12px; color: var(--text-dim); font-size: 12.5px; }
.simple-sliders { display: flex; flex-direction: column; gap: 11px; }
.simple-row { display: grid; grid-template-columns: 100px 1fr 100px; align-items: center; gap: 12px; }
.simple-end { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.simple-end:last-child { text-align: right; }
.simple-slider { width: 100%; height: 28px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.simple-slider::-webkit-slider-runnable-track { height: 7px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.simple-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; margin-top: -7.5px; border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(26,33,48,.3); cursor: grab; }
.simple-slider:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--pink); outline-offset: 2px; }
.simple-slider::-moz-range-track { height: 7px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.simple-slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }

/* ================= MACHINE SECTIONS (one continuous unit) ================= */
.m-section { margin: 0; }
.m-divider { height: 1px; background: #000; box-shadow: 0 1px 0 rgba(255,255,255,.05); margin: 2px 0; }
.m-brand-mini { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--m-label-faint); font-weight: 700; white-space: nowrap; }
.m-engrave { font-family: var(--mono); font-size: 7.5px; letter-spacing: 1.2px; color: var(--m-label-faint); }

/* ---- sequencer: two-tone groovebox panel (cream, distinct from the synth body) ---- */
.seq-section {
  display: flex; flex-direction: column; gap: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.02) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, #ece5d5, #d9d0ba);
  border: 1px solid #14171d; border-radius: 8px;
  padding: 9px 11px 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 6px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.35);
}
.seq-section .m-brand-mini { color: #8a7d5e; }
.seq-section .m-engrave { color: #8a7d5e; }
.seq-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seq-lcd {
  flex: 1; min-width: 160px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px;
  color: #d69e2e; text-shadow: 0 0 5px rgba(214,158,46,.3);
  background: #141009; border: 1px solid #000; border-radius: 4px;
  padding: 5px 10px; box-shadow: inset 0 2px 6px rgba(0,0,0,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seq-transport { display: flex; gap: 6px; align-items: center; }
.hw-btn {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .5px;
  padding: 7px 12px; border-radius: 5px; cursor: pointer;
  background: linear-gradient(180deg, #4a5162, #363c49);
  border: 1px solid #12151b; color: #e8edf6;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.16);
  transition: all .06s ease;
}
.hw-btn:hover { filter: brightness(1.12); }
.hw-btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.1); }
.hw-play { min-width: 40px; color: var(--led-on); }
.seq-grid {
  display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px;
  background: linear-gradient(180deg, #1d212a, #171a21);
  border: 1px solid #000; border-radius: 6px; padding: 6px;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.7);
}
.seq-cell {
  aspect-ratio: 1; min-height: 16px; border-radius: 3px;
  background: linear-gradient(180deg, #262b36, #1c2029);
  border: 1px solid #000; position: relative; cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
  transition: background .04s ease;
}
/* the "LED" dot in each step */
.seq-cell::after {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 34%; height: 34%; border-radius: 50%;
  background: #31363f; box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
  transition: all .04s ease;
}
.seq-cell.beat { background: linear-gradient(180deg, #2e3442, #22262f); }
.seq-cell.beat::after { background: #3a4150; }
.seq-cell.has-note::after {
  background: radial-gradient(circle at 35% 35%, #ffb35c, #ff7b1c 60%, #b34a00);
  box-shadow: 0 0 8px rgba(255, 123, 28, .85), inset 0 -1px 1px rgba(0,0,0,.3);
}
.seq-cell.playing::after {
  background: radial-gradient(circle at 35% 35%, #7cf29a, #22c55e 60%, #15803d);
  box-shadow: 0 0 12px rgba(74, 222, 128, .95), inset 0 -1px 1px rgba(0,0,0,.3);
}
.seq-foot { display: flex; justify-content: center; }

/* ---- patch memory: LCD unit, continuous with the machine ---- */
.patch-section { display: flex; flex-direction: column; gap: 8px; }
.pu-header { display: flex; align-items: center; gap: 10px; }
.pu-title { font-family: var(--mono); font-size: 9px; letter-spacing: 2px; color: var(--m-label-faint); font-weight: 700; }
.pu-model { margin-left: auto; font-family: var(--mono); font-size: 8.5px; letter-spacing: 2px; color: var(--m-label-faint); }
.pu-led {
  width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7cf29a, var(--led-on) 55%, #1d7a3f);
  box-shadow: 0 0 6px rgba(74, 222, 128, .8), inset 0 -1px 1px rgba(0,0,0,.4);
  animation: ledGlow 2.4s ease-in-out infinite;
}
@keyframes ledGlow { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.pu-footer { display: flex; justify-content: center; }
.pu-hint { font-family: var(--mono); font-size: 7.5px; letter-spacing: 1.2px; color: var(--m-label-faint); }

/* ================= WEB-ISH: TAKES (separate, mirrors hearing panel) ================= */
.takes-bar {
  max-width: 1180px; margin: 18px auto 70px; padding: 12px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.takes-head { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); font-weight: 800; margin-bottom: 8px; }
.takes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 150px; overflow-y: auto; }
.takes-list .empty { font-size: 11px; color: var(--text-faint); font-style: italic; }
.take-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 6px 10px; font-size: 11px;
  animation: slideIn .25s ease;
}
.take-icon { font-size: 14px; }
.take-name { flex: 1; min-width: 0; font-family: var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.take-meta { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; }
.take-dl { font-size: 10px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--accent); cursor: pointer; text-decoration: none; }
.take-dl:hover { border-color: var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ================= 90s/2000s LCD SCREEN (shared) ================= */
/* the LCD screen — dark, subdued amber phosphor */
.pu-screen {
  position: relative;
  background: #141009;
  border: 1px solid #000; border-radius: 6px;
  box-shadow: inset 0 3px 14px rgba(0,0,0,.85), inset 0 0 50px rgba(0,0,0,.5);
  padding: 10px 12px 12px;
  overflow: hidden;
  /* dot-matrix texture, very faint */
  background-image:
    radial-gradient(rgba(214, 158, 46, 0.04) 1px, transparent 1px);
  background-size: 3px 3px;
}
.pu-screen-glare {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.03) 0%, transparent 28%);
  border-radius: 6px;
}
.pu-readout {
  font-family: var(--mono); font-size: 13px; letter-spacing: 1px;
  color: #d69e2e;
  text-shadow: 0 0 6px rgba(214, 158, 46, .35);
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(214, 158, 46, .15);
  white-space: nowrap; overflow: hidden;
}
.pu-readout::before { content: "▸ "; }

.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .5px;
  padding: 5px 10px; border-radius: 4px;
  border: 1px solid rgba(214, 158, 46, .2);
  background: rgba(214, 158, 46, .04);
  color: #c8952e; cursor: pointer;
  text-shadow: 0 0 4px rgba(214, 158, 46, .3);
  transition: all .12s ease;
}
.preset-chip:hover { background: rgba(214, 158, 46, .12); border-color: rgba(214, 158, 46, .4); color: #e0b04a; }
.preset-chip.active {
  background: rgba(214, 158, 46, .2);
  border-color: #d69e2e;
  box-shadow: 0 0 8px rgba(214, 158, 46, .3), inset 0 0 5px rgba(214, 158, 46, .15);
  color: #eec25f;
}
.preset-chip.save { border-style: dashed; color: #a87d28; }
.preset-chip:focus-visible { outline: 2px solid #d69e2e; }

.pu-footer { margin-top: 8px; }
.pu-hint { font-family: var(--mono); font-size: 8px; letter-spacing: 1.5px; color: var(--m-label-faint); }

/* ================= GAME-STYLE HUD OVERLAY (floats, no reserved space) ================= */
.hud {
  position: fixed; left: 16px; bottom: 16px; z-index: 55;
  width: 288px; max-height: 38vh;
  display: flex; flex-direction: column; gap: 0;
  pointer-events: none;
}
.hud.dragging { transition: none; }
.hud.dragging .hud-section { box-shadow: 0 18px 44px rgba(26,33,48,.35); }

/* grip / drag handle */
.hud-grip {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-bottom: 4px;
  background: rgba(255,255,255,0.88); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: grab; user-select: none; touch-action: none;
  box-shadow: var(--shadow);
}
.hud-grip:active { cursor: grabbing; }
.hud-grip-dots {
  width: 14px; height: 10px; flex-shrink: 0;
  background-image: radial-gradient(circle, var(--text-faint) 1.4px, transparent 1.4px);
  background-size: 5px 5px;
}
.hud-grip-label { font-size: 9px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); flex: 1; }
.hud-min {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text-dim);
  font-size: 13px; line-height: 1; padding: 0;
}
.hud-min:hover { border-color: var(--accent); color: var(--accent); }

.hud-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.hud.minimized .hud-body { display: none; }
.hud.minimized { width: auto; max-height: none; }
.hud-body > * { pointer-events: auto; }
.hud-section {
  background: rgba(255,255,255,0.88); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.hud-tools { max-height: 14vh; }
.hud-activity { max-height: 16vh; }
.hud-title { font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.tool-count { margin-left: auto; font-family: var(--mono); font-size: 10px; background: var(--panel-2); border: 1px solid var(--line); padding: 0 7px; border-radius: 999px; color: var(--text-dim); }

.tool-list, .activity-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; scrollbar-width: thin; }
.tool-list { mask-image: linear-gradient(to bottom, transparent 0, black 24px); -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 24px); }
.tool-list li { font-family: var(--mono); font-size: 10px; padding: 3px 7px; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 6px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.t-kind { font-size: 8px; padding: 0 4px; border-radius: 3px; letter-spacing: .4px; flex-shrink: 0; font-weight: 700; }
.t-kind.core { background: rgba(79,107,255,.12); color: var(--accent); }
.t-kind.preset { background: rgba(236,72,153,.12); color: var(--pink); }

.activity-feed { flex-direction: column-reverse; }
.activity-feed li { font-size: 10px; padding: 4px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-soft); line-height: 1.35; }
.activity-feed .a-actor { font-weight: 800; font-size: 8.5px; letter-spacing: .4px; text-transform: uppercase; margin-right: 5px; }
.activity-feed .a-actor.agent { color: var(--accent-2); }
.activity-feed .a-actor.human { color: var(--green); }
.activity-feed .a-tool { font-family: var(--mono); color: var(--accent); font-size: 9.5px; }
.activity-feed .a-detail { color: var(--text-faint); display: block; font-size: 8.5px; word-break: break-word; }

.hud-fade { position: absolute; top: 0; left: 0; right: 0; height: 24px; pointer-events: none; background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%); border-radius: var(--radius-sm) var(--radius-sm) 0 0; z-index: 2; }
.hud-toggle {
  position: fixed; left: 16px; bottom: 16px; z-index: 56;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); font-size: 18px; cursor: pointer;
  box-shadow: var(--shadow); display: none;
}
.hud.collapsed { display: none; }
.hud.collapsed ~ .hud-toggle { display: block; }
@media (max-width: 640px) {
  .hud { display: none; }
  .hud-toggle { display: block; }
  .hud.open { display: flex; }
}

/* ================= AGENT CONSOLE DRAWER ================= */
.ac-fab {
  position: fixed; right: 14px; bottom: 14px; z-index: 70;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 107, 255, .4);
  transition: transform .15s ease;
}
.ac-fab:hover { transform: scale(1.08); }

.agent-console {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 65;
  width: 460px; max-width: 94vw;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(26, 33, 48, .18);
  display: flex; flex-direction: column;
  transform: translateX(0); transition: transform .25s ease;
}
.agent-console.collapsed { transform: translateX(100%); }

.acon-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.acon-title { font-size: 13.5px; font-weight: 800; flex: 1; min-width: 0; }
.acon-sub { display: block; font-size: 10px; font-weight: 400; color: var(--text-faint); }
.acon-count-badge { font-family: var(--mono); font-size: 10px; background: var(--panel); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; color: var(--text-dim); white-space: nowrap; }

.acon-scenarios { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.acon-sc-label { font-size: 10px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.acon-chip { font: inherit; font-size: 11px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; transition: all .13s ease; }
.acon-chip:hover { border-color: var(--accent); color: var(--accent); }

.acon-body { flex: 1; display: grid; grid-template-columns: 168px 1fr; overflow: hidden; min-height: 0; }
.ac-tool-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 3px; }
.ac-tool { padding: 5px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.ac-tool:hover { background: var(--panel-2); }
.ac-tool.open { background: rgba(79, 107, 255, .1); border-color: rgba(79, 107, 255, .3); }
.ac-name { font-family: var(--mono); font-size: 10px; color: var(--text); word-break: break-all; }

.ac-form { padding: 12px 14px; overflow-y: auto; }
.ac-form-head { margin-bottom: 6px; }
.ac-form-title { font-family: var(--mono); font-size: 13px; font-weight: 800; color: var(--accent); }
.ac-desc { font-size: 11px; color: var(--text-dim); line-height: 1.5; margin: 0 0 12px; }
.ac-dim { font-size: 11px; color: var(--text-faint); font-style: italic; }
.ac-field { display: block; margin-bottom: 10px; }
.ac-label { display: block; font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.ac-label em { font-weight: 400; font-style: normal; color: var(--text-faint); font-family: var(--mono); font-size: 9.5px; }
.ac-hint { display: block; font-size: 9.5px; color: var(--text-faint); margin-bottom: 4px; line-height: 1.4; }
.ac-input { width: 100%; font: inherit; font-size: 12px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); color: var(--text); }
.ac-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.ac-json { font-family: var(--mono); font-size: 11px; resize: vertical; }
.ac-actions { margin: 12px 0 8px; }
.ac-result { font-family: var(--mono); font-size: 10.5px; background: #0d1526; color: #bfe3c8; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow-y: auto; min-height: 44px; }
.ac-result.busy { color: var(--amber); }

/* ================= START DEMO (guided journey) — hardware-styled to match the machine ================= */
.btn-demo {
  background: linear-gradient(180deg, #3d4453, #2b303c);
  border: 1px solid #12151b; color: #fff; font-weight: 700;
  box-shadow: 0 2px 4px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-demo:hover { filter: brightness(1.1); color: #fff; }

.demo-panel {
  position: fixed; right: 14px; bottom: 14px; z-index: 80;
  width: 336px; max-width: calc(100vw - 28px);
  background:
    radial-gradient(120% 150% at 50% 0%, var(--m-face-2) 0%, var(--m-face) 60%);
  border: 1px solid var(--m-edge); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: hidden; position: relative;
}
/* corner screws on the demo unit */
.demo-panel::before, .demo-panel::after {
  content: ""; position: absolute; top: 7px; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6a7284, var(--m-screw) 60%, #20242c);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.6); z-index: 1;
}
.demo-panel::before { left: 7px; }
.demo-panel::after { right: 7px; }

.demo-progressbar { height: 4px; background: #0c0f15; box-shadow: inset 0 1px 3px rgba(0,0,0,.7); }
.demo-progress { height: 100%; background: linear-gradient(90deg, #d69e2e, #ff7b1c); width: 0; transition: width .4s ease; box-shadow: 0 0 8px rgba(214,158,46,.5); }

.demo-panel-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 0; }
.demo-steps { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 0; }
.demo-step {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: .4px; font-weight: 700;
  color: var(--m-label-faint); padding: 3px 6px; border-radius: 3px;
  background: #161a21; border: 1px solid #000;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.5);
}
.demo-step.active {
  color: #ffb35c; border-color: rgba(255,123,28,.4);
  background: #241a10;
  box-shadow: 0 0 8px rgba(255,123,28,.25), inset 0 1px 2px rgba(0,0,0,.5);
}
.demo-step.done { color: var(--led-on); }
.demo-arrow { color: var(--m-label-faint); font-size: 8px; }
.demo-x {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(180deg, #454d5e, #323845); border: 1px solid #12151b; color: #e8edf6;
  font-size: 12px; line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.14);
}
.demo-x:hover { background: linear-gradient(180deg, #6e3a3a, #4a2626); color: #fff; }

.demo-body { padding: 12px 16px 8px; }
.demo-title { margin: 0 0 6px; font-size: 16px; color: #e8ecf4; text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.demo-desc { margin: 0 0 10px; font-size: 12px; color: var(--m-label); line-height: 1.55; }
.demo-hint {
  font-family: var(--mono); font-size: 10px; color: #d69e2e;
  background: #141009; border: 1px solid #000; border-left: 3px solid #d69e2e;
  text-shadow: 0 0 5px rgba(214,158,46,.3);
  padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; line-height: 1.5;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7);
}

.demo-actions { display: flex; align-items: center; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid #000; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.demo-actions .btn { font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .3px; padding: 7px 12px;
  background: linear-gradient(180deg, #454d5e, #323845); border: 1px solid #12151b; color: #e8edf6;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.14); }
.demo-actions .btn:hover { filter: brightness(1.12); color: #fff; border-color: #12151b; }
.demo-actions .btn:active { transform: translateY(1px); }
.demo-actions .btn-primary { background: linear-gradient(180deg, #d69e2e, #b87714); color: #14100a; border-color: #000; flex: 1; }
.demo-actions .btn-primary:hover { color: #000; filter: brightness(1.1); }
.demo-actions .btn-ghost { background: linear-gradient(180deg, #2b303c, #22262e); }

/* FAB 🧪 slides up above the demo panel while it's open */
.ac-fab { transition: transform .15s ease, bottom .25s ease; }
body.demo-active .ac-fab { bottom: 340px; }

/* flash the takes panel when artifacts are prepared (guides the eye) */
.takes-bar.flash-attn { animation: takesFlash 1.2s ease 2; }
@keyframes takesFlash {
  0%, 100% { box-shadow: var(--shadow); border-color: var(--line); }
  50% { box-shadow: 0 0 0 3px rgba(214, 158, 46, .35), var(--shadow); border-color: rgba(214, 158, 46, .6); }
}

/* ================= A11Y ================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.key:focus-visible { outline: 3px solid var(--pink); }
.preset-chip:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
