:root {
  --bg: #080908;
  --surface: #101210;
  --surface-soft: #151816;
  --surface-strong: #1b211d;
  --ink: #f5f2e8;
  --ink-soft: #c5c1b5;
  --muted: #858b82;
  --line: rgba(245, 242, 232, 0.1);
  --line-strong: rgba(245, 242, 232, 0.18);
  --accent: #96d8b1;
  --accent-strong: #b8f0cd;
  --amber: #d8ba73;
  --danger: #d58a8a;
  --shadow: 0 28px 88px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(150, 216, 177, 0.055), transparent 340px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 6px),
    var(--bg);
}

body.focus-mode {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.topbar-actions,
.panel-heading,
.panel-actions,
.input-footer,
.reader-toolbar,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 16px;
}

.topbar-actions,
.panel-actions {
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.24;
}

.session-status,
.progress-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(16, 18, 16, 0.72);
  font-size: 13px;
  font-weight: 750;
}

.workspace {
  min-height: calc(100vh - 190px);
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.input-panel,
.reader-panel,
.transcript-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 16, 0.8);
  box-shadow: var(--shadow);
}

.input-panel,
.reader-panel {
  min-height: 680px;
  padding: 18px;
}

.input-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.reader-panel {
  display: grid;
  grid-template-rows: auto minmax(460px, 1fr) auto auto;
  gap: 14px;
}

.ghost-button,
.primary-button,
.control-button,
.option-button,
.auto-toggle {
  border-radius: 8px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: rgba(21, 24, 22, 0.72);
  font-weight: 760;
}

.ghost-button:hover,
.control-button:hover:not(:disabled),
.option-button:hover,
.auto-toggle:hover,
.primary-button:hover {
  border-color: var(--line-strong);
  background-color: rgba(245, 242, 232, 0.08);
}

textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: rgba(8, 9, 8, 0.78);
  line-height: 1.68;
}

textarea:focus {
  border-color: rgba(150, 216, 177, 0.36);
  box-shadow: 0 0 0 3px rgba(150, 216, 177, 0.08);
}

textarea::placeholder {
  color: #6e756c;
}

.input-footer {
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(150, 216, 177, 0.4);
  color: #06100a;
  background: var(--accent);
  font-weight: 880;
}

.primary-button:hover {
  color: #06100a;
  background: var(--accent-strong);
}

.reader-stage {
  display: grid;
  align-content: center;
  min-height: 0;
  padding: 5vh clamp(22px, 5vw, 72px);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(245, 242, 232, 0.035), transparent 42%),
    rgba(8, 9, 8, 0.82);
  overflow: hidden;
}

.sentence-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.next-label {
  margin-top: 36px;
}

.current-sentence,
.next-sentence {
  transition: opacity 240ms ease, transform 240ms ease, color 200ms ease;
}

.current-sentence {
  min-height: 210px;
  margin: 0;
  color: #fffaf0;
  font-size: clamp(48px, 5.4vw, 64px);
  font-weight: 860;
  line-height: 1.34;
  text-wrap: balance;
  text-shadow: 0 0 30px rgba(150, 216, 177, 0.12);
}

.current-sentence.is-empty {
  color: #737a71;
}

.current-sentence.is-active {
  color: var(--accent-strong);
}

.current-sentence.is-transitioning,
.next-sentence.is-transitioning {
  opacity: 0;
  transform: translateY(8px);
}

