/* Chord Bank Studio. A Mac-app layout (toolbar, sidebar, content, inspector) using
   macOS/iOS system colours, materials, grouped lists and type, in light and dark. */

:root {
  /* surfaces */
  --window: #ffffff;
  --chrome: rgba(246, 246, 246, 0.86);
  --sidebar: #f5f5f7;
  --group: #ffffff;
  --editor-bg: #ffffff;
  --lcd-bg: rgba(0, 0, 0, 0.045);
  --fill-1: rgba(120, 120, 128, 0.16);
  --fill-2: rgba(120, 120, 128, 0.08);
  --sep: rgba(60, 60, 67, 0.16);
  --control: #ffffff;
  --control-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
  /* text */
  --label: rgba(0, 0, 0, 0.87);
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.32);
  /* system colours */
  --accent: #007aff;
  --red: #ff3b30;
  --green: #34c759;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --material: rgba(250, 250, 252, 0.78);
  --material-solid: #fafafc;
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --seg-thumb: #ffffff;
  --switch-off: rgba(120, 120, 128, 0.18);

  /* music colours (canvas reads these) */
  --melody: #ff9500;
  --accomp: #007aff;
  --bass: #af52de;
  --pad: #5ac8fa;
  --drums: #ff2d55;
  --fill: #34c759;
  --rec: #ff3b30;
  --chord: rgba(0, 0, 0, 0.82);
  --chord-bg: rgba(120, 120, 128, 0.14);
  --style: #0062cc;
  --style-bg: rgba(0, 122, 255, 0.12);
  --roll-bg: #ffffff;
  --roll-row: #f7f7f9;
  --roll-grid: #ececf0;
  --roll-bar: #d6d6dc;
  --lane-a: #f2f2f5;
  --lane-b: #f7f7f9;
  --key-label: #8e8e93;

  /* aliases used by the canvas code */
  --text: var(--label);
  --muted: var(--label-2);
  --faint: var(--label-3);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark appearance: system choice, or forced with the appearance button */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --window: #1e1e1e; --chrome: rgba(44, 44, 46, 0.86); --sidebar: #252527; --group: #323234; --editor-bg: #1e1e1e;
    --lcd-bg: rgba(255, 255, 255, 0.07); --fill-1: rgba(120, 120, 128, 0.32); --fill-2: rgba(120, 120, 128, 0.18);
    --sep: rgba(255, 255, 255, 0.12); --control: rgba(255, 255, 255, 0.14); --control-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 1px 1px rgba(0, 0, 0, 0.3);
    --label: rgba(255, 255, 255, 0.88); --label-2: rgba(235, 235, 245, 0.6); --label-3: rgba(235, 235, 245, 0.3);
    --accent: #0a84ff; --red: #ff453a; --green: #30d158; --orange: #ff9f0a; --yellow: #ffd60a;
    --material: rgba(40, 40, 42, 0.78); --material-solid: #2a2a2c; --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
    --seg-thumb: #636366; --switch-off: rgba(120, 120, 128, 0.36);
    --melody: #ff9f0a; --accomp: #0a84ff; --bass: #bf5af2; --pad: #64d2ff; --drums: #ff375f; --fill: #30d158; --rec: #ff453a;
    --chord: rgba(255, 255, 255, 0.88); --chord-bg: rgba(120, 120, 128, 0.28); --style: #64b5ff; --style-bg: rgba(10, 132, 255, 0.2);
    --roll-bg: #1c1c1e; --roll-row: #222224; --roll-grid: #2c2c2e; --roll-bar: #3a3a3c; --lane-a: #252527; --lane-b: #2a2a2c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --window: #1e1e1e; --chrome: rgba(44, 44, 46, 0.86); --sidebar: #252527; --group: #323234; --editor-bg: #1e1e1e;
  --lcd-bg: rgba(255, 255, 255, 0.07); --fill-1: rgba(120, 120, 128, 0.32); --fill-2: rgba(120, 120, 128, 0.18);
  --sep: rgba(255, 255, 255, 0.12); --control: rgba(255, 255, 255, 0.14); --control-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 1px 1px rgba(0, 0, 0, 0.3);
  --label: rgba(255, 255, 255, 0.88); --label-2: rgba(235, 235, 245, 0.6); --label-3: rgba(235, 235, 245, 0.3);
  --accent: #0a84ff; --red: #ff453a; --green: #30d158; --orange: #ff9f0a; --yellow: #ffd60a;
  --material: rgba(40, 40, 42, 0.78); --material-solid: #2a2a2c; --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
  --seg-thumb: #636366; --switch-off: rgba(120, 120, 128, 0.36);
  --melody: #ff9f0a; --accomp: #0a84ff; --bass: #bf5af2; --pad: #64d2ff; --drums: #ff375f; --fill: #30d158; --rec: #ff453a;
  --chord: rgba(255, 255, 255, 0.88); --chord-bg: rgba(120, 120, 128, 0.28); --style: #64b5ff; --style-bg: rgba(10, 132, 255, 0.2);
  --roll-bg: #1c1c1e; --roll-row: #222224; --roll-grid: #2c2c2e; --roll-bar: #3a3a3c; --lane-a: #252527; --lane-b: #2a2a2c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--window);
  color: var(--label);
  font: 13px/1.38 var(--font-ui);
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}
h1, h2, h3 { margin: 0; }
h2 { font-size: 13px; font-weight: 600; }
code, kbd { font-family: var(--font-mono); font-size: 11.5px; }
code { background: var(--fill-2); padding: 1px 4px; border-radius: 4px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-radius: 6px; }
button { font: inherit; color: inherit; }
.i { width: 17px; height: 17px; flex: none; }
.dim { color: var(--label-2); }

