/* ═══════════════════════════════════════════════════════════════════════════
   ON THE ONE — TURNTABLE DESIGN SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Fonts ───────────────────────────────────────────────────────────────── */

/* DM Mono and Inter loaded via <link> in index.html */

/* ─── Tokens ──────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg:              #1a1a18;
  --surface:         #222220;
  --surface-recessed:#141412;
  --surface-raised:  #2a2a27;
  --surface-overlay: rgba(10, 10, 9, 0.92);

  /* Groove / borders */
  --groove:       #2e2e2a;
  --bevel-light:  rgba(255, 255, 240, 0.04);
  --bevel-dark:   rgba(0, 0, 0, 0.3);

  /* Text */
  --text-1: #e8e0d0;
  --text-2: #8a8478;
  --text-3: #5a5650;

  /* Accent: amber */
  --accent:      #d4a054;
  --accent-dim:  #a07838;
  --accent-hi:   #e8b86a;
  --accent-glow: rgba(212, 160, 84, 0.15);
  --accent-text: #1a1a18;

  /* Semantic */
  --warn:    #c45040;
  --success: #5a9a5a;

  /* Focus ring */
  --focus: rgba(212, 160, 84, 0.4);

  /* Typography */
  --font-ui:      'DM Mono', 'SF Mono', 'Consolas', monospace;
  --font-display: 'Inter', system-ui, sans-serif;

  /* Type scale */
  --f-xs: 10px;
  --f-sm: 11px;
  --f-m:  13px;
  --f-l:  16px;

  /* Spacing */
  --xs: 0.25rem;
  --s:  0.5rem;
  --m:  1rem;
  --l:  1.5rem;
  --xl: 2.5rem;

  /* Shape */
  --r:  3px;
  --rl: 10px;

  /* Motion */
  --ease-mechanical: cubic-bezier(0.22, 0.68, 0.35, 1.0);
  --dur-snap: 100ms;
  --dur-fade: 200ms;
  --dur-slide: 300ms;
}

/* ─── Reset ───────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Accessibility utility ───────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ─── Base ────────────────────────────────────────────────────────────────── */

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-1);
  font-size: var(--f-m);
}

/* ═══════════════════════════════════════════════════════════════════════════
   DISPLAY — "THE PLATTER"
═══════════════════════════════════════════════════════════════════════════ */

#display-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  /* Vinyl texture — concentric rings */
  background:
    radial-gradient(
      circle at 50% 50%,
      transparent 20%,
      rgba(255,255,240,0.006) 20.5%,
      transparent 21%,
      transparent 30%,
      rgba(255,255,240,0.004) 30.5%,
      transparent 31%,
      transparent 42%,
      rgba(255,255,240,0.005) 42.5%,
      transparent 43%,
      transparent 56%,
      rgba(255,255,240,0.003) 56.5%,
      transparent 57%,
      transparent 70%,
      rgba(255,255,240,0.004) 70.5%,
      transparent 71%
    ),
    radial-gradient(
      circle at 50% 50%,
      rgba(212,160,84,0.02) 0%,
      transparent 60%
    );
}

#content-display {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-display);
  font-size: 20vw;
  font-weight: 800;
  color: var(--text-1);
  text-align: center;
  transition: opacity var(--dur-fade) ease;
  padding: var(--l);
  overflow: hidden;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 40px rgba(212,160,84,0.08);
  --border-radius: 0px;
}

/* ─── Loading indicator ───────────────────────────────────────────────────── */

#loading-indicator {
  display: none;
  position: fixed;
  bottom: var(--l);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  z-index: 10;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HUD — beat indicator + item counter (top-left)
═══════════════════════════════════════════════════════════════════════════ */

#hud {
  position: fixed;
  top: var(--m);
  left: var(--m);
  display: flex;
  align-items: center;
  gap: var(--s);
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
}

/* Beat dots — lit amber LEDs */
#beat-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.beat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background var(--dur-fade) ease, box-shadow var(--dur-fade) ease;
}

.beat-dot.active {
  background: var(--accent-hi);
  box-shadow: 0 0 6px rgba(212,160,84,0.5), 0 0 2px rgba(212,160,84,0.8);
  animation: dotPulse 120ms ease-out;
}

@keyframes dotPulse {
  from { transform: scale(1.5); }
  to   { transform: scale(1);   }
}

