/* Producer Tools — local web UI
 * --------------------------------------------------------------------
 * Brand-aligned with thatsoundshot.com (the brand site at
 * Apps/thatsoundshot-site). Same palette, same typography, same
 * card/button vocabulary. Light-only — the brand is built around
 * cream paper, no dark-mode variant.
 */

:root {
  /* Surfaces & ink — same tokens as brand site styles.css */
  --bg:           #FAF6EE;     /* cream paper */
  --surface:     #FFFFFF;      /* card backgrounds */
  --surface-2:  #F1ECE0;       /* secondary surface (subtle warm tint) */
  --text:        #2A2D34;      /* primary text — never pure black */
  --text-muted: #6B7280;       /* secondary text */
  --border:     #E5DFD0;       /* hairlines */

  /* Functional accents — each tool / section owns one. These mirror
   * the brand site's tool-card top-bar colors verbatim. */
  --c-blue:    #3FB8E0;        /* Video Slicer */
  --c-orange:  #F5A040;        /* Audio Chopper */
  --c-yellow:  #FCC439;        /* Micro Audio Chopper */
  --c-mint:    #5FBFA0;        /* Chain Maker */
  --c-coral:   #E85F4D;        /* Drum Rack Maker */
  --c-violet:  #7A4FD4;        /* Reference panel */
  --c-pink:    #F0A0C5;        /* hover / soft accents */

  /* Tool-aware accent. Default to violet (the reference / brand
   * neutral). Overridden per-tool below via body[data-active-tool=…].
   * Existing CSS uses var(--accent) extensively — keeping that
   * variable name means the rest of the file inherits the new color
   * without each rule needing to change. */
  --accent:        var(--c-violet);
  --accent-hover:  #6740c0;    /* darker violet for hover */
  --accent-soft:   rgba(122, 79, 212, 0.12);

  --error:    #c43c2e;         /* coral-leaning red, harmonizes with palette */
  --success:  #4a9b7e;         /* mint-leaning green, same vibe */

  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  16px;
  --gap:        16px;

  /* Typography — Manrope (display) + Inter (body). Loaded from Google
   * Fonts in index.html; system-font fallback if offline. */
  --font:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display:"Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shadow-sm: 0 1px 2px rgba(42, 45, 52, 0.04), 0 2px 6px rgba(42, 45, 52, 0.04);
  --shadow:    0 4px 16px rgba(42, 45, 52, 0.06), 0 2px 6px rgba(42, 45, 52, 0.04);
  --shadow-lg: 0 12px 32px rgba(42, 45, 52, 0.08), 0 4px 12px rgba(42, 45, 52, 0.05);
}

/* Per-tool accent. JS sets body[data-active-tool=…] when tabs change.
 * Each tool inherits the brand-site mapping so the visual identity
 * carries across surfaces. */
