:root {
  color-scheme: dark;
  --bg: #090e14;
  --panel: #111923;
  --panel-2: #17222e;
  --line: rgba(208, 231, 255, 0.12);
  --text: #f6f3eb;
  --muted: #9babb9;
  --accent: #e5bd68;
  --accent-2: #6fd8c9;
  --danger: #ff8c87;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 2%, rgba(229, 189, 104, 0.11), transparent 26rem),
    radial-gradient(circle at 95% 25%, rgba(111, 216, 201, 0.08), transparent 30rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header, .layout {
  width: min(1500px, calc(100% - 36px));
  margin-inline: auto;
}

.site-header { padding: 32px 0 24px; }
.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, .detail-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.98;
}

.intro { max-width: 700px; margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.layout {
  display: grid;
  grid-template-columns: minmax(390px, 0.9fr) minmax(520px, 1.35fr);
  gap: 22px;
  padding-bottom: 50px;
  align-items: start;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(17, 25, 35, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls { padding: 18px; border-bottom: 1px solid var(--line); }
.search-wrap { position: relative; display: block; }
.search-wrap::before {
  position: absolute;
  top: 50%;
  left: 15px;
  content: "⌕";
  color: var(--accent);
  font-size: 1.4rem;
  transform: translateY(-54%);
}

#searchInput, select {
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--panel-2);
}

#searchInput {
  width: 100%;
  padding: 14px 15px 14px 45px;
  outline: none;
}

#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229, 189, 104, 0.12); }
.filter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 11px; }
select { min-width: 0; width: 100%; padding: 10px; }