.next-sentence {
  min-height: 74px;
  margin: 0;
  color: rgba(245, 242, 232, 0.48);
  font-size: clamp(19px, 2vw, 28px);
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.control-button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px;
  border: 1px solid transparent;
  background: rgba(21, 24, 22, 0.58);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.control-button span:first-child {
  font-size: 24px;
  line-height: 1;
}

.main-control {
  border-color: rgba(150, 216, 177, 0.22);
  color: var(--ink);
  background: rgba(150, 216, 177, 0.11);
}

.main-control:not(:disabled) {
  box-shadow: inset 0 0 0 1px rgba(150, 216, 177, 0.05);
}

.reader-settings {
  display: grid;
  gap: 10px;
}

.setting-row {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(21, 24, 22, 0.42);
  font-size: 13px;
  font-weight: 820;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.option-button,
.auto-toggle {
  min-width: 50px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: rgba(8, 9, 8, 0.58);
  font-weight: 850;
}

.option-button.is-active,
.auto-toggle.is-active {
  border-color: rgba(150, 216, 177, 0.44);
  color: #06100a;
  background: var(--accent);
}

.experimental-option {
  color: var(--amber);
}

.auto-toggle {
  min-width: 92px;
}

.transcript-panel {
  margin-top: 16px;
  padding: 18px;
}

.subtitle-list {
  max-height: 260px;
  margin: 14px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.subtitle-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  color: rgba(245, 242, 232, 0.58);
  line-height: 1.56;
  cursor: pointer;
}

.subtitle-item:first-child {
  border-top: 0;
}

.subtitle-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.subtitle-item.is-active {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(150, 216, 177, 0.1), transparent 72%);
}

.subtitle-item.is-active .subtitle-index {
  color: var(--accent);
}

.subtitle-empty {
  margin: 0;
  padding: 20px 0 4px;
  color: var(--muted);
}

.subtitle-window-note {
  margin: 0;
  padding: 10px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.app-shell.has-error .session-status {
  border-color: rgba(213, 138, 138, 0.4);
  color: var(--danger);
}

body.focus-mode .app-shell {
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

body.focus-mode .topbar,
body.focus-mode .input-panel,
body.focus-mode .transcript-panel,
body.focus-mode .reader-toolbar,
body.focus-mode .reader-settings,
body.focus-mode .secondary-control,
body.focus-mode .sentence-label {
  display: none;
}

body.focus-mode .workspace {
  min-height: 100vh;
  display: block;
}

body.focus-mode .reader-panel {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0;
  padding: clamp(18px, 4vw, 56px);
  border: 0;
  border-radius: 0;
  background: #070807;
  box-shadow: none;
}

body.focus-mode .reader-stage {
  min-height: 0;
  align-content: center;
  justify-items: center;
  padding: 0 clamp(16px, 9vw, 140px);
  background: transparent;
}

body.focus-mode .current-sentence {
  width: min(1120px, 100%);
  min-height: 0;
  text-align: center;
  font-size: clamp(58px, 7vw, 88px);
  line-height: 1.28;
}

body.focus-mode .next-sentence {
  width: min(900px, 100%);
  min-height: 0;
  margin-top: 34px;
  text-align: center;
  font-size: clamp(22px, 3vw, 38px);
  opacity: 0.54;
}

body.focus-mode .controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px);
  justify-content: center;
  padding-bottom: clamp(12px, 4vh, 52px);
}

body.focus-mode .main-control {
  min-height: 64px;
  border-color: rgba(150, 216, 177, 0.28);
  background: rgba(150, 216, 177, 0.12);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .reader-panel {
    min-height: auto;
  }

  .reader-panel {
    grid-template-rows: auto minmax(520px, auto) auto auto;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1360px);
    padding: 18px 0 28px;
  }

  .topbar,
  .panel-heading,
  .input-footer,
  .reader-toolbar,
  .setting-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-actions,
  .option-group {
    justify-content: stretch;
  }

  .ghost-button,
  .primary-button,
  .option-button,
  .auto-toggle {
    width: 100%;
  }

  h1 {
    font-size: 30px;
  }

  .reader-panel {
    grid-template-rows: auto minmax(430px, auto) auto auto;
  }

  .reader-stage {
    padding: 30px 20px;
  }

  .current-sentence {
    min-height: 156px;
    font-size: clamp(38px, 10vw, 48px);
  }

  .next-sentence {
    font-size: 18px;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.focus-mode .current-sentence {
    font-size: clamp(42px, 12vw, 64px);
  }

  body.focus-mode .next-sentence {
    font-size: clamp(19px, 6vw, 28px);
  }
}
