/* Tom — music machine. A single dark "hardware" look on purpose: charcoal
   body, LCD readouts, and bright Lego bricks for song blocks. */
:root {
  color-scheme: dark;
  --body: #14161b; --panel: #1d2028; --panel-2: #252935; --edge: #2f3442;
  --ink: #eef0f5; --muted: #9aa1b3; --faint: #626a7d;
  --lcd: #0c1410; --lcd-ink: #9ff2b8; --lcd-dim: #4f8a63;
  --accent: #ffd23f; --accent-ink: #1a1400; --danger: #ff6b6b;
  --style: #b36bff;
  --r: 14px;
  --ui: "Rubik", "Avenir Next", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--body); color: var(--ink); font: 15px/1.45 var(--ui); padding-inline: 16px; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.machine { max-width: 1240px; margin: 0 auto; padding-block: 18px 32px; display: flex; flex-direction: column; gap: 16px; }

/* ── header ── */
.top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.gecko { width: 40px; height: 40px; filter: drop-shadow(0 2px 6px rgba(111, 207, 151, .35)); }
.wordmark { font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.sub { font: 500 11px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .18em; padding-top: 6px; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--edge); padding: 4px; border-radius: 999px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 999px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge); }
.transport { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn { border: 1px solid var(--edge); background: var(--panel-2); color: var(--ink); padding: 9px 14px; border-radius: 10px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { border-color: #3d4456; }
.btn.ghost { background: transparent; }
.btn.play { background: var(--accent); color: var(--accent-ink); border-color: transparent; min-width: 96px; justify-content: center; }
.btn.play.on { background: var(--danger); color: #230000; }
.lcd { font: 700 13px/1 var(--mono); background: var(--lcd); color: var(--lcd-ink); padding: 10px 12px; border-radius: 8px; border: 1px solid #1d2a22; font-variant-numeric: tabular-nums; min-width: 128px; text-align: center; }
.lcd-text { font: 500 12px/1.3 var(--mono); color: var(--lcd-ink); }
.lcd-text.dim { color: var(--lcd-dim); }

.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--panel-2); border: 1px solid var(--edge); border-radius: 12px; padding: 6px; min-width: 250px; display: flex; flex-direction: column; box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.menu-list button, .menu-list .file-btn { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.menu-list button:hover, .menu-list .file-btn:hover { background: var(--panel); }
.file-btn { cursor: pointer; }
.file-btn input { display: none; }

/* ── melody machine ── */
.view { display: flex; flex-direction: column; gap: 16px; }
.screen-wrap { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: stretch; }
.screen { background: var(--lcd); border: 1px solid #1d2a22; border-radius: var(--r); padding: 12px; box-shadow: inset 0 0 0 6px #0f1a14, inset 0 10px 40px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#roll { width: 100%; height: 260px; display: block; }
.screen-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.big-actions { display: flex; flex-direction: column; gap: 12px; justify-content: center; width: 240px; }
.btn.dice { background: var(--accent); color: var(--accent-ink); border: 0; font-size: 18px; font-weight: 800; padding: 18px; justify-content: center; border-radius: 16px; box-shadow: 0 6px 0 #b8940f; transition: transform .06s ease, box-shadow .06s ease; }
.btn.dice:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8940f; }
.die { font-size: 22px; }
.seed { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.seed label { font: 500 11px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.help { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.lcd-input { width: 100%; background: var(--lcd); color: var(--lcd-ink); border: 1px solid #1d2a22; border-radius: 8px; padding: 8px 10px; font: 700 14px/1 var(--mono); }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: var(--r); padding: 16px; }
.dials { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 20px; }
.dial { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dial.wide { grid-column: span 2; }
.dial-label { font: 500 11px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; display: flex; justify-content: space-between; }
.dial-label b { color: var(--lcd-ink); font-weight: 700; letter-spacing: 0; }
select, input.num { background: var(--panel-2); border: 1px solid var(--edge); border-radius: 9px; padding: 8px 10px; }
input[type="range"] { width: 100%; accent-color: var(--style); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--edge); background: var(--panel-2); color: var(--muted); padding: 7px 11px; border-radius: 999px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { color: var(--ink); background: color-mix(in srgb, var(--chip, var(--style)) 28%, var(--panel-2)); border-color: var(--chip, var(--style)); }
.chip .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--chip); }
.chip svg { width: 26px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

/* ── composer ── */
.song-bar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
.title-input { background: transparent; border: 0; border-bottom: 1px dashed var(--edge); font-size: 22px; font-weight: 800; padding: 4px 2px; min-width: 0; flex: 1 1 220px; }
.mini { display: inline-flex; align-items: center; gap: 6px; font: 500 11px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.mini .num { width: 76px; }
.auto-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.auto-label { font-weight: 800; margin-right: 4px; }

.board { display: flex; flex-direction: column; gap: 12px; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; }
.brick { --c: #888; position: relative; border: 0; color: #111; background: var(--c); border-radius: 8px; padding: 18px 14px 10px; font-weight: 800; box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 3px 0 rgba(0,0,0,.35); text-align: left; user-select: none; }
.brick::before { content: ""; position: absolute; top: -7px; left: 10px; right: 10px; height: 8px; background: radial-gradient(circle at 9px 5px, var(--c) 5px, transparent 5.5px) 0 0 / 22px 8px repeat-x; filter: brightness(1.08); }
.palette .brick { min-width: 96px; cursor: grab; }
.palette .brick small { display: block; font: 600 11px/1.2 var(--mono); opacity: .75; }

.timeline-wrap { position: relative; background: repeating-linear-gradient(90deg, #1a1d24 0 23px, #1d2129 23px 24px); border: 1px solid var(--edge); border-radius: var(--r); padding: 26px 14px 14px; min-height: 150px; overflow-x: auto; }
.timeline { display: flex; gap: 6px; align-items: stretch; min-height: 100px; }
.timeline .brick { flex: 0 0 auto; min-width: 70px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.timeline .brick[aria-selected="true"] { outline: 3px solid #fff; outline-offset: 2px; }
.timeline .brick.locked::after { content: "🔒"; position: absolute; top: 4px; right: 6px; font-size: 12px; }
.timeline .brick.drop-before { box-shadow: -6px 0 0 var(--accent), inset 0 -5px 0 rgba(0,0,0,.18); }
.brick .b-name { font-size: 14px; }
.brick .b-bars { font: 700 11px/1 var(--mono); opacity: .7; }
.brick .b-layers { display: flex; flex-wrap: wrap; gap: 3px; }
.brick .b-layers i { font-style: normal; font: 700 9px/1 var(--mono); background: rgba(0,0,0,.18); padding: 3px 4px; border-radius: 4px; }
.playhead { position: absolute; top: 8px; bottom: 8px; width: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); pointer-events: none; }
.empty { position: absolute; inset: 26px 14px 14px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); margin: 0; pointer-events: none; }

.inspector { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 20px; }
.inspector h3 { grid-column: 1 / -1; margin: 0; display: flex; align-items: center; gap: 12px; font-size: 18px; }
.inspector h3 .tag { width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
.inspector .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.inspector .hint { grid-column: 1 / -1; color: var(--muted); margin: 0; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--edge); background: var(--panel-2); font-weight: 800; }
.stepper output { font: 700 16px/1 var(--mono); min-width: 32px; text-align: center; }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--faint); font-size: 13px; }
.foot a { color: var(--muted); }

.toast.update { display: flex; align-items: center; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--edge); padding: 10px 16px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); z-index: 50; }

@media (max-width: 760px) {
  .screen-wrap { grid-template-columns: 1fr; }
  .big-actions { width: auto; }
  .dial.wide { grid-column: auto; }
  .transport { margin-left: 0; width: 100%; }
  .transport .lcd { flex: 1; }
  #roll { height: 200px; }
}
@media (prefers-reduced-motion: reduce) { .btn.dice { transition: none; } }
