/* Cool Edit Pro design system: a late-90s desktop audio editor skin.
   Tokens first, then primitives (bevels, buttons, fields), then layout. */

:root {
  /* Chrome */
  --face: #d4d0c8;
  --face-hi: #ffffff;
  --face-light: #e8e6e1;
  --face-shadow: #808080;
  --face-dark: #404040;
  --ink: #000000;
  --ink-muted: #4a4a4a;
  --ink-disabled: #8d8d8d;
  --title-a: #0a246a;
  --title-b: #a6caf0;
  --title-ink: #ffffff;
  --focus: #000000;

  /* Slate panels (file list, transport, time) */
  --slate: #626c7b;
  --slate-hi: #adb0b7;
  --slate-shadow: #212c31;
  --slate-ink: #f0f0f0;
  --slate-tab: #7a8794;

  /* Readouts */
  --lcd-bg: #49545f;
  --lcd-ink: #e4e4e4;
  --lcd-rec: #ff7b7b;
  --field-bg: #394349;
  --field-ink: #e8e8e8;

  /* Waveform (read by app.ts through getComputedStyle). Slate and waveform colors are Cool Edit Pro 2.1's default scheme. */
  --wave-bg: #000000;
  --wave: #84d35a;
  --wave-center: #84d35a;
  --wave-grid: #002f00;
  --wave-sel-bg: #394349;
  --wave-sel: #adcfad;
  --wave-sel-line: #ffffff;
  --wave-bound: #fdfdfe;
  --cursor: #ffffff;
  --play: #ff5050;
  --axis-bg: #394349;
  --axis-ink: #dee5de;
  --axis-tick: #adb0b7;
  --axis-font: 11px Tahoma, Verdana, "Segoe UI", sans-serif;
  --overview: #84d35a;
  --overview-track: #596874;
  /* Multitrack View, from Cool Edit's default colours */
  --mt-track: #353639;
  --mt-track-current: #45474a;
  --mt-sel: rgb(255 255 255 / 22%);
  --mt-sep-light: #96989e;
  --mt-sep-dark: #222325;
  --mt-env-volume: #96b43d;
  --mt-env-pan: #98cffc;
  --mt-font: 11px Tahoma, Verdana, "Segoe UI", sans-serif;
  --mt-panel: #626c7b;
  --mt-module: #828c9b;
  --mt-box: #596270;
  --mt-box-ink: #eeeeef;
  --mt-r: #814040;
  --mt-r-armed: #ff0000;
  --mt-s: #8b8d54;
  --mt-m: #5d9a5f;
  --mt-dev: #8d8f91;
  --mt-lock: #6e8dbf;
  --mt-gap: #414751;

  /* Meter */
  --meter-bg: #000000;
  --meter-green: #3bd16f;
  --meter-yellow: #f0e03a;
  --meter-red: #ff3b3b;
  --meter-peak: #f0e03a;
  --meter-valley: #5ad2f0;

  /* Transport glyphs */
  --glyph-play: #0b8a2a;
  --glyph-rec: #d01010;
  --glyph-stop: #1d2a8a;
  --glyph-pause: #6a6a78;
  --zoom-face: #f4e27a;

  --font-dialog: "MS Sans Serif", Tahoma, Verdana, "Segoe UI", Geneva, sans-serif;
  --dialog-shade: rgba(0, 0, 0, .18);
  --graph-bg: #000000;
  --graph-grid: #0d7a0d;
  --graph-curve: #3a8cff;
  --graph-point: #ffffff;
  --graph-selected: #e03030;
  --cursor-busy: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' shape-rendering='crispEdges'><path fill='%23fff' d='M10 5h13v1h-13zM10 7h13v1h-13zM10 8h13v1h-13zM10 9h13v1h-13zM11 10h1v1h-1zM13 10h1v1h-1zM15 10h1v1h-1zM17 10h1v1h-1zM19 10h1v1h-1zM21 10h1v1h-1zM12 11h1v1h-1zM14 11h1v1h-1zM16 11h1v1h-1zM18 11h1v1h-1zM20 11h1v1h-1zM13 12h1v1h-1zM15 12h1v1h-1zM17 12h1v1h-1zM19 12h1v1h-1zM14 13h1v1h-1zM16 13h1v1h-1zM18 13h1v1h-1zM15 14h1v1h-1zM17 14h1v1h-1zM16 15h1v1h-1zM16 17h1v1h-1zM15 18h1v1h-1zM17 18h1v1h-1zM14 19h5v1h-5zM13 20h7v1h-7zM12 21h9v1h-9zM11 22h11v1h-11zM10 23h6v1h-6zM17 23h6v1h-6zM10 24h5v1h-5zM16 24h1v1h-1zM18 24h5v1h-5zM10 25h2v1h-2zM13 25h1v1h-1zM15 25h1v1h-1zM17 25h1v1h-1zM19 25h1v1h-1zM21 25h2v1h-2zM10 27h13v1h-13z'/><path d='M8 4h17v1h-17zM8 5h2v1h-2zM23 5h2v1h-2zM8 6h17v1h-17zM9 7h1v1h-1zM23 7h1v1h-1zM9 8h1v1h-1zM23 8h1v1h-1zM9 9h1v1h-1zM23 9h1v1h-1zM9 10h2v1h-2zM12 10h1v1h-1zM14 10h1v1h-1zM16 10h1v1h-1zM18 10h1v1h-1zM20 10h1v1h-1zM22 10h2v1h-2zM10 11h2v1h-2zM13 11h1v1h-1zM15 11h1v1h-1zM17 11h1v1h-1zM19 11h1v1h-1zM21 11h2v1h-2zM11 12h2v1h-2zM14 12h1v1h-1zM16 12h1v1h-1zM18 12h1v1h-1zM20 12h2v1h-2zM12 13h2v1h-2zM15 13h1v1h-1zM17 13h1v1h-1zM19 13h2v1h-2zM13 14h2v1h-2zM16 14h1v1h-1zM18 14h2v1h-2zM14 15h2v1h-2zM17 15h2v1h-2zM15 16h1v1h-1zM16 16h1v1h-1zM17 16h1v1h-1zM14 17h2v1h-2zM17 17h2v1h-2zM13 18h2v1h-2zM16 18h1v1h-1zM18 18h2v1h-2zM12 19h2v1h-2zM19 19h2v1h-2zM11 20h2v1h-2zM20 20h2v1h-2zM10 21h2v1h-2zM21 21h2v1h-2zM9 22h2v1h-2zM22 22h2v1h-2zM9 23h1v1h-1zM16 23h1v1h-1zM23 23h1v1h-1zM9 24h1v1h-1zM15 24h1v1h-1zM17 24h1v1h-1zM23 24h1v1h-1zM9 25h1v1h-1zM12 25h1v1h-1zM14 25h1v1h-1zM16 25h1v1h-1zM18 25h1v1h-1zM20 25h1v1h-1zM23 25h1v1h-1zM8 26h17v1h-17zM8 27h2v1h-2zM23 27h2v1h-2zM8 28h17v1h-17z'/></svg>") 16 16, wait;
  --font: 11px Tahoma, Verdana, "Segoe UI", Geneva, sans-serif;
  --font-lcd: 600 44px Arial, Helvetica, sans-serif;
  --font-big-note: 700 18px Arial, Helvetica, sans-serif;

  /* Bevels, fields and radius. Classic values; themes override them. */
  --color-scheme: light;
  --boot-bg: Canvas;
  --radius: 0;
  --field-fill: var(--face-hi);
  --raised-border: var(--face-hi) var(--face-dark) var(--face-dark) var(--face-hi);
  --raised-shadow: inset -1px -1px 0 var(--face-shadow), inset 1px 1px 0 var(--face-light);
  --sunken-border: var(--face-shadow) var(--face-hi) var(--face-hi) var(--face-shadow);
  --sunken-shadow: inset 1px 1px 0 var(--face-dark), inset -1px -1px 0 var(--face-light);
  --field-shadow: inset 1px 1px 0 var(--face-dark);
  --etched-border: var(--face-shadow) var(--face-hi) var(--face-hi) var(--face-shadow);
  --pressed-border: var(--face-dark) var(--face-hi) var(--face-hi) var(--face-dark);
  --pressed-shadow: inset 1px 1px 0 var(--face-shadow);
  --pressed-fill: repeating-conic-gradient(var(--face-hi) 0 25%, var(--face) 0 50%) 0 0 / 2px 2px;
  --track-fill: repeating-conic-gradient(var(--face) 0 25%, var(--face-hi) 0 50%) 0 0 / 2px 2px;
  --edge-shadow: inset -1px -1px 0 var(--face-shadow);
  --disabled-shadow: 1px 1px 0 var(--face-hi);
  --menu-border: var(--face-light) var(--face-dark) var(--face-dark) var(--face-light);
  --menu-shadow: inset -1px -1px 0 var(--face-shadow), inset 1px 1px 0 var(--face-hi), 2px 2px 0 rgb(0 0 0 / .3);
  --dlg-border: var(--face-light) var(--face-dark) var(--face-dark) var(--face-light);
  --dlg-shadow: inset -1px -1px 0 var(--face-shadow), inset 1px 1px 0 var(--face-hi), 2px 2px 6px rgba(0, 0, 0, .4);
  --default-border: var(--ink);
  --default-shadow: inset -1px -1px 0 var(--face-dark), inset 1px 1px 0 var(--face-hi), inset -2px -2px 0 var(--face-shadow);
  --tab-border: var(--face-hi) var(--face-dark) transparent var(--face-hi);
  --tab-border-sel: var(--face-hi) var(--face-dark) var(--face) var(--face-hi);
  --tab-shadow: inset -1px 0 0 var(--face-shadow);
  --slate-raised-border: var(--slate-hi) var(--slate-shadow) var(--slate-shadow) var(--slate-hi);
  --slate-sunken-border: var(--slate-shadow) var(--slate-hi) var(--slate-hi) var(--slate-shadow);
  --slate-tab-border: var(--slate-hi) var(--slate-shadow) transparent var(--slate-hi);

  /* Literal colors and fonts that themes change */
  --tab-ink: #000000;
  --slate-muted: #cfd6dc;
  --slate-dim: #9aa6b0;
  --file-open-bg: #c7c7c7;
  --tree-unavailable-selected: #4a5a78;
  --mt-tab-on: #d6e5ff;
  --mt-foot: #96e0b4;
  --mt-disabled-ink: #c9d0da;
  --transport-on: #c6ecd0;
  --font-field: 11px Tahoma, sans-serif;
  --font-kbd: 10px Tahoma, sans-serif;
  --font-readout: 13px/1.1 Arial, Helvetica, sans-serif;
}


