:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #171b22;
  --panel-soft: #202632;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f3f6fa;
  --muted: #aeb7c5;
  --dim: #7f8a9c;
  --accent: #e6c67a;
  --accent-2: #82d4c7;
  --danger: #ff8e8e;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 0%, rgba(130, 212, 199, 0.1), transparent 26rem),
    #111318;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.58;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 24, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a {
  padding: 7px 4px;
}

.engine-shell {
  width: min(880px, calc(100% - 32px));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 40px 0;
}

.engine-panel {
  width: 100%;
}

.engine-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
}

.engine-box input {
  min-width: 0;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 20px;
  background: #0d1016;
  color: var(--text);
  outline: none;
  font-size: 18px;
}

.engine-box input::placeholder {
  color: transparent;
}

.engine-box input:focus {
  border-color: rgba(130, 212, 199, 0.72);
}

.engine-box button,
.reader-control button,
.reader-control select,
.filter,
.tab,
.listen-inline,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.engine-box button {
  min-width: 92px;
  height: 64px;
  background: var(--accent);
  color: #17130b;
  font-weight: 800;
}

.engine-message,
.message {
  margin: 14px 0 0;
  color: var(--muted);
}

.learn-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(24px, 4vw, 46px) 0 70px;
}

.movie-header,
.sentence-item,
.word-row,
.directory-header,
.material-row,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.88);
}

.movie-header {
  margin-bottom: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1;
  letter-spacing: 0;
}

.movie-header h1 {
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.08;
  max-width: 14ch;
}

.reader-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 16, 22, 0.58);
}

.reader-control select,
.reader-control button,
.filter,
.tab,
.listen-inline {
  min-height: 42px;
  padding: 0 14px;
}

.reader-control button:not(.ghost-control),
.listen-inline {
  background: rgba(230, 198, 122, 0.16);
  border-color: rgba(230, 198, 122, 0.48);
  color: var(--accent);
}

