/* ═══════════════════════════════════════════════════════════════════════════
   styles.css — Stem Player
   Farbwelt von schmitt.works: dunkler Grund, dezente Graustufen, Orange-Akzent.
   Dark ist Default; [data-theme="light"] liefert ein helles Pendant.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand / dark (Default) */
  --bg: #0a131c;
  --bg2: #0e1a26;
  --card: #162232;
  --card-hi: #1d2c3d;
  --line: rgba(232, 238, 245, .09);
  --line-hi: rgba(232, 238, 245, .18);
  --tx: #e8eef5;
  --tx-d: rgba(232, 238, 245, .62);
  --tx-m: rgba(232, 238, 245, .40);
  --ac: #d65a26;
  --ac-hi: #ef7038;
  --ac-dim: rgba(214, 90, 38, .16);
  --ok: #3fae86;

  /* Meterfarben */
  --m-lo: #3fae86;
  --m-mid: #cdb43a;
  --m-hi: #e2542a;
  --meter-bg: rgba(232, 238, 245, .07);

  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, 'SF Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --bg: #f4f6f9;
  --bg2: #eef1f5;
  --card: #ffffff;
  --card-hi: #f5f7fa;
  --line: rgba(20, 30, 45, .10);
  --line-hi: rgba(20, 30, 45, .20);
  --tx: #16202c;
  --tx-d: rgba(22, 32, 44, .66);
  --tx-m: rgba(22, 32, 44, .45);
  --ac: #d65a26;
  --ac-hi: #c04c1d;
  --ac-dim: rgba(214, 90, 38, .12);
  --meter-bg: rgba(20, 30, 45, .08);
  --shadow: 0 8px 26px rgba(20, 30, 45, .10);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg2), transparent 70%),
    var(--bg);
  color: var(--tx);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  /* Kein versehentliches Markieren beim Ziehen von Slidern/Timeline */
  user-select: none; -webkit-user-select: none;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.4vw, 22px);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--tx-m);
  text-decoration: none;
  transition: color .15s;
  white-space: nowrap;
}
.back-link:hover { color: var(--tx-d); }

.brand { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 3px;
  background: var(--ac);
  box-shadow: 0 0 14px 1px var(--ac);
}
.brand-text { display: flex; flex-direction: column; line-height: 1; text-align: right; }
.brand-title { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-sub { font-family: var(--mono); font-size: 8px; letter-spacing: .28em; color: var(--tx-m); margin-top: 4px; }

.icon-btn {
  margin-left: 8px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--tx-d);
  font-size: 16px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--tx); border-color: var(--line-hi); }

/* ── Drop zone ──────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--line-hi);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color .18s, background .18s, padding .2s;
}
.dz-inner {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: clamp(26px, 5vw, 44px);
  text-align: center;
  color: var(--tx-d);
}
.dz-icon { color: var(--ac); opacity: .9; }
.dz-title { font-size: 17px; font-weight: 600; color: var(--tx); }
.dz-hint { font-size: 12.5px; color: var(--tx-m); }
.dropzone.is-dragover {
  border-color: var(--ac);
  background: var(--ac-dim);
}
/* Kompakt, sobald Spuren geladen sind */
#app.has-tracks .dropzone .dz-inner { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 12px 18px; gap: 14px; }
#app.has-tracks .dropzone .dz-icon { width: 22px; height: 22px; }
#app.has-tracks .dropzone .dz-title { font-size: 14px; }
#app.has-tracks .dropzone .dz-hint { display: none; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--tx);
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .14s, border-color .14s, color .14s, transform .04s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--line-hi); background: var(--card); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--ac); border-color: var(--ac); color: #fff;
  width: 52px; height: 52px; border-radius: 50%; padding: 0;
}
.btn-primary:hover { background: var(--ac-hi); border-color: var(--ac-hi); }
.btn-primary svg { margin-left: 2px; }
.btn-tog { padding: 8px 12px; font-size: 13px; color: var(--tx-d); }
.btn-tog.active { background: var(--ac-dim); border-color: var(--ac); color: var(--ac-hi); }

:focus-visible { outline: 2px solid var(--ac-hi); outline-offset: 2px; }

/* ── Transport ──────────────────────────────────────────────────────────── */
.transport {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 20px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.transport-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.transport-buttons { display: flex; align-items: center; gap: 8px; }
.transport-buttons .btn:not(.btn-primary) { width: 44px; height: 44px; padding: 0; border-radius: 50%; color: var(--tx-d); }

.timeline-wrap { flex: 1 1 320px; min-width: 220px; }
.timeline {
  position: relative;
  height: 34px;
  display: flex; align-items: center;
  cursor: pointer;
  touch-action: none; /* Pointer-Dragging auf Touch nicht als Scroll werten */
}
.timeline-track {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 8px; border-radius: 6px; background: var(--meter-bg);
}
.timeline-progress {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 8px; border-radius: 6px; width: 0;
  background: linear-gradient(90deg, var(--ac), var(--ac-hi));
  pointer-events: none;
}
.timeline-playhead {
  position: absolute; top: 50%; left: 0;
  width: 3px; height: 22px; margin-left: -1.5px;
  transform: translateY(-50%);
  background: var(--tx);
  border-radius: 2px;
  box-shadow: 0 0 0 3px var(--bg), 0 0 10px rgba(0,0,0,.4);
  pointer-events: none;
}
.timeline-markers { position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; }
.marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px; padding: 0;
  border: 2px solid var(--bg); border-radius: 50%;
  background: var(--ac-hi);
  cursor: pointer; pointer-events: auto;
  transition: transform .1s;
}
.marker:hover { transform: translate(-50%, -50%) scale(1.3); }