/* ---------- Themes (set with data-theme on the root; Classic has none) ---------- */

:root[data-theme="dark"] {
  --color-scheme: dark;
  --boot-bg: var(--face);
  --face: #2e3033;
  --face-hi: #5a5d62;
  --face-light: #3f4247;
  --face-shadow: #1d1e20;
  --face-dark: #0c0d0e;
  --field-fill: #1b1c1e;
  --ink: #e8e8e8;
  --ink-muted: #b5b8bd;
  --ink-disabled: #8a8d92;
  --title-a: #1d3f84;
  --title-b: #3a6aad;
  --focus: #ffffff;
  --disabled-shadow: none;
  --dialog-shade: rgba(0, 0, 0, .5);
  --menu-shadow: inset -1px -1px 0 var(--face-shadow), inset 1px 1px 0 var(--face-hi), 2px 2px 0 rgb(0 0 0 / .5);
  --dlg-shadow: inset -1px -1px 0 var(--face-shadow), inset 1px 1px 0 var(--face-hi), 2px 2px 6px rgba(0, 0, 0, .7);

  --slate: #3a424d;
  --slate-hi: #5d6775;
  --slate-shadow: #14191d;
  --slate-ink: #eceff2;
  --slate-tab: #4a5360;
  --tab-ink: #e0e0e0;
  --slate-muted: #b4bdc6;
  --slate-dim: #a8b2bc;
  --file-open-bg: #4d5866;
  --tree-unavailable-selected: #2f4a78;
  --lcd-bg: #2b333b;
  --field-bg: #232a2f;

  --axis-bg: #22282c;
  --overview-track: #3a4650;
  --mt-track: #232426;
  --mt-track-current: #303134;
  --mt-sep-light: #55575c;
  --mt-sep-dark: #0f1011;
  --mt-panel: #3a424d;
  --mt-module: #566070;
  --mt-box: #3a414d;
  --mt-dev: #5a5d62;
  --mt-lock: #4a6694;
  --mt-gap: #2a2f37;
  --mt-tab-on: #3a5578;
  --mt-foot: #2f6b4a;
  --transport-on: #2f6a44;

  --glyph-play: #3bd16f;
  --glyph-rec: #ff6b6b;
  --glyph-stop: #8fa0ff;
  --glyph-pause: #b4b8c4;
  --zoom-face: #6b5d17;
}