/* Item counter */
#item-counter {
  font-family: var(--font-ui);
  font-size: var(--f-m);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTROLS TAB — external affordance to open the panel
═══════════════════════════════════════════════════════════════════════════ */

#controls-tab {
  position: fixed;
  bottom: 0;
  right: var(--l);
  background: var(--surface);
  border: 1px solid var(--groove);
  border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  color: var(--text-3);
  cursor: pointer;
  z-index: 90;
  transition: color var(--dur-snap), opacity 150ms;
  user-select: none;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#controls-tab:hover { color: var(--text-2); }

body.panel-open #controls-tab {
  opacity: 0;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTROLS PANEL — "THE CONSOLE"
═══════════════════════════════════════════════════════════════════════════ */

#controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: var(--surface);
  border-top: 1px solid var(--groove);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.4), 0 -1px 0 var(--bevel-light);
  z-index: 100;
  transform: translateY(100%);
  transition: transform var(--dur-slide) var(--ease-mechanical);
  /* Brushed metal texture */
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent,
      rgba(255,255,240,0.008) 1px,
      transparent 2px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      rgba(0,0,0,0.015) 1px,
      transparent 3px
    );
  background-color: var(--surface);
}

#controls.visible { transform: translateY(0); }

#controls.playing {
  border-top-color: var(--accent-dim);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.4), 0 -1px 0 var(--accent-glow);
}

/* ── Single-bar layout ─────────────────────────────────────────────────── */

.controls-bar {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
}

/* ── Groove divider (vertical line between control groups) ───────────── */

.groove-divider {
  width: 1px;
  height: 40px;
  background: var(--groove);
  box-shadow: 1px 0 0 var(--bevel-light);
  margin: 0 16px;
  flex-shrink: 0;
}

/* ── Control group containers ────────────────────────────────────────── */

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ctrl-group--right {
  margin-left: auto;
}

/* ── Selector columns (SET / TRACK) ────────────────────────────────────── */

.ctrl-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}

.ctrl-col--track {
  flex: 1;
  min-width: 0;
}

.ctrl-label {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  flex-shrink: 0;
  margin-left: 2px;
}

.ctrl-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Selector pill — recessed input feel ───────────────────────────────── */

.sel-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-dark);
  border-bottom-color: var(--bevel-light);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
  border-radius: var(--r);
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color var(--dur-snap);
  min-width: 0;
}
.sel-pill:hover {
  border-color: var(--accent-dim);
}
.sel-pill:focus-within {
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), 0 0 0 1px var(--accent-glow);
}

.sel-value-text {
  font-size: var(--f-sm);
  font-weight: 400;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sel-pill select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: var(--f-m);
}

.sel-pill--track {
  min-width: 120px;
  width: 100%;
}

.sel-pill--speed {
  align-self: center;
  flex-shrink: 0;
}
.sel-pill--speed .sel-value-text {
  font-size: var(--f-xs);
  letter-spacing: 0.08em;
}

/* ── Edit / New buttons — hardware panel buttons ─────────────────────── */

#edit-content-btn,
#custom-btn {
  background: var(--surface-raised);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  border-bottom-color: var(--bevel-dark);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--dur-snap), color var(--dur-snap);
}
#edit-content-btn:hover,
#custom-btn:hover {
  background: #333330;
  color: var(--text-1);
}
#edit-content-btn:focus-visible,
#custom-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
}

/* ── Transport section ──────────────────────────────────────────────────── */

.ctrl-transport {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ctrl-transport button {
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-snap), color var(--dur-snap);
}
.ctrl-transport button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
}

/* Play button — circular amber, the hero element */
#play-pause-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d4a054 0%, #b8883e 100%);
  border: 2px solid var(--accent-dim);
  box-shadow:
    0 2px 8px rgba(0,0,0,0.4),
    0 0 20px var(--accent-glow),
    inset 0 1px 0 rgba(255,255,240,0.2);
}
#play-pause-btn:hover {
  background: linear-gradient(180deg, #e8b86a 0%, #c49548 100%);
  box-shadow:
    0 2px 12px rgba(0,0,0,0.4),
    0 0 28px rgba(212,160,84,0.25),
    inset 0 1px 0 rgba(255,255,240,0.25);
}
#play-pause-btn:active {
  transform: scale(0.96);
  box-shadow:
    0 1px 4px rgba(0,0,0,0.4),
    0 0 12px var(--accent-glow),
    inset 0 2px 3px rgba(0,0,0,0.2);
}
#play-pause-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--focus);
}