body[data-active-tool="video"]    { --accent: var(--c-blue);   --accent-hover: #2fa1c9; --accent-soft: rgba(63, 184, 224, 0.14); }
body[data-active-tool="audio"]    { --accent: var(--c-orange); --accent-hover: #e08a2a; --accent-soft: rgba(245, 160, 64, 0.14); }
body[data-active-tool="micro"]    { --accent: var(--c-yellow); --accent-hover: #e8b020; --accent-soft: rgba(252, 196, 57, 0.18); }
body[data-active-tool="chain"]    { --accent: var(--c-mint);   --accent-hover: #4aa888; --accent-soft: rgba(95, 191, 160, 0.14); }
body[data-active-tool="drumrack"] { --accent: var(--c-coral);  --accent-hover: #d8543f; --accent-soft: rgba(232, 95, 77, 0.14); }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px 80px;
}

/* Display headings use Manrope (matching brand site h1/h2/h3 treatment).
 * Body text stays in Inter. Negative tracking on display only. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}
header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.lede { color: var(--text-muted); margin: 0 0 28px; font-size: 15px; }

/* Brand site-style sticky header. Cream-tinted glass effect via blur,
 * matches the .site-header pattern used in thatsoundshot-site. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header > .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.site-header .wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: none;
}
.site-header .wordmark:hover { color: var(--c-violet); }
.site-header .wordmark .subtitle {
  margin-left: 10px;
  font-family: var(--font);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
  font-weight: 500;
}
.site-nav > a, .site-nav > button {
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  transition: color 120ms;
}
.site-nav > a:hover, .site-nav > button:hover { color: var(--c-violet); }

/* ── Nav dropdown (Books) ─────────────────────────────────────────────
 * Same component as the brand site. Native <details>/<summary> for
 * accessibility + zero-JS toggle. The outside-click handler at the
 * bottom of app.js closes the menu when the user clicks elsewhere. */
.site-nav .nav-dropdown {
  position: relative;
}
.site-nav .nav-dropdown summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  user-select: none;
  transition: color 120ms;
}
.site-nav .nav-dropdown summary::-webkit-details-marker { display: none; }
.site-nav .nav-dropdown summary::after {
  content: '▾';
  font-size: 10px;
  opacity: 0.6;
  transition: transform 120ms ease, opacity 120ms;
}
.site-nav .nav-dropdown summary:hover { color: var(--c-violet); }
.site-nav .nav-dropdown summary:hover::after { opacity: 1; }
.site-nav .nav-dropdown[open] summary { color: var(--c-violet); }
.site-nav .nav-dropdown[open] summary::after {
  transform: rotate(180deg);
  opacity: 1;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 60;
}
.nav-dropdown-menu li { margin: 0; }
.nav-dropdown-menu a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 100ms;
  border-bottom: none;
}
.nav-dropdown-menu a:hover {
  background: var(--bg);
  color: var(--c-violet);
}
.nav-dropdown-menu .dropdown-meta {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.nav-dropdown-menu a:hover .dropdown-meta { color: var(--text-muted); }

/* Brand-style footer at the bottom of the page (outside main). Matches
 * the brand-site footer layout — wordmark left, links right. */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 0 56px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 48px;
}
.site-footer > .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.site-footer .wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: none;
}
.site-footer a:hover { color: var(--c-violet); }

/* ── Tab navigation ──────────────────────────────────────────────── */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 18px 0 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  font: inherit;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
  border-radius: 0;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 120ms, border-color 120ms;
}
/* Tiny color dot on the left of each tab so users see the per-tool
 * color before they click. Matches the brand-site tool-card top-bar. */
.tab::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tab-color, var(--text-muted));
  opacity: 0.55;
  transition: opacity 120ms, transform 120ms;
}
.tab:hover { color: var(--text); }
.tab:hover::before { opacity: 1; }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--tab-color, var(--accent));
}
.tab.active::before { opacity: 1; transform: scale(1.15); }

.tab[data-tool="video"]    { --tab-color: var(--c-blue); }
.tab[data-tool="audio"]    { --tab-color: var(--c-orange); }
.tab[data-tool="micro"]    { --tab-color: var(--c-yellow); }
.tab[data-tool="chain"]    { --tab-color: var(--c-mint); }
.tab[data-tool="drumrack"] { --tab-color: var(--c-coral); }

.tool-panel { /* visual no-op; the panel is just a container */ }

/* ── Filename options sub-controls ── */

.indented-row {
  margin: 4px 0 10px 28px;          /* aligns with checkbox text above */
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.indented-row input[type=text] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.indented-row input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filename-preview {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.filename-preview code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}

/* ── Audio Chopper extras ── */

#audio-info {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
}
#audio-waveform {
  display: block;
  width: 100%;
  height: 70px;
  margin: 12px 0 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ── Recent jobs: per-tool indicator pill ── */

.tool-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: none;
}

.intro {
  margin: 18px 0 28px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
/* Color-coded top bar per active tool — same vocabulary as the
 * brand site's tool cards (.tool-card::before). */
.intro::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.intro > p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.55;
}
.intro ul {
  margin: 0;
  padding-left: 22px;
  font-size: 13.5px;
}
.intro li {
  margin: 6px 0;
  line-height: 1.55;
  color: var(--text);
}
.intro li strong { font-weight: 600; }
.intro code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

details.card summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary h2 { display: inline; }
details.card summary::after {
  content: "▾";
  float: right;
  color: var(--text-muted);
  transition: transform .15s;
  display: inline-block;
}
details.card[open] summary::after { transform: rotate(180deg); }
details.card[open] summary { margin-bottom: 16px; }

/* ── Dropzones ── */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  background: var(--surface-2);
}
.dropzone:hover { background: var(--accent-soft); border-color: var(--accent); }
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.has-file { border-style: solid; border-color: var(--accent); }

.dz-label strong { font-size: 14px; }
.badge {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 2px;
}
.badge.req { background: var(--accent); color: white; }
.badge.opt { background: var(--border); color: var(--text-muted); }

