:root {
  color-scheme: dark;
  --bg: #15120f;
  --panel: #1e1a16;
  --panel-raised: #252019;
  --line: #393027;
  --text: #f4eee7;
  --muted: #a89a89;
  --accent: #ee9c45;
  --danger: #b44942;
}

* { box-sizing: border-box; }

body {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 18px 44px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, textarea { font: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 18px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.2rem; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 1rem; font-weight: 650; }

main { display: grid; gap: 12px; }

.statusbar, .card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.statusbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, .7fr) auto;
  align-items: center;
  gap: 18px;
  padding: 13px 15px;
}

.track-status { min-width: 0; }
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.now { overflow-wrap: anywhere; margin-top: 2px; font-weight: 600; }
.queue-meta { color: var(--muted); font-size: .8rem; }

label {
  display: block;
  margin: 10px 0 5px;
  color: var(--muted);
  font-size: .83rem;
}
label b { color: var(--text); font-weight: 600; }

input[type="text"], input[type="number"], textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #15120f;
  color: var(--text);
}
textarea { min-height: 78px; resize: vertical; }
input:focus, textarea:focus, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="range"] { width: 100%; margin: 7px 0 0; accent-color: var(--accent); }

.master-volume label { margin-top: 0; }
.master-volume input { margin-top: 0; }

.card { padding: 15px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.muted, .summary-hint, .field-help { color: var(--muted); font-size: .8rem; }
.field-help { display: block; margin-top: 4px; }

.preset-block { margin-top: 13px; }
.field-label { margin-bottom: 6px; color: var(--muted); font-size: .83rem; }
.presets, .lengths { display: flex; flex-wrap: wrap; gap: 7px; }
.more-presets { margin-top: 9px; }
.more-presets > summary, .more-clip-presets > summary { color: var(--muted); font-size: .8rem; font-weight: 500; }
.more-presets .presets { margin-top: 8px; }

button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .08s ease;
}
button:hover { border-color: #62503b; background: #302820; }
button:active { transform: translateY(1px); }
.ghost { min-height: 34px; padding: 6px 10px; background: transparent; color: var(--muted); }
.primary { min-width: 104px; border-color: var(--accent); background: var(--accent); color: #21160b; font-weight: 700; }
.primary:hover { border-color: #f5b363; background: #f5b363; }
.stop { min-height: 34px; padding: 6px 11px; border-color: #63403b; background: transparent; color: #f0b0aa; }
.stop:hover { border-color: var(--danger); background: #35201e; }
.preset { min-height: 33px; padding: 5px 10px; border-radius: 999px; font-size: .82rem; }
.preset[aria-pressed="true"] { border-color: var(--accent); background: #392819; color: #ffd5a2; }
.chip { min-height: 32px; padding: 5px 10px; border-radius: 999px; font-size: .8rem; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: #392819; color: #ffd5a2; }

.clip-library { margin-bottom: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #191611; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.library-heading .field-label { margin: 0; }
.library-tabs { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.library-tab { min-height: 30px; padding: 4px 11px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: .8rem; }
.library-tab:hover { background: var(--panel-raised); }
.library-tab[aria-pressed="true"] { background: var(--panel-raised); color: var(--text); }
.clip-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.clip-presets[hidden] { display: none; }
.clip-preset { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.clip-preset span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-preset small { flex: 0 0 auto; color: var(--muted); font-size: .72rem; }
.clip-preset[aria-pressed="true"] { border-color: var(--accent); background: #392819; }
.clip-library .field-help { margin-top: 9px; }
.more-clip-presets { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); }
.more-clip-presets .clip-presets { margin-top: 8px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid > div { min-width: 0; }

details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 1.1rem; font-weight: 400; }
details[open] > summary::after { content: "−"; }
.advanced { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.advanced > summary { color: var(--muted); font-size: .82rem; font-weight: 500; }
.advanced .grid { margin-top: 6px; }
.advanced .grid label { margin-top: 8px; }
.collapsible { padding: 13px 15px; }
.details-content { padding-top: 12px; }
.clip-options { justify-content: space-between; }
.check { display: inline-flex; align-items: center; gap: 7px; margin: 0; white-space: nowrap; }
.check input { accent-color: var(--accent); }

.events { margin: 0; padding: 0; list-style: none; font-size: .86rem; }
.events li { padding: 7px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.events li:last-child { border-bottom: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  max-width: 90vw;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #252019;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .18s ease, transform .18s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: #743a35; background: #3a211e; }

body.center { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card.login { width: 100%; max-width: 360px; }
.card.login h1 { margin-bottom: 14px; }
.card.login form > button { margin-top: 14px; }

@media (max-width: 560px) {
  body { padding: 17px 13px 32px; }
  .statusbar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; }
  .master-volume { grid-column: 1 / -1; grid-row: 2; }
  .stop { grid-column: 2; grid-row: 1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
  .grid > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .section-heading { align-items: center; }
  .summary-hint { display: none; }
  .clip-options { align-items: flex-start; flex-direction: column; }
  .clip-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clip-library { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
