:root {
  --bg: #161515;
  --panel: rgba(36, 32, 30, 0.9);
  --panel-strong: rgba(25, 22, 21, 0.94);
  --border: rgba(222, 195, 169, 0.16);
  --text: #f3e6d7;
  --muted: #b6a18e;
  --accent: #6cb8ff;
  --accent-soft: rgba(108, 184, 255, 0.14);
  --gold: #e2be96;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
  --left-panel-width: 50vw;
  --resizer-width: 24px;
  --video-aspect-ratio: 16 / 9;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Times New Roman", Georgia, "Songti SC", "STSong", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(124, 86, 48, 0.24), transparent 32%),
    radial-gradient(circle at 85% 14%, rgba(77, 121, 180, 0.18), transparent 22%),
    linear-gradient(135deg, #171313 0%, #1e1b1a 45%, #111111 100%);
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 100%);
  opacity: 0.42;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, var(--left-panel-width)) var(--resizer-width) minmax(360px, 1fr);
  gap: 0;
  height: 100vh;
  padding: 28px;
}

.player-panel,
.transcript-panel {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.player-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px;
  overflow: hidden;
  height: calc(100vh - 56px);
  margin-right: 8px;
}

.transcript-panel {
  display: flex;
  flex-direction: column;
  padding: 26px 22px 18px;
  height: calc(100vh - 56px);
  min-height: 0;
  margin-left: 8px;
}

.panel-resizer {
  position: relative;
  height: calc(100vh - 56px);
  cursor: col-resize;
  touch-action: none;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(226, 190, 150, 0.18) 0%, rgba(108, 184, 255, 0.55) 45%, rgba(226, 190, 150, 0.18) 100%);
  box-shadow: 0 0 18px rgba(108, 184, 255, 0.18);
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 62px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(226, 190, 150, 0.18);
  border-radius: 999px;
  background: rgba(21, 19, 18, 0.86);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

body.is-resizing,
body.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.panel-head {
  margin-bottom: 0;
}

.eyebrow,
.meta-label,
.hint {
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.panel-head h1,
.transcript-head h3,
.video-info h2 {
  margin: 0;
  font-family: var(--font-serif);
  line-height: 0.95;
}

.panel-head h1 {
  font-size: clamp(1.28rem, 1.7vw, 1.86rem);
  max-width: 16ch;
  line-height: 1.02;
}

.panel-copy {
  margin: 6px 0 0;
  max-width: 52ch;
  color: #ddcfbe;
  line-height: 1.35;
  font-size: 0.8rem;
}

.video-card,
.control-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.025);
}

.video-card {
  margin-top: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.video-topbar,
.video-info,
.control-card {
  padding: 12px 16px;
}

.video-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.live-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(226, 190, 150, 0.12);
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.video-frame-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-frame-wrap iframe,
#youtubePlayer {
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
  border: 0;
}

.video-info {
  border-top: 1px solid var(--border);
}

.video-info h2 {
  font-size: clamp(1rem, 1.15vw, 1.35rem);
  line-height: 1.15;
  margin-bottom: 4px;
}

.video-info p {
  margin: 0;
  color: #c9b39a;
  line-height: 1.35;
  font-size: 0.8rem;
}

.control-card {
  margin-top: 0;
}

.fetch-status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: #dcc8b5;
  line-height: 1.6;
}

.fetch-status[data-tone="loading"] {
  color: #f0d3ab;
  background: rgba(226, 190, 150, 0.12);
}

.fetch-status[data-tone="success"] {
  color: #b8dbff;
  background: rgba(108, 184, 255, 0.12);
}

.fetch-status[data-tone="error"] {
  color: #ffb1b1;
  background: rgba(255, 105, 105, 0.12);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #ebd8c4;
  font-weight: 700;
  font-size: 0.92rem;
}

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

.url-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  font: inherit;
}

.url-row input:focus {
  outline: 1px solid rgba(108, 184, 255, 0.7);
}

.url-row button,
.mode-btn,
.transcript-trigger {
  font: inherit;
}

.url-row button {
  padding: 11px 16px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0ceb0 0%, #b27a49 100%);
  color: #1a1412;
  font-weight: 800;
  cursor: pointer;
}

.transcript-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border);
}

.transcript-head h3 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.transcript-meta {
  margin: 10px 0 0;
  color: #c9b39a;
  line-height: 1.6;
}

.view-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.mode-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.transcript-list {
  overflow: auto;
  padding: 14px 8px 8px;
  flex: 1;
  min-height: 0;
  scroll-behavior: smooth;
}

.empty-state {
  margin: 22px 0;
  padding: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: #d7c3af;
  line-height: 1.8;
  background: rgba(255, 255, 255, 0.03);
}

.transcript-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 5px 0 7px;
  user-select: text;
}

.transcript-trigger {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 16px;
  transition: background 160ms ease, transform 160ms ease;
  user-select: text;
}

.transcript-trigger:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(3px);
}

.english-line {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
  color: #efe2d3;
}

.translation {
  display: none;
  margin: 6px 0 0;
  padding: 0 0 2px;
  color: #d3dbe4;
  line-height: 1.65;
  font-size: 0.92rem;
}

.translation:empty {
  display: none !important;
}

.transcript-item.is-open .translation,
.transcript-list.show-all .translation {
  display: block;
}

.transcript-item.is-open .transcript-trigger {
  background: rgba(108, 184, 255, 0.08);
}

.transcript-item.is-active .transcript-trigger {
  background: linear-gradient(90deg, rgba(226, 190, 150, 0.18) 0%, rgba(226, 190, 150, 0.05) 100%);
  box-shadow: inset 3px 0 0 rgba(226, 190, 150, 0.7), 0 10px 30px rgba(0, 0, 0, 0.16);
}

.transcript-item.is-active .english-line {
  color: #fff4e6;
}

.transcript-item.is-open .english-line {
  color: var(--accent);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    padding: 78px 16px 16px;
  }

  .panel-resizer {
    display: none;
  }

  .player-panel,
  .transcript-panel {
    height: auto;
    min-height: auto;
    margin: 0;
  }

  .player-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: auto;
  }

  .panel-head h1 {
    max-width: none;
  }

  .app-home-link-wrap {
    top: 14px;
    left: 16px;
  }
}

@media (max-width: 640px) {
  .player-panel,
  .transcript-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .transcript-head {
    flex-direction: column;
    align-items: start;
  }

  .url-row {
    flex-direction: column;
  }
}