.reader-control button {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.reader-control button:active,
.icon-btn:active,
.word-row:active,
.material-row:active {
  transform: scale(0.98);
}

.reader-control button.is-active {
  background: rgba(230, 198, 122, 0.28);
  border-color: rgba(230, 198, 122, 0.9);
  box-shadow: 0 0 0 4px rgba(230, 198, 122, 0.1);
}

.reader-control button.is-paused {
  background: rgba(130, 212, 199, 0.16);
  border-color: rgba(130, 212, 199, 0.6);
  color: var(--accent-2);
}

body.is-reading .reader-control {
  border-color: rgba(230, 198, 122, 0.42);
}

body.is-paused .reader-control {
  border-color: rgba(130, 212, 199, 0.42);
}

.reader-control select {
  min-width: 148px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    var(--panel-soft);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px,
    0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}

.reader-control button {
  min-width: 46px;
  font-size: 16px;
  line-height: 1;
}

.ghost-control {
  color: var(--muted);
}

.tabs,
.sentence-toolbar {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  overflow-x: auto;
}

.sentence-toolbar {
  justify-content: space-between;
  align-items: center;
}

.sentence-filters {
  display: flex;
  gap: 8px;
}

.tab.active,
.filter.active {
  border-color: rgba(230, 198, 122, 0.8);
  background: rgba(230, 198, 122, 0.16);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.word-list {
  display: grid;
  gap: 10px;
}

.word-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 106px;
  padding: 16px;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.word-row:hover,
.material-row:hover,
.sentence-item:hover {
  border-color: rgba(130, 212, 199, 0.34);
  background: rgba(27, 33, 42, 0.94);
}

.word-row.is-current,
.sentence-item.is-current {
  border-color: rgba(230, 198, 122, 0.82);
  background: rgba(230, 198, 122, 0.08);
  box-shadow: inset 3px 0 0 rgba(230, 198, 122, 0.82);
}

.word-index {
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.word-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.word-title-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.word-title-line h3,
.word-card h3 {
  margin-bottom: 0;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.05;
}

.word-title-line span,
.translation,
.note,
.transfer,
.word-card-head p {
  color: var(--muted);
  font-size: 14px;
}

.translation-shell {
  display: grid;
  gap: 8px;
  align-items: start;
}

.translation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  border: 1px solid rgba(130, 212, 199, 0.18);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(130, 212, 199, 0.08);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
}

.translation-toggle:hover,
.translation-toggle:focus {
  border-color: rgba(130, 212, 199, 0.38);
  background: rgba(130, 212, 199, 0.14);
  outline: none;
}

.translation-toggle-mark {
  width: 14px;
  text-align: center;
  font-size: 14px;
}

.translation-panel {
  display: none;
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid rgba(230, 198, 122, 0.42);
  border-radius: 8px;
  background: rgba(13, 16, 22, 0.55);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.translation-shell.is-open .translation-panel {
  display: block;
}

.translation-shell.is-open .translation-toggle {
  border-color: rgba(230, 198, 122, 0.44);
  background: rgba(230, 198, 122, 0.12);
  color: var(--accent);
}

.bubble-shell {
  gap: 6px;
}

.bubble-meaning {
  color: var(--accent);
}

.sentence-shell .translation-panel,
.bubble-shell .translation-panel {
  background: rgba(255, 255, 255, 0.04);
}

.meaning {
  color: var(--text);
  font-weight: 650;
}

.transfer {
  margin-bottom: 0;
}

.icon-btn {
  min-width: 42px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--accent);
}

.speaker-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 38px;
  padding: 0;
  font-size: 17px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.speaker-btn:hover,
.speaker-btn:focus {
  border-color: rgba(130, 212, 199, 0.5);
  background: rgba(130, 212, 199, 0.1);
  outline: none;
}

.directory-header {
  margin-bottom: 16px;
  padding: 22px;
}

.directory-header h1 {
  font-size: clamp(38px, 6vw, 72px);
}

.material-list {
  display: grid;
  gap: 10px;
}

.material-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 78px;
  padding: 16px;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.material-index {
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.material-title {
  min-width: 0;
  color: var(--text);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 800;
}

.material-meta {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.sentence-list {
  display: grid;
  gap: 14px;
}

.sentence-item {
  padding: 18px;
}

.sentence-type {
  margin-bottom: 10px;
  color: var(--accent-2);
  font-size: 13px;
}

.sentence-text {
  margin-bottom: 8px;
  color: #f8fafc;
  font-size: clamp(19px, 3vw, 27px);
  line-height: 1.45;
}

.word-token {
  border: 0;
  border-bottom: 1px dashed rgba(130, 212, 199, 0.55);
  padding: 0 1px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.word-token:hover,
.word-token:focus {
  color: var(--accent-2);
  outline: none;
}

.word-bubble {
  position: absolute;
  z-index: 50;
  width: min(272px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid rgba(230, 198, 122, 0.42);
  border-radius: 8px;
  background: #111721;
  box-shadow: var(--shadow);
}

.bubble-head,
.word-card-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.word-bubble p {
  margin-bottom: 8px;
  color: var(--muted);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.word-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 34, 0.88);
  padding: 16px;
}

.empty-state {
  padding: 20px;
}

@media (max-width: 760px) {
  .topbar,
  .compact-header,
  .sentence-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .engine-box {
    grid-template-columns: 1fr;
  }

  .engine-box button {
    width: 100%;
  }

  .reader-control {
    width: 100%;
    justify-content: flex-start;
  }

  .reader-control select,
  .reader-control button,
  .listen-inline {
    flex: 1 1 auto;
  }

  .word-row {
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: start;
  }

  .word-row .icon-btn {
    grid-column: 2;
    width: 42px;
  }

  .material-row {
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: start;
  }

  .material-meta {
    grid-column: 2;
  }

  h1 {
    font-size: 38px;
  }
}