:root[data-theme="modern"] {
  --color-scheme: light;
  --boot-bg: var(--face);
  --radius: 4px;
  --face: #f0f1f3;
  --face-hi: #ffffff;
  --face-light: #e4e7eb;
  --face-shadow: #b4b9c0;
  --face-dark: #8a9099;
  --ink: #1f2328;
  --ink-muted: #57606a;
  --ink-disabled: #8c959f;
  --title-a: #1f5fbf;
  --title-b: #1f5fbf;
  --focus: #1f5fbf;
  --font: 11px system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-field: 11px system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-kbd: 10px system-ui, -apple-system, "Segoe UI", sans-serif;
  --axis-font: 11px system-ui, -apple-system, "Segoe UI", sans-serif;
  --mt-font: 11px system-ui, -apple-system, "Segoe UI", sans-serif;

  --raised-border: #b4b9c0;
  --raised-shadow: 0 1px 0 rgb(0 0 0 / 6%);
  --sunken-border: #b4b9c0;
  --sunken-shadow: none;
  --field-shadow: none;
  --etched-border: #c9ced5;
  --pressed-border: #8a9099;
  --pressed-shadow: inset 0 1px 2px rgb(0 0 0 / 18%);
  --pressed-fill: var(--face-light);
  --track-fill: var(--face-light);
  --edge-shadow: none;
  --disabled-shadow: none;
  --menu-border: #c4c9d0;
  --menu-shadow: 0 4px 12px rgb(0 0 0 / 18%);
  --dlg-border: #b4b9c0;
  --dlg-shadow: 0 8px 24px rgb(0 0 0 / 28%);
  --default-border: var(--title-a);
  --default-shadow: 0 0 0 1px var(--title-a);
  --tab-border: #b4b9c0 #b4b9c0 transparent #b4b9c0;
  --tab-border-sel: #b4b9c0 #b4b9c0 var(--face) #b4b9c0;
  --tab-shadow: none;
  --slate: #56616f;
  --slate-raised-border: #3f4853;
  --slate-sunken-border: #3f4853;
  --slate-tab-border: #3f4853 #3f4853 transparent #3f4853;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- Primitives ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

html { color-scheme: var(--color-scheme); background: var(--face); transition: background-color .15s ease-out; }

body {
  margin: 0;
  font: var(--font);
  color: var(--ink);
  color-scheme: var(--color-scheme);
  background: var(--face);
  transition: opacity .15s ease-out;
}

/* The page stays hidden until startup has built the menus and restored the last view. It shows after 3 s regardless. */
html.booting { color-scheme: light dark; background: var(--boot-bg); }
html.booting body { opacity: 0; animation: boot-reveal 0s 3s forwards; }
@keyframes boot-reveal { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { html, body { transition: none; } }

.raised {
  border: 1px solid;
  border-color: var(--raised-border);
  box-shadow: var(--raised-shadow);
}

.sunken {
  border: 1px solid;
  border-color: var(--sunken-border);
  box-shadow: var(--sunken-shadow);
}

.etched {
  border: 1px solid;
  border-color: var(--etched-border);
}

button, select, input { font: inherit; color: inherit; }

button {
  min-height: 22px;
  padding: 2px 7px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--raised-border);
  box-shadow: var(--raised-shadow);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
button:active:not(:disabled), button.on {
  border-color: var(--pressed-border);
  box-shadow: var(--pressed-shadow);
  padding: 3px 6px 1px 8px;
}
button.on { background: var(--face-light); }
button[aria-pressed=true]:not(:disabled) {
  border-color: var(--pressed-border);
  box-shadow: var(--pressed-shadow);
  background: var(--pressed-fill);
}
button:disabled { color: var(--ink-disabled); text-shadow: var(--disabled-shadow); cursor: default; }
button:disabled .glyph, button:disabled .ico { opacity: .35; }
button:focus-visible, select:focus-visible, input:focus-visible, [role=tab]:focus-visible {
  outline: 1px dotted var(--focus);
  outline-offset: -4px;
}

select, input[type=text], input[type=number] {
  height: 21px;
  padding: 1px 3px;
  background: var(--field-fill);
  border: 1px solid;
  border-color: var(--sunken-border);
  box-shadow: var(--field-shadow);
  border-radius: var(--radius);
}

kbd { font: var(--font-kbd); padding: 0 3px; }

.glyph { display: inline-block; width: 1.2em; text-align: center; font-size: 13px; line-height: 1; }
.glyph.play { color: var(--glyph-play); }
.glyph.rec { color: var(--glyph-rec); }
.glyph.stop { color: var(--glyph-stop); }

/* ---------- App frame ---------- */

.app {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto auto;
  height: 100vh;
  min-height: 560px;
  padding: 0 0 0;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 6px;
  color: var(--title-ink);
  font-weight: bold;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
}
.titlebar .logo {
  width: 16px; height: 16px;
  background: url("favicon.svg") center / contain no-repeat;
}

/* Menu bar */
.menubar { position: relative; display: flex; flex-wrap: wrap; padding: 1px 2px; }
.menu { position: relative; }
.menu-title {
  min-height: 0;
  padding: 2px 7px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.menu-title:active:not(:disabled) { padding: 2px 7px; }
.menu-title[aria-expanded=true] {
  padding: 2px 7px;
  border-color: var(--etched-border);
  box-shadow: none;
}
.menu-pop {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--face);
  border: 1px solid;
  border-color: var(--menu-border);
  box-shadow: var(--menu-shadow);
}
.menu-pop[hidden] { display: none; }
.menu-pop [role^=menuitem] {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 0;
  padding: 3px 8px 3px 18px;
  text-align: left;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.menu-pop [role^=menuitem]:active:not(:disabled) { padding: 3px 8px 3px 18px; }
.menu-pop [role^=menuitem]:hover:not(:disabled) { background: var(--title-a); color: var(--title-ink); }
.menu-pop [role=menuitemradio][aria-checked=true]::before, .menu-pop [role=menuitemcheckbox][aria-checked=true]::before { content: "✓"; position: absolute; left: 5px; }
.menu-pop [role=menuitemradio], .menu-pop [role=menuitemcheckbox] { position: relative; }
.menu-pop hr {
  width: 100%;
  margin: 3px 0;
  border: 0;
  border-top: 1px solid var(--face-shadow);
  border-bottom: 1px solid var(--face-hi);
}
.menu-pop [role^=menuitem]:disabled { color: var(--ink-disabled); }
.menu-pop [role^=menuitem][aria-expanded=true] { background: var(--title-a); color: var(--title-ink); }
.submenu { position: relative; }
.submenu > [role=menuitem] { width: 100%; }
.menu-pop.sub { top: -3px; left: 100%; }
.arrow {
  align-self: center;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-left: 5px solid currentColor;
  border-right: 0;
}
.menu > .menu-pop.flip { left: auto; right: 0; }
.menu-pop.sub.flip { left: auto; right: 100%; }

/* Icons */
.ico { display: block; width: 16px; height: 16px; color: var(--glyph-stop); }
#pause .ico { color: var(--glyph-pause); }
.ico-btn { display: grid; place-items: center; width: 24px; height: 22px; padding: 0; }
.ico-btn:active:not(:disabled), .ico-btn.on { padding: 1px 0 0 1px; }
.view-switch { width: 52px; margin-right: 6px; }
.view-switch .ico { width: 48px; height: 20px; }
.btn-grid button { display: grid; place-items: center; }

/* Toolbars */
.toolbars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--face-shadow);
  box-shadow: 0 1px 0 var(--face-hi);
}
.toolbars[hidden], .menubar[hidden] { display: none; }
.tb-row { display: flex; flex-wrap: wrap; gap: 2px; }
.tb {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px 5px 1px 8px;
  position: relative;
  border-right: 1px solid var(--face-shadow);
  box-shadow: 1px 0 0 var(--face-hi);
}
.tb::before {
  content: "";
  position: absolute; left: 2px; top: 3px; bottom: 3px;
  width: 3px;
  border: 1px solid;
  border-color: var(--face-hi) var(--face-shadow) var(--face-shadow) var(--face-hi);
}
.tb .label { margin: 0 4px 0 2px; color: var(--ink-muted); }
.tb-popup {
  position: fixed;
  z-index: 20;
  min-width: 150px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 3px 0;
}
.tb-popup label { display: flex; align-items: center; gap: 6px; padding: 2px 10px; white-space: nowrap; }
.tb-popup label:hover { background: var(--title-a); color: var(--title-ink); }
.tb-popup input { margin: 0; }

/* Workspace: left panel plus wave area */
.workspace {
  display: grid;
  grid-template-columns: 236px 1fr;
  gap: 3px;
  padding: 3px;
  min-height: 0;
}

/* Slate side panel with tabs */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--slate);
  color: var(--slate-ink);
  padding: 6px;
  border: 1px solid;
  border-color: var(--slate-raised-border);
}
.tabs { display: flex; gap: 0; padding-left: 2px; }
.tabs [role=tab] {
  min-height: 0;
  padding: 3px 8px 2px;
  margin-right: -1px;
  color: var(--tab-ink);
  background: var(--slate-tab);
  border: 1px solid;
  border-color: var(--slate-tab-border);
  box-shadow: none;
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  top: 1px;
}
.tabs [role=tab][aria-selected=true] {
  color: var(--slate-ink);
  background: var(--slate);
  top: 0;
  padding-bottom: 4px;
  z-index: 1;
}
.tabs [role=tab]:active { padding: 3px 8px 2px; }
.tabpanel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 6px;
  border: 1px solid;
  border-color: var(--slate-raised-border);
}
.tabpanel[hidden] { display: none; }
.side button { color: var(--ink); }
.side .muted { color: var(--slate-muted); }
.side h3 { margin: 12px 0 6px; font-size: 11px; font-weight: bold; }