/* ---------- Window ---------- */
.window { display: grid; grid-template-rows: 52px minmax(0, 1fr); height: 100vh; height: 100dvh; }

/* ---------- Unified toolbar ---------- */
.toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 0 12px 0 16px; position: relative; z-index: 10;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 0.5px solid var(--sep);
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-icon {
  width: 26px; height: 26px; border-radius: 6.5px; flex: none;
  background:
    linear-gradient(#fff, #fff) 5px 8px / 16px 12px no-repeat,
    linear-gradient(135deg, #ff9f0a, #ff375f);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.25), inset 0 0 0 0.5px rgba(0, 0, 0, 0.1);
  position: relative;
}
.app-icon::after {
  content: ""; position: absolute; left: 7.5px; top: 8px; width: 11px; height: 7px;
  background: linear-gradient(90deg, #1d1d1f 0 2px, transparent 2px 4.5px, #1d1d1f 4.5px 6.5px, transparent 6.5px 9px, #1d1d1f 9px 11px);
}
.doc-title { min-width: 0; line-height: 1.15; }
.doc-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 11px; color: var(--label-2); }
.tb-center { display: flex; align-items: center; gap: 10px; }
.tb-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.transport, .tgroup { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px; background: var(--fill-2); }
.tbtn {
  width: 32px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--label-2);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:hover { background: var(--fill-2); color: var(--label); }
.tbtn:active { background: var(--fill-1); transform: scale(0.94); transition-duration: 0s; }
.tbtn.toggle.on { color: var(--accent); }
.tbtn.play { color: var(--label); }
.tbtn.play.playing { color: var(--accent); }
.tbtn.rec { color: var(--red); }
.tbtn.rec.recording { background: var(--red); color: #fff; }
.tbtn.rec.recording .i { animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: 0.45; } }

/* ---------- LCD display (like Logic's control bar) ---------- */
.lcd {
  display: flex; align-items: stretch; height: 40px; border-radius: 8px; padding: 0 2px;
  background: var(--lcd-bg); box-shadow: inset 0 0 0 0.5px var(--sep), inset 0 1px 1.5px rgba(0, 0, 0, 0.05);
}
.lcd-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 12px; position: relative; min-width: 56px; }
.lcd-cell + .lcd-cell::before, .lcd-status::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 0.5px; background: var(--sep); }
.lcd-val {
  font: 600 16px/1.05 var(--font-rounded); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
  color: var(--label); white-space: nowrap;
}
.lcd-pos .lcd-val { min-width: 4.2ch; text-align: center; }
.lcd-chord .lcd-val { min-width: 3.5ch; text-align: center; }
.lcd-lbl { font: 600 8.5px var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--label-2); margin-top: 3px; }
#tempo {
  width: 3.4ch; border: 0; padding: 0; background: transparent; text-align: center; cursor: ns-resize;
  border-radius: 4px; caret-color: var(--accent);
}
#tempo:focus { cursor: text; outline: none; background: var(--fill-2); }
.lcd-tempo.dragging #tempo { color: var(--accent); }
.lcd-status {
  position: relative; align-self: center; max-width: 240px; padding: 0 12px; font-size: 11.5px; color: var(--label-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: max-width 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
}
.lcd-status.quiet { max-width: 0; opacity: 0; padding: 0; }
.lcd-status.err { color: var(--red); }
.lcd-status.warn { color: var(--orange); }
.lcd-status.rec { color: var(--red); font-weight: 600; }
.lcd-status.busy::before { display: none; }
.lcd-status.busy { padding-left: 28px; }
.lcd-status.busy::after {
  content: ""; position: absolute; left: 10px; top: 50%; width: 10px; height: 10px; margin-top: -6px;
  border: 1.8px solid var(--label-3); border-top-color: var(--label-2); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pop-up buttons ---------- */
.popup-wrap { position: relative; display: inline-flex; align-items: center; }
.popup {
  appearance: none; -webkit-appearance: none; height: 24px; padding: 0 26px 0 10px; border: 0; border-radius: 6px;
  background: var(--control); box-shadow: var(--control-shadow); color: var(--label); font: 13px var(--font-ui); cursor: pointer;
  max-width: 220px; text-overflow: ellipsis;
}
.popup-wrap .chev { position: absolute; right: 6px; width: 11px; height: 11px; pointer-events: none; color: var(--label-2); }
.tb-right .popup { max-width: 150px; }
/* inside grouped lists pop-ups read like iOS menu rows */
.popup-wrap.end { margin-left: auto; }
.popup-wrap.end .popup { background: transparent; box-shadow: none; color: var(--label-2); text-align: right; text-align-last: right; padding-right: 20px; direction: rtl; }
.popup-wrap.end .popup option { direction: ltr; }
.popup-wrap.end .chev { right: 2px; }

/* ---------- Panes ---------- */
.panes {
  display: grid; grid-template-columns: 380px minmax(0, 1fr) 320px; min-height: 0;
  transition: grid-template-columns 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.panes.no-inspector { grid-template-columns: 380px minmax(0, 1fr) 0px; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--editor-bg); border-right: 0.5px solid var(--sep); }
.content { overflow: auto; min-width: 0; padding: 26px 30px 36px; background: var(--window); }
.inspector { overflow: auto; min-width: 0; background: var(--sidebar); border-left: 0.5px solid var(--sep); }
.panes.no-inspector .inspector { border-left: 0; }

.pane-head { display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-bottom: 0.5px solid var(--sep); flex: none; }
.pane-note { margin-left: auto; font-size: 11.5px; color: var(--label-3); }

/* ---------- Editor ---------- */
.editor { position: relative; flex: 1; display: flex; min-height: 0; background: var(--editor-bg); }
.gutter {
  width: 44px; flex: none; overflow: hidden; padding: 10px 0 60px;
  font: 11.5px/20px var(--font-mono); color: var(--label-3); text-align: right; user-select: none;
}
.gutter div { padding-right: 10px; height: 20px; }
.gutter div.warn { color: var(--orange); }
.gutter div.err { color: #fff; background: var(--red); border-radius: 0 4px 4px 0; }
.gutter div.active { color: var(--accent); font-weight: 700; }
#code {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; margin: 0; padding: 10px 14px 10px 6px;
  background: transparent; color: var(--label);
  font: 12.5px/20px var(--font-mono); letter-spacing: 0; tab-size: 2; white-space: pre; overflow: auto; caret-color: var(--accent);
}
#code::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.issues { list-style: none; margin: 0; padding: 6px; max-height: 150px; overflow: auto; border-top: 0.5px solid var(--sep); background: var(--sidebar); flex: none; }
.issues li { display: flex; gap: 8px; align-items: flex-start; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.issues li:hover { background: var(--fill-2); }
.issues li .i { width: 15px; height: 15px; margin-top: 1px; }
.issues li.err .i { color: var(--red); }
.issues li.warn .i { color: var(--orange); }
.issues li.ok { cursor: default; color: var(--label-2); }
.issues li.ok .i { color: var(--green); }
.issues li b { font-weight: 600; color: var(--label-2); flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Content ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.hero-text { min-width: 0; flex: 1 1 auto; }
.now-card { flex: none; }
.large-title { font: 700 30px/1.1 var(--font-display); letter-spacing: -0.022em; overflow-wrap: anywhere; }
.title2 { font: 700 20px/1.2 var(--font-display); letter-spacing: -0.017em; }
.hero-meta { margin: 5px 0 0; color: var(--label-2); font-size: 13px; }
.now-card {
  display: flex; gap: 22px; align-items: center; padding: 12px 18px; border-radius: 14px; background: var(--fill-2);
}
.eyebrow { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.07em; color: var(--label-2); }
.eyebrow.gap { margin-top: 6px; }
.now-chord { font: 700 40px/1.02 var(--font-display); letter-spacing: -0.03em; min-width: 120px; will-change: transform, opacity; }
.now-roman { font: 500 12px var(--font-ui); color: var(--label-2); min-height: 16px; }
.next-chord { font: 600 20px/1.15 var(--font-display); letter-spacing: -0.015em; color: var(--label-2); }
.now-style { font: 600 13px var(--font-ui); color: var(--accent); text-transform: capitalize; }

.card { border-radius: 14px; background: var(--window); box-shadow: 0 0 0 0.5px var(--sep), 0 1px 3px rgba(0, 0, 0, 0.04); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 14px; padding: 10px 14px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 5px; color: var(--label-2); font-size: 11.5px; flex-wrap: wrap; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend i:not(:first-child) { margin-left: 8px; }
.zoom { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.zoom .i { width: 15px; height: 15px; }
.zoom input { width: 110px; }
.roll { position: relative; height: 300px; overflow-x: auto; overflow-y: hidden; background: var(--roll-bg); border-top: 0.5px solid var(--sep); overscroll-behavior-x: contain; }
.roll-inner { position: relative; }
.roll canvas { display: block; cursor: col-resize; touch-action: pan-y; }
.playhead { position: absolute; left: 0; top: 0; width: 2px; margin-left: -1px; background: var(--red); pointer-events: none; will-change: transform; border-radius: 1px; }
.playhead::before { content: ""; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top: 6px solid var(--red); }

/* GarageBand-like keys on a dark rail */
.keybed {
  margin-top: 14px; padding: 9px 8px 8px; border-radius: 14px;
  background: linear-gradient(#2c2c2e, #1a1a1c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.18);
}
.keybed canvas { display: block; width: 100%; cursor: pointer; touch-action: none; border-radius: 4px; }

/* Apple Music-style shelf */
.shelf { margin-top: 28px; }
.shelf-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.shelf-head .hero-meta { margin: 0; }
.shelf-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 200px; gap: 14px;
  overflow-x: auto; padding: 2px 2px 14px; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.tile { scroll-snap-align: start; display: flex; flex-direction: column; gap: 8px; }
.art {
  position: relative; aspect-ratio: 1.55; border-radius: 12px; padding: 12px; color: #fff; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.35), inset 0 0 0 0.5px rgba(255, 255, 255, 0.15);
}
.art-romans { font: 700 19px/1.15 var(--font-display); letter-spacing: -0.02em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); overflow-wrap: anywhere; }
.art-play {
  position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.92); color: #1d1d1f; display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); transition: transform 0.18s ease;
}
.art-play .i { width: 15px; height: 15px; margin-left: 2px; }
.art-play:active { transform: scale(0.92); transition-duration: 0s; }
.tile-meta { display: flex; align-items: flex-start; gap: 8px; }
.tile-text { min-width: 0; flex: 1; }
.tile-name { font-weight: 600; font-size: 13px; }
.tile-chords { color: var(--label-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Inspector: grouped lists ---------- */
.insp-tabs { position: sticky; top: 0; z-index: 2; padding: 12px 12px 6px; background: var(--sidebar); }
.insp-tabs .seg { display: grid; width: 100%; }
.insp-pane { padding-bottom: 24px; }
.group-label { padding: 16px 28px 6px; font: 600 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.04em; color: var(--label-2); }
.group { margin: 0 12px; background: var(--group); border-radius: 10px; box-shadow: 0 0 0 0.5px var(--sep); overflow: hidden; }
.group.tight { margin: 0 0 10px; }
.group-foot { margin: 6px 0 0; padding: 0 28px; font-size: 11.5px; color: var(--label-2); }
.row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 12px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: 0.5px; background: var(--sep); }
.row.sub { min-height: 32px; padding-top: 0; }
.row.sub::before { display: none; }
.row-label { font-size: 13px; color: var(--label); flex: none; min-width: 84px; }
.row-label.small { font-size: 12px; color: var(--label-2); min-width: 60px; }
.row-value { font: 500 12px var(--font-ui); color: var(--label-2); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.stepper-field { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--label-2); }
.stepper-field input {
  width: 58px; height: 24px; border: 0; border-radius: 6px; text-align: center; font: 13px var(--font-ui); font-variant-numeric: tabular-nums;
  background: var(--control); box-shadow: var(--control-shadow); color: var(--label);
}
#scopeBars[hidden] { display: none; }

/* selectable rows with a checkmark */
.pick {
  width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 12px; position: relative;
}
.pick + .pick::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: 0.5px; background: var(--sep); }
.pick:hover { background: var(--fill-2); }
.pick:active { background: var(--fill-1); }
.pick .name { font-size: 13px; text-transform: capitalize; }
.pick .hint { color: var(--label-3); font-size: 11.5px; margin-left: auto; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pick .i { color: var(--accent); width: 15px; height: 15px; visibility: hidden; flex: none; }
.pick.on .i { visibility: visible; margin-left: auto; }
.pick.on .hint { display: none; }
.pick.on .name { color: var(--accent); font-weight: 600; }
.pick .check-slot { margin-left: auto; display: inline-flex; }

/* change rows: iOS edit-mode delete control */
.change-row { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 12px; position: relative; }
.change-row + .change-row::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; height: 0.5px; background: var(--sep); }
.del { border: 0; padding: 0; background: transparent; color: var(--red); cursor: pointer; display: inline-grid; }
.del .i { width: 20px; height: 20px; }
.change-text { cursor: pointer; flex: 1; }
.change-text b { font-weight: 600; text-transform: capitalize; }
.change-where { color: var(--label-2); font-size: 12px; }
.empty-row { padding: 11px 12px; color: var(--label-3); font-size: 12.5px; }

/* mixer rows */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mix-row .row-label { min-width: 52px; }
.mute-btn { width: 30px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--label-2); display: grid; place-items: center; cursor: pointer; }
.mute-btn:hover { background: var(--fill-2); }
.mute-btn .i { width: 17px; height: 17px; }
.mute-btn.on { color: var(--red); }

/* iOS switch */
.switch {
  appearance: none; -webkit-appearance: none; width: 42px; height: 25px; border-radius: 13px; margin: 0 0 0 auto; flex: none;
  background: var(--switch-off); position: relative; cursor: pointer; transition: background-color 0.25s ease;
}
.switch::before {
  content: ""; position: absolute; left: 2px; top: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.32s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.switch:checked { background: var(--green); }
.switch:checked::before { transform: translateX(17px); }

/* ---------- Segmented control ---------- */
.seg {
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 2px; border-radius: 8px; background: var(--fill-1);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; color: var(--label);
  font: 500 12.5px var(--font-ui); padding: 0 10px; height: 24px; cursor: pointer; white-space: nowrap;
}
.seg button.on { font-weight: 600; }
.seg-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 0; border-radius: 6px;
  background: var(--seg-thumb); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  will-change: transform, width;
}
.seg.pressing .seg-thumb { filter: brightness(0.97); }

/* ---------- Sliders ---------- */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 22px; margin: 0; min-width: 0; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--fill-1) var(--p)); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 0.18s ease;
}
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); transition-duration: 0.06s; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill-1); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12); }