.dropzone .hint { color: var(--text-muted); font-size: 12.5px; margin: 4px 0 0; }
.dropzone .picked {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dropzone .picked .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone .picked button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.dropzone .picked button:hover { color: var(--error); }

.rule { color: var(--text-muted); font-size: 12.5px; margin: 8px 0 0; }

/* ── Form fields ── */

.grid { display: grid; gap: 16px 20px; grid-template-columns: 1fr 1fr; }
.grid .span2 { grid-column: span 2; }
.grid label, .grid fieldset {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}
.grid label > span:first-child { font-weight: 500; }
.grid input[type=text],
.grid input[type=number] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.grid input[type=text]:focus,
.grid input[type=number]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.help {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
}

.section-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  line-height: 1.5;
}
.section-intro strong { color: var(--text); font-weight: 600; }

fieldset { border: none; padding: 0; margin: 0; }
fieldset legend { font-size: 13px; font-weight: 500; margin: 0 0 8px; padding: 0; }

/* Override .grid label's column direction for radio/checkbox rows.
   Specificity must match `.grid label` (0,1,1) so source-order wins. */
label.radio, label.checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-weight: 400;
  padding: 6px 0;
}
label.radio input, label.checkbox input {
  margin-top: 3px;
  flex-shrink: 0;
}
label.radio > span, label.checkbox > span {
  flex: 1;
  display: block;
}
label.radio + label.radio { margin-top: -2px; }

/* ── Buttons / actions ── */

.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

button, .btn {
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 120ms, border-color 120ms, transform 100ms, box-shadow 120ms;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover {
  background: var(--surface);
  border-color: var(--text);
  transform: translateY(-1px);
}
button:active, .btn:active { transform: translateY(0); }
button.primary, .btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
button.primary:hover, .btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
/* Yellow has terrible contrast with white text. When Micro Audio
 * Chopper is active, switch the primary button to dark text on yellow. */
body[data-active-tool="micro"] button.primary,
body[data-active-tool="micro"] .btn.primary {
  color: var(--text);
}
#submit-btn { font-size: 15px; padding: 11px 24px; }
#submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Progress / result ── */

.bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0 8px;
  position: relative;
}
#progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .25s ease;
  width: 0;
}
#progress-fill.indeterminate {
  width: 30% !important;
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(370%); }
}

#progress-msg { font-weight: 500; margin: 0 0 4px; }

.error { color: var(--error); font-size: 14px; margin: 8px 0 0; }
.mono {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 8px 0 16px;
}

footer { margin-top: 32px; text-align: center; }
footer .hint { font-size: 12px; color: var(--text-muted); }

/* ── Header layout w/ Recent jobs link ── */

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.header-row > div { flex: 1; }