.time-display { font-family: var(--mono); font-size: 15px; color: var(--tx); white-space: nowrap; }
.time-display #time-dur { color: var(--tx-m); }
.time-sep { color: var(--tx-m); margin: 0 4px; }

.controls-row { display: flex; align-items: center; gap: 18px 22px; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: 10px; }
.ctl-label { font-size: 12px; color: var(--tx-d); font-family: var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.ctl-val { font-family: var(--mono); font-size: 13px; color: var(--tx-d); min-width: 42px; }
.ctl-master { flex: 1 1 220px; }
.ctl-master input { flex: 1; }
.ctl-rate { flex: 1 1 200px; }
.ctl-rate input { flex: 1; }
.ctl-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ── Range-Slider (einheitlich) ─────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 22px; background: transparent; cursor: pointer;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 4px; background: var(--meter-bg);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 4px; background: var(--meter-bg); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--tx); border: 3px solid var(--ac);
  margin-top: -6px;
  transition: transform .08s;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--tx); border: 3px solid var(--ac);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

/* ── Tracks ─────────────────────────────────────────────────────────────── */
.tracks-head { display: flex; align-items: baseline; gap: 10px; padding: 0 2px; }
.tracks-title { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--tx-d); }
.tracks-count { font-family: var(--mono); font-size: 12px; color: var(--tx-m); }
.track-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.empty-hint { color: var(--tx-m); font-size: 13.5px; padding: 18px 2px; }

.track {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color .15s, background .15s;
}
.track.selected { border-left-color: var(--ac); background: var(--card-hi); }
.track.is-loading { opacity: .7; }
.track.is-error { border-left-color: #c0432b; }
.track.inactive .track-meter { opacity: .35; }
.track.inactive .track-name { color: var(--tx-m); }

.track-info { flex: 1 1 180px; min-width: 140px; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.track-index { font-family: var(--mono); font-size: 12px; color: var(--tx-m); width: 18px; flex-shrink: 0; }
.track-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-status { font-family: var(--mono); font-size: 11px; color: var(--tx-m); flex-shrink: 0; }
.track.is-error .track-status { color: #e0755e; }

.track-meter {
  position: relative; flex: 2 1 180px; min-width: 120px;
  height: 12px; border-radius: 6px;
  background: var(--meter-bg); overflow: hidden;
}
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, var(--m-lo) 0%, var(--m-mid) 68%, var(--m-hi) 100%);
  border-radius: 6px;
  transition: width .04s linear;
}
.meter-peak {
  position: absolute; top: 0; bottom: 0; width: 2px; left: 0;
  background: var(--tx); opacity: 0;
  transition: left .05s linear;
}

.track-controls { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.tbtn {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-hi);
  color: var(--tx-d);
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:hover { border-color: var(--line-hi); color: var(--tx); }
.btn-mute.active { background: rgba(214, 90, 38, .18); border-color: var(--ac); color: var(--ac-hi); }
.btn-solo.active { background: rgba(63, 174, 134, .18); border-color: var(--ok); color: var(--ok); }
.btn-remove { font-size: 18px; font-weight: 400; }
.btn-remove:hover { color: #e0755e; border-color: #c0432b; }
.track-controls .vol { width: 120px; }
.track-controls .vol-val { font-family: var(--mono); font-size: 12px; color: var(--tx-m); width: 28px; text-align: right; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 10px 0 20px; color: var(--tx-m); }
.privacy { font-size: 12.5px; color: var(--tx-d); }
.shortcuts { font-size: 12px; margin-top: 8px; }
kbd {
  font-family: var(--mono); font-size: 11px;
  background: var(--card-hi); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 6px; color: var(--tx-d);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--card-hi); color: var(--tx);
  border: 1px solid var(--line-hi); border-radius: 10px;
  padding: 11px 18px; font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Responsive (Tablet / kompakt) ──────────────────────────────────────── */
@media (max-width: 640px) {
  .track-info { flex: 1 1 100%; }
  .track-meter { flex: 1 1 100%; order: 3; }
  .track-controls { flex: 1 1 100%; order: 2; justify-content: space-between; }
  .track-controls .vol { flex: 1; width: auto; }
  .brand-sub { display: none; }
  .ctl-buttons { margin-left: 0; }
  .time-display { font-size: 14px; }
}