.list {
  margin-top: 6px;
  min-height: 120px;
  background: var(--slate-shadow);
  border: 1px solid;
  border-color: var(--slate-sunken-border);
  padding: 2px;
}
.side-tools { display: flex; gap: 2px; }
.files-list { flex: 1; overflow: auto; margin-top: 8px; }
.file { display: flex; align-items: center; gap: 4px; padding: 2px 3px; cursor: default; }
.file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ico { width: 14px; height: 14px; flex: none; }
.file.open { background: var(--file-open-bg); color: var(--ink); }
.file input { flex: 1; min-width: 0; height: 19px; color: var(--ink); }
#panel-files:not([hidden]) { display: flex; flex-direction: column; }
.advanced { display: flex; gap: 8px; margin-top: 8px; }
.advanced[hidden] { display: none; }
.types { flex: 1; margin: 0; padding: 2px 6px 4px; border: 1px solid; border-color: var(--slate-sunken-border); }
.types legend { padding: 0 2px; font-size: 11px; }
.types label { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.types label:has(:disabled) { color: var(--slate-dim); }
.type-ico { width: 14px; height: 14px; }
.sort-col { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sort-col select { color: var(--ink); min-width: 0; }
.side button:disabled { color: var(--ink-disabled); }
.side-buttons { display: grid; gap: 4px; margin-top: 6px; }

.tree { max-height: 240px; overflow: auto; padding: 2px 0; }
.tree-group, .tree-leaf { padding: 1px 4px; cursor: default; white-space: nowrap; }
.tree-group { display: flex; align-items: center; gap: 4px; }
.tree-box { display: inline-grid; place-items: center; width: 9px; height: 9px; border: 1px solid var(--slate-dim); font-size: 9px; line-height: 1; }
.tree-leaf.indented { padding-left: 26px; }
.tree-leaf.selected { background: var(--title-a); color: var(--title-ink); }
.tree-leaf.unavailable { color: var(--slate-dim); }
.tree-leaf.unavailable.selected { color: var(--title-ink); background: var(--tree-unavailable-selected); }
.tree [tabindex]:focus-visible { outline: 1px dotted var(--slate-ink); outline-offset: -1px; }
.fav-list { min-height: 180px; }

.fav { display: flex; gap: 2px; }
.fav button { color: var(--slate-ink); background: transparent; border: 0; box-shadow: none; min-height: 0; padding: 2px 4px; }
.fav button:first-child { flex: 1; text-align: left; }
.fav button:hover:not(:disabled) { background: var(--title-a); }
.fav button:disabled { color: var(--slate-dim); }
.fav button:last-child:not(:first-child) { color: var(--slate-muted); font-size: 10px; }

/* Wave area: overview, wave + amp axis, ruler */
.wavearea {
  display: grid;
  grid-template-columns: 1fr 46px;
  grid-template-rows: 14px 1fr 20px;
  min-width: 0;
  min-height: 0;
  background: var(--axis-bg);
}
#overview { display: block; width: 100%; height: 14px; cursor: grab; border: 1px solid var(--face-shadow); box-sizing: border-box; }
#wave-wrap {
  position: relative;
  min-height: 200px;
  background: var(--wave-bg);
  border-left: 1px solid var(--face-dark);
}
#wave { position: absolute; inset: 0; width: 100%; height: 100%; cursor: text; touch-action: none; }
#empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--wave);
  pointer-events: none;
}
#empty[hidden] { display: none; }
#amp { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
#ruler { display: block; width: 100%; height: 20px; min-width: 0; min-height: 0; }
.ctx { position: fixed; z-index: 30; }
.corner { display: grid; font: var(--axis-font); user-select: none; place-items: center; color: var(--axis-ink); }