.play-glyph {
  font-size: 1rem;
  color: var(--accent-text);
  line-height: 1;
  margin-left: 2px; /* optical centering for play triangle */
}

/* Play label hidden — icon only */
.play-label { display: none; }

/* Prev / Next — recessed transport buttons */
#prev-item-btn,
#next-item-btn {
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  color: var(--text-2);
  font-size: 1.2rem;
  width: 30px;
  height: 30px;
  border-radius: var(--r);
}
#prev-item-btn:hover,
#next-item-btn:hover {
  background: var(--surface-raised);
  color: var(--text-1);
}

/* Stop button */
#stop-btn {
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  color: var(--warn);
  font-size: 0.8rem;
  width: 30px;
  height: 30px;
  border-radius: var(--r);
}
#stop-btn:hover {
  background: var(--surface-raised);
  color: #e06050;
}

/* Cue button — preview loop audio next to the track selector */
#cue-btn {
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  color: var(--text-3);
  font-size: 0.9rem;
  width: 26px;
  height: 26px;
  border-radius: var(--r);
  flex-shrink: 0;
  line-height: 1;
}
#cue-btn:hover {
  background: var(--surface-raised);
  color: var(--text-2);
}
#cue-btn.cue-active {
  color: var(--accent);
  border-color: var(--accent-dim);
  box-shadow: 0 0 6px var(--accent-glow), 0 1px 2px rgba(0,0,0,0.2);
}

/* ── Vol + utilities section ────────────────────────────────────────────── */

.ctrl-utils {
  display: flex;
  align-items: center;
  gap: var(--s);
  flex: 1;
  min-width: 0;
}

.ctrl-utils-right {
  display: flex;
  align-items: center;
  gap: var(--s);
  margin-left: auto;
  flex-shrink: 0;
}

#volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 1 80px;
  min-width: 50px;
  height: 4px;
  background: var(--surface-recessed);
  border-radius: 2px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
  cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e8e0d0 0%, #b0a898 100%);
  border: 1px solid rgba(0,0,0,0.3);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}
#volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e8e0d0 0%, #b0a898 100%);
  border: 1px solid rgba(0,0,0,0.3);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}
#volume-slider:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-radius: 9999px;
}

/* Utility icon buttons — fullscreen, reset audio, collapse */
#fullscreen-btn,
#reset-audio-btn,
#controls-expand-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  background: transparent;
  border: 1px solid var(--groove);
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-snap), color var(--dur-snap), border-color var(--dur-snap);
  line-height: 1;
}
#fullscreen-btn:hover,
#reset-audio-btn:hover,
#controls-expand-btn:hover {
  background: var(--surface-raised);
  border-color: var(--groove);
  color: var(--text-1);
}
#fullscreen-btn:focus-visible,
#reset-audio-btn:focus-visible,
#controls-expand-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
  border-radius: var(--r);
}

#reset-audio-btn { display: none; }
#reset-audio-btn.visible { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL — "THE PATCH BAY"
═══════════════════════════════════════════════════════════════════════════ */

#custom-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: var(--m);
}

#custom-modal-content {
  background: var(--surface);
  border: 1px solid var(--groove);
  border-radius: var(--rl);
  box-shadow:
    0 24px 80px rgba(0,0,0,0.6),
    0 0 0 1px var(--bevel-light),
    inset 0 1px 0 rgba(255,255,240,0.03);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Modal header ─────────────────────────────────────────────────────── */

#modal-header {
  padding: var(--l) var(--l) var(--m);
  border-bottom: 1px solid var(--groove);
  flex-shrink: 0;
}

#modal-header-row {
  display: flex;
  align-items: flex-start;
  gap: var(--m);
}

.modal-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#modal-title {
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Set name — large, monospace, equipment-label feel */
#set-name {
  font-family: var(--font-ui);
  font-size: var(--f-l);
  background: none;
  border: none;
  color: var(--text-1);
  outline: none;
  line-height: 1.3;
  width: 100%;
  letter-spacing: 0.02em;
}
#set-name::placeholder {
  color: var(--text-3);
}
#set-name:focus { color: var(--text-1); }

