:root {
  color-scheme: dark;
  --bg: #10141b;
  --panel: #181f29;
  --field: #111821;
  --border: #333f4f;
  --ink: #f0f4fa;
  --muted: #a9b7cb;
  --accent: #b9ed8d;
  --accent-ink: #17220e;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea { font: inherit; }
button {
  min-height: 44px;
  padding: .55rem .85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { cursor: default; opacity: .55; }
p { margin: 0; }
h1, h2 { margin: 0; line-height: 1.15; }
h2 { font-size: 1.18rem; }

.topbar {
  border-bottom: 1px solid var(--border);
  background: #141923;
}
.topbar-inner, main {
  width: min(1080px, calc(100% - 2.5rem));
  margin-inline: auto;
}
.topbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem 1rem;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; }
.brand-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.15rem;
}
nav, .mode { display: flex; flex-wrap: wrap; gap: .25rem; }
.nav-button { color: var(--muted); }
.button-link, a.nav-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .55rem .85rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.button-link.primary { color: var(--accent-ink); }
a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.nav-button:hover, .text-button:hover { background: #253040; color: var(--ink); }
.nav-button[aria-pressed=true], .nav-button[aria-current=page] {
  background: #293748;
  color: var(--ink);
}
main { padding-block: clamp(1.6rem, 4vw, 3.4rem); }
.movie {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .8rem;
  padding-bottom: 1.55rem;
}
.meta, .label, .cue, .help, .extent { color: var(--muted); font-size: .875rem; }
.meta span { margin-inline: .25rem; }
h1 {
  font-size: clamp(2.4rem, 7vw, 4rem);
  letter-spacing: -.055em;
  margin-top: .15rem;
}
.cue {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem .7rem;
  white-space: nowrap;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
  align-items: start;
  gap: 1rem;
}
.film-study {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
  gap: .75rem 1.4rem;
  margin-bottom: 1rem;
}
.training-route { margin-bottom: 1rem; }
.training-route summary { font-weight: 600; cursor: pointer; }
#training-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem 1rem; margin-top: .55rem; }
.training-stages { display: flex; flex-wrap: wrap; gap: .25rem; margin: .2rem 0 0; padding: 0; list-style: none; }
.training-stages a { display: inline-flex; align-items: center; min-height: 38px; padding: .25rem .5rem; border-radius: 6px; color: var(--ink); font-size: .875rem; text-decoration: none; }
.training-stages a:hover { background: var(--field); }
.training-stages a[aria-current=step] { background: var(--field); color: var(--accent); }
@media (max-width: 660px) { #training-groups { grid-template-columns: minmax(0, 1fr); } }
.film-study label { display: block; margin-bottom: .28rem; font-weight: 600; }
.film-study progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.film-meters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: .65rem 1rem;
}
.film-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.film-progress-heading label { margin: 0; }
.film-progress-details { position: relative; flex-shrink: 0; }
.film-progress-details summary {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding-inline: .25rem;
  border-radius: 6px;
  list-style: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.film-progress-details summary::-webkit-details-marker { display: none; }
.film-progress-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.film-progress-tooltip {
  position: absolute;
  z-index: 1;
  inset: 100% 0 auto auto;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  visibility: hidden;
}
#film-learned-count {
  width: max-content;
  max-width: min(16rem, calc(100vw - 3rem));
  white-space: normal;
  overflow-wrap: anywhere;
}
.film-progress-details[open] .film-progress-tooltip,
.film-progress-details summary:focus-visible .film-progress-tooltip { visibility: visible; }
@media (hover: hover) {
  .film-progress-details:hover .film-progress-tooltip { visibility: visible; }
}
.study-selector select {
  width: 100%;
  min-height: 44px;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}
.study-selector button { margin-top: .5rem; }
#mark-reviewed[aria-pressed=true] { color: var(--accent); }
@media (max-width: 660px) { .film-study { grid-template-columns: minmax(0, 1fr); } }
.panel {
  padding: clamp(1rem, 3vw, 1.8rem);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}
.phrase {
  font-size: clamp(1.55rem, 3.6vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: -.025em;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.panel > .phrase { margin: .35rem 0 1.6rem; }
.panel > [data-english] { margin-bottom: .3rem; }
.word-help { margin-top: .3rem; }
.panel > .word-help { margin-bottom: 1.1rem; }
.word {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline dotted;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
.word:hover, .word[data-speaking], .word[data-selected] {
  color: var(--accent);
  text-decoration-color: currentColor;
}
.audio-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.text-button { color: var(--accent); font-size: .875rem; }
.audio-heading .text-button { margin-right: -.55rem; }
.help { line-height: 1.45; }
.waveform {
  position: relative;
  height: 110px;
  margin: .95rem 10px 0;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
}
#wave, #selection, #playhead { position: absolute; pointer-events: none; }
#wave { inset: 0; width: 100%; height: 100%; border-radius: inherit; }
#selection {
  top: 0;
  bottom: 0;
  background: #b9ed8d24;
  border-block: 2px solid #b9ed8d78;
}
#playhead { top: 0; bottom: 0; width: 2px; background: white; }
.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
  cursor: ew-resize;
  touch-action: none;
}
.handle::before, .handle::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
}
.handle::before { top: 0; bottom: 0; width: 2px; }
.handle::after { top: 3px; width: 12px; height: 12px; border-radius: 4px; }
#end-handle::after { top: auto; bottom: 3px; }
.extent, .boundaries { display: flex; justify-content: space-between; }
.extent { margin: .25rem 10px .8rem; font-variant-numeric: tabular-nums; }
.boundaries { flex-wrap: wrap; gap: .7rem 1rem; }
.boundary { display: grid; gap: .25rem; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper button, .icon-button {
  width: 44px;
  padding: 0;
  border-color: var(--border);
  background: var(--field);
  font-size: 1.15rem;
}
output { min-width: 9ch; text-align: center; font-variant-numeric: tabular-nums; }
.actions, .card-footer, .card-audio-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions { margin-top: 1.1rem; }
.film-gain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(7rem, 1fr) 5ch;
  align-items: center;
  gap: .55rem;
  max-width: 25rem;
  margin: .7rem 0;
  color: var(--muted);
  font-size: .875rem;
}
.film-gain input {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}
.film-gain [data-gain-value] { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #d3ffaa; }
.secondary { border-color: var(--border); background: var(--field); }
.secondary:hover, .stepper button:hover, .icon-button:hover { background: #293748; }
.export { margin-left: auto; }
.error { margin-top: .65rem; color: #ffb5a8; }

.notes label { display: block; margin: 1rem 0 .35rem; font-size: .9rem; }
textarea {
  display: block;
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  resize: vertical;
}
.notes .primary { margin-top: 1rem; }
.notes .field-hint { margin-bottom: .45rem; }
#storage-note { margin-top: .65rem; }
.practice { max-width: 685px; margin-inline: auto; }
.mode { margin-bottom: .8rem; }
.card { min-height: 355px; display: flex; flex-direction: column; }
.card .phrase, .card-audio-actions { margin-top: .7rem; }
#play-text-card { margin-top: .65rem; }
.card-footer { margin-top: auto; padding-top: 1.65rem; }
#card-translation, #card-literal, .explanation { white-space: pre-wrap; overflow-wrap: anywhere; }
#card-literal { margin: .3rem 0 1rem; }
.translation-heading {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .65rem;
  align-items: center;
  justify-content: space-between;
}
#ru-audio-note { margin-top: .5rem; }
#card-back .text-button[data-speaking], #card-info-dialog .text-button[data-speaking] { background: #293748; }
#info-button { margin-top: .9rem; }
.explanation {
  margin-top: .7rem;
  padding: .7rem .85rem;
  border-left: 2px solid var(--accent);
  background: var(--field);
  color: var(--muted);
}

.examples-page { max-width: 780px; }
.examples-dialog {
  width: min(740px, calc(100% - 1.25rem));
  max-height: min(80vh, 820px);
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  color: var(--ink);
}
.examples-dialog::backdrop { background: rgb(0 0 0 / .68); }
.examples-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}
.examples-heading { margin: .4rem 0 1rem; overflow-wrap: anywhere; }
.example-list {
  display: grid;
  gap: .65rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}
.example-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .85rem 1rem;
  background: var(--panel);
}
.example-text { overflow-wrap: anywhere; }
.example-text mark { background: #3b4935; color: var(--accent); border-radius: 3px; }
.example-meta { margin-top: .2rem; }
.example-item button[data-playing] { color: var(--accent); }
.example-item button { min-width: 8.5rem; }
.example-actions { display: grid; gap: .3rem; }
.example-actions a { color: var(--accent); font-size: .875rem; text-align: center; }
.vocab-main { max-width: 760px; }
.vocab-main h1 { margin-bottom: 1rem; }
.vocab-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.vocab-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.vocab-term { margin: .55rem 0 1rem; }
.vocab-origin { display: inline-block; margin-top: .65rem; color: var(--accent); }
.vocab-note { color: var(--muted); margin-top: .6rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.vocab-add { margin-top: 1rem; }
.vocab-add summary { font-weight: 600; cursor: pointer; }
.vocab-form label { display: block; margin-top: .75rem; }
.vocab-form input {
  width: 100%;
  padding: .6rem .75rem;
  margin-top: .3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}
.vocab-form button { margin-top: .8rem; }
.vocab-form .help { margin-top: .45rem; }
.learning-page { scrollbar-gutter: stable; }
.learning-header .topbar-inner, .learning-main { max-width: 42rem; }
.learning-header .topbar-inner { min-height: 3rem; padding-block: 0; }
.learning-header h1 { margin: 0; font-size: 1.05rem; letter-spacing: normal; }
.learning-header a.nav-button { padding-inline: .55rem; }
.learning-main { padding-block: .35rem 2rem; }
.login-main { max-width: 28rem; padding-block: 2rem; }
.login-form { display: grid; gap: .8rem; }
.login-form label { display: grid; gap: .35rem; }
.login-form button { justify-self: start; }
.learn-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin-bottom: .25rem; }
.learn-context { display: flex; align-items: center; gap: .3rem; margin-inline-end: auto; }
#learn-film-summary { font-size: .875rem; padding-inline: .35rem; }
#learn-film-count { inset-inline: -4rem auto; }
.learn-toolbar button { padding-inline: .6rem; }
#learn-progress {
  appearance: none;
  display: block;
  width: 100%;
  height: .3rem;
  margin: 0 0 .65rem;
  border: 0;
  border-radius: 999px;
  background: var(--border);
}
#learn-progress::-webkit-progress-bar { border-radius: 999px; background: var(--border); }
#learn-progress::-webkit-progress-value { border-radius: 999px; background: var(--accent); }
#learn-progress::-moz-progress-bar { border-radius: 999px; background: var(--accent); }
.learn-stages { display: grid; gap: .25rem; margin: .65rem 0 0; padding: 0; list-style: none; }
.learn-stages li { padding: .3rem .5rem; color: var(--muted); border-radius: 6px; font-size: .875rem; }
.learn-stages li[aria-current=step] { background: var(--field); color: var(--accent); }
.learn-stages li[data-done] { color: var(--ink); }
#learn-feedback:not(:empty) { margin-bottom: .55rem; }
.learn-card .phrase { margin-block: .65rem 1rem; }
.learn-listen { margin-top: .65rem; }
#learn-hint-status { margin-top: .4rem; color: var(--accent); }
.learn-card h2 + .help, #learn-timer { margin-top: .55rem; }
.learn-dialog { width: min(31rem, calc(100% - 1.25rem)); }
.learn-dialog .examples-dialog-header { align-items: center; margin-bottom: .65rem; }
.learn-dialog .phrase { margin-block: .4rem .85rem; }
.learn-reviews ul { display: grid; gap: .5rem; list-style: none; margin: .65rem 0 0; padding: 0; }
.learn-review-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .5rem; }
.learn-review-row a { color: var(--accent); font-size: .875rem; }

.popular-catalog { display: grid; gap: .95rem; }
.popular-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.popular-section { line-height: 1.25; }
.popular-list { margin: .65rem 0 0; padding-inline-start: 1.65rem; }
ul.popular-list { list-style: none; padding-inline-start: 0; }
.popular-list li::marker { color: var(--muted); }
.popular-item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .2rem .65rem;
  border-bottom: 1px solid var(--border);
  padding: .35rem .15rem;
  overflow-wrap: anywhere;
}
.popular-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .5rem; }
.popular-item a { color: var(--ink); font-weight: 600; text-underline-offset: .2rem; }
.popular-item a:hover { color: var(--accent); }
.popular-item-details:empty { display: none; }
.popular-personal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.popular-personal h3, .popular-add h3 { margin: 0; font-size: 1rem; }
.popular-personal .button-link { margin-top: .65rem; }
.popular-add { display: grid; gap: .65rem; border-top: 1px solid var(--border); padding-top: .85rem; }
.popular-add label { display: grid; gap: .25rem; font-size: .9rem; }
.popular-add input, .popular-add select {
  width: 100%;
  min-height: 44px;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}
