:root {
  --bg: #0b0b0d;
  --bg-strip: #111114;
  --line: #202024;
  --text: #ececee;
  --text-dim: #97979d;
  --bar: #a2a2a8;
  --bar-played: #3ed17e;
  --lane-dim: #3d3d44;
  --btn-bg: #1d1d21;
  --btn-bg-hover: #29292e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.top {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.top h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.wave-wrap {
  padding: 18px 16px 0;
  user-select: none;
  -webkit-user-select: none;
}

#wave {
  display: block;
  width: 100%;
  height: 170px;
  cursor: crosshair;
  touch-action: none;
}

#ruler {
  display: block;
  width: 100%;
  height: 30px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.timecode {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  min-width: 24ch;
}

.tc-sep, #tc-total { color: var(--text-dim); }

.transport { display: flex; align-items: center; gap: 10px; }
.tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease;
}

.icon-btn:hover { background: var(--btn-bg-hover); }

.icon-btn svg { width: 20px; height: 20px; fill: var(--text); }

.icon-btn svg.stroke {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.play { background: var(--btn-bg); width: 44px; height: 40px; }
.icon-btn.play:hover { background: var(--btn-bg-hover); }
.icon-btn.sm svg { width: 18px; height: 18px; }

.icon-btn.speed {
  width: auto;
  min-width: 40px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
}

/* ---- file strip with tabs ---- */

.file-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg-strip);
  flex-wrap: wrap;
}

.file-id { display: flex; align-items: center; gap: 12px; min-width: 0; }

.check { width: 26px; height: 26px; flex: none; }

.strip-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.spinner {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--bar-played);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.choose-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 1px solid #3a3a41;
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.choose-btn:hover { background: var(--btn-bg-hover); border-color: #4a4a52; }
.choose-btn svg { width: 17px; height: 17px; fill: var(--text); }
.choose-btn.solid { background: var(--btn-bg); }

/* ---- select-audio dialog ---- */

.dlg-backdrop[hidden] { display: none; }

.dlg-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  z-index: 50;
  overflow-y: auto;
}

.dlg {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: #141417;
  border: 1px solid #26262b;
  border-radius: 16px;
  padding: 26px 28px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.dlg h2 { font-size: 22px; font-weight: 650; margin-bottom: 8px; }

.dlg-sub { color: var(--text-dim); font-size: 14.5px; margin-bottom: 18px; }

.dlg-close {
  position: absolute;
  top: 16px;
  right: 16px;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
}

.dlg-close:hover { color: var(--text); background: var(--btn-bg-hover); }

.dlg-tabs {
  display: flex;
  gap: 6px;
  background: #1b1b1f;
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 18px;
}

.dlg-tabs button {
  flex: 1;
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 8px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dlg-tabs button:hover { color: var(--text); }

.dlg-tabs button.active {
  color: var(--text);
  background: #26262c;
  border-color: #3a3a41;
}

.dlg-tabs button svg { width: 16px; height: 16px; }
.dlg-tabs button svg.stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dlg-note { color: var(--text-dim); font-size: 14px; margin-bottom: 10px; }

.dlg-label { display: block; font-size: 15px; margin: 14px 0 8px; }

#file-input {
  width: 100%;
  background: #0e0e11;
  border: 1px solid #26262b;
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

#file-input::file-selector-button {
  appearance: none;
  border: 1px solid #3a3a41;
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  margin-right: 12px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.url-row { display: flex; gap: 10px; }

#url-input {
  flex: 1;
  min-width: 0;
  background: #0e0e11;
  border: 1px solid #26262b;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
}

#url-input:focus { outline: none; border-color: #4a4a52; }

.dlg-rule { height: 1px; background: var(--line); margin: 22px 0 16px; }

.dlg-recents h3 {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.rec-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: #0e0e11;
  border: 1px solid #26262b;
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 8px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.rec-row:hover { border-color: #3a3a41; background: #131318; }

.rec-icon { width: 22px; height: 22px; flex: none; fill: var(--text-dim); }

.rec-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rec-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-sub { font-size: 12.5px; color: var(--text-dim); }

.file-meta { display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 14px; }
.file-uuid { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }

.tabs { display: flex; align-items: center; gap: 4px; }

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s ease;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: #fff; }

/* ---- panels ---- */

.panel { padding: 18px 24px 34px; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-title { font-size: 16.5px; font-weight: 500; }

.panel-note {
  font-size: 11.5px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
}

.panel-rule { flex: 1; height: 1px; background: var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--btn-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
}

.pill svg { width: 15px; height: 15px; color: var(--text-dim); }

.lane {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.lane-label {
  flex: none;
  width: 128px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 5px;
}

.lane canvas {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ---- JSON panel ---- */

#json-pre {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #c7c7cc;
  background: var(--bg-strip);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  max-height: 460px;
  overflow: auto;
  white-space: pre;
}

@media (max-width: 640px) {
  .controls { justify-content: center; }
  .timecode { min-width: 0; font-size: 13px; width: 100%; text-align: center; }
  .top { padding: 16px; }
  .wave-wrap { padding: 12px 8px 0; }
  #wave { height: 120px; }
  .panel { padding: 14px 12px 24px; }
  .lane { gap: 8px; }
  .lane-label { width: 96px; font-size: 11px; padding: 5px 7px; }
  .lane canvas { height: 32px; }
}