#modal-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur-snap), color var(--dur-snap), border-color var(--dur-snap);
  line-height: 1;
}
#modal-close-btn:hover {
  background: var(--surface-raised);
  border-color: var(--groove);
  color: var(--text-1);
}
#modal-close-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
  border-radius: var(--r);
}

#modal-mode-hint {
  font-size: var(--f-xs);
  color: var(--text-3);
  margin-top: var(--xs);
  letter-spacing: 0.06em;
}

/* ── Modal body — scrollable ──────────────────────────────────────────── */

#modal-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--groove) transparent;
}

/* Section ordering */
#modal-section-name       { order: 0; display: none; }
#modal-section-timing     { order: 1; }
#modal-section-list       { order: 2; flex: 1; }
#modal-section-add        { order: 3; }
#modal-section-appearance { order: 4; }

/* ── Timing section ───────────────────────────────────────────────────── */

#modal-section-timing {
  padding: var(--m) var(--l);
  border-bottom: 1px solid var(--groove);
}

#modal-section-timing .section-header {
  display: none;
}

#timing-grid {
  display: flex;
  gap: var(--xl);
  align-items: flex-end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-group label {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}

.field-group input[type="number"],
.field-group input[type="text"],
.field-group select {
  font-family: var(--font-ui);
  font-size: var(--f-m);
  color: var(--text-1);
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
  border-radius: var(--r);
  padding: 5px var(--s);
  outline: none;
  transition: border-color var(--dur-snap);
}
.field-group input:focus,
.field-group select:focus {
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), 0 0 0 1px var(--accent-glow);
}

.field-group input[type="number"] { width: 64px; }

.field-hint {
  font-size: var(--f-xs);
  color: var(--text-3);
  margin-top: 1px;
  letter-spacing: 0.04em;
}

/* ── Content list section ─────────────────────────────────────────────── */

#modal-section-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#modal-section-list .section-header {
  display: flex;
  align-items: center;
  gap: var(--m);
  padding: var(--xs) var(--l);
  border-bottom: 1px solid var(--groove);
  flex-shrink: 0;
}

.section-title {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  flex: 1;
}

#content-items-count {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* Import button */
#import-set-label {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--surface-raised);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  border-bottom-color: var(--bevel-dark);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  border-radius: var(--r);
  padding: 3px var(--s);
  cursor: pointer;
  transition: background var(--dur-snap), color var(--dur-snap);
  user-select: none;
}
#import-set-label:hover { background: #333330; color: var(--text-1); }
#import-set-label input[type="file"] { display: none; }

/* Content items list */
#content-items-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--groove) transparent;
}