.link {
  background: none;
  border: none;
  padding: 6px 0;
  color: var(--accent);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.link:hover { text-decoration: underline; color: var(--accent-hover); }

/* ── Recent jobs panel ── */

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.card-header h2 { flex: 1; margin: 0; }
.card-header-actions { display: flex; gap: 8px; }

.btn-small {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.btn-small:hover { background: var(--surface); border-color: var(--accent); }

.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.recent-list li:last-child { border-bottom: none; }
.recent-info { min-width: 0; }
.recent-name {
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  color: var(--text);
  margin: 0 0 4px;
}
.recent-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.recent-error-line {
  font-size: 12px;
  color: var(--error);
  margin: 4px 0 0;
}

.status-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pill.processing       { background: var(--accent-soft); color: var(--accent); }
.status-pill.created          { background: var(--accent-soft); color: var(--accent); }
.status-pill.done             { background: rgba(48, 209, 88, .18); color: var(--success); }
.status-pill.paid             { background: rgba(48, 209, 88, .18); color: var(--success); }
.status-pill.awaiting_payment { background: rgba(255, 159, 10, .18); color: #b46c00; }
.status-pill.failed           { background: rgba(255, 69, 58, .15); color: var(--error); }

.recent-actions { display: flex; gap: 6px; flex-shrink: 0; }

.footnote { margin-top: 16px; font-size: 11.5px; }

@media (max-width: 540px) {
  .header-row { flex-direction: column; align-items: stretch; }
  .recent-list li { grid-template-columns: 1fr; }
  .recent-actions { justify-content: flex-end; }
}

@media (max-width: 540px) {
  main { padding: 16px 16px 60px; margin: 16px auto; }
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-column: span 1; }
  header h1 { font-size: 24px; }
}

/* ── Chain Maker: sample list ── */

.chain-list-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 12px 0 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.chain-list-stats {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 200px;
}
.chain-list-stats strong { color: var(--text); }
.chain-list-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chain-warning {
  margin: 0 0 8px;
  padding: 8px 12px;
  background: rgba(255, 149, 0, 0.10);
  border: 1px solid rgba(255, 149, 0, 0.4);
  border-radius: 6px;
  color: #b25e00;
  font-size: 12.5px;
}
@media (prefers-color-scheme: dark) {
  .chain-warning { color: #ffb958; background: rgba(255, 149, 0, 0.15); }
}

.chain-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.chain-list:empty { display: none; }

.chain-row {
  display: grid;
  grid-template-columns: 22px 36px 1fr auto 28px 28px;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  user-select: none;
}
.chain-row:last-child { border-bottom: none; }
.chain-row.sortable-chosen { background: var(--accent-soft); }
.chain-row.sortable-ghost  { opacity: 0.4; }

.chain-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  line-height: 1;
}
.chain-handle:active { cursor: grabbing; }

.chain-position {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.chain-info {
  min-width: 0;
  font-size: 13px;
}
.chain-info .name {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.chain-info .meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chain-stretch {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.chain-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chain-action-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
}
.chain-action-btn.playing {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.chain-action-btn.delete:hover {
  background: rgba(215, 0, 21, 0.1);
  color: var(--error);
  border-color: var(--error);
}

#chain-preview-audio { display: none; }

/* ── Drum Rack Maker: 4×32 pad grid ── */

.drumrack-grid-wrap {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin: 8px 0 0;
}
.drumrack-grid-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  white-space: nowrap;
  writing-mode: sideways-lr;
  text-align: center;
  flex-shrink: 0;
}
@supports not (writing-mode: sideways-lr) {
  .drumrack-grid-axis { writing-mode: vertical-rl; transform: rotate(180deg); }
}

.drumrack-grid {
  flex: 1;
  /* minmax(0, 1fr) — without the explicit 0 floor, grid items default to
     min-width: auto which expands columns to fit unbreakable content
     (long filenames with white-space: nowrap). That overflow was breaking
     the card's bounding box. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  /* No inner background / border / padding — the parent .card is the
     bounding box. Keeps the visual clean and centered. */
  min-width: 0;
}

.pad {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 8px;
  /* Default to half-height; assigned pads (below) override to full height,
     which pulls their entire grid row up to match. Empty pads in an active
     row stretch to fill via the grid's default align-self: stretch. */
  min-height: 28px;
  /* Same as above: lets the cell shrink below its content min-width so
     long filenames + ellipsis behave correctly. */
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  position: relative;
  font-size: 11px;
  cursor: grab;
}
.pad:active { cursor: grabbing; }
.pad.empty {
  background: transparent;
  border-style: dashed;
  cursor: default;
  opacity: 0.6;
}
.pad.assigned {
  background: var(--bg);
  border-color: var(--accent-soft);
  padding: 6px 8px;
  min-height: 56px;
}
.pad.assigned:hover { border-color: var(--accent); }
.pad.dragging { opacity: 0.4; }
.pad.drop-target { border-color: var(--accent); border-style: solid; background: var(--accent-soft); }

.pad-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}
.pad-header .midi { font-weight: 600; }
.pad-header .note { color: var(--text-muted); }

.pad-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.25;
  outline: none;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 1px 3px;
  margin: 0 -3px;
  cursor: text;
  /* Cap at 2 lines so a long name doesn't blow up the row's height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pad-name:hover { border-color: var(--border); background: var(--bg); }
.pad-name:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--accent-soft);
  -webkit-line-clamp: unset;
  overflow: visible;
}

.pad-source {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.2;
  /* Truncate at 1 line; full name is in the title attribute. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drumrack-counter {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.drumrack-counter.full {
  color: var(--accent);
  font-weight: 500;
}

.pad-actions {
  display: flex;
  gap: 4px;
  margin-top: auto;
  padding-top: 2px;
}
.pad-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0;
  width: 22px;
  height: 18px;
  font-size: 10px;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pad-action-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--accent);
}
.pad-action-btn.playing {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.pad-action-btn.delete:hover {
  background: rgba(215, 0, 21, 0.1);
  color: var(--error);
  border-color: var(--error);
}

#drumrack-preview-audio { display: none; }
#drumrack-grid-hint { margin: 0 0 12px; }

/* ─────────────────────────── Reference rail ────────────────────────────
 *
 * A persistent reference panel pinned to the top-right of the viewport.
 * `position: fixed` keeps it in view as the user scrolls, and crucially
 * removes it from the document flow so it can't disrupt <main>'s existing
 * 720px centering. On narrower viewports the fixed panel would overlap
 * the form, so the @media block at the bottom of this file repositions
 * it to the bottom of the viewport as a thin horizontal bar.
 *
 * Selectors use `aside.reference-rail` (element + class) for slightly
 * higher specificity than a bare class, which makes these rules robust
 * against generic `aside` resets in the page or browser stylesheets.
 *
 * Adding a tool is purely additive — drop an image in
 * Producer_Tools/reference/, add an <li> in index.html. No CSS change.
 */

aside.reference-rail {
  position: fixed;
  top: 100px;
  right: 24px;
  width: 210px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px 16px;   /* extra top padding so the heading clears the new accent bar */
  margin: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
/* Violet accent bar across the top — same vocabulary as the brand-site
 * tool cards (which use ::before for their colored top stripe). The
 * Reference panel is the brand's "violet" surface, matching the brand
 * book card's BOOK 01 / SERIES badges. The bar's own border-radius
 * keeps the corners flush with the rail's rounded shape. */
aside.reference-rail::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--c-violet);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
/* Heading: match the in-card h2 treatment (Manrope, 17px, weight 700,
 * charcoal) so "Reference" reads as a real section title — same visual
 * weight as "Marker source" / "Settings" / "Files" in the tool panels. */
aside.reference-rail h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}
aside.reference-rail .ref-group { margin-top: 14px; }
aside.reference-rail .ref-group:first-of-type { margin-top: 0; }
aside.reference-rail .ref-group h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
aside.reference-rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
aside.reference-rail li { margin: 0; padding: 0; }
.ref-btn {
  font: inherit;
  font-size: 14px;
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 80ms, border-color 80ms, color 80ms;
}
.ref-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.ref-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Reference modal — image lightbox with close-affordance */

.ref-modal[hidden] { display: none; }
.ref-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ref-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.ref-modal-content {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
  /* `--ref-natural-w` is set by the JS in openRefModal() once the image
     loads, to the image's intrinsic width in px. So the modal sizes
     itself to fit each image — wide horizontal charts (Notes→Hz,
     2110×804) get a wide modal, tall portrait charts get a narrow one.
     1500px is just the fallback while the image is still decoding. */
  max-width: min(96vw, var(--ref-natural-w, 1500px));
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.ref-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.ref-modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.ref-modal-close {
  font: inherit;
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.ref-modal-close:hover {
  background: var(--surface);
  color: var(--text);
}
.ref-modal-close:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ref-modal-body {
  /* No padding — when the modal sizes itself to the image's natural
     width (set by JS via --ref-natural-w), we want the image to occupy
     the full body so the modal frame matches the image dimensions
     instead of having a letterbox border. */
  padding: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref-modal-image {
  display: block;
  /* Flex children get an implicit `min-width: auto` equal to their
     intrinsic width, which beats `max-width: 100%` and causes the image
     to overflow when the source is wider than the modal. Explicitly
     setting `min-width: 0` lets the image shrink to fit. */
  min-width: 0;
  /* Fill the modal body width. Combined with the modal-content's
     `max-width: var(--ref-natural-w)`, this means the image renders at
     its natural size when there's screen room, and scales down to fit
     when there isn't — never letterboxed. */
  width: 100%;
  max-width: 100%;
  /* Header is ~50px; leave that much vertical room. The image's auto
     height plus this cap keeps the modal inside the viewport on short
     screens (e.g. laptop with browser chrome). */
  max-height: calc(92vh - 50px);
  height: auto;
  object-fit: contain;
  border-radius: 0 0 var(--radius) var(--radius);
}

body.ref-modal-open { overflow: hidden; }

/* Narrow viewports — fixed rail would overlap main. Move it to the bottom
 * of the viewport as a thin horizontal bar with the same z-index, so it
 * stays accessible without claiming horizontal real estate. Threshold =
 * main's 720px max-width + ~340px headroom for the 200px-wide rail. */

@media (max-width: 1100px) {
  aside.reference-rail {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 40vh;     /* leave most of the screen for the active tool */
    padding: 8px 12px;
  }
  aside.reference-rail h2 { display: none; }
  aside.reference-rail .ref-group { margin-top: 0; }
  aside.reference-rail .ref-group h3 { display: none; }
  aside.reference-rail ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
  }
  .ref-btn { width: auto; padding: 6px 10px; font-size: 13px; }
}

/* ─────────────────── Video Slicer: marker source mode ──────────────────
 *
 * Two modes feed the same downstream pipeline:
 *   - "manual"  → BPM + bar markers (DAW-agnostic, default)
 *   - "ableton" → drop a .als and read markers from it
 *
 * UI: pill toggle, mode-pane containers shown/hidden based on selection,
 * a structured marker-rows table with +/✕ controls, and a live preview
 * line that echoes the computed seconds so users catch typos before
 * submitting.
 */

.mode-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  margin: 4px 0 12px;
}
.mode-pill {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.mode-pill:hover { color: var(--text); }
.mode-pill.active {
  background: var(--accent);
  color: white;
}
.mode-help {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.mode-help code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
}

.mode-pane[hidden] { display: none; }

/* ── Marker rows table ─────────────────────────────────────────────── */

.markers-table {
  margin: 16px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.markers-row {
  display: grid;
  grid-template-columns: 1fr 140px 36px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.markers-row:last-child { border-bottom: none; }
.markers-row.markers-header {
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.marker-row input[type="text"],
.marker-row input[type="number"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.marker-row input[type="text"]:focus,
.marker-row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.marker-row .marker-num { text-align: right; }

.marker-remove {
  font: inherit;
  font-size: 14px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.marker-remove:hover {
  background: #fee;
  border-color: var(--error);
  color: var(--error);
}

#add-marker-btn {
  margin: 4px 0 12px;
}

/* ── Live preview line ─────────────────────────────────────────────── */

.marker-preview {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  word-break: break-word;
  min-height: 38px;
}
.marker-preview.error {
  background: #fff5f5;
  border-color: var(--error);
  color: var(--error);
}
.marker-preview .preview-label {
  font-family: var(--font);
  font-weight: 600;
  color: var(--text);
  margin-right: 6px;
}

/* Narrow viewports — collapse the column widths */
@media (max-width: 540px) {
  .markers-row {
    grid-template-columns: 1fr 100px 32px;
    gap: 6px;
    padding: 6px 8px;
  }
}

/* ────────────── Micro Audio Chopper: transient-mode UI ───────────────
 *
 * Reuses the .mode-toggle / .mode-pill / .mode-pane / .mode-help classes
 * already defined by the Video Slicer's marker-source toggle. The pieces
 * below are specific to the transient-mode pane:
 *   - sensitivity slider with anchor labels at each end
 *   - waveform overlay div for slice-line markers
 */

.sensitivity-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sensitivity-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
.sensitivity-anchor {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.sensitivity-readout {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.sensitivity-readout #micro-sensitivity-value {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}
.sensitivity-meta {
  margin: 0 4px;
  color: var(--border);
}

/* Slice-line overlay positioned over the waveform canvas. The wrapper
 * is position: relative so this absolute overlay aligns to the canvas
 * pixel-for-pixel. JS adds individual <div class="slice-line"> children
 * with `left: <percent>%` for each detected onset. */

.waveform-wrapper {
  position: relative;
  margin: 12px 0 0;
}
.waveform-wrapper > #micro-waveform {
  display: block;
  width: 100%;
  height: 70px;
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
/* When the canvas has the hidden attribute (no file loaded yet), hide
 * it AND the overlay together so the empty box doesn't visually clutter
 * the form. drawWaveform() (in app.js) flips hidden=false BEFORE measuring
 * dimensions, so the canvas is in layout when the backing store is sized.
 * If you remove that "unhide first" line, this rule will cause solid-color
 * stretched-pixel artifacts. */
.waveform-wrapper > #micro-waveform[hidden] { display: none; }
.waveform-wrapper:has(> #micro-waveform[hidden]) > .waveform-overlay { display: none; }
.waveform-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 6px;
  overflow: hidden;
}
.waveform-overlay[hidden] { display: none; }
.slice-line {
  position: absolute;
  top: 4px;
  bottom: 4px;
  /* 2px charcoal line with a bright cream outer halo. Old design used
     var(--accent), which for the Micro Chopper resolves to a yellow that
     blended right into the gold waveform. Charcoal against gold is high
     contrast; the cream halo separates it from any dark waveform pixels
     it crosses, so the line stays legible regardless of which part of
     the wave it sits on. */
  width: 2px;
  background: var(--text);
  opacity: 0.95;
  box-shadow:
    0 0 0 1px var(--bg),
    0 0 2px rgba(0, 0, 0, 0.4);
}
/* First slice line is the start-of-file pinned marker — render it a bit
 * lighter so users see "yep, the first hit is at the very beginning". */
.slice-line.is-first {
  opacity: 0.55;
}
