
:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --panel-2: #f4f4f2;
  --line: #e4e3df;
  --line-strong: #d3d2cc;
  --ink: #1c1c1a;
  --ink-dim: #6b6b64;
  --ink-faint: #9d9c95;
  --accent: #EA580C;
  --accent-soft: #fff7ed;
  --teal: #0ea88e;
  --teal-soft: #e3f7f2;
  --red: #dc2626;
  --radius: 12px;
  --disp: 'Space Grotesk', sans-serif;
  --body: 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); }
::selection { background: var(--accent-soft); color: var(--accent); }

.wrap { max-width: 980px; margin: 0 auto; }
.top-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px;
  margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.card h2 { font-family: var(--disp); font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }

.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 600px) { .meta-grid { grid-template-columns: repeat(2, 1fr); } }
.meta-item .label { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 4px; }
.meta-item .value { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 720px) { .settings-row { grid-template-columns: 1fr; } }

/* Canvas stack */
.canvas-stack {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #140803;
  margin-bottom: 4px;
}
.wave-bg, .time-layer { display: block; width: 100%; }
.time-layer { cursor: crosshair; }

.tl-hint { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); margin-bottom: 0; }

/* Playback row */
.preview-row { display: flex; gap: 8px; align-items: center; }
.half-btn { flex: 1; }
.play-time { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-dim); min-width: 60px; text-align: right; }

/* Import/export row */
.import-row { display: flex; gap: 6px; margin-bottom: 8px; }
.import-btn { flex: 1; font-size: 11.5px; padding: 8px 6px; margin-bottom: 0; }
.import-hint { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); }
.import-hint code { background: var(--panel-2); border-radius: 3px; padding: 1px 4px; font-size: 9px; }

/* Presets */
.preset-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-btn { font-family: var(--mono); font-size: 10.5px; font-weight: 600; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink-dim); cursor: pointer; transition: all .1s; }
.preset-btn:hover { border-color: var(--accent); color: var(--accent); }
.preset-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.preset-clear:hover { border-color: var(--red); color: var(--red); }

/* Controls */
.ctrl { margin-bottom: 16px; }
.ctrl label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }

/* Chapter header */
.ch-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ch-header h2 { margin-bottom: 0; }
.add-ch-btn { font-size: 12px; padding: 7px 14px; margin-bottom: 0; }

/* Chapter list */
.chapter-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; margin-bottom: 4px; padding-right: 2px; }
.chapter-list::-webkit-scrollbar { width: 5px; }
.chapter-list::-webkit-scrollbar-track { background: transparent; }
.chapter-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.no-chapters { font-family: var(--body); font-size: 13px; color: var(--ink-faint); text-align: center; padding: 28px 16px; line-height: 1.7; }
.no-chapters strong { color: var(--accent); }

/* Chapter row */
.chapter-row {
  display: grid;
  grid-template-columns: 14px 22px 1fr 28px;
  gap: 8px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color .12s;
}
.chapter-row:hover { border-color: var(--accent); }

.ch-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ch-num { font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--ink-faint); text-align: center; }
.ch-fields { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.ch-time, .ch-title, .ch-desc {
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink);
  padding: 4px 7px;
  width: 100%;
  outline: none;
  transition: border-color .1s;
}
.ch-time:focus, .ch-title:focus, .ch-desc:focus { border-color: var(--accent); }
.ch-time.invalid { border-color: var(--red); }
.ch-time { font-weight: 700; color: var(--accent); font-size: 11px; }
.ch-title { font-weight: 600; }
.ch-desc { font-size: 10.5px; color: var(--ink-dim); }

.ch-del-btn { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line); background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 11px; display: flex; align-items: center; justify-content: center; transition: all .1s; align-self: center; }
.ch-del-btn:hover { border-color: var(--red); color: var(--red); background: #fef2f2; }

/* Format select */
.out-select { font-family: var(--mono); font-size: 12.5px; width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-2); color: var(--ink); cursor: pointer; outline: none; transition: border-color .1s; }
.out-select:focus { border-color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 13px; font-weight: 700; padding: 12px 20px; border-radius: 8px; border: none; background: var(--accent); color: #fff; cursor: pointer; width: 100%; margin-bottom: 12px; transition: filter .12s, opacity .12s; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-dim); margin-bottom: 0; }
.btn.ghost:hover:not(:disabled) { filter: none; border-color: var(--accent); color: var(--accent); }
.btn.download-result { background: var(--teal); width: auto; padding: 10px 18px; margin-bottom: 0; }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--accent)); border-radius: 2px; transition: width .15s ease; }
.status-line { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); min-height: 16px; }

/* Result */
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.result-heading h2 { margin-bottom: 4px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--teal); }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); display: inline-block; }
.result-body { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 700px) { .result-body { grid-template-columns: 1fr; } }
.result-side { display: flex; flex-direction: column; gap: 16px; }
.file-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; background: var(--panel-2); border-radius: 8px; border: 1px solid var(--line); }
.file-pair .label { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 4px; }
.file-pair .fname { font-family: var(--mono); font-size: 12px; color: var(--ink); word-break: break-all; }
.result-stats { display: flex; flex-direction: column; }
.stat-row { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 11.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.stat-label { color: var(--ink-faint); }
.stat-value { color: var(--ink); font-weight: 600; }
.stat-value.accent { color: var(--accent); }
.result-info-box { font-family: var(--body); font-size: 12.5px; line-height: 1.6; color: var(--ink-dim); background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; }