/* ---------- Buttons ---------- */
.pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 28px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: 600 13px var(--font-ui); cursor: pointer;
  transition: filter 0.15s ease, transform 0.18s ease;
}
.pill-btn:hover { filter: brightness(1.07); }
.pill-btn:active { transform: scale(0.97); transition-duration: 0s; }
.pill-btn.quiet { background: var(--fill-1); color: var(--accent); }
.pill-btn.small { height: 24px; padding: 0 11px; font-size: 12px; }

/* ---------- Floating materials: popovers, menu, sheet, toast ---------- */
.popover, .sheet, .toast {
  background: var(--material); color: var(--label);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-pop);
}
.popover { position: fixed; z-index: 40; width: 340px; max-width: calc(100vw - 24px); padding: 14px; border-radius: 14px; opacity: 0; pointer-events: none; will-change: transform, opacity, filter; }
.pop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pop-head h3 { font: 600 15px var(--font-display); letter-spacing: -0.012em; }
.pop-sub { color: var(--label-2); font-size: 11.5px; margin: 8px 0 0; }
.popover .row-label { min-width: 72px; }
.popover .seg { margin-left: auto; }
.rec-help { background: var(--fill-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0 0; font-size: 12px; color: var(--label-2); }
.rec-help p { margin: 8px 0 0; }
.typing { display: flex; gap: 4px; justify-content: center; margin-bottom: 4px; }
.typing:first-child { padding-left: 10px; }
.typing .k {
  width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; background: var(--group); color: var(--label);
  font: 600 10.5px var(--font-ui); box-shadow: var(--control-shadow);
}
.typing .k.b { background: #2c2c2e; color: #f2f2f7; }
.typing .gap { width: 22px; }
.meter { height: 5px; border-radius: 3px; background: var(--fill-1); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--green); border-radius: 3px; transition: width 0.06s linear; }
.voice-note { display: inline-block; min-width: 38px; font: 700 15px var(--font-rounded); color: var(--label); }
.rec-start { width: 100%; height: 34px; margin-top: 12px; background: var(--red); }
.rec-start .i { width: 13px; height: 13px; color: #fff; }

.menu { width: 230px; padding: 5px; border-radius: 10px; }
.menu button {
  display: flex; align-items: center; justify-content: space-between; width: 100%; height: 26px; padding: 0 10px;
  border: 0; border-radius: 5px; background: transparent; color: var(--label); font: 13px var(--font-ui); cursor: default; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menu button:hover kbd, .menu button:focus-visible kbd { color: rgba(255, 255, 255, 0.85); }
.menu kbd { font: 12px var(--font-ui); color: var(--label-3); }
.menu hr { border: 0; height: 0.5px; background: var(--sep); margin: 5px 10px; }

.sheet {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border: 0; border-radius: 14px; padding: 0; opacity: 0; overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.25); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 0.5px solid var(--sep); }
.help-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; padding: 4px 20px 22px; overflow: auto; }
.help-cols h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; }
.help-cols pre { background: var(--fill-2); border-radius: 8px; padding: 10px; font: 11.5px/1.55 var(--font-mono); overflow: auto; margin: 0; }
.help-cols p { color: var(--label-2); font-size: 12.5px; margin: 6px 0; }