.wavearea[hidden] { display: none; }

/* Multitrack View: track controls, tracks, track ruler, time ruler */
.mtarea {
  display: grid;
  grid-template-columns: 112px 1fr 30px;
  grid-template-rows: 22px 1fr 20px;
  column-gap: 4px;
  min-width: 0;
  min-height: 0;
  background: var(--mt-panel);
}
.mtarea[hidden] { display: none; }
.mt-tabs { display: flex; gap: 1px; align-items: end; }
.mt-tabs button { min-height: 0; padding: 0 5px; font: var(--mt-font); }
.mt-tabs button[aria-pressed="true"] { background: var(--mt-tab-on); }
#mt-overview { display: block; width: 100%; height: 14px; align-self: start; cursor: grab; }
.mt-controls { position: relative; overflow: hidden; min-height: 200px; background: var(--mt-gap); }
.mt-list { position: absolute; inset: 0 0 auto; }
#mt-tracks { display: block; width: 100%; height: 100%; min-width: 0; min-height: 200px; touch-action: none; cursor: default; }
#mt-numbers { display: block; width: 100%; height: 100%; min-height: 0; cursor: ns-resize; touch-action: none; }
#mt-ruler { display: block; width: 100%; height: 20px; min-width: 0; }
.mt-foot { background: var(--mt-foot); margin: 4px 0; }

