:root {
  --bg: #0d1017;
  --bg-2: #131824;
  --panel: #102f57;
  --panel-2: #123b69;
  --line: #23527f;
  --text: #e7ecf5;
  --muted: #8b97ad;
  --accent: #18d4f4;
  --accent-2: #00f0a8;
  --danger: #ff6b6b;
  --wave: #43a8dd;
  --wave-sel: #00f0a8;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 12% -12%, #1c2540 0%, transparent 60%),
    radial-gradient(900px 420px at 100% 0%, #10302c 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------- top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 23, .72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; letter-spacing: .2px; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0d1017; font-weight: 800;
}
.brand-text b { color: var(--accent-2); font-weight: 700; }
.tabs { display: flex; gap: 6px; background: var(--panel); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 16px; border-radius: 7px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--accent); color: #0b0e15; }
.topbar-right { margin-left: auto; }
.badge {
  font-size: 12px; color: var(--accent-2); border: 1px solid rgba(55, 214, 192, .35);
  background: rgba(55, 214, 192, .08); padding: 5px 10px; border-radius: 999px;
}

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 22px 40px; }
.view { display: none; }
.view.is-active { display: block; }

/* ---------------- dropzone ---------------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 18px;
  padding: 62px 24px;
  text-align: center;
  background: linear-gradient(180deg, rgba(23, 29, 43, .7), rgba(19, 24, 36, .35));
}
.dropzone.is-over { border-color: var(--accent); background: rgba(108, 140, 255, .08); }
.dz-icon { font-size: 46px; }
.dropzone h1 { margin: 12px 0 6px; font-size: 30px; }
.dz-sub { color: var(--muted); max-width: 560px; margin: 0 auto 22px; }
.dz-hint { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------------- buttons ---------------- */
.btn {
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 9px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover:not(:disabled) { background: #263049; border-color: #38456180; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5a7bff); border-color: transparent; color: #0b0e15; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), #5a7bff); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 26px; font-size: 16px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-mini { padding: 4px 8px; font-size: 12px; }
.btn-icon { width: 34px; padding: 6px 0; text-align: center; font-size: 17px; line-height: 1; }
.btn-round { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; padding: 0; }
.full { width: 100%; }

/* ---------------- editor shell ---------------- */
.editor { display: flex; flex-direction: column; gap: 16px; }
.file-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
}
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info { color: var(--muted); font-size: 12.5px; }
.file-actions { margin-left: auto; display: flex; gap: 8px; }

.wave-wrap { background: linear-gradient(180deg, #0d4678, #0d3967); border: 1px solid #1b6598; border-radius: 14px; padding: 12px; box-shadow: 0 20px 45px rgba(0, 15, 40, .38); }
.wave-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.wave-toolbar .group { display: flex; align-items: center; gap: 6px; }
.wave-toolbar .group:last-child { margin-left: auto; }
.wave-toolbar .btn { background: rgba(4, 34, 67, .55); border-color: rgba(79, 177, 224, .25); }
.wave-canvas { width: 100%; height: 288px; display: block; border-radius: 10px; background: #0b4778; cursor: text; touch-action: none; }
.wave-canvas.small { height: 120px; cursor: pointer; margin-bottom: 6px; }
.overview-canvas { width: 100%; height: 48px; display: block; margin-top: 8px; border-radius: 8px; background: #082f55; cursor: grab; touch-action: none; }
.track .tmini { width: 130px; height: 30px; }

.selection-dock {
  display: grid; grid-template-columns: minmax(205px, 1fr) minmax(130px, .7fr) minmax(205px, 1fr) auto;
  align-items: end; gap: 12px; margin-top: 12px; padding: 13px;
  background: rgba(4, 29, 59, .72); border: 1px solid rgba(46, 180, 228, .24); border-radius: 11px;
}
.time-card { display: grid; gap: 6px; min-width: 0; }
.time-card-label, .selection-length > span { color: #8ec9e9; font-size: 13px; font-weight: 650; letter-spacing: .02em; }
.time-card input, .selection-length input {
  height: 46px; font: 700 18px/1 "Cascadia Mono", Consolas, monospace;
  color: #fff; background: #071f3b; border-color: #2475a4;
}
.time-card input:focus { outline-color: var(--accent); box-shadow: 0 0 0 3px rgba(24, 212, 244, .14); }
.time-card .btn-mini { min-width: 42px; color: #06213a; background: var(--accent); border-color: transparent; font-size: 17px; }
.selection-length { display: grid; gap: 6px; min-width: 0; text-align: center; }
.selection-length input { text-align: center; color: var(--accent-2); border-color: rgba(0, 240, 168, .3); }
.selection-quick { display: flex; gap: 7px; padding-bottom: 2px; }
#view-cut .panels { grid-template-columns: 1fr 1fr; }

.transport {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px;
}
.transport.compact { background: transparent; border: 0; padding: 6px 0; }
.tp-left { display: flex; align-items: center; gap: 10px; }
.tp-time { margin-left: auto; font-variant-numeric: tabular-nums; font-family: "Cascadia Mono", Consolas, monospace; color: var(--muted); }
.tp-time #tp-cur, .tp-time #merge-cur { color: var(--text); }
.tp-time .sep { margin: 0 6px; }

/* ---------------- panels ---------------- */
.panels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.time-fields { display: grid; gap: 10px; }
.time-fields label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.tf { display: flex; gap: 6px; }
input[type=text], select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; font-variant-numeric: tabular-nums;
}
input[type=text]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[readonly] { color: var(--muted); }
select { cursor: pointer; }
option { background: var(--bg-2); }
.nudge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-grid .btn { text-align: left; font-size: 13.5px; padding: 10px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.fld { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.fld b { color: var(--text); }
.export-row { display: flex; gap: 10px; align-items: end; }
.export-row .fld { margin-bottom: 10px; }
.export-row .grow { flex: 1; }
.export-row .fld:first-child { width: 148px; flex: none; }
.panel-export .check { margin: 2px 0 12px; }
.hint { color: var(--muted); font-size: 12px; margin: -4px 0 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.progress { margin-top: 10px; position: relative; height: 22px; }
.progress .bar { height: 6px; border-radius: 3px; background: var(--accent); width: 0%; transition: width .12s; }
.progress .ptext { font-size: 12px; color: var(--muted); }

/* ---------------- track list ---------------- */
.tracklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.track {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.track.dragging { opacity: .45; }
.track.drop-target { border-color: var(--accent); }
.track .grip { cursor: grab; color: var(--muted); font-size: 17px; user-select: none; }
.track .idx {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--panel-2); color: var(--muted); font-size: 12.5px; font-weight: 700;
}
.track .tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .tmini { width: 130px; height: 30px; flex: none; }
.track .tdur { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.track .tbtns { display: flex; gap: 4px; }

/* ---------------- overlays ---------------- */
.foot {
  border-top: 1px solid var(--line); padding: 14px 22px; color: var(--muted); font-size: 12.5px;
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}
.mp3-status { color: var(--accent-2); }
.mp3-status.warn { color: #ffcc66; }

.drop-overlay {
  position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  background: rgba(13, 16, 23, .82); backdrop-filter: blur(3px);
  font-size: 26px; font-weight: 700; color: var(--accent);
}
.drop-overlay.is-on { display: grid; }
.drop-overlay div { border: 3px dashed var(--accent); border-radius: 20px; padding: 46px 80px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow); animation: pop .18s ease-out; max-width: 340px;
}
.toast.err { border-left-color: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.busy {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; gap: 14px;
  background: rgba(13, 16, 23, .7); backdrop-filter: blur(2px); font-weight: 600;
}
.busy[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .18); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .panels { grid-template-columns: 1fr; }
  #view-cut .panels { grid-template-columns: 1fr; }
  .selection-dock { grid-template-columns: 1fr 1fr; }
  .selection-length { order: 3; }
  .selection-quick { order: 4; justify-content: flex-end; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .track .tmini { display: none; }
}

@media (max-width: 560px) {
  main { padding-inline: 10px; }
  .wave-wrap { padding: 8px; }
  .wave-canvas { height: 235px; }
  .wave-toolbar { align-items: flex-start; }
  .wave-toolbar .group:last-child { display: none; }
  .selection-dock { grid-template-columns: 1fr; }
  .selection-length, .selection-quick { order: initial; }
  .selection-quick { justify-content: stretch; }
  .selection-quick .btn { flex: 1; }
}

[hidden] { display: none !important; }