.results-meta { display: flex; justify-content: space-between; padding: 13px 18px; color: var(--muted); font-size: 0.78rem; }
.text-button { padding: 0; border: 0; color: var(--accent); background: transparent; cursor: pointer; }
.sketch-list { max-height: calc(100vh - 275px); min-height: 360px; overflow-y: auto; border-top: 1px solid var(--line); }
.episode-group { border-bottom: 1px solid var(--line); }
.episode-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 18px;
  color: var(--accent);
  background: rgba(9, 14, 20, 0.96);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sketch-card {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-top: 1px solid var(--line);
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.sketch-card:hover { background: rgba(255, 255, 255, 0.035); }
.sketch-card.selected { background: rgba(229, 189, 104, 0.12); box-shadow: inset 3px 0 var(--accent); }
.track-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.card-copy { min-width: 0; }
.sketch-card h3 { margin-bottom: 4px; font-family: Georgia, "Times New Roman", serif; font-size: 1.04rem; line-height: 1.2; }
.card-filename { display: block; overflow: hidden; color: var(--muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.badge { align-self: start; padding: 4px 7px; border-radius: 999px; color: var(--accent-2); background: rgba(111, 216, 201, 0.09); font-size: 0.64rem; font-weight: 800; }
.empty-state { padding: 55px 25px; color: var(--muted); text-align: center; line-height: 1.6; }

.detail-panel { position: sticky; top: 18px; }
.detail-header { padding: clamp(20px, 3vw, 32px); }
.detail-header h2 { margin-bottom: 7px; font-size: clamp(1.9rem, 4vw, 3.3rem); line-height: 1.02; }
.filename { margin-bottom: 16px; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.subtitle-stage {
  display: grid;
  min-height: clamp(260px, 36vh, 410px);
  padding: clamp(24px, 5vw, 58px);
  place-items: center;
  border-block: 1px solid var(--line);
  background: radial-gradient(circle at 50% 110%, rgba(111, 216, 201, 0.13), transparent 52%), rgba(4, 8, 12, 0.42);
  text-align: center;
}

.subtitle-text { display: grid; gap: 0.42em; width: 100%; max-width: 880px; font-size: clamp(1.4rem, 3.2vw, 2.7rem); font-weight: 720; line-height: 1.25; text-wrap: balance; }
.subtitle-text.is-empty { color: var(--muted); font-size: 1rem; font-weight: 500; }
.subtitle-line { display: block; }
.subtitle-word.future { visibility: hidden; }
.subtitle-word.current { color: var(--accent-2); text-shadow: 0 0 24px rgba(111, 216, 201, 0.34); }
.subtitle-text.line-change { animation: lyric-flow-down 420ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes lyric-flow-down { from { opacity: 0.5; transform: translateY(-0.55em); } to { opacity: 1; transform: none; } }

.player-box { padding: 18px 22px 22px; }
.player-topline { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: 0.8rem; }
#timeDisplay { color: var(--accent); font-family: Consolas, monospace; font-variant-numeric: tabular-nums; }
audio { width: 100%; height: 48px; accent-color: var(--accent); }
.status { min-height: 1.3em; margin: 10px 2px 0; color: var(--muted); font-size: 0.78rem; }
.status.error { color: var(--danger); }
.status.success { color: var(--accent-2); }

.subtitle-actions { display: flex; justify-content: flex-end; padding: 10px 22px; border-bottom: 1px solid var(--line); font-size: 0.84rem; }
.text-button:disabled { color: var(--muted); cursor: default; opacity: 0.6; }
.text-button:focus-visible, .icon-button:focus-visible, .primary-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.editor { padding: 18px 22px 20px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.editor-topline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.editor-topline .text-button { margin-left: auto; }
.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.icon-button:disabled { opacity: 0.35; cursor: default; }
.field-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.editor textarea, .editor input, .review-card textarea, .review-login input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: var(--bg);
}
.editor textarea, .review-card textarea { resize: vertical; font-size: 1.05rem; line-height: 1.45; }
.editor textarea:focus, .editor input:focus, .review-card textarea:focus, .review-login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229, 189, 104, 0.12); }
.editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 14px; }
.editor-actions .status { margin: 0; }
.primary-button {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  color: var(--bg);
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.primary-button:disabled { opacity: 0.55; cursor: default; }
.danger-button { color: var(--danger); }

.review-layout { width: min(980px, calc(100% - 36px)); margin-inline: auto; padding-bottom: 50px; }
.review-login { display: grid; gap: 12px; max-width: 460px; padding: 22px; }
.review-list { display: grid; gap: 16px; }
.review-card { padding: 20px 22px; }
.review-card h2 { margin-bottom: 4px; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 500; }
.review-meta { margin-bottom: 12px; color: var(--muted); font-size: 0.78rem; }
.review-note { margin-bottom: 12px; padding: 10px 12px; border-left: 3px solid var(--accent); color: #c6d0d8; background: rgba(229, 189, 104, 0.06); font-size: 0.86rem; }
.diff { margin-bottom: 12px; font-size: 1.05rem; line-height: 1.6; }
.diff del { color: var(--danger); text-decoration: line-through; }
.diff ins { color: var(--accent-2); text-decoration: none; border-bottom: 2px solid rgba(111, 216, 201, 0.5); }
.review-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 12px; }
.review-actions .status { margin: 0; }
.review-card.decided { opacity: 0.55; }
.metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.metadata-section { padding: 20px 22px; background: var(--panel); }
.metadata-section.wide { grid-column: 1 / -1; }
.metadata-section h3 { margin-bottom: 9px; color: var(--accent); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; }
.metadata-section p, .metadata-section li { color: #c6d0d8; font-size: 0.84rem; line-height: 1.55; }
.metadata-section p:last-child { margin-bottom: 0; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .sketch-list { max-height: 560px; }
}
@media (max-width: 580px) {
  .site-header, .layout { width: min(100% - 20px, 1500px); }
  .filter-row { grid-template-columns: 1fr; }
  .filter-options { right: auto; left: 0; width: 100%; }
  .metadata { grid-template-columns: 1fr; }
  .editor-fields { grid-template-columns: 1fr; }
  .review-layout { width: min(100% - 20px, 980px); }
  .metadata-section.wide { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .subtitle-text.line-change { animation: none; }
}