.mt-track {
  display: grid;
  grid-template-columns: 18px 1fr 1fr;
  grid-template-rows: 14px 15px 14px 14px 14px;
  gap: 1px 2px;
  box-sizing: border-box;
  height: var(--mt-pitch, 83px);
  overflow: hidden;
  padding: 0 4px 5px 4px;
  border-bottom: 1px solid var(--mt-sep-dark);
  background: var(--mt-panel);
  font: var(--mt-font);
}
.mt-track > * { min-height: 0; min-width: 0; padding: 0; font: inherit; }
.mt-name {
  grid-column: 1 / -1;
  margin: 0 -4px;
  padding: 0 4px;
  border: 0;
  background: var(--mt-module);
  color: #ffffff;
}
.mt-track.current .mt-name { color: #ffff80; }
.mt-rsm { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 2px; }
.mt-rsm button { width: 15px; min-height: 0; padding: 0; font: inherit; color: #ffffff; }
.mt-r { background: var(--mt-r); }
.mt-s { background: var(--mt-s); }
.mt-m { background: var(--mt-m); }
.mt-rsm button[aria-pressed="true"] { color: #ffff40; box-shadow: inset 1px 1px 0 #000000; }
.mt-rsm .mt-r[aria-pressed="true"] { background: var(--mt-r-armed); }
.mt-rsm .mt-s[aria-pressed="true"] { background: var(--mt-s); }
.mt-rsm .mt-m[aria-pressed="true"] { background: var(--mt-m); }
.mt-box {
  grid-column: 2;
  display: block;
  padding: 0 3px;
  background: var(--mt-box);
  color: var(--mt-box-ink);
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.mt-dev { background: var(--mt-dev); color: #ffffff; }
.mt-lock { background: var(--mt-lock); color: #ffffff; }
.mt-track button:disabled { color: var(--mt-disabled-ink); text-shadow: none; }
.mt-track .mt-lock-btn { grid-column: 2; }

/* Bottom deck: transport, zoom, time, selection/view */
.deck {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 0 3px 3px;
}
.slab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--slate);
  color: var(--slate-ink);
  border: 1px solid;
  border-color: var(--slate-raised-border);
}
.slab button { color: var(--ink); }
.btn-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), 30px); gap: 2px; }
.btn-grid.transport { --cols: 5; }
.btn-grid.zoom { --cols: 4; }
.btn-grid button { width: 30px; height: 24px; padding: 0; }
.btn-grid button:active:not(:disabled), .btn-grid button.on { padding: 1px 0 0 1px; }
.btn-grid.zoom button.yellow:not(:disabled) { background: var(--zoom-face); }
.rec-mode { display: flex; flex-direction: column; gap: 3px; }
.rec-mode label { font-size: 10px; }
#rec-mode { color: var(--ink); }

#rec.on .ico { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }
#play.on, #play-end.on, #play-loop.on, #pause.on { background: var(--transport-on); }

.lcd {
  flex: 1;
  justify-content: center;
  min-width: 240px;
}
#time {
  font: var(--font-lcd);
  font-variant-numeric: tabular-nums;
  color: var(--lcd-ink);
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 var(--slate-shadow);
}
#time.rec { color: var(--lcd-rec); }

.selview {
  display: grid;
  grid-template-columns: auto repeat(3, 84px);
  gap: 2px 3px;
  align-items: center;
}
.selview .head { text-align: center; font-size: 11px; }
.selview .rowhead { text-align: right; padding-right: 3px; }
.selview input:focus { outline: 1px solid var(--title-a); outline-offset: -1px; }
.selview input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  display: block;
  height: 19px;
  padding: 2px 4px;
  font: var(--font-field);
  font-variant-numeric: tabular-nums;
  color: var(--field-ink);
  background: var(--field-bg);
  border: 1px solid;
  border-color: var(--slate-sunken-border);
  text-align: right;
}

/* Level meter with dB scale */
.meterbar {
  display: grid;
  gap: 1px;
  padding: 2px 6px 4px;
  border-top: 1px solid var(--face-hi);
}
.meter-rows { display: grid; gap: 2px; }
.meter-row { display: grid; grid-template-columns: 1fr 14px; gap: 2px; }
.meter {
  position: relative;
  height: 10px;
  overflow: hidden;
  border: 1px solid;
  border-color: var(--etched-border);
}
.meter::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 3px, var(--meter-bg) 3px 4px);
  pointer-events: none;
}
/* The cover hides the unlit part of the bar from the right. */
.meter .cover {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 100%;
  background: var(--meter-bg);
}
.meter .peak, .meter .valley {
  position: absolute; top: 0; bottom: 0;
  width: 2px;
  margin-left: -1px;
  z-index: 1;
}
.meter .peak { background: var(--meter-peak); }
.meter .valley { background: var(--meter-valley); }
.meter [hidden] { display: none; }
.clip {
  padding: 0;
  min-height: 0;
  background: var(--meter-bg);
  border: 1px solid;
  border-color: var(--etched-border);
}
.clip.lit { background: var(--meter-red); }
.scale { position: relative; height: 12px; margin-right: 16px; font-size: 9px; color: var(--ink-muted); }
.scale span { position: absolute; top: 0; transform: translateX(-50%); }
.scale span:first-child { transform: none; }
.scale span:last-child { transform: translateX(-100%); }

/* Status bar */
.statusbar { display: flex; gap: 2px; padding: 2px; }
.statusbar > * {
  padding: 2px 6px;
  border: 1px solid;
  border-color: var(--etched-border);
  white-space: nowrap;
}
.statusbar .dim { color: var(--ink-disabled); }
.statusbar .mods b { font-weight: normal; color: var(--ink-disabled); }
.statusbar .mods b.on { font-weight: bold; color: var(--ink); }
#status { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Window Toggles hide deck parts, the meter, and the status bar. */
[data-panel][hidden], .deck[hidden], .statusbar [hidden] { display: none; }

.help { margin: 0; padding: 0 6px 2px; color: var(--ink-muted); }

/* ---------- Dialogs (generated from Cool Edit's dialog templates) ---------- */

.dlg-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  overflow: auto;
  background: var(--dialog-shade);
}
.dlg {
  position: relative;
  margin: auto;
  flex: none;
  padding: 3px;
  background: var(--face);
  border-radius: var(--radius);
  border: 1px solid;
  border-color: var(--dlg-border);
  box-shadow: var(--dlg-shadow);
}
.dlg:focus { outline: none; }
.dlg-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  padding: 0 2px 0 4px;
  color: var(--title-ink);
  font-weight: bold;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  cursor: default;
  user-select: none;
  touch-action: none;
}
.dlg-close {
  min-height: 0;
  width: 16px;
  height: 14px;
  padding: 0;
  line-height: 10px;
  font: bold 12px/1 var(--font-dialog);
  color: var(--ink);
}
.dlg-popout {
  position: relative;
  min-height: 0;
  width: 16px;
  height: 14px;
  margin: 0 2px 0 auto;
  padding: 0;
}
.dlg-popout::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 3px;
  width: 6px;
  height: 5px;
  border: 1px solid var(--ink);
  border-top-width: 2px;
}
.dlg-popout.in::before { top: 4px; left: 3px; width: 7px; height: 4px; }
.dlg-body {
  position: relative;
  margin-top: 3px;
  font-family: var(--font-dialog);
  color: var(--ink);
}
.dlg-ctl { position: absolute; }
.dlg-ctl[hidden] { display: none; }
.dlg-ctl > * { max-width: 100%; }

