:root {
  color-scheme: dark;
  --bg: #0b1018;
  --surface: #121a26;
  --surface-strong: #182333;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f7fb;
  --muted: #93a0b4;
  --accent: #79f2c5;
  --accent-strong: #32d89b;
  --gold: #ffd166;
  --danger: #ff8b8b;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 2%, rgba(70, 131, 255, 0.14), transparent 26rem),
    radial-gradient(circle at 90% 18%, rgba(50, 216, 155, 0.1), transparent 28rem),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 24, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  color: #07120e;
  background: linear-gradient(135deg, var(--accent), #74a9ff);
  box-shadow: 0 8px 28px rgba(50, 216, 155, 0.18);
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 0 28px 64px;
}

.hero {
  max-width: 900px;
  padding: 66px 0 36px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 15px;
  font-size: clamp(2.3rem, 7vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.hero-copy {
  max-width: 670px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.video-form {
  display: flex;
  gap: 10px;
  max-width: 820px;
}

.video-form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  color: var(--text);
  background: rgba(18, 26, 38, 0.86);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.video-form input {
  min-height: 52px;
  padding: 0 17px;
  border-radius: 15px;
}

.video-form input:focus,
textarea:focus {
  border-color: rgba(121, 242, 197, 0.62);
  box-shadow: 0 0 0 4px rgba(121, 242, 197, 0.1);
}

.form-error {
  min-height: 22px;
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.button,
.chip,
.icon-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 740;
  white-space: nowrap;
}

.button-primary {
  color: #07120e;
  background: var(--accent);
}

.button-primary:hover {
  background: #a4f8d9;
}

.button-secondary {
  color: #07120e;
  background: linear-gradient(135deg, var(--accent), #76b9ff);
}

.button-quiet {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.count {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(121, 242, 197, 0.1);
  font-size: 0.75rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(350px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.video-column {
  display: grid;
  gap: 20px;
}

.card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(24, 35, 51, 0.92), rgba(16, 23, 34, 0.94));
  box-shadow: var(--shadow);
}

.player-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #020304;
}

#player,
#player iframe {
  width: 100%;
  height: 100%;
}

.subtitle-overlay {
  position: absolute;
  z-index: 2;
  right: 4%;
  bottom: clamp(48px, 9%, 78px);
  left: 4%;
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0;
  pointer-events: none;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(1rem, 2.15vw, 1.7rem);
  font-weight: 720;
  line-height: 1.45;
  text-shadow: 0 2px 12px #000, 0 0 3px #000;
}

.subtitle-overlay .word {
  pointer-events: auto;
}

.subtitle-placeholder {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
  font-weight: 500;
}

.player-meta,
.section-heading,
.transcript-heading,
.drawer-heading,
.review-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.player-meta {
  padding: 18px 20px 12px;
}

.video-title {
  margin-bottom: 5px;
  font-weight: 740;
}

.muted,
.hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.player-meta .muted {
  margin-bottom: 0;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.74rem;
  font-weight: 720;
}

.status-pill[data-tone="good"] {
  color: var(--accent);
  background: rgba(121, 242, 197, 0.1);
}

.status-pill[data-tone="warn"] {
  color: var(--gold);
  background: rgba(255, 209, 102, 0.1);
}

.sync-tools {
  display: flex;
  gap: 8px;
  padding: 0 20px 18px;
  overflow-x: auto;
}

.chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(121, 242, 197, 0.35);
}

.transcript-card {
  position: sticky;
  top: 88px;
  display: flex;
  height: min(760px, calc(100vh - 110px));
  min-height: 520px;
  flex-direction: column;
  padding: 20px 0 0;
}

.transcript-heading,
.transcript-card .hint {
  padding-right: 20px;
  padding-left: 20px;
}

.count-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint {
  margin: 10px 0 14px;
  line-height: 1.55;
}

.transcript {
  flex: 1;
  margin: 0;
  padding: 0 10px 18px;
  overflow: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.cue {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 11px;
  padding: 12px 10px;
  border-radius: 13px;
  color: #c6ced9;
  line-height: 1.58;
  transition: color 140ms ease, background 140ms ease;
}

.cue.active {
  color: var(--text);
  background: rgba(121, 242, 197, 0.09);
}

.cue-time {
  align-self: start;
  padding: 3px 0;
  border: 0;
  color: var(--accent);
  background: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.cue-text {
  min-width: 0;
}

.word {
  display: inline;
  margin: 0;
  padding: 1px 2px;
  border: 0;
  border-radius: 5px;
  color: inherit;
  background: transparent;
  cursor: help;
  font-weight: inherit;
  line-height: inherit;
}

.word:hover,
.word:focus-visible {
  outline: none;
  color: #07120e;
  background: var(--accent);
}

.word.saved {
  color: var(--gold);
  box-shadow: inset 0 -1px currentColor;
}

.word.saved:hover {
  color: #07120e;
}

.empty-state {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 10px 0 3px;
}

.empty-state.compact {
  min-height: 180px;
}

.loader {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.review-card {
  padding: 22px;
}

.review-summary {
  margin: 0;
  color: var(--gold);
  font-weight: 720;
}

.review-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.review-form label {
  color: var(--muted);
  font-size: 0.8rem;
}

textarea {
  min-height: 88px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 13px;
  line-height: 1.5;
}

.stars {
  display: flex;
  gap: 3px;
}

.stars button {
  padding: 2px;
  border: 0;
  color: #445066;
  background: none;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.stars button.active {
  color: var(--gold);
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.review-item {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.review-item p {
  margin: 5px 0 0;
  color: #cbd3df;
  line-height: 1.55;
}

.review-stars {
  color: var(--gold);
  letter-spacing: 0.08em;
}

.drawer {
  position: fixed;
  z-index: 40;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(0, 0, 0, 0.58);
  transition: opacity 180ms ease;
}

.drawer.open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 92vw);
  height: 100%;
  padding: 24px 18px max(24px, env(safe-area-inset-bottom));
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #101722;
  box-shadow: -24px 0 80px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 220ms ease;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.3rem;
}

.saved-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.saved-item {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

.saved-item h3 {
  margin: 0 0 5px;
  font-size: 1.05rem;
}

.saved-item p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.saved-item a {
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
}

.dictionary-dialog {
  width: min(570px, calc(100vw - 28px));
  max-height: min(720px, calc(100dvh - 28px));
  padding: 28px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: #131c28;
  box-shadow: var(--shadow);
}

.dictionary-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.dictionary-word {
  margin: 0 46px 4px 0;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
}

.phonetic {
  color: var(--accent);
}

.meaning {
  margin-top: 20px;
}

.part-of-speech {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.definition {
  margin: 8px 0;
  color: #d8dee8;
  line-height: 1.55;
}

.example {
  color: var(--muted);
  font-size: 0.87rem;
  font-style: italic;
}

.dictionary-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 980px) {
  main {
    padding-right: 18px;
    padding-left: 18px;
  }

  .hero {
    padding-top: 44px;
  }

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

  .transcript-card {
    position: static;
    height: 620px;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 60px;
  }

  main {
    padding: 0 12px max(34px, env(safe-area-inset-bottom));
  }

  .hero {
    padding: 38px 4px 22px;
  }

  h1 {
    font-size: clamp(2.25rem, 13vw, 3.6rem);
  }

  .video-form {
    flex-direction: column;
  }

  .video-form .button {
    width: 100%;
  }

  .card {
    border-radius: 17px;
  }

  .player-meta,
  .section-heading,
  .review-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .subtitle-overlay {
    right: 2.5%;
    bottom: 38px;
    left: 2.5%;
    font-size: clamp(0.86rem, 4.2vw, 1.15rem);
  }

  .sync-tools {
    padding-right: 14px;
    padding-left: 14px;
  }

  .transcript-card {
    height: 72dvh;
    min-height: 480px;
  }

  .cue {
    grid-template-columns: 46px 1fr;
    gap: 7px;
    padding: 11px 7px;
  }

  .word {
    padding: 3px 2px;
    cursor: pointer;
  }

  .review-card {
    padding: 18px;
  }

  .review-actions .button {
    width: 100%;
  }

  .dictionary-dialog {
    width: 100%;
    max-width: none;
    max-height: 82dvh;
    margin: auto 0 0;
    padding: 24px 18px max(24px, env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
  }

  .dictionary-actions {
    flex-direction: column;
  }

  .dictionary-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