.popular-add button { justify-self: start; }
.popular-back { margin-bottom: .6rem; }
#learn-emma-note { margin-top: .8rem; }

@media (max-width: 440px) {
  .popular-personal { grid-template-columns: minmax(0, 1fr); }
  .popular-section { font-size: .875rem; }
}

@media (max-width: 550px) {
  .example-item { grid-template-columns: minmax(0, 1fr); }
  .example-item button { justify-self: start; }
}

@media (max-width: 780px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 500px) {
  .topbar-inner, main { width: calc(100% - 1.4rem); }
  .topbar-inner { flex-wrap: wrap; padding-block: .55rem; }
  .export { margin-left: 0; }
}

.study-profile-controls { display: flex; align-items: center; gap: .15rem; min-width: 0; }
.profile-trigger { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-control { position: relative; display: inline-flex; }
#stock-open { min-width: 2.5rem; font-variant-numeric: tabular-nums; }
.stock-tooltip {
  position: absolute;
  top: calc(100% + .2rem);
  right: -2rem;
  z-index: 1;
  padding: .35rem .55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font-size: .8rem;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
}
.stock-control:hover .stock-tooltip, .stock-control:focus-within .stock-tooltip { visibility: visible; }
#profile-welcome button { margin-top: 1rem; }
.profile-list { display: grid; gap: .35rem; margin: 0 0 .8rem; padding: 0; list-style: none; }
.profile-list:empty { display: none; }
.profile-list button { width: 100%; text-align: start; overflow-wrap: anywhere; }
.profile-list button[aria-current] { border-color: var(--accent); color: var(--accent); }
.profile-create { display: grid; gap: .4rem; }
.profile-create label { font-size: .9rem; }
.profile-form-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.profile-form-row input {
  min-width: 0;
  min-height: 44px;
  flex: 1 1 9rem;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}
.profile-form-row input:focus-visible, #stock-week:focus-visible { outline: 2px solid var(--accent); }
.profile-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
#profile-status { margin-top: .65rem; overflow-wrap: anywhere; }
#media-status { margin-bottom: .65rem; overflow-wrap: anywhere; }
.stock-dialog { width: min(40rem, calc(100% - 1.25rem)); }
.stock-week-detail { margin-top: .7rem; min-height: 1.5rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.stock-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 1px;
  height: clamp(7rem, 32vh, 11rem);
  margin-top: .55rem;
  border-bottom: 1px solid var(--border);
  background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--border) calc(25% - 1px) 25%);
}
.stock-bar { display: grid; align-items: end; min-width: 0; padding-block: 1px; cursor: pointer; }
.stock-bar[data-selected] { background: #303e4f; }
.stock-bar[data-missing]::before { content: ""; border-bottom: 2px dotted var(--muted); opacity: .45; }
.stock-bar progress {
  appearance: none;
  display: block;
  writing-mode: vertical-lr;
  direction: rtl;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 1px;
  max-block-size: 100%;
  border: 0;
  background: transparent;
}
.stock-bar progress::-webkit-progress-bar { background: transparent; }
.stock-bar progress::-webkit-progress-value { background: var(--accent); }
.stock-bar progress::-moz-progress-bar { background: var(--accent); }
.stock-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.stock-scrubber { display: flex; align-items: center; gap: .6rem; margin-top: .55rem; font-size: .85rem; }
#stock-week { flex: 1; min-width: 0; min-height: 44px; accent-color: var(--accent); }
@media (max-width: 430px) {
  .profile-trigger { max-width: 8rem; }
}