.dlg-text { overflow: hidden; line-height: 1.2; white-space: pre-line; }
.dlg-text.nowrap { white-space: nowrap; overflow: visible; }
.dlg-text.sunken { padding: 1px 2px; }
.dlg-text.disabled, .dlg-choice.disabled, .dlg-group.disabled { color: var(--ink-disabled); text-shadow: var(--disabled-shadow); }

.dlg-frame { pointer-events: none; }
.dlg-frame canvas { display: block; width: 100%; height: 100%; }
.dlg-frame.plain { border: 1px solid var(--face-shadow); }
.dlg-frame.color-swatch { pointer-events: auto; }
.dlg-frame.color-swatch > canvas { display: none; }
.dlg-frame.color-swatch > input { display: block; width: 100%; height: 100%; padding: 0; border: 0; }
.dlg-frame.sunken { box-shadow: none; }
.dlg-etched { border: 1px solid; border-color: var(--etched-border); }
.dlg-image { background: var(--face); }
.dlg-image.swatch-curve { background: var(--graph-curve); }
.dlg-image.swatch-selected { background: var(--graph-selected); }

.dlg-group { pointer-events: none; margin-top: 0; }
.dlg-group::before {
  content: "";
  position: absolute;
  inset: 6px 0 0 0;
  border: 1px solid var(--face-shadow);
  box-shadow: 1px 1px 0 var(--face-hi), inset 1px 1px 0 var(--face-hi);
}
.dlg-group-label { position: absolute; top: 0; left: 8px; padding: 0 2px; background: var(--face); line-height: 13px; white-space: nowrap; }

.dlg-push { display: block; }
.dlg-push > .dlg-button, .dlg-edit > input, .dlg-edit > textarea, .dlg-combo > select, .dlg-combo > input, .dlg-list > select {
  width: 100%;
  height: 100%;
}
.dlg-button { min-height: 0; padding: 0 4px; white-space: nowrap; text-align: center; }
.dlg-button.default {
  border-color: var(--default-border);
  box-shadow: var(--default-shadow);
}
.dlg-button u { text-decoration: underline; }
.dlg-edit > input, .dlg-edit > textarea, .dlg-combo > input { padding: 0 3px; min-height: 0; }
.dlg-edit > textarea { resize: none; padding: 2px 3px; }
.dlg-edit input:disabled, .dlg-combo select:disabled, .dlg-combo input:disabled { color: var(--ink-disabled); background: var(--face); }
.dlg-combo > select, .dlg-list > select { height: 100%; padding: 0 2px; }
.dlg-combo > select { height: 21px; }
.dlg-list > select { padding: 0; overflow-y: auto; }
.dlg-list > select option { padding: 0 3px; }

.dlg-choice { display: flex; align-items: center; gap: 4px; height: 100%; white-space: nowrap; cursor: default; }
.dlg-choice.left { flex-direction: row-reverse; justify-content: flex-end; }
.dlg-choice.multi { white-space: pre-line; line-height: 1.15; }
.dlg-button.multi { white-space: normal; line-height: 1.15; }
.dlg-button.dlg-tool { padding: 0 1px; font-size: inherit; }
.dlg-button.dlg-tool[aria-pressed=true] { padding: 1px 0 0 2px; }
.dlg-big-note { font: var(--font-big-note); line-height: 1; overflow: visible; white-space: nowrap; text-align: center; }
.dlg-grip {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 0 45%, var(--face-shadow) 45% 52%, transparent 52% 62%, var(--face-shadow) 62% 69%, transparent 69% 79%, var(--face-shadow) 79% 86%, transparent 86%);
}
.dlg-grip[hidden] { display: none; }
.dlg-button.dlg-hold { color: var(--ink); font-weight: bold; padding: 0; background: var(--hold-up, var(--face)); }
.dlg-button.dlg-hold[aria-pressed=true] { background: var(--hold-down, var(--face-dark)); box-shadow: var(--pressed-shadow); }
.dlg-readout { font: var(--font-readout); white-space: nowrap; overflow: hidden; padding: 1px 0 0 2px; }
.dlg-analysis-frame {
  position: absolute;
  pointer-events: none;
  border: 1px solid;
  border-color: var(--etched-border);
}
.dlg-ruler { position: absolute; display: block; }
.dlg-overlay.modeless { inset: auto; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; background: none; z-index: 9; }
.dlg-overlay.modeless .dlg { pointer-events: auto; }
.dlg-choice input { margin: 0; width: 13px; height: 13px; flex: none; accent-color: var(--ink); }
.dlg-choice:has(input:focus-visible) span { outline: 1px dotted var(--focus); }

.dlg-scroll input, .dlg-track input {
  width: 100%;
  height: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
}
.dlg-scroll.vertical input, .dlg-track.vertical input { writing-mode: vertical-lr; direction: rtl; }
.dlg-scroll input::-webkit-slider-runnable-track, .dlg-track input::-webkit-slider-runnable-track {
  height: 100%;
  background: var(--track-fill);
  border: 1px solid;
  border-color: var(--etched-border);
}
.dlg-scroll input::-webkit-slider-thumb, .dlg-track input::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 100%;
  background: var(--face);
  border: 1px solid;
  border-color: var(--raised-border);
  box-shadow: var(--edge-shadow);
}
.dlg-scroll.vertical input::-webkit-slider-thumb, .dlg-track.vertical input::-webkit-slider-thumb { width: 100%; height: 16px; }
.dlg-scroll input::-moz-range-track, .dlg-track input::-moz-range-track {
  height: 100%;
  background: var(--track-fill);
  border: 1px solid var(--face-shadow);
}
.dlg-scroll input::-moz-range-thumb, .dlg-track input::-moz-range-thumb {
  width: 16px;
  height: 100%;
  border-radius: 0;
  background: var(--face);
  border: 1px solid var(--face-dark);
}
.dlg-scroll input:disabled, .dlg-track input:disabled { opacity: .5; }