/* Empty state */
.content-items-empty {
  padding: var(--xl) var(--l);
  text-align: center;
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Content item row */
.content-item {
  display: flex;
  align-items: center;
  gap: var(--m);
  padding: var(--s) var(--l);
  border-bottom: 1px solid var(--groove);
  transition: background var(--dur-snap);
  cursor: default;
}
.content-item:last-child { border-bottom: none; }
.content-item:hover { background: rgba(212,160,84,0.03); }

/* Drag handle */
.drag-handle {
  font-size: 0.75rem;
  color: var(--text-3);
  cursor: grab;
  padding: var(--xs) var(--xs);
  flex-shrink: 0;
  transition: color var(--dur-snap);
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle--pulse { animation: handlePulse 200ms ease-out; }
@keyframes handlePulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.content-item.dragging { opacity: 0.4; }
.content-item.drop-above { border-top: 2px solid var(--accent); }
.content-item.drop-below { border-bottom: 2px solid var(--accent); }

/* Item preview */
.content-item-preview {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-recessed);
  border: 1px solid var(--groove);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.content-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Item info */
.content-item-info {
  flex: 1;
  min-width: 0;
}

.content-item-info--with-hint {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.content-item-name {
  font-size: var(--f-m);
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-item-caption-hint {
  font-size: var(--f-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-item-badge {
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.10em;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Item action buttons */
.content-item-edit,
.content-item-delete {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px 5px;
  transition: color var(--dur-snap);
  flex-shrink: 0;
  line-height: 1;
}
.content-item-edit:hover  { color: var(--text-1); }
.content-item-delete:hover { color: var(--warn); }
.content-item-edit:focus-visible,
.content-item-delete:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
  border-radius: var(--r);
}

/* Inline item editor */
.item-editor {
  display: flex;
  align-items: center;
  gap: var(--s);
  padding: var(--s) var(--l);
  background: var(--surface-recessed);
  border-bottom: 1px solid var(--groove);
}

.img-zone {
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  border: 1px dashed var(--groove);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.6rem;
  color: var(--text-3);
  overflow: hidden;
  position: relative;
  transition: border-color var(--dur-snap), color var(--dur-snap);
}
.img-zone:hover { border-color: var(--accent); color: var(--accent); }
.img-zone.has-image { border-style: solid; border-color: var(--groove); }

.img-zone-empty { pointer-events: none; }
.img-zone-input { display: none; }

.img-zone-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-zone-remove {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 9, 0.65);
  color: var(--text-1);
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-snap);
}
.img-zone:hover .img-zone-remove { opacity: 1; }

.item-editor-text {
  flex: 1;
  font-family: var(--font-ui);
  font-size: var(--f-m);
  color: var(--text-1);
  background: none;
  border: none;
  border-bottom: 1px solid var(--groove);
  padding: 3px 0;
  outline: none;
  min-width: 0;
}
.item-editor-text::placeholder { color: var(--text-3); }
.item-editor-text:focus { border-bottom-color: var(--accent); }

.item-editor-beats {
  width: 48px;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--groove);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  border-radius: var(--r);
  padding: 4px var(--xs);
  text-align: center;
  outline: none;
}
.item-editor-beats:focus {
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px var(--accent-glow);
}

.item-editor-apply {
  background: linear-gradient(180deg, #d4a054 0%, #b8883e 100%);
  color: var(--accent-text);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px var(--m);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-snap);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,240,0.15);
}
.item-editor-apply:hover {
  background: linear-gradient(180deg, #e8b86a 0%, #c49548 100%);
}

/* ── Add section ──────────────────────────────────────────────────────── */

#modal-section-add {
  border-top: 1px solid var(--groove);
}

#modal-section-add .section-header { display: none; }
#add-section-toggle { display: none; }

#add-section-body { display: block !important; }
#add-section-body.collapsed { display: block !important; }

#add-section-inner {
  padding: 0;
}

/* Composer — horizontal add row */
#item-composer {
  display: flex;
  align-items: center;
  gap: var(--m);
  padding: var(--s) var(--l);
  background: var(--surface-recessed);
}

#composer-image-zone {
  width: 30px;
  height: 30px;
  border-radius: var(--r);
  border: 1px dashed var(--groove);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.6rem;
  color: var(--text-3);
  overflow: hidden;
  position: relative;
  transition: border-color var(--dur-snap), color var(--dur-snap);
}
#composer-image-zone:hover { border-color: var(--accent); color: var(--accent); }
#composer-image-zone.has-image { border-style: solid; border-color: var(--groove); }
#composer-image-input { display: none; }

#composer-text-input {
  flex: 1;
  font-family: var(--font-ui);
  font-size: var(--f-m);
  color: var(--text-1);
  background: none;
  border: none;
  border-bottom: 1px solid var(--groove);
  padding: 3px 0;
  outline: none;
  min-width: 0;
}
#composer-text-input::placeholder { color: var(--text-3); }
#composer-text-input:focus { border-bottom-color: var(--accent); }

#composer-footer {
  display: flex;
  align-items: center;
  gap: var(--s);
  flex-shrink: 0;
}

#composer-beats {
  width: 48px;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--groove);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  border-radius: var(--r);
  padding: 4px var(--xs);
  text-align: center;
  outline: none;
}
#composer-beats:focus {
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px var(--accent-glow);
}

#composer-add-btn {
  background: linear-gradient(180deg, #d4a054 0%, #b8883e 100%);
  color: var(--accent-text);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px var(--m);
  cursor: pointer;
  transition: background var(--dur-snap);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,240,0.15);
}
#composer-add-btn:hover {
  background: linear-gradient(180deg, #e8b86a 0%, #c49548 100%);
}
#composer-add-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
}

/* Batch text */
#batch-text-area {
  padding: var(--xs) var(--l) var(--s);
  background: var(--surface-recessed);
  border-top: 1px solid var(--groove);
}

#batch-text-toggle {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  cursor: pointer;
  padding: var(--xs) 0;
  transition: color var(--dur-snap);
}
#batch-text-toggle:hover { color: var(--text-2); }