.toast {
  position: fixed; bottom: 22px; left: 50%; z-index: 50; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; max-width: calc(100vw - 32px); will-change: transform, opacity, filter;
}

/* ---------- Smaller windows ---------- */
@media (max-width: 1280px) {
  .panes { grid-template-columns: 330px minmax(0, 1fr) 300px; }
  .panes.no-inspector { grid-template-columns: 330px minmax(0, 1fr) 0px; }
  .lcd-cell { padding: 0 9px; min-width: 48px; }
  .doc-sub { display: none; }
}
@media (max-width: 1080px) {
  /* inspector floats over the content as a sheet from the right */
  .panes, .panes.no-inspector { grid-template-columns: 320px minmax(0, 1fr); }
  .inspector {
    position: fixed; top: 52px; right: 0; bottom: 0; width: 320px; z-index: 15;
    box-shadow: -12px 0 40px -12px rgba(0, 0, 0, 0.3); transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .panes.no-inspector .inspector { transform: translateX(100%); box-shadow: none; }
  .lcd-cell:nth-child(4), .tb-left .doc-title { display: none; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .hero { flex-wrap: wrap; }
  .window { height: auto; grid-template-rows: auto auto; }
  .toolbar { grid-template-columns: 1fr; padding: 8px 12px; position: sticky; top: 0; }
  .tb-left { display: none; }
  .tb-center { flex-wrap: wrap; justify-content: center; }
  .tb-right { justify-content: center; }
  .panes, .panes.no-inspector { display: flex; flex-direction: column; }
  .content { order: -1; padding: 18px 16px; overflow: visible; }
  .sidebar { height: 460px; border-right: 0; border-top: 0.5px solid var(--sep); }
  .inspector, .panes.no-inspector .inspector { position: static; width: auto; transform: none; box-shadow: none; border-left: 0; }
  .now-card { width: 100%; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01s !important; }
  .tbtn:active, .pill-btn:active, .art-play:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .toolbar, .popover, .sheet, .toast { background: var(--material-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --sep: rgba(127, 127, 127, 0.7); --label-2: var(--label); --label-3: rgba(127, 127, 127, 0.9); }
  .toolbar, .popover, .sheet, .toast { background: var(--material-solid); }
}