.dlg-tabs { position: absolute; }
.dlg-tab-panel {
  position: absolute;
  inset: 22px 0 0 0;
  border: 1px solid;
  border-color: var(--raised-border);
  box-shadow: var(--edge-shadow);
}
.dlg-tabs.bottom .dlg-tab-panel { inset: 0 0 22px 0; }
.dlg-tablist { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-end; height: 24px; padding-left: 2px; }
.dlg-tabs.bottom .dlg-tablist { top: auto; bottom: 0; align-items: flex-start; }
.dlg-tablist [role=tab] {
  position: relative;
  min-height: 0;
  height: 20px;
  margin: 0 0 0 -1px;
  padding: 0 8px;
  background: var(--face);
  border: 1px solid;
  border-color: var(--tab-border);
  box-shadow: var(--tab-shadow);
  border-radius: var(--radius) var(--radius) 0 0;
}
.dlg-tablist [role=tab].selected {
  z-index: 1;
  height: 23px;
  margin-bottom: -1px;
  padding: 0 8px 1px;
  box-shadow: var(--tab-shadow);
}
.dlg-tablist [role=tab].selected, .dlg-tablist [role=tab]:active:not(:disabled) { padding: 0 8px 1px; border-color: var(--tab-border-sel); }

.dlg-ctl.disabled > .dlg-button, .dlg-ctl.disabled input[type=text], .dlg-ctl.disabled textarea { color: var(--ink-disabled); text-shadow: var(--disabled-shadow); }

/* The processing dialog: the effect's name, the percent done, a progress bar, and Cancel. */
.processing-overlay { z-index: 50; }
.processing { width: 300px; }
.processing-body { display: grid; gap: 8px; padding: 10px 8px 8px; font-family: var(--font-dialog); color: var(--ink); }
.processing-track { height: 16px; padding: 1px; background: var(--field-fill); }
.processing-bar { width: 0; height: 100%; background: var(--title-a); }
.processing-cancel { justify-self: center; min-width: 75px; }

/* The Presets box the host draws inside an effect dialog. */
.dlg-presets { position: absolute; display: flex; flex-direction: column; gap: 2px; background: var(--face); }
.dlg-presets-head { display: flex; align-items: center; gap: 4px; height: 20px; flex: none; }
.dlg-presets-head span { flex: 1; font: italic bold 13px/1 var(--font-dialog); }
.dlg-presets-head button { min-height: 0; height: 18px; padding: 0 8px; color: var(--ink); }
.dlg-presets select { flex: 1; min-height: 0; width: 100%; padding: 0; color: var(--ink); }
.dlg-presets select option { padding: 0 3px; }
.music-palette, .music-staff { position: absolute; overflow: hidden; background: var(--field-fill); }
.music-staff { box-shadow: inset 1px 1px var(--face-shadow); }
.music-palette canvas, .music-staff canvas { display: block; touch-action: none; }

/* ---------- Narrow screens ---------- */

@media (max-width: 860px) {
  .app { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .side { order: 2; max-height: 340px; }
  #wave-wrap { min-height: 220px; }
  .lcd { min-width: 0; }
  #time { font-size: 32px; }
  .selview { grid-template-columns: auto repeat(3, minmax(0, 1fr)); flex: 1; }
  .statusbar .fmt { display: none; }
  .menu { position: static; }
  .menu-pop, .menu > .menu-pop.flip { left: 0; right: 0; min-width: 0; max-height: 70vh; overflow-y: auto; }
  .menu-pop.sub, .menu-pop.sub.flip {
    position: static;
    min-width: 0;
    padding-left: 12px;
    box-shadow: none;
    border: 0;
  }
  .dlg-overlay { align-items: flex-start; justify-content: flex-start; }
  .dlg { margin: 4px; }
}

@media (max-width: 600px) {
  .menubar { flex-wrap: nowrap; overflow-x: auto; }
  .menu-pop, .menu > .menu-pop.flip { position: fixed; top: auto; max-height: 60vh; }
  .toolbars { overflow-x: auto; }
  .tb-row { flex-wrap: nowrap; }
  .tb { flex: none; }
  .side { max-height: 50vh; }
  .tabs { overflow-x: auto; }
  .tabs [role=tab] { flex: none; }
  .dlg-overlay { overscroll-behavior: contain; }
  .dlg { margin: 0; }
}

/* Finger-sized tap targets on touch screens. */
@media (pointer: coarse) {
  .menu-title, .menu-title:active:not(:disabled), .menu-title[aria-expanded=true] { padding: 10px 10px; }
  .menu-pop [role^=menuitem], .menu-pop [role^=menuitem]:active:not(:disabled) { min-height: 44px; align-items: center; }
  .ico-btn { width: 40px; height: 40px; }
  .view-switch { width: 56px; }
  .tabs [role=tab], .tabs [role=tab]:active { padding: 10px 12px 9px; }
  .tb-popup label { min-height: 40px; }
  .dlg-title { height: 36px; }
  .dlg-close, .dlg-popout { width: 32px; height: 28px; }
  .dlg-presets-head { height: auto; }
  .dlg-presets-head button { height: 32px; }
}

/* The hourglass while an effect or a preview processes (src/presentation/busy.ts). */
:root.busy,
:root.busy * {
  cursor: var(--cursor-busy) !important;
}