#batch-text-panel {
  overflow: hidden;
  max-height: 200px;
  transition: max-height 200ms ease;
}
#batch-text-panel.collapsed { max-height: 0; }

.batch-panel-inner {
  padding-top: var(--s);
  display: flex;
  flex-direction: column;
  gap: var(--s);
}

#add-text-input {
  font-family: var(--font-ui);
  font-size: var(--f-m);
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--groove);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
  border-radius: var(--r);
  padding: var(--s);
  outline: none;
  resize: vertical;
  width: 100%;
}
#add-text-input::placeholder { color: var(--text-3); }
#add-text-input:focus {
  border-color: var(--accent-dim);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35), 0 0 0 1px var(--accent-glow);
}

#batch-text-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s);
}

#add-text-hint {
  font-size: var(--f-xs);
  color: var(--text-3);
  letter-spacing: 0.04em;
}

#add-text-btn {
  background: linear-gradient(180deg, #d4a054 0%, #b8883e 100%);
  color: var(--accent-text);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px var(--m);
  cursor: pointer;
  transition: background var(--dur-snap);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,240,0.15);
}
#add-text-btn:hover {
  background: linear-gradient(180deg, #e8b86a 0%, #c49548 100%);
}

/* ── Appearance section ───────────────────────────────────────────────── */

#modal-section-appearance {
  border-top: 1px solid var(--groove);
}

#advanced-settings-toggle {
  display: flex;
  align-items: center;
  gap: var(--s);
  width: 100%;
  padding: var(--s) var(--l);
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  transition: color var(--dur-snap);
}
#advanced-settings-toggle:hover { color: var(--text-1); }

.toggle-arrow {
  font-size: 0.55rem;
  transition: transform 150ms;
  display: inline-block;
}
#advanced-settings-toggle[aria-expanded="true"] .toggle-arrow {
  transform: rotate(90deg);
}

#advanced-settings {
  overflow: hidden;
  max-height: 400px;
  transition: max-height 200ms ease;
}
#advanced-settings.collapsed { max-height: 0; }

.appearance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--m) var(--xl);
  padding: var(--m) var(--l);
}

.field-group--full { grid-column: 1 / -1; }

.color-field {
  display: flex;
  align-items: center;
  gap: var(--s);
}

.color-field input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1px solid var(--groove);
  border-radius: var(--r);
  background: none;
  cursor: pointer;
  padding: 2px;
}

.color-field input[type="text"] {
  width: 80px;
}

/* ── Modal footer ─────────────────────────────────────────────────────── */

#modal-footer {
  display: flex;
  align-items: center;
  gap: var(--s);
  padding: var(--l);
  border-top: 1px solid var(--groove);
  flex-shrink: 0;
}

#modal-footer-spacer { flex: 1; }

#delete-custom-btn {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-3);
  cursor: pointer;
  padding: var(--xs) 0;
  transition: color var(--dur-snap);
}
#delete-custom-btn:hover { color: var(--warn); }
#delete-custom-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(196, 80, 64, 0.5);
  border-radius: var(--r);
}

#export-set-btn {
  background: var(--surface-raised);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  border-bottom-color: var(--bevel-dark);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-xs);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 4px var(--s);
  cursor: pointer;
  transition: background var(--dur-snap);
}
#export-set-btn:hover { background: #333330; color: var(--text-1); }

#cancel-custom-btn {
  background: var(--surface-raised);
  border: 1px solid var(--groove);
  border-top-color: var(--bevel-light);
  border-bottom-color: var(--bevel-dark);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-m);
  color: var(--text-2);
  padding: var(--s) var(--m);
  cursor: pointer;
  transition: background var(--dur-snap);
}
#cancel-custom-btn:hover { background: #333330; color: var(--text-1); }

/* Create / Save — amber gradient button */
#create-custom-btn {
  background: linear-gradient(180deg, #d4a054 0%, #b8883e 100%);
  color: var(--accent-text);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: var(--f-m);
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: var(--s) var(--l);
  cursor: pointer;
  transition: background var(--dur-snap);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,240,0.15);
}
#create-custom-btn:hover {
  background: linear-gradient(180deg, #e8b86a 0%, #c49548 100%);
}
#create-custom-btn:disabled { opacity: 0.4; cursor: default; }
#create-custom-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}
