/* 音訊剪裁：時間軸編輯器 */
:root {
  --ink: #1c2624;
  --muted: #5c6a66;
  --line: #d9d2c4;
  --line-strong: #c3baa8;
  --bg: #f3efe6;
  --paper: #fffdf8;
  --brand: #0e4a45;
  --brand-dark: #0a3532;
  --brand-soft: #e4f0ee;
  --accent: #d85a30;
  --accent-soft: #f8e4db;
  --focus: #1f7a72;
  --ok: #1d5c45;
  --ok-bg: #e7f4ee;
  --warn: #8a5a12;
  --warn-bg: #fff4e0;
  --danger: #922c38;
  --danger-bg: #fdecee;
  --danger-hover: #7a2230;
  --track: #102826;
  --shadow: 0 1px 2px rgba(28, 38, 36, 0.05), 0 10px 28px rgba(28, 38, 36, 0.07);
  --radius: 16px;
  --font: "Noto Sans TC", "Source Han Sans TC", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --mono: "Noto Sans Mono", "SFMono-Regular", "Menlo", "Consolas", ui-monospace, monospace;
}

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

html {
  scroll-behavior: smooth;
}

html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background:
    radial-gradient(900px 360px at 12% -8%, rgba(14, 74, 69, 0.12), transparent 60%),
    radial-gradient(700px 280px at 100% 0%, rgba(216, 90, 48, 0.08), transparent 55%),
    var(--bg);
}

img,
svg,
audio,
canvas,
video {
  max-width: 100%;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 20;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
}

.skip-link:focus {
  top: 1rem;
}

.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;
}

.wrap {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  padding: 1.6rem 0 1.2rem;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.brand-mark {
  display: block;
  color: var(--brand);
  flex: none;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(14, 74, 69, 0.2);
}

.kicker {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--brand);
}

.site-header h1 {
  margin-top: 0.15rem;
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  color: var(--brand-dark);
}

.lede {
  margin-top: 0.4rem;
  color: var(--muted);
  max-width: 40rem;
}

.notice,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notice {
  padding: 0.95rem 1.1rem;
  border-left: 4px solid var(--brand);
  color: var(--muted);
  font-size: 0.95rem;
}

.panel {
  margin-top: 1.15rem;
  padding: 1.2rem 1.15rem 1.25rem;
}

.panel-head h2 {
  font-size: 1.15rem;
}

.panel-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.hint {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.dropzone {
  margin-top: 1rem;
  padding: 1.4rem 1rem 1.2rem;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(14, 74, 69, 0.03), transparent 55%),
    #fbfaf5;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.dropzone-inner {
  pointer-events: none;
}

.dropzone-icon {
  color: var(--brand);
}

.dropzone-title {
  margin-top: 0.55rem;
  font-weight: 650;
}

.dropzone-help {
  margin: 0.25rem auto 1rem;
  max-width: 26rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: #c9dedb;
}

.btn-secondary:hover {
  background: #d5e9e6;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  background: #f4f0e6;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.alert-list {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.5rem;
}

.alert {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-size: 0.95rem;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.playhead-readout {
  margin-left: 0.2rem;
  min-width: 6.5rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: var(--brand-dark);
}

.zoom-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.tick-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.timeline-scroll {
  margin-top: 0.85rem;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #0a3532;
  border-radius: 12px;
  background: var(--track);
  touch-action: pan-x;
}

.timeline-inner {
  position: relative;
  min-width: 100%;
  padding: 10px 16px 0;
}

.clip-track {
  position: relative;
  height: 112px;
}

.timeline-clip {
  position: absolute;
  top: 8px;
  height: 96px;
  border: 2px solid rgba(243, 239, 230, 0.35);
  border-radius: 10px;
  background: #1a3f3b;
  overflow: hidden;
  color: #f3efe6;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.timeline-clip.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(216, 90, 48, 0.35);
  z-index: 2;
}

.timeline-clip canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.clip-label {
  position: absolute;
  left: 10px;
  top: 6px;
  right: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.clip-handle {
  position: absolute;
  top: 0;
  width: 18px;
  height: 100%;
  z-index: 3;
  cursor: ew-resize;
  touch-action: none;
}

.clip-handle::after {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  width: 4px;
  border-radius: 4px;
  background: #d85a30;
}

.clip-handle-left {
  left: 0;
}

.clip-handle-left::after {
  left: 5px;
}

.clip-handle-right {
  right: 0;
}

.clip-handle-right::after {
  right: 5px;
}

.gap-mark {
  position: absolute;
  top: 16px;
  height: 80px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(216, 90, 48, 0.08),
      rgba(216, 90, 48, 0.08) 6px,
      rgba(216, 90, 48, 0.2) 6px,
      rgba(216, 90, 48, 0.2) 12px
    );
  border: 1px dashed rgba(216, 90, 48, 0.7);
  color: #f3c7b5;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 0 4px;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  z-index: 5;
  pointer-events: none;
}

.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -6px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #fff;
}

.ruler {
  display: block;
  width: 100%;
  height: 52px;
  cursor: pointer;
}

.extras {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffcf6;
}

.extras h3 {
  font-size: 1.05rem;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.volume-row input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 44px;
  accent-color: var(--brand);
}

.volume-row input[type="number"],
.fade-grid input {
  width: 5.5rem;
  min-height: 44px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font-family: var(--mono);
}

.field {
  display: block;
  margin-top: 0.8rem;
}

.field span {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 650;
  font-size: 0.92rem;
}

.fade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.extras .btn-danger {
  margin-top: 1rem;
}

.save-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 1rem;
}

.save-hint {
  flex: 1 1 16rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 0.95rem;
}

.save-hint.is-blocked {
  background: var(--warn-bg);
  color: var(--warn);
}

.export-status {
  min-height: 1.4em;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state {
  margin-top: 0.85rem;
  padding: 1.2rem 0.2rem 0.4rem;
  color: var(--muted);
}

.empty-title {
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.clip-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.clip-card {
  display: grid;
  gap: 0.7rem;
  padding: 0.9rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffcf6;
}

.clip-card.is-new {
  border-color: #b7d4cf;
  background: #f4faf8;
}

.clip-name {
  font-weight: 700;
  word-break: break-word;
}

.clip-meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.clip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.clip-player {
  width: 100%;
  height: 40px;
}

.site-footer {
  padding: 1.6rem 0 2.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.confirm-dialog {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.2rem 1.15rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--paper);
}

.confirm-dialog::backdrop {
  background: rgba(16, 24, 22, 0.45);
}

.confirm-dialog h2 {
  font-size: 1.15rem;
}

.confirm-dialog p {
  margin: 0.55rem 0 1rem;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (max-width: 720px) {
  .wrap {
    width: min(980px, calc(100% - 1.25rem));
  }

  .zoom-group {
    margin-left: 0;
    width: 100%;
  }

  .fade-grid {
    grid-template-columns: 1fr;
  }

  .save-row,
  .save-row .btn {
    width: 100%;
  }

  .clip-actions .btn {
    flex: 1 1 auto;
  }

  .clip-handle {
    width: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
