:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --text: #171717;
  --muted: #737373;
  --line: #dedede;
  --line-strong: #bdbdbd;
  --accent: #111111;
  --green: #1f6f52;
  --green-soft: #edf6f1;
  --red: #d74b3f;
  --red-soft: #fbebe8;
  --yellow-soft: #fff8df;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.word-token:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ambient,
.hero-copy,
.feature-row,
.import-card::before,
.focus-card::after {
  display: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 0;
  background: transparent;
  text-align: left;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 14px;
  font-weight: 650;
}

.brand small {
  color: var(--muted);
  font-size: 10px;
}

.brand-mark {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.brand-mark span {
  display: block;
  width: 2px;
  background: var(--accent);
}

.brand-mark span:nth-child(1) { height: 6px; }
.brand-mark span:nth-child(2) { height: 11px; }
.brand-mark span:nth-child(3) { height: 8px; }
.brand-mark span:nth-child(4) { height: 13px; }

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.engine-pill,
.icon-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-size: 11px;
}

.engine-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  max-width: 260px;
  padding: 0 10px;
  color: var(--muted);
}

.engine-pill:hover,
.icon-button:hover {
  border-color: var(--line-strong);
}

.icon-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 10px;
}

.status-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.status-dot.ready { background: var(--green); }
.status-dot.warn { background: #c58b16; }

main {
  width: 100%;
}

.setup-view {
  width: min(760px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.import-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.import-card-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.card-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.import-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.format-note {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.text-input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.text-input {
  width: 100%;
  height: 40px;
  margin-bottom: 18px;
  padding: 0 11px;
  font-size: 13px;
}

textarea {
  width: 100%;
  height: 220px;
  padding: 11px;
  resize: vertical;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.65;
}

.text-input:focus,
textarea:focus,
select:focus {
  border-color: #888;
}

textarea::placeholder,
.text-input::placeholder {
  color: #aaa;
}

.textarea-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.textarea-head span {
  color: var(--muted);
  font-size: 9px;
}

.textarea-wrap.dragging::after {
  display: grid;
  position: absolute;
  inset: 4px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  background: #f5f5f5;
  content: "松开鼠标以导入文章";
  font-size: 11px;
}

.import-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.file-action {
  display: flex;
  gap: 12px;
}

.text-button,
.primary-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.text-button {
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.text-button:hover {
  color: var(--text);
}

.primary-button {
  padding: 0 14px;
  color: white;
  background: var(--accent);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.privacy-note {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.practice-view {
  min-height: calc(100vh - 57px);
}

.practice-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: stretch;
  min-height: calc(100vh - 57px);
}

.article-panel {
  position: sticky;
  top: 56px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.article-panel-head {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.back-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
}

.article-heading {
  min-width: 0;
}

.article-heading h2 {
  overflow: hidden;
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.article-progress-track {
  height: 2px;
  background: #e7e7e7;
}

.article-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.sentence-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sentence-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: start;
  width: 100%;
  margin-bottom: 2px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
}

.sentence-row:hover {
  background: #f0f0f0;
}

.sentence-row.active {
  border-color: var(--line-strong);
  background: var(--bg);
}

.sentence-number {
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.sentence-copy {
  display: -webkit-box;
  overflow: hidden;
  color: #686868;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.sentence-row.active .sentence-copy {
  color: var(--text);
}

.sentence-state {
  display: flex;
  gap: 3px;
}

.state-mark {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 8px;
}

.state-mark.recorded {
  color: var(--red);
  background: var(--red-soft);
}

.practice-stage {
  min-width: 0;
  padding: 20px 28px 32px;
}

.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.stage-position {
  display: grid;
  gap: 3px;
}

.stage-label {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.stage-position strong {
  font-size: 20px;
  font-weight: 500;
}

.stage-position strong small {
  color: var(--muted);
  font-size: 12px;
}

.settings-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.select-control,
.speed-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 8px;
}

.select-control select {
  width: 140px;
  height: 31px;
  padding: 0 8px;
  font-size: 10px;
}

.repeat-control select {
  width: 82px;
}

.speed-control {
  width: 135px;
}

.speed-control > span {
  display: flex;
  justify-content: space-between;
}

.speed-control strong {
  color: var(--text);
  font-size: 9px;
}

input[type="range"] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--accent);
}

.focus-card {
  padding: 34px 0 24px;
  border-bottom: 1px solid var(--line);
}

.focus-card-top {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.sentence-badge {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-top-right,
.focus-edit-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.focus-hint {
  color: var(--muted);
  font-size: 9px;
}

.edit-sentence-button {
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
  font-size: 9px;
}

.edit-sentence-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.focus-text {
  min-height: 130px;
  margin: 26px 0 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 2.6vw, 36px);
  line-height: 1.45;
}

.transport {
  display: flex;
  gap: 7px;
  align-items: center;
}

.transport-button,
.loop-button,
.play-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.transport-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--muted);
}

.loop-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 11px;
  color: var(--muted);
  font-size: 9px;
}

.loop-button[aria-pressed="true"] {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.play-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 0 18px;
  color: white;
  border-color: var(--accent);
  background: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.play-button .pause-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.playing .pause-icon {
  display: block;
}

.audio-state {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 9px;
}

.audio-wave {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  height: 10px;
}

.audio-wave i {
  width: 2px;
  height: 3px;
  background: var(--accent);
}

.record-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) auto minmax(170px, 0.7fr);
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.record-copy h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.record-copy > p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.record-center {
  display: grid;
  justify-items: center;
}

.record-visualizer {
  display: none;
}

.record-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: white;
  background: var(--red);
}

.record-button .stop-icon {
  display: none;
}

.record-card.recording .record-button .mic-icon {
  display: none;
}

.record-card.recording .record-button .stop-icon {
  display: block;
}

.record-card.starting .record-button {
  color: white;
  background: #a06a00;
}

.record-timer {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.recording-actions {
  display: grid;
  gap: 6px;
}

.guided-button,
.secondary-button,
.ghost-button {
  min-height: 32px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
}

.guided-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  color: var(--green);
  border: 1px solid #cfe3da;
  background: var(--green-soft);
}

.guided-button.active {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.secondary-button,
.ghost-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.secondary-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--bg);
}

.ghost-button {
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.secondary-button .recording-stop-icon {
  display: none;
}

.secondary-button.playing {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.secondary-button.playing .recording-play-icon {
  display: none;
}

.secondary-button.playing .recording-stop-icon {
  display: block;
}

.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.stage-footer {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
}

.complete-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
}

.check-circle {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.check-circle svg {
  opacity: 0;
}

.complete-button.completed {
  color: var(--green);
}

.complete-button.completed .check-circle {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.complete-button.completed .check-circle svg {
  opacity: 1;
}

.stage-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
}

kbd {
  min-width: 18px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  font-family: inherit;
  font-size: 8px;
}

.word-token {
  display: inline;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.word-token:hover,
.word-token:focus-visible,
.word-token.active {
  color: var(--text);
  background: var(--yellow-soft);
  outline: none;
}

.word-token.spoken {
  background: #f5f5f5;
}

.word-token.speaking {
  position: relative;
  color: white;
  background: var(--green);
}

.word-token.speaking::after {
  position: absolute;
  top: -0.05em;
  right: -4px;
  bottom: -0.05em;
  width: 2px;
  background: var(--red);
  content: "";
  animation: cursor-blink 0.75s steps(1) infinite;
}

.word-token.speaking.paused::after {
  animation: none;
}

@keyframes cursor-blink {
  50% { opacity: 0.15; }
}

.word-tooltip {
  position: fixed;
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  max-height: 280px;
  overflow-y: auto;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.word-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.word-tooltip.loading {
  color: var(--muted);
}

.word-tooltip-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 7px;
}

.word-tooltip-head strong {
  font-size: 16px;
}

.word-tooltip-head span {
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
}

.word-tooltip p {
  margin: 0;
  white-space: pre-line;
}

.word-tooltip-translation {
  font-size: 11px;
  line-height: 1.55;
}

.word-tooltip-definition {
  margin-top: 7px !important;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  line-height: 1.5;
}

.word-tooltip-definition:empty {
  display: none;
}

.word-tooltip small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 8px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  color: #7d1e18;
  border-color: #ecc3be;
  background: #fff4f2;
}

.toast.success {
  color: #13553e;
  border-color: #c8e1d5;
  background: #f1faf5;
}

.toast span {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #efefef;
  font-size: 10px;
  font-weight: 700;
}

.toast p {
  margin: 0;
  font-size: 10px;
}

@media (max-width: 900px) {
  .practice-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .practice-stage {
    padding: 16px 18px 28px;
  }

  .record-card {
    grid-template-columns: 1fr auto;
  }

  .recording-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 50px;
    padding: 0 12px;
  }

  .brand small,
  .engine-pill #engineStatus,
  .stage-footer p {
    display: none;
  }

  .setup-view {
    width: calc(100% - 24px);
    padding: 20px 0 40px;
  }

  .import-card {
    padding: 18px;
  }

  .import-card-head {
    display: block;
  }

  .format-note {
    display: inline-block;
    margin-top: 10px;
  }

  .import-footer {
    display: grid;
  }

  .primary-button {
    width: 100%;
  }

  .practice-layout {
    display: block;
  }

  .article-panel {
    position: relative;
    top: 0;
    height: auto;
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .practice-stage {
    padding: 14px 14px 28px;
  }

  .stage-toolbar {
    display: block;
  }

  .settings-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
  }

  .select-control select,
  .speed-control,

  .speed-control {
    grid-column: 1 / -1;
  }

  .focus-card {
    padding-top: 24px;
  }

  .focus-card-top {
    align-items: flex-start;
  }

  .focus-hint {
    display: none;
  }

  .focus-text {
    min-height: 110px;
    font-size: 24px;
  }

  .transport {
    flex-wrap: wrap;
  }

  .play-button {
    order: 3;
    width: 100%;
  }

  .record-card {
    grid-template-columns: 1fr auto;
  }

  .record-copy {
    grid-column: 1 / -1;
  }

  .recording-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .stage-footer {
    display: grid;
  }

  .word-tooltip {
    width: calc(100vw - 20px);
  }
}

/* A quiet inline correction path for translations that need human judgment. */
.focus-translation-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: -10px 0 18px;
}

.focus-translation-row .focus-translation {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.translation-edit-button {
  flex: none;
  padding: 4px 0;
  color: #456755;
  background: none;
  font-size: 12px;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.translation-edit-button:hover,
.translation-edit-button:focus-visible {
  color: #224d39;
}

.translation-editor[hidden],
.translation-restore-button[hidden] {
  display: none;
}

.translation-editor {
  display: grid;
  gap: 9px;
  margin: -5px 0 20px;
  padding: 16px;
  border: 1px solid #cbd9d0;
  border-radius: 14px;
  background: #f5faf6;
}

.translation-editor label {
  color: #315541;
  font-size: 12px;
  font-weight: 700;
}

.translation-editor textarea {
  width: 100%;
  min-height: 82px;
  padding: 11px 13px;
  border: 1px solid #b9c9bd;
  border-radius: 10px;
  background: #fff;
  color: #253128;
  font: inherit;
  line-height: 1.55;
  resize: vertical;
}

.translation-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.translation-editor-actions button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
}

.translation-restore-button {
  margin-right: auto;
  color: #637166;
  background: none;
}

.translation-cancel-button {
  border: 1px solid #cbd9d0;
  background: #fff;
  color: #415347;
}

.translation-save-button {
  background: #2d604a;
  color: #fff;
}

@media (max-width: 700px) {
  .focus-translation-row {
    align-items: flex-start;
  }

  .translation-edit-button {
    margin-top: 3px;
  }
}

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

/* Comfort theme */
:root {
  --bg: #f3f1eb;
  --panel: #f8f6f1;
  --text: #28312c;
  --muted: #747c76;
  --line: #e2ddd3;
  --line-strong: #c9c2b7;
  --accent: #315f4d;
  --green: #316b53;
  --green-soft: #e5efe9;
  --red: #d15f4c;
  --red-soft: #fbe9e4;
  --yellow-soft: #fbf2d4;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.95), transparent 44%),
    var(--bg);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 66px;
  padding: 0 max(20px, calc((100vw - 1400px) / 2));
  border-color: rgba(201, 194, 183, 0.72);
  background: rgba(243, 241, 235, 0.88);
  backdrop-filter: blur(16px);
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand small {
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-color: #b8b3a8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.engine-pill,
.icon-button {
  min-height: 35px;
  border-color: var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 249, 0.76);
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.engine-pill:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: #fffdf9;
  box-shadow: 0 4px 14px rgba(45, 52, 47, 0.05);
}

main {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
}

.setup-view {
  width: min(780px, 100%);
  padding: 64px 0 80px;
}

.import-card {
  padding: clamp(28px, 4vw, 44px);
  border-color: rgba(214, 208, 198, 0.9);
  border-radius: 22px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 18px 60px rgba(55, 60, 55, 0.07);
}

.import-card h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.card-kicker {
  color: var(--accent);
}

.format-note {
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
  font-weight: 700;
}

.text-input,
textarea,
select {
  border-color: #ddd7cc;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
}

.text-input {
  height: 46px;
  padding: 0 14px;
  font-size: 14px;
}

textarea {
  height: 250px;
  padding: 16px;
  font-size: 15px;
  line-height: 1.75;
}

.text-input:focus,
textarea:focus,
select:focus {
  border-color: rgba(49, 95, 77, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 95, 77, 0.08);
  outline: none;
}

.text-button {
  min-height: 38px;
  padding: 0 4px;
}

.primary-button {
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(49, 95, 77, 0.17);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(49, 95, 77, 0.2);
}

.practice-view {
  padding: 20px 0 42px;
}

.practice-layout {
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 108px);
}

.article-panel {
  top: 86px;
  height: calc(100vh - 106px);
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.05);
}

.article-panel-head {
  padding: 17px 16px 14px;
  border-bottom-color: rgba(226, 221, 211, 0.85);
}

.back-button {
  width: 32px;
  height: 32px;
  border-color: var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.68);
}

.article-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
}

.article-progress-track {
  height: 3px;
  background: #e9e5dd;
}

.article-progress-track span {
  background: var(--accent);
}

.sentence-list {
  padding: 10px;
}

.sentence-row {
  padding: 11px 10px;
  border-radius: 11px;
}

.sentence-row:hover {
  background: rgba(49, 95, 77, 0.045);
}

.sentence-row.active {
  border-color: rgba(49, 95, 77, 0.15);
  background: var(--green-soft);
}

.sentence-number {
  padding-top: 1px;
  color: #9b9e98;
  font-weight: 650;
}

.sentence-copy {
  color: #69716b;
  font-size: 12px;
  line-height: 1.55;
}

.practice-stage {
  padding: 0;
}

.stage-toolbar {
  min-height: 68px;
  padding: 14px 18px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.85);
  box-shadow: 0 8px 28px rgba(55, 60, 55, 0.045);
}

.stage-position strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
}

.select-control select {
  height: 35px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
}

.speed-control {
  width: 145px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.focus-card {
  min-height: 300px;
  margin-top: 16px;
  padding: clamp(30px, 4vw, 48px);
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 14px 44px rgba(55, 60, 55, 0.055);
}

.focus-card-top {
  min-height: 28px;
}

.sentence-badge {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
}

.edit-sentence-button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.focus-text {
  min-height: 145px;
  margin: 28px 0;
  font-size: clamp(27px, 3vw, 40px);
  line-height: 1.5;
  letter-spacing: -0.018em;
}

.transport-button,
.loop-button,
.play-button {
  min-height: 42px;
  border-radius: 11px;
}

.transport-button {
  width: 44px;
  background: rgba(255, 255, 255, 0.72);
}

.transport-button:hover,
.loop-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.play-button {
  min-width: 168px;
  border-radius: 999px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(49, 95, 77, 0.16);
}

.loop-button {
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.audio-state {
  margin-top: 16px;
}

.record-card {
  margin-top: 16px;
  padding: 24px 28px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.045);
}

.record-button {
  width: 62px;
  height: 62px;
  box-shadow: 0 9px 22px rgba(209, 95, 76, 0.2);
}

.guided-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  border-radius: 10px;
}

.ghost-button:hover,
.secondary-button:hover,
.guided-button:hover {
  transform: translateY(-1px);
}

.stage-footer {
  padding: 18px 4px 0;
}

.word-token:hover,
.word-token:focus-visible,
.word-token.active {
  background: var(--yellow-soft);
}

.word-token.spoken {
  background: #f0eee8;
}

.word-tooltip {
  border-color: #dcd6ca;
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 18px 50px rgba(45, 52, 47, 0.14);
}

.toast {
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 16px 44px rgba(45, 52, 47, 0.14);
}

@media (max-width: 900px) {
  main {
    width: min(100% - 24px, 760px);
  }

  .practice-layout {
    display: block;
  }

  .article-panel {
    position: relative;
    top: 0;
    height: auto;
    max-height: 250px;
    margin-bottom: 16px;
  }

  .practice-stage {
    padding: 0;
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 60px;
    padding: 0 12px;
  }

  .setup-view {
    width: 100%;
    padding: 30px 0 50px;
  }

  .import-card {
    padding: 24px 20px;
    border-radius: 18px;
  }

  .stage-toolbar,
  .focus-card,
  .record-card {
    border-radius: 16px;
  }

  .focus-card {
    padding: 24px 20px;
  }

  .record-card {
    padding: 22px 20px;
  }

  .focus-text {
    font-size: 26px;
  }
}


/* Voice selection is presented without engine controls. */
.engine-pill,
.engine-control {
  display: none !important;
}

/* Immersive mode */
.stage-footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.immersive-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 650;
}

.immersive-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.grammar-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 650;
}

.grammar-button svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grammar-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.grammar-button.active {
  color: var(--green);
  border-color: var(--green);
}

.grammar-panel {
  display: grid;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.grammar-block {
  display: grid;
  gap: 8px;
}

.grammar-kicker {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.grammar-translation p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.85;
}

.grammar-notes ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.grammar-notes li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text);
}

.grammar-tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(46, 139, 87, 0.1);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.grammar-detail {
  min-width: 0;
}

.grammar-notes .grammar-empty {
  color: var(--muted);
}


body.immersive-open {
  overflow: hidden;
}

.immersive-view {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  place-items: center;
  padding: 34px clamp(22px, 6vw, 90px);
  color: #f5f2ea;
  background: #18201c;
}

.immersive-position {
  justify-self: start;
  color: rgba(245, 242, 234, 0.46);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.immersive-exit {
  position: absolute;
  top: 22px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.immersive-exit:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.42);
}

.immersive-text {
  width: min(1120px, 100%);
  margin: 0;
  align-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5.4vw, 76px);
  line-height: 1.36;
  letter-spacing: -0.026em;
  text-align: center;
  text-wrap: balance;
}

.immersive-translation {
  margin: 26px auto 0;
  max-width: 56ch;
  color: rgba(245, 242, 234, 0.5);
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.75;
  text-align: center;
  letter-spacing: 0.01em;
}

.immersive-translation:empty {
  display: none;
}

.immersive-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding-bottom: 8px;
}

.immersive-control {
  min-width: 100px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.immersive-control:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.42);
}

.immersive-control.primary {
  color: #15231c;
  border-color: #f2eee4;
  background: #f2eee4;
}

.immersive-control:disabled {
  cursor: not-allowed;
  opacity: 0.32;
}

@media (max-width: 700px) {
  .stage-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .immersive-button {
    justify-content: center;
  }

  .immersive-view {
    padding: 26px 18px;
  }

  .immersive-text {
    font-size: clamp(30px, 9vw, 46px);
    line-height: 1.42;
  }

  .immersive-controls {
    width: 100%;
    gap: 7px;
  }

  .immersive-translation {
    margin-top: 18px;
    font-size: 14px;
  }

  .immersive-control {
    min-width: 0;
    flex: 1;
    padding: 0 9px;
  }
}

/* Immersive visual effects and word cursor */
.immersive-view {
  --immersive-progress: 0%;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, #25352d 0%, #18201c 46%, #101512 100%);
}

.immersive-view::before {
  position: absolute;
  z-index: -2;
  inset: -35%;
  background:
    radial-gradient(circle at 28% 38%, rgba(89, 151, 120, 0.2), transparent 22%),
    radial-gradient(circle at 72% 62%, rgba(210, 139, 95, 0.15), transparent 24%),
    radial-gradient(circle at 54% 22%, rgba(125, 153, 206, 0.1), transparent 20%);
  content: "";
  animation: immersive-drift 18s ease-in-out infinite alternate;
}

.immersive-view::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.28) 100%);
  content: "";
  pointer-events: none;
}

.immersive-view > * {
  position: relative;
  z-index: 1;
}

@keyframes immersive-drift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  50% { transform: translate3d(2%, 3%, 0) scale(1.06); }
  100% { transform: translate3d(5%, -3%, 0) scale(1.02); }
}

.immersive-progress {
  position: absolute !important;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.immersive-progress span {
  display: block;
  width: var(--immersive-progress);
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, #77b797, #f0d38d, #e38d76);
  box-shadow: 0 0 18px rgba(240, 211, 141, 0.46);
  transition: width 180ms linear;
}

.immersive-text {
  transition: opacity 300ms ease, filter 300ms ease;
  text-shadow: 0 4px 32px rgba(0, 0, 0, 0.24);
}

.immersive-text .word-token {
  padding: 0.03em 0.04em;
  border-radius: 8px;
  transition: color 220ms ease, background-color 220ms ease, opacity 220ms ease, transform 220ms ease, text-shadow 220ms ease;
}

.immersive-text .word-token:hover,
.immersive-text .word-token:focus-visible,
.immersive-text .word-token.active {
  color: #18201c;
  background: #fff4cf;
  box-shadow: 0 0 0 4px #fff4cf, 0 0 30px rgba(255, 244, 207, 0.25);
  outline: none;
}

.immersive-text .word-token.spoken {
  color: rgba(245, 242, 234, 0.3);
  background: transparent;
  box-shadow: none;
  text-shadow: none;
}

.immersive-text .word-token.speaking {
  color: #142019;
  background: linear-gradient(135deg, #fff7df, #e6f4eb);
  box-shadow:
    0 0 0 5px rgba(244, 239, 224, 0.96),
    0 0 28px rgba(222, 239, 228, 0.34),
    0 0 70px rgba(118, 184, 149, 0.25);
  text-shadow: none;
  transform: translateY(-2px) scale(1.025);
}

.immersive-text .word-token.speaking::after {
  top: -0.12em;
  right: -7px;
  bottom: -0.12em;
  width: 3px;
  border-radius: 99px;
  background: #f08b73;
  box-shadow: 0 0 12px rgba(240, 139, 115, 0.72);
}

.immersive-text .word-token.speaking.paused {
  box-shadow:
    0 0 0 5px rgba(244, 239, 224, 0.96),
    0 0 24px rgba(222, 239, 228, 0.24);
}

.immersive-controls {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
}

.immersive-control.primary {
  box-shadow: 0 0 28px rgba(242, 238, 228, 0.18);
}

@media (max-width: 700px) {
  .immersive-text .word-token.speaking {
    transform: scale(1.015);
  }

  .immersive-controls {
    border-radius: 18px;
    padding: 10px;
  }
}

/* Keyboard-key controls in immersive mode */
.immersive-key {
  display: grid;
  gap: 5px;
  place-items: center;
  min-width: 94px;
  min-height: 64px;
  padding: 8px 12px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  font-size: 9px;
  font-weight: 650;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.immersive-key kbd {
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 25px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: #f7f4ec;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
}

.immersive-key:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-2px);
}

.immersive-key.primary {
  color: #17221c;
  border-color: #f1ede2;
  background: #f1ede2;
  box-shadow: 0 0 28px rgba(242, 238, 228, 0.18), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key.primary kbd {
  color: #17221c;
  border-color: rgba(23, 34, 28, 0.18);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 0 rgba(23, 34, 28, 0.12);
}

.immersive-key:disabled {
  cursor: not-allowed;
  opacity: 0.28;
  transform: none;
}

@media (max-width: 700px) {
  .immersive-key {
    min-width: 0;
    min-height: 58px;
    padding: 7px 4px;
  }

  .immersive-key kbd {
    min-width: 29px;
    font-size: 9px;
  }
}

/* Immersive cursor toggle */
.immersive-cursor-toggle {
  position: absolute;
  top: 22px;
  right: 70px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.045);
  font-size: 9px;
  font-weight: 650;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

.immersive-cursor-toggle kbd {
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-size: 9px;
}

.immersive-cursor-toggle:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.38);
}

.immersive-cursor-toggle[aria-pressed="false"] {
  opacity: 0.45;
  text-decoration: line-through;
}

.immersive-view.cursor-hidden .immersive-text .word-token.speaking::after {
  display: none;
}

@media (max-width: 700px) {
  .immersive-cursor-toggle {
    top: 18px;
    right: 62px;
    padding: 0 8px;
  }

  .immersive-cursor-toggle span {
    display: none;
  }
}

/* Softer immersive appearance */
.immersive-view {
  color: #e9e5dc;
  background:
    radial-gradient(circle at 48% 35%, #35433c 0%, #2b3732 42%, #252e2a 100%);
}

.immersive-view::before {
  inset: -28%;
  opacity: 0.55;
  background:
    radial-gradient(circle at 30% 42%, rgba(113, 154, 132, 0.11), transparent 25%),
    radial-gradient(circle at 72% 58%, rgba(176, 132, 103, 0.08), transparent 26%);
  animation-duration: 26s;
}

.immersive-view::after {
  display: none;
}

.immersive-text {
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.12);
}

.immersive-text .word-token:hover,
.immersive-text .word-token:focus-visible,
.immersive-text .word-token.active {
  color: #f1ede4;
  background: rgba(239, 218, 161, 0.12);
  box-shadow: 0 0 0 3px rgba(239, 218, 161, 0.08);
}

.immersive-text .word-token.spoken {
  color: rgba(233, 229, 220, 0.48);
  background: transparent;
  box-shadow: none;
}

.immersive-text .word-token.speaking {
  color: #f5f1e8;
  background: rgba(255, 255, 255, 0.105);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.13),
    0 0 18px rgba(190, 214, 199, 0.11);
  text-shadow: none;
  transform: translateY(-1px);
}

.immersive-text .word-token.speaking::after {
  width: 2px;
  background: #d99077;
  box-shadow: 0 0 7px rgba(217, 144, 119, 0.38);
}

.immersive-progress span {
  background: linear-gradient(90deg, #769b87, #c5ad78, #bc826e);
  box-shadow: 0 0 10px rgba(197, 173, 120, 0.22);
}

.immersive-controls {
  border-color: rgba(255, 255, 255, 0.055);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
}

.immersive-key {
  color: rgba(233, 229, 220, 0.68);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key:hover {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.055);
}

.immersive-key.primary {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key.primary kbd {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}

.immersive-cursor-toggle,
.immersive-exit {
  color: rgba(233, 229, 220, 0.58);
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
}

.immersive-cursor-toggle:hover,
.immersive-exit:hover {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.18);
}

/* No visible cursor or top-right controls in immersive mode. */
.immersive-text .word-token.speaking::after {
  display: none !important;
  content: none !important;
}

.immersive-cursor-toggle,
.immersive-exit {
  display: none !important;
}

/* Remove the red word cursor everywhere; keep word highlighting only. */
.word-token.speaking::after,
.immersive-text .word-token.speaking::after {
  display: none !important;
  content: none !important;
}

/* Local article library */
.library-panel {
  margin-top: 18px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.88);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.045);
  overflow: hidden;
}

.library-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.library-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 600;
}

.library-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.library-head > span {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 700;
}

.article-list {
  max-height: 330px;
  overflow-y: auto;
}

.article-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(226, 221, 211, 0.7);
}

.article-list-item:last-child {
  border-bottom: 0;
}

.article-list-item.current {
  background: var(--green-soft);
}

.article-list-main {
  min-width: 0;
}

.article-open-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: transparent;
  text-align: left;
}

.article-open-button strong {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
}

.article-delete-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(209, 95, 76, 0.18);
  border-radius: 999px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 9px;
  font-weight: 650;
}

.article-delete-button:hover {
  color: white;
  background: var(--red);
}

.library-empty {
  margin: 0;
  padding: 20px 18px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

@media (max-width: 700px) {
  .article-list-item {
    padding: 12px 14px;
  }

  .article-list-item {
    gap: 8px;
  }
}


/* Setup page title */
.setup-hero {
  margin: 8px 0 30px;
  padding: 0 6px;
}

.setup-hero > p {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.setup-hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6.2vw, 72px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.052em;
}

.setup-hero h1 em {
  color: var(--accent);
  font-style: italic;
}

.setup-hero > span {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 700px) {
  .setup-hero {
    margin-bottom: 22px;
  }

  .setup-hero h1 {
    font-size: 40px;
  }

  .setup-hero > span {
    font-size: 12px;
  }
}

oot {
  --bg: #ffffff;
  --panel: #fafafa;
  --text: #171717;
  --muted: #737373;
  --line: #dedede;
  --line-strong: #bdbdbd;
  --accent: #111111;
  --green: #1f6f52;
  --green-soft: #edf6f1;
  --red: #d74b3f;
  --red-soft: #fbebe8;
  --yellow-soft: #fff8df;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.word-token:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ambient,
.hero-copy,
.feature-row,
.import-card::before,
.focus-card::after {
  display: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 0;
  background: transparent;
  text-align: left;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 14px;
  font-weight: 650;
}

.brand small {
  color: var(--muted);
  font-size: 10px;
}

.brand-mark {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.brand-mark span {
  display: block;
  width: 2px;
  background: var(--accent);
}

.brand-mark span:nth-child(1) { height: 6px; }
.brand-mark span:nth-child(2) { height: 11px; }
.brand-mark span:nth-child(3) { height: 8px; }
.brand-mark span:nth-child(4) { height: 13px; }

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.engine-pill,
.icon-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-size: 11px;
}

.engine-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  max-width: 260px;
  padding: 0 10px;
  color: var(--muted);
}

.engine-pill:hover,
.icon-button:hover {
  border-color: var(--line-strong);
}

.icon-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 10px;
}

.status-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.status-dot.ready { background: var(--green); }
.status-dot.warn { background: #c58b16; }

main {
  width: 100%;
}

.setup-view {
  width: min(760px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.import-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.import-card-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.card-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.import-card h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.format-note {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.text-input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.text-input {
  width: 100%;
  height: 40px;
  margin-bottom: 18px;
  padding: 0 11px;
  font-size: 13px;
}

textarea {
  width: 100%;
  height: 220px;
  padding: 11px;
  resize: vertical;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.65;
}

.text-input:focus,
textarea:focus,
select:focus {
  border-color: #888;
}

textarea::placeholder,
.text-input::placeholder {
  color: #aaa;
}

.textarea-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.textarea-head span {
  color: var(--muted);
  font-size: 9px;
}

.textarea-wrap.dragging::after {
  display: grid;
  position: absolute;
  inset: 4px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  background: #f5f5f5;
  content: "松开鼠标以导入文章";
  font-size: 11px;
}

.import-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.file-action {
  display: flex;
  gap: 12px;
}

.text-button,
.primary-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.text-button {
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.text-button:hover {
  color: var(--text);
}

.primary-button {
  padding: 0 14px;
  color: white;
  background: var(--accent);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.privacy-note {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.practice-view {
  min-height: calc(100vh - 57px);
}

.practice-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: stretch;
  min-height: calc(100vh - 57px);
}

.article-panel {
  position: sticky;
  top: 56px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.article-panel-head {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.back-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
}

.article-heading {
  min-width: 0;
}

.article-heading h2 {
  overflow: hidden;
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.article-progress-track {
  height: 2px;
  background: #e7e7e7;
}

.article-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.sentence-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sentence-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: start;
  width: 100%;
  margin-bottom: 2px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: left;
}

.sentence-row:hover {
  background: #f0f0f0;
}

.sentence-row.active {
  border-color: var(--line-strong);
  background: var(--bg);
}

.sentence-number {
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.sentence-copy {
  display: -webkit-box;
  overflow: hidden;
  color: #686868;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.sentence-row.active .sentence-copy {
  color: var(--text);
}

.sentence-state {
  display: flex;
  gap: 3px;
}

.state-mark {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 8px;
}

.state-mark.recorded {
  color: var(--red);
  background: var(--red-soft);
}

.practice-stage {
  min-width: 0;
  padding: 20px 28px 32px;
}

.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.stage-position {
  display: grid;
  gap: 3px;
}

.stage-label {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.stage-position strong {
  font-size: 20px;
  font-weight: 500;
}

.stage-position strong small {
  color: var(--muted);
  font-size: 12px;
}

.settings-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.select-control,
.speed-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 8px;
}

.select-control select {
  width: 140px;
  height: 31px;
  padding: 0 8px;
  font-size: 10px;
}

.repeat-control select {
  width: 82px;
}

.speed-control {
  width: 135px;
}

.speed-control > span {
  display: flex;
  justify-content: space-between;
}

.speed-control strong {
  color: var(--text);
  font-size: 9px;
}

input[type="range"] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--accent);
}

.focus-card {
  padding: 34px 0 24px;
  border-bottom: 1px solid var(--line);
}

.focus-card-top {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.sentence-badge {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-top-right,
.focus-edit-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.focus-hint {
  color: var(--muted);
  font-size: 9px;
}

.edit-sentence-button {
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--bg);
  font-size: 9px;
}

.edit-sentence-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.focus-text {
  min-height: 130px;
  margin: 26px 0 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 2.6vw, 36px);
  line-height: 1.45;
}

.transport {
  display: flex;
  gap: 7px;
  align-items: center;
}

.transport-button,
.loop-button,
.play-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.transport-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--muted);
}

.loop-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 11px;
  color: var(--muted);
  font-size: 9px;
}

.loop-button[aria-pressed="true"] {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.play-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 0 18px;
  color: white;
  border-color: var(--accent);
  background: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.play-button .pause-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.playing .pause-icon {
  display: block;
}

.audio-state {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 9px;
}

.audio-wave {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  height: 10px;
}

.audio-wave i {
  width: 2px;
  height: 3px;
  background: var(--accent);
}

.record-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) auto minmax(170px, 0.7fr);
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.record-copy h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.record-copy > p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.record-center {
  display: grid;
  justify-items: center;
}

.record-visualizer {
  display: none;
}

.record-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: white;
  background: var(--red);
}

.record-button .stop-icon {
  display: none;
}

.record-card.recording .record-button .mic-icon {
  display: none;
}

.record-card.recording .record-button .stop-icon {
  display: block;
}

.record-card.starting .record-button {
  color: white;
  background: #a06a00;
}

.record-timer {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.recording-actions {
  display: grid;
  gap: 6px;
}

.guided-button,
.secondary-button,
.ghost-button {
  min-height: 32px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
}

.guided-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  color: var(--green);
  border: 1px solid #cfe3da;
  background: var(--green-soft);
}

.guided-button.active {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.secondary-button,
.ghost-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.secondary-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--bg);
}

.ghost-button {
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.secondary-button .recording-stop-icon {
  display: none;
}

.secondary-button.playing {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.secondary-button.playing .recording-play-icon {
  display: none;
}

.secondary-button.playing .recording-stop-icon {
  display: block;
}

.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.stage-footer {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
}

.complete-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
}

.check-circle {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.check-circle svg {
  opacity: 0;
}

.complete-button.completed {
  color: var(--green);
}

.complete-button.completed .check-circle {
  color: white;
  border-color: var(--green);
  background: var(--green);
}

.complete-button.completed .check-circle svg {
  opacity: 1;
}

.stage-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
}

kbd {
  min-width: 18px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  font-family: inherit;
  font-size: 8px;
}

.word-token {
  display: inline;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.word-token:hover,
.word-token:focus-visible,
.word-token.active {
  color: var(--text);
  background: var(--yellow-soft);
  outline: none;
}

.word-token.spoken {
  background: #f5f5f5;
}

.word-token.speaking {
  position: relative;
  color: white;
  background: var(--green);
}

.word-token.speaking::after {
  position: absolute;
  top: -0.05em;
  right: -4px;
  bottom: -0.05em;
  width: 2px;
  background: var(--red);
  content: "";
  animation: cursor-blink 0.75s steps(1) infinite;
}

.word-token.speaking.paused::after {
  animation: none;
}

@keyframes cursor-blink {
  50% { opacity: 0.15; }
}

.word-tooltip {
  position: fixed;
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  max-height: 280px;
  overflow-y: auto;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.word-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.word-tooltip.loading {
  color: var(--muted);
}

.word-tooltip-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 7px;
}

.word-tooltip-head strong {
  font-size: 16px;
}

.word-tooltip-head span {
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
}

.word-tooltip p {
  margin: 0;
  white-space: pre-line;
}

.word-tooltip-translation {
  font-size: 11px;
  line-height: 1.55;
}

.word-tooltip-definition {
  margin-top: 7px !important;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  line-height: 1.5;
}

.word-tooltip-definition:empty {
  display: none;
}

.word-tooltip small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 8px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  color: #7d1e18;
  border-color: #ecc3be;
  background: #fff4f2;
}

.toast.success {
  color: #13553e;
  border-color: #c8e1d5;
  background: #f1faf5;
}

.toast span {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #efefef;
  font-size: 10px;
  font-weight: 700;
}

.toast p {
  margin: 0;
  font-size: 10px;
}

@media (max-width: 900px) {
  .practice-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .practice-stage {
    padding: 16px 18px 28px;
  }

  .record-card {
    grid-template-columns: 1fr auto;
  }

  .recording-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 50px;
    padding: 0 12px;
  }

  .brand small,
  .engine-pill #engineStatus,
  .stage-footer p {
    display: none;
  }

  .setup-view {
    width: calc(100% - 24px);
    padding: 20px 0 40px;
  }

  .import-card {
    padding: 18px;
  }

  .import-card-head {
    display: block;
  }

  .format-note {
    display: inline-block;
    margin-top: 10px;
  }

  .import-footer {
    display: grid;
  }

  .primary-button {
    width: 100%;
  }

  .practice-layout {
    display: block;
  }

  .article-panel {
    position: relative;
    top: 0;
    height: auto;
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .practice-stage {
    padding: 14px 14px 28px;
  }

  .stage-toolbar {
    display: block;
  }

  .settings-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
  }

  .select-control select,
  .speed-control,

  .speed-control {
    grid-column: 1 / -1;
  }

  .focus-card {
    padding-top: 24px;
  }

  .focus-card-top {
    align-items: flex-start;
  }

  .focus-hint {
    display: none;
  }

  .focus-text {
    min-height: 110px;
    font-size: 24px;
  }

  .transport {
    flex-wrap: wrap;
  }

  .play-button {
    order: 3;
    width: 100%;
  }

  .record-card {
    grid-template-columns: 1fr auto;
  }

  .record-copy {
    grid-column: 1 / -1;
  }

  .recording-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .stage-footer {
    display: grid;
  }

  .word-tooltip {
    width: calc(100vw - 20px);
  }
}

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

/* Comfort theme */
:root {
  --bg: #f3f1eb;
  --panel: #f8f6f1;
  --text: #28312c;
  --muted: #747c76;
  --line: #e2ddd3;
  --line-strong: #c9c2b7;
  --accent: #315f4d;
  --green: #316b53;
  --green-soft: #e5efe9;
  --red: #d15f4c;
  --red-soft: #fbe9e4;
  --yellow-soft: #fbf2d4;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.95), transparent 44%),
    var(--bg);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 66px;
  padding: 0 max(20px, calc((100vw - 1400px) / 2));
  border-color: rgba(201, 194, 183, 0.72);
  background: rgba(243, 241, 235, 0.88);
  backdrop-filter: blur(16px);
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand small {
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  padding: 6px;
  border-color: #b8b3a8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.engine-pill,
.icon-button {
  min-height: 35px;
  border-color: var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 249, 0.76);
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.engine-pill:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: #fffdf9;
  box-shadow: 0 4px 14px rgba(45, 52, 47, 0.05);
}

main {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
}

.setup-view {
  width: min(780px, 100%);
  padding: 64px 0 80px;
}

.import-card {
  padding: clamp(28px, 4vw, 44px);
  border-color: rgba(214, 208, 198, 0.9);
  border-radius: 22px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 18px 60px rgba(55, 60, 55, 0.07);
}

.import-card h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.card-kicker {
  color: var(--accent);
}

.format-note {
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
  font-weight: 700;
}

.text-input,
textarea,
select {
  border-color: #ddd7cc;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
}

.text-input {
  height: 46px;
  padding: 0 14px;
  font-size: 14px;
}

textarea {
  height: 250px;
  padding: 16px;
  font-size: 15px;
  line-height: 1.75;
}

.text-input:focus,
textarea:focus,
select:focus {
  border-color: rgba(49, 95, 77, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 95, 77, 0.08);
  outline: none;
}

.text-button {
  min-height: 38px;
  padding: 0 4px;
}

.primary-button {
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(49, 95, 77, 0.17);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(49, 95, 77, 0.2);
}

.practice-view {
  padding: 20px 0 42px;
}

.practice-layout {
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 108px);
}

.article-panel {
  top: 86px;
  height: calc(100vh - 106px);
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.05);
}

.article-panel-head {
  padding: 17px 16px 14px;
  border-bottom-color: rgba(226, 221, 211, 0.85);
}

.back-button {
  width: 32px;
  height: 32px;
  border-color: var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.68);
}

.article-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
}

.article-progress-track {
  height: 3px;
  background: #e9e5dd;
}

.article-progress-track span {
  background: var(--accent);
}

.sentence-list {
  padding: 10px;
}

.sentence-row {
  padding: 11px 10px;
  border-radius: 11px;
}

.sentence-row:hover {
  background: rgba(49, 95, 77, 0.045);
}

.sentence-row.active {
  border-color: rgba(49, 95, 77, 0.15);
  background: var(--green-soft);
}

.sentence-number {
  padding-top: 1px;
  color: #9b9e98;
  font-weight: 650;
}

.sentence-copy {
  color: #69716b;
  font-size: 12px;
  line-height: 1.55;
}

.practice-stage {
  padding: 0;
}

.stage-toolbar {
  min-height: 68px;
  padding: 14px 18px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.85);
  box-shadow: 0 8px 28px rgba(55, 60, 55, 0.045);
}

.stage-position strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
}

.select-control select {
  height: 35px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
}

.speed-control {
  width: 145px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.focus-card {
  min-height: 300px;
  margin-top: 16px;
  padding: clamp(30px, 4vw, 48px);
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 14px 44px rgba(55, 60, 55, 0.055);
}

.focus-card-top {
  min-height: 28px;
}

.sentence-badge {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
}

.edit-sentence-button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.focus-text {
  min-height: 145px;
  margin: 28px 0;
  font-size: clamp(27px, 3vw, 40px);
  line-height: 1.5;
  letter-spacing: -0.018em;
}

.transport-button,
.loop-button,
.play-button {
  min-height: 42px;
  border-radius: 11px;
}

.transport-button {
  width: 44px;
  background: rgba(255, 255, 255, 0.72);
}

.transport-button:hover,
.loop-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.play-button {
  min-width: 168px;
  border-radius: 999px;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(49, 95, 77, 0.16);
}

.loop-button {
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.audio-state {
  margin-top: 16px;
}

.record-card {
  margin-top: 16px;
  padding: 24px 28px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.9);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.045);
}

.record-button {
  width: 62px;
  height: 62px;
  box-shadow: 0 9px 22px rgba(209, 95, 76, 0.2);
}

.guided-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  border-radius: 10px;
}

.ghost-button:hover,
.secondary-button:hover,
.guided-button:hover {
  transform: translateY(-1px);
}

.stage-footer {
  padding: 18px 4px 0;
}

.word-token:hover,
.word-token:focus-visible,
.word-token.active {
  background: var(--yellow-soft);
}

.word-token.spoken {
  background: #f0eee8;
}

.word-tooltip {
  border-color: #dcd6ca;
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 18px 50px rgba(45, 52, 47, 0.14);
}

.toast {
  border-radius: 12px;
  background: #fffdf9;
  box-shadow: 0 16px 44px rgba(45, 52, 47, 0.14);
}

@media (max-width: 900px) {
  main {
    width: min(100% - 24px, 760px);
  }

  .practice-layout {
    display: block;
  }

  .article-panel {
    position: relative;
    top: 0;
    height: auto;
    max-height: 250px;
    margin-bottom: 16px;
  }

  .practice-stage {
    padding: 0;
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 60px;
    padding: 0 12px;
  }

  .setup-view {
    width: 100%;
    padding: 30px 0 50px;
  }

  .import-card {
    padding: 24px 20px;
    border-radius: 18px;
  }

  .stage-toolbar,
  .focus-card,
  .record-card {
    border-radius: 16px;
  }

  .focus-card {
    padding: 24px 20px;
  }

  .record-card {
    padding: 22px 20px;
  }

  .focus-text {
    font-size: 26px;
  }
}


/* Voice selection is presented without engine controls. */
.engine-pill,
.engine-control {
  display: none !important;
}

/* Immersive mode */
.stage-footer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.immersive-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 650;
}

.immersive-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

body.immersive-open {
  overflow: hidden;
}

.immersive-view {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  place-items: center;
  padding: 34px clamp(22px, 6vw, 90px);
  color: #f5f2ea;
  background: #18201c;
}

.immersive-position {
  justify-self: start;
  color: rgba(245, 242, 234, 0.46);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.immersive-exit {
  position: absolute;
  top: 22px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.immersive-exit:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.42);
}

.immersive-text {
  width: min(1120px, 100%);
  margin: 0;
  align-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5.4vw, 76px);
  line-height: 1.36;
  letter-spacing: -0.026em;
  text-align: center;
  text-wrap: balance;
}

.immersive-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding-bottom: 8px;
}

.immersive-control {
  min-width: 100px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.immersive-control:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.42);
}

.immersive-control.primary {
  color: #15231c;
  border-color: #f2eee4;
  background: #f2eee4;
}

.immersive-control:disabled {
  cursor: not-allowed;
  opacity: 0.32;
}

@media (max-width: 700px) {
  .stage-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .immersive-button {
    justify-content: center;
  }

  .immersive-view {
    padding: 26px 18px;
  }

  .immersive-text {
    font-size: clamp(30px, 9vw, 46px);
    line-height: 1.42;
  }

  .immersive-controls {
    width: 100%;
    gap: 7px;
  }

  .immersive-control {
    min-width: 0;
    flex: 1;
    padding: 0 9px;
  }
}

/* Immersive visual effects and word cursor */
.immersive-view {
  --immersive-progress: 0%;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, #25352d 0%, #18201c 46%, #101512 100%);
}

.immersive-view::before {
  position: absolute;
  z-index: -2;
  inset: -35%;
  background:
    radial-gradient(circle at 28% 38%, rgba(89, 151, 120, 0.2), transparent 22%),
    radial-gradient(circle at 72% 62%, rgba(210, 139, 95, 0.15), transparent 24%),
    radial-gradient(circle at 54% 22%, rgba(125, 153, 206, 0.1), transparent 20%);
  content: "";
  animation: immersive-drift 18s ease-in-out infinite alternate;
}

.immersive-view::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at center, transparent 42%, rgba(0, 0, 0, 0.28) 100%);
  content: "";
  pointer-events: none;
}

.immersive-view > * {
  position: relative;
  z-index: 1;
}

@keyframes immersive-drift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  50% { transform: translate3d(2%, 3%, 0) scale(1.06); }
  100% { transform: translate3d(5%, -3%, 0) scale(1.02); }
}

.immersive-progress {
  position: absolute !important;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.immersive-progress span {
  display: block;
  width: var(--immersive-progress);
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, #77b797, #f0d38d, #e38d76);
  box-shadow: 0 0 18px rgba(240, 211, 141, 0.46);
  transition: width 180ms linear;
}

.immersive-text {
  transition: opacity 300ms ease, filter 300ms ease;
  text-shadow: 0 4px 32px rgba(0, 0, 0, 0.24);
}

.immersive-text .word-token {
  padding: 0.03em 0.04em;
  border-radius: 8px;
  transition: color 220ms ease, background-color 220ms ease, opacity 220ms ease, transform 220ms ease, text-shadow 220ms ease;
}

.immersive-text .word-token:hover,
.immersive-text .word-token:focus-visible,
.immersive-text .word-token.active {
  color: #18201c;
  background: #fff4cf;
  box-shadow: 0 0 0 4px #fff4cf, 0 0 30px rgba(255, 244, 207, 0.25);
  outline: none;
}

.immersive-text .word-token.spoken {
  color: rgba(245, 242, 234, 0.3);
  background: transparent;
  box-shadow: none;
  text-shadow: none;
}

.immersive-text .word-token.speaking {
  color: #142019;
  background: linear-gradient(135deg, #fff7df, #e6f4eb);
  box-shadow:
    0 0 0 5px rgba(244, 239, 224, 0.96),
    0 0 28px rgba(222, 239, 228, 0.34),
    0 0 70px rgba(118, 184, 149, 0.25);
  text-shadow: none;
  transform: translateY(-2px) scale(1.025);
}

.immersive-text .word-token.speaking::after {
  top: -0.12em;
  right: -7px;
  bottom: -0.12em;
  width: 3px;
  border-radius: 99px;
  background: #f08b73;
  box-shadow: 0 0 12px rgba(240, 139, 115, 0.72);
}

.immersive-text .word-token.speaking.paused {
  box-shadow:
    0 0 0 5px rgba(244, 239, 224, 0.96),
    0 0 24px rgba(222, 239, 228, 0.24);
}

.immersive-controls {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
}

.immersive-control.primary {
  box-shadow: 0 0 28px rgba(242, 238, 228, 0.18);
}

@media (max-width: 700px) {
  .immersive-text .word-token.speaking {
    transform: scale(1.015);
  }

  .immersive-controls {
    border-radius: 18px;
    padding: 10px;
  }
}

/* Keyboard-key controls in immersive mode */
.immersive-key {
  display: grid;
  gap: 5px;
  place-items: center;
  min-width: 94px;
  min-height: 64px;
  padding: 8px 12px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  font-size: 9px;
  font-weight: 650;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.immersive-key kbd {
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 25px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: #f7f4ec;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
}

.immersive-key:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-2px);
}

.immersive-key.primary {
  color: #17221c;
  border-color: #f1ede2;
  background: #f1ede2;
  box-shadow: 0 0 28px rgba(242, 238, 228, 0.18), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key.primary kbd {
  color: #17221c;
  border-color: rgba(23, 34, 28, 0.18);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 0 rgba(23, 34, 28, 0.12);
}

.immersive-key:disabled {
  cursor: not-allowed;
  opacity: 0.28;
  transform: none;
}

@media (max-width: 700px) {
  .immersive-key {
    min-width: 0;
    min-height: 58px;
    padding: 7px 4px;
  }

  .immersive-key kbd {
    min-width: 29px;
    font-size: 9px;
  }
}

/* Immersive cursor toggle */
.immersive-cursor-toggle {
  position: absolute;
  top: 22px;
  right: 70px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.045);
  font-size: 9px;
  font-weight: 650;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

.immersive-cursor-toggle kbd {
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-size: 9px;
}

.immersive-cursor-toggle:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.38);
}

.immersive-cursor-toggle[aria-pressed="false"] {
  opacity: 0.45;
  text-decoration: line-through;
}

.immersive-view.cursor-hidden .immersive-text .word-token.speaking::after {
  display: none;
}

@media (max-width: 700px) {
  .immersive-cursor-toggle {
    top: 18px;
    right: 62px;
    padding: 0 8px;
  }

  .immersive-cursor-toggle span {
    display: none;
  }
}

/* Softer immersive appearance */
.immersive-view {
  color: #e9e5dc;
  background:
    radial-gradient(circle at 48% 35%, #35433c 0%, #2b3732 42%, #252e2a 100%);
}

.immersive-view::before {
  inset: -28%;
  opacity: 0.55;
  background:
    radial-gradient(circle at 30% 42%, rgba(113, 154, 132, 0.11), transparent 25%),
    radial-gradient(circle at 72% 58%, rgba(176, 132, 103, 0.08), transparent 26%);
  animation-duration: 26s;
}

.immersive-view::after {
  display: none;
}

.immersive-text {
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.12);
}

.immersive-text .word-token:hover,
.immersive-text .word-token:focus-visible,
.immersive-text .word-token.active {
  color: #f1ede4;
  background: rgba(239, 218, 161, 0.12);
  box-shadow: 0 0 0 3px rgba(239, 218, 161, 0.08);
}

.immersive-text .word-token.spoken {
  color: rgba(233, 229, 220, 0.48);
  background: transparent;
  box-shadow: none;
}

.immersive-text .word-token.speaking {
  color: #f5f1e8;
  background: rgba(255, 255, 255, 0.105);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.13),
    0 0 18px rgba(190, 214, 199, 0.11);
  text-shadow: none;
  transform: translateY(-1px);
}

.immersive-text .word-token.speaking::after {
  width: 2px;
  background: #d99077;
  box-shadow: 0 0 7px rgba(217, 144, 119, 0.38);
}

.immersive-progress span {
  background: linear-gradient(90deg, #769b87, #c5ad78, #bc826e);
  box-shadow: 0 0 10px rgba(197, 173, 120, 0.22);
}

.immersive-controls {
  border-color: rgba(255, 255, 255, 0.055);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
}

.immersive-key {
  color: rgba(233, 229, 220, 0.68);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key:hover {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.055);
}

.immersive-key.primary {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.17);
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.immersive-key.primary kbd {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14);
}

.immersive-cursor-toggle,
.immersive-exit {
  color: rgba(233, 229, 220, 0.58);
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
}

.immersive-cursor-toggle:hover,
.immersive-exit:hover {
  color: #f4f0e7;
  border-color: rgba(255, 255, 255, 0.18);
}

/* No visible cursor or top-right controls in immersive mode. */
.immersive-text .word-token.speaking::after {
  display: none !important;
  content: none !important;
}

.immersive-cursor-toggle,
.immersive-exit {
  display: none !important;
}

/* Remove the red word cursor everywhere; keep word highlighting only. */
.word-token.speaking::after,
.immersive-text .word-token.speaking::after {
  display: none !important;
  content: none !important;
}

/* Local article library */
.library-panel {
  margin-top: 18px;
  border: 1px solid rgba(214, 208, 198, 0.88);
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.88);
  box-shadow: 0 10px 34px rgba(55, 60, 55, 0.045);
  overflow: hidden;
}

.library-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.library-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 600;
}

.library-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.library-head > span {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 700;
}

.article-list {
  max-height: 330px;
  overflow-y: auto;
}

.article-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(226, 221, 211, 0.7);
}

.article-list-item:last-child {
  border-bottom: 0;
}

.article-list-item.current {
  background: var(--green-soft);
}

.article-list-main {
  min-width: 0;
}

.article-open-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: transparent;
  text-align: left;
}

.article-open-button strong {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
}

.article-delete-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(209, 95, 76, 0.18);
  border-radius: 999px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 9px;
  font-weight: 650;
}

.article-delete-button:hover {
  color: white;
  background: var(--red);
}

.library-empty {
  margin: 0;
  padding: 20px 18px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

@media (max-width: 700px) {
  .article-list-item {
    padding: 12px 14px;
  }

  .article-list-item {
    gap: 8px;
  }
}


/* Setup page title */
.setup-hero {
  margin: 8px 0 30px;
  padding: 0 6px;
}

.setup-hero > p {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.setup-hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6.2vw, 72px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.052em;
}

.setup-hero h1 em {
  color: var(--accent);
  font-style: italic;
}

.setup-hero > span {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 700px) {
  .setup-hero {
    margin-bottom: 22px;
  }

  .setup-hero h1 {
    font-size: 40px;
  }

  .setup-hero > span {
    font-size: 12px;
  }
}

/* In-app sentence split dialog. Native prompt() can be blocked in embedded browsers. */
.split-modal {
  position: fixed;
  z-index: 45;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.split-modal[hidden] {
  display: none;
}

.split-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.42);
  backdrop-filter: blur(5px);
}

.split-modal-card {
  position: relative;
  width: min(560px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

.split-modal-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.split-modal-head h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.split-modal-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.split-modal-head code {
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
  background: var(--panel);
  font-size: 11px;
}

.split-modal-card textarea {
  width: 100%;
  min-height: 112px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--bg);
  font: 13px/1.6 Georgia, "Times New Roman", serif;
  resize: vertical;
}

.split-modal-card textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.split-modal-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Account and server sync */
.auth-view {
  display: grid;
  position: relative;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
  padding: 24px;
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(49, 95, 77, 0.13), transparent 34%),
    radial-gradient(circle at 82% 86%, rgba(209, 95, 76, 0.09), transparent 32%),
    linear-gradient(145deg, #f7f4ec 0%, #efede5 52%, #f5f2ea 100%);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid rgba(201, 194, 183, 0.86);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: 0 24px 80px rgba(45, 52, 47, 0.13);
  backdrop-filter: blur(18px);
}

.auth-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 34px;
}

.auth-brand > span:last-child {
  display: grid;
  gap: 1px;
}

.auth-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.auth-brand small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.auth-heading {
  margin-bottom: 22px;
}

.auth-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.auth-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.auth-heading p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.auth-tab {
  min-height: 34px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.auth-tab.active {
  color: var(--text);
  background: #fffdf9;
  box-shadow: 0 2px 10px rgba(45, 52, 47, 0.08);
}

.auth-tab:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.auth-form .text-input {
  margin-bottom: 15px;
}

.auth-form .field-label {
  margin-top: 0;
}

.auth-form .field-label:not(:first-child) {
  margin-top: 1px;
}

.auth-error {
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid #ecc3be;
  border-radius: 9px;
  color: #7d1e18;
  background: #fff4f2;
  font-size: 11px;
  line-height: 1.45;
}

.auth-submit {
  width: 100%;
  margin-top: 5px;
}

.auth-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  text-align: center;
}

.account-pill {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 35px;
  max-width: 170px;
  padding: 0 11px 0 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 253, 249, 0.76);
  font-size: 10px;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.account-pill:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: #fffdf9;
  box-shadow: 0 4px 14px rgba(45, 52, 47, 0.05);
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
}

#accountName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-exit {
  flex: 0 0 auto;
  padding-left: 5px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
}

@media (max-width: 700px) {
  .auth-view {
    padding: 14px;
  }

  .auth-card {
    padding: 24px 20px;
    border-radius: 20px;
  }

  .auth-brand {
    margin-bottom: 26px;
  }

  .account-pill {
    max-width: 112px;
    padding-right: 8px;
  }

  .account-exit {
    display: none;
  }
}

/* Daily quote area on the left of the sign-in screen */
.auth-view {
  width: min(1280px, 100%);
  margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: clamp(48px, 8vw, 130px);
  place-items: center stretch;
}

.auth-quote-panel {
  position: relative;
  z-index: 1;
  max-width: 650px;
  padding: 24px 0;
}

.auth-quote-panel::before {
  display: block;
  height: 0.65em;
  margin-bottom: -0.1em;
  color: rgba(49, 95, 77, 0.15);
  content: "“";
  font-family: Georgia, "Times New Roman", serif;
  font-size: 126px;
  line-height: 0.7;
}

.auth-quote-kicker {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.2em;
}

.auth-quote-panel blockquote {
  max-width: 620px;
  margin: 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4.2vw, 60px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.16;
}

.auth-quote-translation {
  max-width: 520px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.auth-quote-date {
  display: inline-block;
  margin-top: 28px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
}

.auth-card {
  width: 100%;
  justify-self: end;
}

@media (max-width: 900px) {
  .auth-view {
    grid-template-columns: 1fr;
    gap: 0;
    place-items: center;
    padding: 18px;
  }

  .auth-quote-panel {
    display: none;
  }

  .auth-card {
    justify-self: center;
  }
}

/* Final comfort pass: calmer surfaces, clearer hierarchy, softer controls */
:root {
  --bg: #f1efe8;
  --panel: #f8f6f1;
  --text: #26302a;
  --muted: #707973;
  --line: #e2ddd3;
  --line-strong: #c8c1b5;
  --accent: #2f5d4a;
  --green: #2f6a51;
  --green-soft: #e5efe9;
  --red: #cf6350;
  --red-soft: #fbeae5;
  --yellow-soft: #fbf2d4;
}

body {
  background:
    radial-gradient(circle at 50% -18%, rgba(255, 255, 255, 0.96), transparent 42%),
    linear-gradient(180deg, #f5f3ed 0%, var(--bg) 48%, #eeebe3 100%);
}

.topbar {
  min-height: 70px;
  padding: 0 max(22px, calc((100vw - 1400px) / 2));
  border-bottom-color: rgba(201, 194, 183, 0.65);
  background: rgba(245, 243, 237, 0.86);
  box-shadow: 0 8px 30px rgba(45, 52, 47, 0.045);
}

.brand strong {
  font-size: 16px;
}

.brand small {
  font-size: 9px;
  letter-spacing: 0.09em;
}

.account-pill,
.icon-button,
.engine-pill {
  min-height: 38px;
  border-radius: 12px;
}

.account-pill {
  max-width: 190px;
  padding-right: 13px;
  font-size: 11px;
}

.account-avatar {
  width: 25px;
  height: 25px;
  border-radius: 9px;
}

main {
  width: min(1420px, calc(100% - 48px));
}

.setup-view {
  width: min(860px, 100%);
  padding: 58px 0 92px;
}

.setup-hero {
  margin: 0 0 34px;
  padding: 0 4px;
}

.setup-hero h1 {
  font-size: clamp(44px, 5.6vw, 74px);
  letter-spacing: -0.055em;
}

.setup-hero > span {
  max-width: 520px;
  font-size: 14px;
}

.import-card,
.library-panel {
  border-color: rgba(211, 205, 194, 0.9);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.95);
  box-shadow: 0 20px 64px rgba(55, 60, 55, 0.075);
}

.import-card {
  padding: clamp(28px, 4vw, 46px);
}

.library-panel {
  margin-top: 24px;
}

.library-head {
  padding: 18px 22px;
}

.library-head h2 {
  font-size: 19px;
}

.library-head p,
.library-head > span {
  font-size: 10px;
}

.article-list {
  max-height: 340px;
}

.article-list-item {
  padding: 15px 22px;
  transition: background-color 150ms ease;
}

.article-list-item:hover {
  background: rgba(239, 245, 241, 0.55);
}

.article-list-item.current {
  background: var(--green-soft);
}

.article-open-button strong {
  font-size: 14px;
}

.article-meta,
.article-delete-button {
  font-size: 10px;
}

.text-input,
textarea,
select {
  border-color: #ddd7cc;
  background: rgba(255, 255, 255, 0.76);
}

.text-input {
  height: 48px;
  padding: 0 15px;
  border-radius: 12px;
}

textarea {
  min-height: 260px;
  border-radius: 14px;
  line-height: 1.75;
}

.text-input:focus,
textarea:focus,
select:focus {
  border-color: rgba(47, 93, 74, 0.55);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 93, 74, 0.09);
}

.primary-button {
  min-height: 44px;
  border-radius: 999px;
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 11px 24px rgba(47, 93, 74, 0.2);
}

.practice-view {
  padding-top: 24px;
  padding-bottom: 54px;
}

.practice-layout {
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 22px;
  min-height: calc(100vh - 118px);
}

.article-panel {
  top: 92px;
  height: calc(100vh - 116px);
  border-color: rgba(211, 205, 194, 0.9);
  border-radius: 20px;
  background: rgba(255, 253, 249, 0.88);
  box-shadow: 0 14px 42px rgba(55, 60, 55, 0.055);
}

.article-panel-head {
  padding: 18px 17px 15px;
}

.sentence-list {
  padding: 11px;
}

.sentence-row {
  margin-bottom: 4px;
  padding: 12px 11px;
  border-radius: 12px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.sentence-row.active {
  border-color: rgba(47, 93, 74, 0.16);
  background: var(--green-soft);
}

.stage-toolbar,
.focus-card,
.record-card,
.grammar-panel {
  border-color: rgba(211, 205, 194, 0.9);
  background: rgba(255, 253, 249, 0.93);
  box-shadow: 0 14px 44px rgba(55, 60, 55, 0.06);
}

.stage-toolbar {
  min-height: 74px;
  padding: 16px 20px;
  border-radius: 18px;
}

.focus-card {
  min-height: 330px;
  margin-top: 18px;
  padding: clamp(32px, 4.3vw, 54px);
  border-radius: 24px;
}

.focus-text {
  min-height: 155px;
  margin: 30px 0;
  line-height: 1.48;
}

.transport-button,
.loop-button,
.play-button {
  min-height: 44px;
}

.play-button {
  min-width: 176px;
}

.record-card {
  margin-top: 18px;
  padding: 26px 30px;
  border-radius: 22px;
}

.record-copy h3 {
  font-size: 17px;
}

.record-number,
.record-timer,
.record-copy p,
.audio-state,
.stage-footer p {
  letter-spacing: 0.005em;
}

.record-button {
  width: 64px;
  height: 64px;
}

.stage-footer {
  padding-top: 20px;
}

.auth-view {
  min-height: 100svh;
}

.auth-card {
  border-color: rgba(201, 194, 183, 0.82);
  box-shadow: 0 28px 90px rgba(45, 52, 47, 0.14);
}

.auth-tab.active {
  box-shadow: 0 3px 14px rgba(45, 52, 47, 0.09);
}

@media (max-width: 900px) {
  main {
    width: min(100% - 28px, 780px);
  }

  .practice-view {
    padding-top: 18px;
  }

  .article-panel {
    max-height: 270px;
    margin-bottom: 18px;
    border-radius: 18px;
  }

  .focus-card {
    min-height: auto;
  }
}

@media (max-width: 700px) {
  .topbar {
    min-height: 62px;
    gap: 8px;
    padding: 0 12px;
  }

  .top-actions {
    min-width: 0;
    gap: 6px;
  }

  .account-pill {
    max-width: 44px;
    min-height: 36px;
    padding: 0 9px;
  }

  #accountName,
  .account-exit {
    display: none;
  }

  .icon-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .icon-button > span {
    display: none;
  }

  main {
    width: min(100% - 20px, 680px);
  }

  .setup-view {
    padding: 34px 0 56px;
  }

  .setup-hero {
    margin-bottom: 24px;
    padding: 0;
  }

  .setup-hero h1 {
    font-size: 41px;
  }

  .setup-hero > span {
    margin-top: 12px;
    font-size: 13px;
  }

  .import-card,
  .library-panel {
    border-radius: 20px;
  }

  .import-card {
    padding: 24px 20px;
  }

  .library-head,
  .article-list-item {
    padding-right: 16px;
    padding-left: 16px;
  }

  .stage-toolbar,
  .focus-card,
  .record-card,
  .grammar-panel {
    border-radius: 16px;
  }

  .focus-card {
    padding: 26px 20px;
  }

  .record-card {
    padding: 22px 20px;
  }
}


/* Sentence translation below the English paragraph */
.focus-translation {
  min-height: 24px;
  margin: -10px 0 18px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.55;
}

.focus-translation:empty {
  display: none;
}

/* A quieter, more guided article setup screen. */
.setup-view {
  width: min(900px, 100%);
  padding-top: clamp(36px, 5vw, 68px);
}

.setup-hero {
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.17em;
}

.hero-eyebrow i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7aa28b;
  box-shadow: 0 0 0 4px rgba(122, 162, 139, 0.16);
}

.setup-hero h1 {
  font-size: clamp(46px, 5.8vw, 70px);
}

.setup-hero > span {
  max-width: 650px;
  margin-top: 14px;
  color: #64716a;
  font-size: 15px;
}

.practice-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  color: #64716a;
  font-size: 12px;
}

.practice-steps span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  white-space: nowrap;
}

.practice-steps b {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.practice-steps > i {
  width: 20px;
  height: 1px;
  background: #c7d3ca;
}

.import-card {
  padding: clamp(24px, 3.5vw, 38px);
}

.import-card-heading {
  display: flex;
  gap: 18px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.import-card-heading p {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.import-card-heading h2 {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.import-card-heading > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.import-card .field-label {
  margin-bottom: 9px;
  color: #46574c;
  font-size: 12px;
}

.import-card .text-input {
  margin-bottom: 24px;
}

.import-card textarea {
  height: 210px;
  min-height: 210px;
  padding: 17px 18px;
  font-family: inherit;
  font-size: 14px;
}

.import-card .import-footer {
  margin-top: 20px;
}

.import-card .text-button {
  min-height: 42px;
  font-size: 12px;
}

.import-card #startButton {
  min-height: 46px;
  padding: 0 22px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .setup-view {
    padding-top: 36px;
  }

  .setup-hero h1 {
    font-size: clamp(38px, 9vw, 48px);
  }

  .setup-hero > span {
    font-size: 13px;
  }

  .practice-steps {
    gap: 9px;
    font-size: 11px;
  }

  .practice-steps > i {
    width: 10px;
  }

  .import-card-heading {
    align-items: start;
  }

  .import-card-heading > span {
    display: none;
  }

  .import-card textarea {
    height: 200px;
    min-height: 200px;
  }
}

/* Sentence analysis focuses on structure; the translation is already above. */
.sentence-structure {
  padding-bottom: 18px;
  border-bottom: 1px solid #e3e9e3;
}

.structure-formula {
  margin: 0;
  color: #263d31;
  font-size: 15px;
  font-weight: 700;
}

.structure-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.structure-part {
  display: grid;
  flex: 1 1 170px;
  gap: 5px;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid #e2e9e2;
  border-radius: 10px;
  background: #f8faf7;
}

.structure-role {
  color: #6a806e;
  font-size: 11px;
  font-weight: 700;
}

.structure-text {
  overflow-wrap: anywhere;
  color: #26342a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.structure-explanation {
  color: #637466;
  font-size: 12px;
  line-height: 1.55;
}

.structure-tip {
  margin: 0;
  color: #69776c;
  font-size: 12px;
  line-height: 1.55;
}

.grammar-intro {
  margin: 0 0 10px;
  color: #68766a;
  font-size: 13px;
  line-height: 1.65;
}

.grammar-kicker {
  color: #365d49;
  font-size: 14px;
  letter-spacing: 0;
}

.grammar-notes li.expression-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 16px;
  align-items: start;
  padding: 15px 17px;
  border: 1px solid #e3ebe4;
  background: #f7faf7;
}

.expression-phrase {
  color: #26372b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 600;
}

.expression-meaning {
  color: #365d49;
  font-size: 13px;
  font-weight: 650;
  text-align: right;
}

.expression-usage {
  grid-column: 1 / -1;
  margin: 0;
  color: #68776a;
  font-size: 12px;
  line-height: 1.65;
}

.grammar-notes li.grammar-empty {
  padding: 16px 17px;
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 700px) {
  .grammar-notes li.expression-item {
    grid-template-columns: 1fr;
  }

  .expression-meaning {
    text-align: left;
  }
}

/* Soft karaoke tracking: color fills the current word from left to right. */
.focus-text {
  color: #222222;
}

.focus-text .word-token {
  color: #222222;
}

.focus-text .word-token.spoken {
  color: #707070;
  background: transparent;
}

.focus-text .word-token.speaking {
  color: #222222;
  background: linear-gradient(90deg,
    #707070 0 var(--karaoke-fill, 0%),
    #222222 var(--karaoke-fill, 0%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  box-shadow: none;
  text-shadow: none;
  transform: none;
}

.immersive-text .word-token.spoken {
  color: #9ba7a0;
  background: transparent;
}

.immersive-text .word-token.speaking,
.immersive-text .word-token.speaking.paused {
  color: #f0eee6;
  background: linear-gradient(90deg,
    #9ba7a0 0 var(--karaoke-fill, 0%),
    #f0eee6 var(--karaoke-fill, 0%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  box-shadow: none;
  text-shadow: none;
  transform: none;
}

@media (max-width: 700px) {
  .immersive-text .word-token.speaking {
    transform: none;
  }
}

/* Article-first setup: saved work is visible before the import form. */
.setup-view {
  width: min(1220px, 100%);
  padding: clamp(24px, 3vw, 42px) 0 72px;
}

.setup-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 22px;
  padding: 0 2px;
}

.setup-hero h1 {
  font-size: clamp(34px, 4vw, 50px);
  line-height: 1.1;
}

.setup-hero > span {
  max-width: 350px;
  margin: 0 0 4px;
  font-size: 13px;
  text-align: right;
}

.setup-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 20px;
  align-items: stretch;
}

.setup-view:not(.has-articles) .setup-workspace {
  grid-template-columns: minmax(0, 1fr);
  max-width: 720px;
  margin-inline: auto;
}

.setup-view:not(.has-articles) .library-panel {
  order: 2;
  height: auto;
}

.library-panel,
.import-card {
  min-width: 0;
  height: 528px;
  margin: 0;
  border-radius: 20px;
  box-shadow: 0 12px 38px rgba(45, 62, 49, 0.055);
}

.library-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-head {
  flex-shrink: 0;
  padding: 24px 26px 18px;
  border-bottom: 0;
}

.library-head p {
  margin: 0 0 5px;
  color: #738778;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.13em;
}

.library-head h2 {
  font-size: 25px;
}

.library-head > span {
  padding: 6px 11px;
  font-size: 11px;
}

.library-search-wrap {
  flex-shrink: 0;
  padding: 0 26px 16px;
}

.library-search {
  width: 100%;
  height: 42px;
  padding: 0 15px;
  border: 1px solid #dedfd6;
  border-radius: 12px;
  color: var(--text);
  background: #f8f8f4;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.library-search:focus {
  border-color: #7da18a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 122, 91, 0.10);
}

.article-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.library-footnote {
  flex-shrink: 0;
  margin: auto 0 0;
  padding: 16px 26px;
  border-top: 1px solid rgba(226, 221, 211, 0.7);
  color: #8b968c;
  font-size: 11px;
}

.setup-view:not(.has-articles) .library-footnote {
  display: none;
}

.article-list-item {
  gap: 12px;
  padding: 17px 26px;
}

.article-open-button strong {
  margin-bottom: 6px;
  font-size: 16px;
}

.article-meta {
  color: #7b877e;
  font-size: 11px;
}

.article-item-progress {
  display: block;
  height: 3px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ece6;
}

.article-item-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #81a990;
}

.article-delete-button {
  border-color: transparent;
  color: #8c7770;
  background: transparent;
}

.import-card {
  display: flex;
  flex-direction: column;
  padding: 26px;
}

.import-card .privacy-note {
  margin-top: auto;
  padding-top: 16px;
}

.import-card-heading {
  margin-bottom: 20px;
  padding-bottom: 16px;
}

.import-card-heading h2 {
  font-size: 24px;
}

.import-card .text-input {
  height: 44px;
  margin-bottom: 18px;
}

.import-card textarea {
  height: 175px;
  min-height: 175px;
}

.import-card .import-footer {
  gap: 10px;
  margin-top: 16px;
}

.import-card .file-action {
  gap: 10px;
}

.import-card #startButton {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .setup-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-panel {
    height: 420px;
  }

  .import-card {
    height: auto;
    min-height: 528px;
  }
}

@media (max-width: 700px) {
  .setup-view {
    padding-top: 26px;
  }

  .setup-hero {
    display: block;
    margin-bottom: 18px;
  }

  .setup-hero h1 {
    font-size: 38px;
  }

  .setup-hero > span {
    margin-top: 8px;
    text-align: left;
  }

  .library-head,
  .article-list-item {
    padding-right: 18px;
    padding-left: 18px;
  }

  .library-search-wrap {
    padding-right: 18px;
    padding-left: 18px;
  }

  .library-footnote {
    padding-right: 18px;
    padding-left: 18px;
  }

  .import-card {
    padding: 22px 18px;
  }
}

/* Keep the paired setup cards equal through viewport and zoom breakpoints. */
.setup-view.has-articles .library-panel,
.setup-view.has-articles .import-card {
  height: clamp(528px, 68dvh, 640px);
  min-height: 0;
}

.setup-view.has-articles .import-card {
  overflow-y: auto;
}

.setup-view.has-articles .textarea-wrap {
  display: flex;
  flex: 1 1 auto;
  min-height: 120px;
}

.setup-view.has-articles .import-card textarea {
  height: 100%;
  min-height: 120px;
  resize: none;
}

/* On wide screens the sentence panel stretches with the complete practice stage. */
@media (min-width: 901px) {
  .practice-layout {
    position: relative;
  }

  .practice-layout .article-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: 320px;
    height: 100%;
    min-height: 0;
  }

  .practice-layout .practice-stage {
    grid-column: 2;
  }

  .practice-layout .sentence-list {
    min-height: 0;
    overflow-y: auto;
  }
}

@media (max-width: 900px) {
  .setup-view.has-articles .library-panel,
  .setup-view.has-articles .import-card {
    height: 528px;
  }
}

/* Sentence changes should not move the controls or the recording card. */
.focus-card {
  display: flex;
  flex-direction: column;
  height: clamp(560px, 70dvh, 620px);
}

.focus-card-top,
.focus-translation-row,
.transport,
.audio-state {
  flex-shrink: 0;
}

.focus-card .focus-text {
  flex: 1 1 auto;
  min-height: 0;
  margin: 24px 0 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c9d3c9 transparent;
}

.focus-card .focus-translation {
  max-height: 100px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.focus-card:has(.translation-editor:not([hidden])) {
  height: auto;
  min-height: 560px;
}

@media (max-width: 700px) {
  .focus-card {
    height: 560px;
  }

  .focus-card:has(.translation-editor:not([hidden])) {
    min-height: 560px;
  }
}

/* A compact desktop stage keeps the practice controls in one viewport. */
@media (min-width: 901px) {
  .practice-layout .practice-stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
  }
  .practice-layout .practice-stage > .stage-toolbar,
  .practice-layout .practice-stage > .record-card,
  .practice-layout .practice-stage > .stage-footer { flex-shrink: 0; }
  .practice-layout .practice-stage > .focus-card {
    flex: 1 0 370px;
    height: auto;
    min-height: 370px;
  }
  .practice-layout .practice-stage > .stage-footer { margin-top: auto; }
  .practice-view {
    min-height: 0;
    padding-top: 14px;
    padding-bottom: 8px;
  }

  .stage-toolbar {
    min-height: 68px;
    padding: 10px 16px;
  }

  .focus-card {
    height: clamp(370px, calc(100dvh - 440px), 560px);
    margin-top: 12px;
    padding: clamp(22px, 2.3vw, 34px);
  }

  .focus-card .focus-text {
    margin: 18px 0 12px;
    font-size: clamp(27px, 2.8vw, 43px);
    line-height: 1.4;
  }

  .focus-card .focus-translation-row {
    margin-bottom: 12px;
  }

  .focus-card .audio-state {
    margin-top: 10px;
  }

  .record-card {
    margin-top: 12px;
    padding: 18px 22px;
  }

  .recording-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .guided-button {
    grid-column: 1 / -1;
  }

  .secondary-button {
    grid-column: 1;
  }

  .ghost-button {
    grid-column: 2;
  }

  .record-button {
    width: 56px;
    height: 56px;
  }

  .stage-footer {
    padding-top: 10px;
  }
}

@media (min-width: 901px) and (max-height: 820px) {
  .stage-footer p {
    display: none;
  }

  .record-card {
    padding-block: 13px;
  }
}

@media (min-width: 901px) and (max-height: 700px) {
  .focus-card {
    height: 350px;
    min-height: 350px;
  }

  .focus-card .focus-text {
    font-size: clamp(24px, 2.4vw, 34px);
    line-height: 1.32;
  }

  .record-card {
    padding-block: 10px;
  }

  .stage-footer {
    padding-top: 6px;
  }
}

/* The analysis dialog is independent of the two-column page layout. */
.grammar-panel:not([open]) {
  display: none;
}

.grammar-panel[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(720px, calc(100vw - 32px));
  max-width: none;
  max-height: min(80dvh, 760px);
  margin: 0;
  padding: 0 26px 26px;
  overflow-y: auto;
  border: 1px solid rgba(211, 205, 194, 0.95);
  border-radius: 22px;
  background: #fffdf9;
  box-shadow: 0 28px 80px rgba(29, 40, 33, 0.22);
  transform: translate(-50%, -50%);
}

.grammar-panel::backdrop {
  background: rgba(26, 37, 30, 0.42);
  backdrop-filter: blur(3px);
}

.grammar-modal-head {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 21px 0 16px;
  border-bottom: 1px solid #e3e9e3;
  background: #fffdf9;
}

.grammar-modal-head h2 {
  margin: 5px 0 0;
  color: #26342a;
  font-size: 22px;
}

.grammar-modal-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #dde5dc;
  border-radius: 50%;
  background: #f7faf7;
  color: #485d4d;
  font-size: 26px;
  line-height: 1;
}

.grammar-modal-close:hover,
.grammar-modal-close:focus-visible {
  background: #e9f1e9;
}

@media (max-width: 700px) {
  .grammar-panel[open] {
    width: calc(100vw - 20px);
    max-height: 88dvh;
    padding: 0 18px 20px;
    border-radius: 18px;
  }
}
/* Editing uses the existing sentence card and its reserved height. */
@media (min-width: 701px) {
  .focus-card.editing-content > :not(.focus-card-top):not(.sentence-content-editor) { display: none !important; }
  .focus-card.editing-content .focus-top-right { display: none; }
}
.sentence-content-editor[hidden] { display: none; }
.sentence-content-editor:not([hidden]) {
  display: flex; flex: 1; flex-direction: column; min-height: 0; gap: 12px; padding-top: 22px;
}
.sentence-content-editor label { font-size: 14px; color: #305d4e; font-weight: 600; }
.sentence-content-editor #sentenceContentInput {
  flex: 1; width: 100%; height: auto; min-height: 110px; max-height: none;
  resize: none; padding: 16px; border: 1px solid #dadfd7; border-radius: 12px;
  color: #222; background: #fff; font: inherit; font-size: clamp(18px, 2vw, 25px); line-height: 1.6;
}
.sentence-content-editor p { margin: 0; font-size: 12px; color: #707870; line-height: 1.5; }
.sentence-content-actions { display: flex; justify-content: flex-end; gap: 10px; }
.focus-edit-actions { flex-wrap: wrap; }
.sentence-list-toolbar {
  display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 17px 8px;
}
.sentence-list-toolbar > span { color: #7b847c; font-size: 12px; }
.sentence-list-toolbar #addSentenceButton { border-radius: 999px; padding: 7px 12px; color: #305d4e; background: #eef4ef; border-color: #dae5dc; }
.sentence-content-actions button {
  min-height: 42px; padding: 10px 24px; border-radius: 999px; font: inherit; font-size: 14px;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.sentence-content-actions .translation-save-button {
  border: 1px solid #305d4e; background: #305d4e; box-shadow: 0 5px 16px rgba(48,93,78,.13);
}
.sentence-content-actions .translation-save-button:hover { background: #264f40; box-shadow: 0 7px 20px rgba(48,93,78,.18); }
.sentence-content-actions .translation-cancel-button { background: #f8f9f5; border-color: #dce3d9; color: #667368; }
.sentence-content-actions .translation-cancel-button:hover { background: #edf2ec; }
.sentence-content-actions button:active { transform: translateY(1px); }
.legal-footer { padding: 18px 20px; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 16px; color: #707070; font-size: 12px; }
.legal-link { border: 0; padding: 2px 4px; background: transparent; color: #305d4e; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.legal-registration-note { color: #707070; font-size: 12px; line-height: 1.7; }
.legal-dialog { width: min(720px, calc(100vw - 32px)); max-height: 85dvh; padding: 0; border: 1px solid #dedbd3; border-radius: 24px; background: #fffdf9; color: #222; box-shadow: 0 24px 80px #0003; }
.legal-dialog::backdrop { background: #17251f66; }
.legal-dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; background: #fffdf9; border-bottom: 1px solid #e9e6df; }
.legal-dialog-head h2 { margin: 0; font-size: 20px; }
.legal-close { border: 1px solid #dedbd3; border-radius: 999px; padding: 9px 18px; background: #f5f4ee; color: #305d4e; cursor: pointer; }
.legal-dialog-body { padding: 8px 24px 24px; font-size: 14px; line-height: 1.85; }
.legal-dialog-body h3 { margin: 22px 0 8px; font-size: 16px; }
.legal-dialog-body p { margin: 10px 0; }
.legal-dialog-body a { color: #305d4e; overflow-wrap: anywhere; }
.legal-meta, .legal-pending { color: #707070; font-size: 12px; }
@media (max-width: 600px) {
  .sentence-content-actions button { padding-inline: 18px; }
}
.article-translation-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  flex-shrink: 0;
  max-width: 100%;
}

/* Playback settings share the practice page's warm, green palette. */
.mobile-home-actions, .mobile-practice-head, .mobile-only { display: none; }
.mobile-sheet { width: min(560px, calc(100% - 24px)); max-height: 85dvh; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: #fffdf9; color: var(--text); }
.mobile-sheet::backdrop { background: #18352b66; }
.mobile-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mobile-sheet-head h2 { margin: 0; font-size: 19px; }
#mobileSheetBody { max-height: 68dvh; overflow-y: auto; overscroll-behavior: contain; }
#mobileSheetBody .library-panel { width: 100%; height: auto; padding: 0; border: 0; box-shadow: none; }
#mobileSheetBody .article-list, #mobileSheetBody .sentence-list { height: auto; max-height: none; overflow: visible; }
#mobileSheetBody .sentence-content-editor, #mobileSheetBody .translation-editor { margin: 0; }
#mobileMoreActions { display: grid; gap: 12px; }
#mobileMoreActions[hidden] { display: none; }
@media (max-width: 700px) {
  body:has(.app-shell:not([hidden])) { height: 100dvh; overflow: hidden; }
  .app-shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .app-shell .topbar { flex: 0 0 58px; min-height: 58px; }
  .app-shell main { flex: 1; min-height: 0; width: 100%; overflow: hidden; }
  .legal-footer { display: none; }
  .app-shell .setup-view { height: 100%; padding: 18px 14px max(12px, env(safe-area-inset-bottom)); overflow: hidden; display: flex; flex-direction: column; }
  .setup-view .setup-workspace { flex: 1; height: auto; min-height: 0; display: flex; flex-direction: column; }
  /* Empty accounts must not inherit the desktop centered, shrink-to-fit column. */
  .app-shell .setup-view .setup-workspace,
  .app-shell .setup-view:not(.has-articles) .setup-workspace {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    align-items: stretch;
  }
  .app-shell .setup-view .library-panel,
  .app-shell .setup-view.mobile-editing .import-card {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    box-sizing: border-box;
  }
  .setup-view .library-panel, .setup-view .import-card { display: none; }
  .setup-view .mobile-home-actions { order: 1; flex-shrink: 0; display: grid; gap: 10px; margin: 12px 0 0; }
  .mobile-home-actions #mobileImportButton { width: 100%; min-height: 44px; border-radius: 12px; }
  .mobile-home-actions .legal-link { justify-self: center; min-height: 28px; font-size: 12px; }
  .setup-view:not(.mobile-editing) .library-panel {
    order: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    height: auto;
    min-height: 0;
    padding: 16px;
    margin: 0;
    border-radius: 20px;
    overflow: hidden;
  }
  .setup-view:not(.mobile-editing) .library-head { flex-shrink: 0; margin-bottom: 12px; }
  .setup-view:not(.mobile-editing) .library-head p { display: none; }
  .setup-view:not(.mobile-editing) .library-head h2 { font-size: 22px; }
  .setup-view:not(.mobile-editing) .library-search-wrap { flex-shrink: 0; margin-bottom: 10px; }
  .setup-view:not(.mobile-editing) .library-search { min-height: 40px; height: 40px; }
  .setup-view:not(.mobile-editing) .article-list { flex: 1; height: auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
  .setup-view:not(.mobile-editing) .article-list-item { padding: 14px 10px; }
  .setup-view:not(.mobile-editing) .article-open-button strong { font-size: 17px; line-height: 1.35; }
  .setup-view:not(.mobile-editing) .article-meta { font-size: 11px; }
  .setup-view:not(.mobile-editing) .library-footnote { display: none; }
  .setup-view:not(.mobile-editing) .library-empty { margin: auto 0; }
  .setup-view:not(.mobile-editing):not(.has-articles) .article-list,
  .setup-view:not(.mobile-editing):not(.has-articles) .library-search-wrap { display: none; }
  .setup-view:not(.mobile-editing):not(.has-articles) .library-head { padding: 4px 0 12px; margin: 0; }
  .setup-view:not(.mobile-editing):not(.has-articles) .library-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0;
    padding: 24px 12px;
    text-align: center;
    line-height: 1.7;
    font-size: 14px;
  }
  .setup-view:not(.mobile-editing):not(.has-articles) .library-empty::before {
    content: "从第一篇文章开始";
    color: var(--accent);
    font-size: 20px;
    font-weight: 600;
  }
  .app-shell .setup-view.mobile-editing .import-card .import-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .app-shell .setup-view.mobile-editing #startButton { width: 100%; }
  .setup-view .setup-hero { flex-shrink: 0; margin-bottom: 18px; }
  .setup-view.mobile-editing .setup-hero, .setup-view.mobile-editing .mobile-home-actions { display: none; }
  .setup-view.mobile-editing .import-card { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 16px; gap: 8px; overflow: hidden; }
  .mobile-only { display: block; }
  .setup-view.mobile-editing .import-card .textarea-wrap { flex: 1; min-height: 40px; height: auto; }
  .setup-view.mobile-editing .import-card #articleText { height: 100%; min-height: 0; resize: none; }
  .import-card .import-footer { flex-shrink: 0; margin-top: 8px; }
  .import-card .privacy-note, .import-card-heading > span { display: none; }
  .app-shell .practice-view { height: 100%; padding: 6px 10px 10px; display: flex; flex-direction: column; overflow: hidden; }
  .practice-view[hidden], .setup-view[hidden] { display: none; }
  .mobile-practice-head { display: flex; justify-content: space-between; flex: 0 0 34px; align-items: center; }
  .practice-view .practice-layout { flex: 1; min-height: 0; display: flex; }
  .practice-view .article-panel { display: none; }
  .practice-view .practice-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; }
  .practice-view .practice-stage .focus-card { flex: 1; min-height: 0; height: auto; padding: 12px; }
  .practice-view .focus-card-top { display: none; }
  .practice-view .practice-stage .focus-card .focus-text { flex: 1; height: auto; min-height: 35px; max-height: none; margin: 8px 0 10px; font-size: clamp(21px, 5.7vw, 27px); }
  .practice-view .focus-translation-row { height: clamp(44px, 9dvh, 72px); min-height: 0; margin-bottom: 10px; }
  .practice-view .article-translation-actions { display: none; }
  .practice-view .continuous-controls { margin-top: 8px; padding-top: 6px; }
  .practice-view .practice-stage .record-card { flex: 0 0 auto; margin-top: 10px; padding: 10px 12px; gap: 8px; }
  .practice-view .record-card .record-button { width: 52px; height: 52px; }
  .practice-view .record-card .record-timer { margin-top: 3px; }
  .practice-stage > .sentence-content-editor, .focus-card > .sentence-content-editor, .focus-card > .translation-editor { display: none; }
  .mobile-sheet { position: fixed; margin: auto auto 10px; max-height: 88dvh; }
}
.sentence-list-toggle { border: 0; background: transparent; color: var(--muted); padding: 8px 0; font: inherit; cursor: pointer; }
.sentence-list-toggle { pointer-events: none; font-size: 0; }
.sentence-list-toggle::after { content: "句子列表"; font-size: 12px; }
.continuous-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.continuous-controls button { display: inline-flex; align-items: center; gap: 12px; padding: 6px 0; border: 0; color: var(--muted); background: transparent; font-size: 12px; }
.continuous-controls button span { font-size: 0; width: 30px; height: 18px; border-radius: 999px; background: var(--line); position: relative; }
.continuous-controls button span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fffdf9; transition: transform .15s; }
.continuous-controls button[aria-pressed="true"] span { background: var(--accent); }
.continuous-controls button[aria-pressed="true"] span::after { transform: translateX(12px); }
.continuous-controls button[aria-pressed="true"] { color: var(--accent); }
.continuous-controls small { color: var(--muted); font-size: 11px; }
.immersive-view {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 16px;
  overflow: hidden;
}
.immersive-view .immersive-position { grid-row: 1; }
.immersive-view .immersive-text {
  grid-row: 2;
  box-sizing: border-box;
  align-self: stretch;
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}
.immersive-view .immersive-translation {
  grid-row: 3;
  max-height: 20dvh;
  overflow: auto;
  margin: 0;
}
.immersive-view .immersive-controls { grid-row: 4; }
.readloom-mark { width: 36px; height: 36px; flex: 0 0 36px; object-fit: contain; }
.brand strong { color: var(--accent); }
.setup-hero #dailyPhrase { font-size: clamp(22px, 2.8vw, 36px); line-height: 1.3; letter-spacing: -0.02em; }
@media (max-width: 700px) {
  .readloom-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .setup-hero #dailyPhrase { font-size: 24px; }
}
.word-context-meaning { white-space: pre-line; font-size: 14px; line-height: 1.7; color: var(--ink); }
.word-expression-usage { border-top:1px solid #e3e7dc; padding-top:10px; margin:10px 0; font-size:13px; line-height:1.6; }
.word-expression-heading { display:block; color:#7b837b; font-size:11px; margin-bottom:3px; }
.word-expression-usage strong { display:block; color:#305d4e; font-size:14px; }
.word-expression-usage p { margin:5px 0 0; }
.word-dictionary-details summary, .expression-item summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.analysis-original { font-family: Georgia, serif; font-size: 22px; line-height: 1.5; margin: 16px 0 8px; }
#grammarFeatures { margin-bottom: 24px; }
#grammarFeatures h3 { font-size: 15px; color: var(--accent); margin: 0 0 12px; }
.grammar-feature { padding: 14px 16px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: #f6f9f5; }
.grammar-feature strong { color: var(--accent); font-size: 14px; }
.grammar-feature p { margin: 7px 0 0; font-size: 14px; line-height: 1.6; }
.playback-status-row { display: contents; }
@media (min-width: 901px) {
  .focus-card .playback-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }
  .focus-card .playback-status-row .audio-state { order: -1; margin-top: 0; }
  .focus-card .playback-status-row .continuous-controls { margin-top: 0; padding-top: 0; border-top: 0; }
}
@media (max-width: 700px) {
  .sentence-list-toggle { pointer-events: auto; font-size: 12px; }
  .sentence-list-toggle::after { content: none; }
  .article-panel:not(.sentences-expanded) .sentence-list { display: none; }
  .practice-layout .article-panel { position: static; height: auto; min-height: 0; max-height: none; margin-bottom: 20px; }
  .article-panel .sentence-list { max-height: 32dvh; overflow-y: auto; }
  .article-panel .sentence-list-toolbar { padding-top: 10px; padding-bottom: 10px; }
  .practice-layout .practice-stage { min-width: 0; }
}
.record-center { justify-self: center; }
.record-button { padding: 0; line-height: 1; }
.record-button svg { display: block; margin: 0; }
.recording-actions #playRecordingButton { grid-column: 1; }
.recording-actions #deleteRecordingButton { grid-column: 2; }
@media (max-width: 700px) {
  .practice-view { padding-top: 10px; padding-bottom: 16px; }
  .practice-layout { display: block; }
  .practice-layout .sentence-sidebar,
  .practice-stage .stage-toolbar,
  .practice-stage .stage-footer,
  .focus-card .focus-hint,
  .focus-card .audio-state,
  .record-card .record-copy,
  .record-card .guided-button { display: none; }
  .practice-stage .focus-card {
    height: auto;
    min-height: 0;
    padding: 18px;
    margin-top: 0;
  }
  .practice-stage .focus-card:has(.translation-editor:not([hidden])) { min-height: 0; }
  .focus-card .focus-card-top { gap: 8px; min-height: 26px; }
  .practice-stage .focus-card .focus-text {
    flex: none;
    height: clamp(140px, 25svh, 200px);
    min-height: clamp(140px, 25svh, 200px);
    max-height: clamp(140px, 25svh, 200px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    margin: 16px 0 12px;
    font-size: clamp(23px, 6vw, 30px);
    line-height: 1.4;
  }
  .focus-card .focus-translation-row {
    height: clamp(68px, 10svh, 88px);
    min-height: clamp(68px, 10svh, 88px);
    margin-bottom: 12px;
    gap: 8px;
    align-items: flex-start;
  }
  .focus-card .focus-translation {
    display: block;
    height: 100%;
    max-height: 100%;
    margin-top: 0;
    margin-bottom: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    font-size: 14px;
    line-height: 1.6;
  }
  .focus-card .transport {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px auto;
    gap: 7px;
  }
  .transport #playButton { order: 0; grid-column: auto; width: 100%; min-height: 42px; padding: 8px; font-size: 12px; }
  .transport #prevButton, .transport #nextButton { width: 40px; height: 42px; }
  .transport #loopButton { min-height: 42px; padding: 8px; }
  .practice-stage .record-card {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 14px;
    padding: 18px;
    margin-top: 12px;
  }
  .record-card .record-center { width: 100%; justify-self: center; justify-items: center; margin: 0; }
  .record-card .record-button { width: 64px; height: 64px; }
  .record-card .record-timer { margin-top: 6px; font-size: 12px; }
  .record-card .recording-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .recording-actions #playRecordingButton,
  .recording-actions #deleteRecordingButton { padding: 8px; font-size: 11px; }
}
#mergeButton, #splitButton, #resegmentButton,
#fullTranslationButton, #retryTranslationButton { display: none !important; }
.sentence-content-actions .sentence-delete-button {
  margin-right: auto;
  color: var(--red);
  border-color: var(--line);
}
.recording-actions #playRecordingButton,
.recording-actions #deleteRecordingButton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf9;
  font-size: 12px;
  font-weight: 500;
  box-shadow: none;
}
.recording-actions #deleteRecordingButton svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.recording-actions #deleteRecordingButton:not(:disabled):hover {
  color: var(--red);
  background: var(--red-soft);
}
.recording-actions #playRecordingButton.playing {
  color: var(--accent);
  background: var(--green-soft);
  border-color: var(--accent);
}
.recording-actions #playRecordingButton svg {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.mobile-sheet-head #mobileSheetClose {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; flex: 0 0 40px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 50%;
  color: var(--muted); background: var(--green-soft); font-size: 0;
  box-shadow: none;
}
.mobile-sheet-head #mobileSheetClose::before { content: none; }
.mobile-sheet-head #mobileSheetClose svg { display:block; width:20px; height:20px; margin:0; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
.mobile-sheet-head #mobileSheetClose:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 700px) {
  #mobileSheet[data-content="sentenceList"] {
    inset: 0;
    margin: auto; max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}
.stage-toolbar .settings-group {
  align-items: center;
  gap: 20px;
}
.stage-toolbar .select-control,
.stage-toolbar .speed-control {
  gap: 7px;
  font-size: 11px;
}
.stage-toolbar .select-control select {
  appearance: none;
  -webkit-appearance: none;
  width: 190px;
  max-width: 100%;
  height: 38px;
  padding: 0 34px 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 12px;
  box-shadow: none;
  background: #fffdf9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  transition: border-color .15s ease, background-color .15s ease;
}
.stage-toolbar .select-control select:hover {
  border-color: var(--accent);
}
.stage-toolbar .speed-control {
  width: 160px;
}
.stage-toolbar .speed-control > span {
  align-items: center;
}
.stage-toolbar .speed-control strong {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--accent);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.stage-toolbar #speedRange {
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  margin: 13px 0;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--speed-progress, 43%), var(--line) var(--speed-progress, 43%), var(--line) 100%);
  cursor: pointer;
}
.stage-toolbar #speedRange::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border: 3px solid #fffdf9;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.stage-toolbar #speedRange::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 3px solid #fffdf9;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
@media (max-width: 600px) {
  .stage-toolbar .settings-group { flex-wrap: wrap; gap: 12px; }
  .stage-toolbar .select-control { flex: 1 1 170px; min-width: 0; }
  .stage-toolbar .select-control select { width: 100%; }
  .stage-toolbar .speed-control { flex: 1 1 130px; }
}
/* Guest preview never exposes article mutation controls. */
.guest-notice { display: none; }
.guest-mode .guest-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px; margin-bottom: 12px; border-radius: 12px; background: #e5eee7; color: #315e4d; font-size: 13px; }
.guest-notice button { border: 0; background: transparent; color: inherit; min-height: 44px; font: inherit; }
.guest-mode .account-exit { display: none !important; }
.guest-mode button:disabled { cursor: not-allowed; }
.guest-mode [data-guest-restricted] { opacity: .45; cursor: pointer; }
.word-tooltip.show { pointer-events: auto; }
.guest-mode .guest-notice { display:none!important; }
.structure-parts { display:flex; flex-direction:column; gap:12px; align-items:stretch; }
.structure-clause{padding:16px;border:1px solid var(--line);border-radius:14px;background:#fffdf9;min-width:0}
.structure-clause h3{margin:0 0 12px;font-size:12px;color:var(--accent);font-weight:600}
.structure-core{display:flex;flex-wrap:wrap;gap:8px;align-items:stretch}
.structure-core>.structure-part{flex:1 1 120px;border-top:3px solid #a5b9aa}
.structure-core>.structure-part:has(.structure-role){background:#f3f6f2}
.structure-core>.structure-subject{border-top-color:#8bab97;background:#edf4ee}
.structure-core>.structure-predicate{border-top-color:#9caec0;background:#eef2f7}
.structure-core>.structure-complement{border-top-color:#c5b58c;background:#f7f3e9}
.structure-connector{margin:0;padding:4px 16px;font-size:13px;color:var(--accent);border-left:3px solid var(--accent)}
.structure-modifiers{margin-top:12px;border-top:1px solid var(--line);padding-top:8px}
.structure-modifiers summary,.grammar-notes>summary{cursor:pointer;color:var(--accent);font-size:13px;line-height:1.6;padding:8px 0}
.grammar-notes>summary{font-weight:600}
.grammar-panel .grammar-kicker{font-size:10px;letter-spacing:1.4px}
.grammar-panel .analysis-original{font-size:clamp(20px,2vw,25px);line-height:1.65;margin:18px 0 10px;overflow-wrap:anywhere}
.grammar-panel .structure-formula{font-size:12px;font-weight:400;color:var(--muted);line-height:1.6;margin:8px 0 14px}
.grammar-panel .structure-tip{font-size:13px;line-height:1.7;margin-top:14px}
.grammar-panel .grammar-block{margin-top:20px}
.grammar-panel[open]{gap:8px;align-content:start}
.grammar-panel #analysisStatus:empty{display:none}
.grammar-panel #analysisTranslation{margin:0 0 8px;line-height:1.7}
.grammar-panel .grammar-block{gap:6px;margin-top:10px}
@media(max-width:700px){.structure-core{flex-direction:column}.structure-core>.structure-part{flex:0 0 auto}.structure-clause{padding:12px}}
.structure-parts .structure-part { min-width:0; min-height:0; gap:5px; padding:10px 12px; align-items:start; align-content:start; border-radius:9px; }
.structure-parts .structure-text { font-size:16px; line-height:1.35; }
.structure-parts .structure-role { font-size:11px; line-height:1.3; }
.structure-parts .structure-explanation { font-size:12px; line-height:1.4; }
.structure-details { width:100%; margin-top:4px; }
.structure-details summary { color:var(--accent); cursor:pointer; font-size:13px; padding:6px 0; }
.structure-children { display:flex; flex-direction:column; gap:8px; margin-top:8px; padding-left:12px; border-left:2px solid var(--line); }
.structure-parts .structure-subpart { width:100%; background:transparent; }
.guest-login-action {
  flex:0 0 auto;
  justify-content:center;
  width:auto;
  max-width:none;
  min-height:36px;
  padding:0 14px;
  background:var(--accent);
  border-color:var(--accent);
  color:#fffdf8;
  font-family:inherit;
  font-size:13px;
  font-weight:500;
  line-height:1;
  white-space:nowrap;
  cursor:pointer;
}
.guest-login-action:hover { background:var(--accent); border-color:var(--accent); color:#fffdf8; }
@media(max-width:700px){
  .guest-mode .top-actions { flex:0 0 auto; gap:6px; }
  .guest-mode .top-actions .guest-login-action { width:auto;max-width:none;padding:0 10px;font-size:12px;min-height:36px;white-space:nowrap; }
  .guest-mode #setupView:not(.mobile-editing) .article-list { display:block; }
}
@media(min-width:701px){
  #appShell #practiceView .focus-card { height:clamp(320px,calc(100dvh - 330px),600px); flex:none; }
  #appShell #practiceView .focus-card .focus-text { flex:1 1 auto; min-height:0; overflow-y:auto; }
  #appShell #practiceView .focus-translation-row { height:76px; min-height:54px; flex-shrink:0; }
  #appShell #practiceView .focus-card .focus-translation { max-height:76px; overflow-y:auto; }
  #practiceView .transport, #practiceView .playback-status-row { flex-shrink:0; }
}
@media(max-width:700px){
  .app-shell main { display:flex; flex-direction:column; }
  .guest-mode .guest-notice { flex:0 0 auto; padding:4px 12px; margin:0; font-size:11px; gap:0; }
  .guest-mode .guest-notice button { min-height:28px; padding:0; }
  .app-shell #setupView { flex:1; height:auto; min-height:0; padding-top:8px; }
  .app-shell #setupView.mobile-editing .import-card { padding:12px; gap:5px; }
  .app-shell #setupView.mobile-editing .import-card-heading { padding-bottom:8px; margin-bottom:4px; }
  .app-shell #setupView.mobile-editing .import-card-heading p { display:none; }
  .app-shell #setupView.mobile-editing .import-card-heading h2 { font-size:22px; }
  .app-shell #setupView.mobile-editing .textarea-wrap { flex:1; min-height:40px; }
  .app-shell #setupView.mobile-editing .import-footer { flex:0 0 auto; margin-top:6px; }
  .guest-mode #setupView.mobile-editing .file-action { display:none; }
}
@media(min-width:701px){
  body:has(#appShell:not([hidden]) #practiceView:not([hidden])) { height:100dvh; overflow:hidden; }
  body:has(#practiceView:not([hidden])) #appShell:not([hidden]) { height:calc(100dvh - 34px); display:flex; flex-direction:column; overflow:hidden; }
  body:has(#practiceView:not([hidden])) #appShell > header { flex-shrink:0; }
  body:has(#practiceView:not([hidden])) #appShell > main { flex:1; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
  #practiceView:not([hidden]) { flex:1; min-height:0; height:auto; padding-block:10px; }
  #practiceView .practice-stage { min-height:0; height:100%; display:flex; flex-direction:column; gap:10px; }
  #practiceView .stage-toolbar, #practiceView .record-card, #practiceView .practice-actions { flex-shrink:0; }
  #practiceView .focus-card { flex:1; min-height:0; padding:20px 28px; overflow-y:auto; overscroll-behavior:contain; }
  #practiceView .focus-text { font-size:clamp(26px,3vw,44px); }
  body:has(#practiceView:not([hidden])) .guest-notice { flex-shrink:0; padding-block:2px; margin-bottom:4px; }
  body:has(#practiceView:not([hidden])) > .legal-footer { padding-block:4px; }
}
/* Article selection uses the viewport; only its content areas scroll. */
@media (min-width: 701px) {
  body:has(#appShell:not([hidden]) #setupView:not([hidden])) { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  body:has(#setupView:not([hidden])) #appShell:not([hidden]) { flex: 1; min-height: 0; height: auto; display: flex; flex-direction: column; overflow: hidden; }
  body:has(#setupView:not([hidden])) #appShell > header { flex-shrink: 0; }
  body:has(#setupView:not([hidden])) #appShell > main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding-block: 12px; }
  body:has(#setupView:not([hidden])) .guest-notice { flex-shrink: 0; padding-block: 4px; margin-bottom: 8px; }
  #appShell #setupView:not([hidden]) { flex: 1; min-height: 0; height: auto; display: flex; flex-direction: column; padding-block: 8px; }
  #appShell #setupView .setup-hero { flex-shrink: 0; margin-bottom: 16px; padding-block: 0; }
  #appShell #setupView .setup-workspace { flex: 1; min-height: 0; height: auto; align-items: stretch; }
  #appShell #setupView .library-panel, #appShell #setupView .import-card { height: 100%; min-height: 0; max-height: none; display: flex; flex-direction: column; overflow: hidden; }
  #appShell #setupView .article-list { flex: 1; min-height: 0; height: auto; overflow-y: auto; overscroll-behavior: contain; }
  #appShell #setupView .import-card { padding-block: 20px; }
  #appShell #setupView .import-card > :not(.textarea-wrap) { flex-shrink: 0; }
  #appShell #setupView .textarea-wrap { flex: 1; min-height: 60px; height: auto; margin-bottom: 0; }
  #appShell #setupView #articleText { height: 100%; min-height: 0; resize: none; overflow-y: auto; overscroll-behavior: contain; }
  #appShell #setupView .import-footer { margin-top: 12px; }
  body:has(#appShell:not([hidden]) #setupView:not([hidden])) > .legal-footer { flex-shrink: 0; padding-block: 6px; }
}
/* Fit ordinary desktop windows, but never clip controls on short screens. */
@media(min-width:701px){
  body:has(#appShell:not([hidden]) #practiceView:not([hidden])) { height:auto; min-height:100dvh; overflow-y:auto; }
  body:has(#practiceView:not([hidden])) #appShell:not([hidden]) { height:auto; min-height:calc(100dvh - 34px); overflow:visible; }
  body:has(#practiceView:not([hidden])) #appShell > main { overflow:visible; }
  #practiceView:not([hidden]) { height:auto; min-height:0; }
  #practiceView .practice-stage { height:auto; min-height:0; gap:8px; }
  #practiceView .stage-toolbar { min-height:60px; padding:8px 16px; }
  #practiceView .focus-card { height:auto; min-height:0; margin-top:0; padding:16px 22px; overflow:visible; }
  #practiceView .focus-card .focus-text { flex:none; font-size:clamp(24px,2.1vw,34px); line-height:1.35; min-height:0; max-height:none; margin:12px 0; overflow:visible; }
  #practiceView .focus-card .focus-translation { font-size:16px; line-height:1.6; margin:4px 0 10px; max-height:none; overflow:visible; }
  #practiceView .record-card { margin-top:0; padding:12px 20px; }
  #practiceView .record-button { width:56px; height:56px; min-height:56px; }
  #practiceView .record-copy p { margin:4px 0; }
  #practiceView .audio-state { margin-top:8px; padding-block:4px; }
  #practiceView .stage-footer { flex-shrink:0; margin-top:0; padding-top:0; }
  #practiceView .lesson-sidebar { max-height:calc(100dvh - 160px); min-height:0; }
  body:has(#practiceView:not([hidden])) .guest-notice button { min-height:28px; }
}
/* Desktop practice: allocate the actual remaining space, not a guessed offset. */
@media(min-width:701px){
  body:has(#appShell:not([hidden]) #practiceView:not([hidden])) { display:flex; flex-direction:column; height:100dvh; min-height:0; overflow:hidden; }
  body:has(#practiceView:not([hidden])) #appShell:not([hidden]) { flex:1 1 0; height:auto; min-height:0; overflow:hidden; }
  body:has(#practiceView:not([hidden])) #appShell > main { flex:1 1 0; min-height:0; overflow:hidden; }
  #appShell #practiceView:not([hidden]) { flex:1 1 0; height:auto; min-height:0; display:flex; flex-direction:column; padding-block:8px; }
  #appShell #practiceView .practice-layout { flex:1 1 0; height:auto; min-height:0; align-items:stretch; }
  #appShell #practiceView .article-panel { height:100%; min-height:0; max-height:none; display:flex; flex-direction:column; overflow:hidden; }
  #appShell #practiceView .sentence-list { flex:1 1 0; height:auto; min-height:0; max-height:none; overflow-y:auto; }
  #appShell #practiceView .practice-stage { height:100%; min-height:0; display:flex; flex-direction:column; }
  #appShell #practiceView .focus-card { flex:1 1 0; height:auto; min-height:0; overflow:hidden; }
  #appShell #practiceView .focus-card .focus-text { flex:1 1 0; min-height:0; overflow-y:auto; }
  #appShell #practiceView .focus-translation-row { height:60px; min-height:0; }
  #appShell #practiceView .stage-toolbar, #appShell #practiceView .record-card, #appShell #practiceView .stage-footer { flex:0 0 auto; }
  body:has(#appShell:not([hidden]) #practiceView:not([hidden])) > .legal-footer { flex:0 0 auto; margin:0; padding-block:4px; }
}
@media(min-width:701px) and (max-height:600px){
  #appShell #practiceView .practice-stage { overflow:hidden; }
  #appShell #practiceView .focus-card { flex:0 0 260px; }
}
.sms-code-row { display: flex; align-items: stretch; gap: 10px; min-width: 0; }
.sms-code-row .text-input { min-width: 0; flex: 1; }
.sms-code-row button { flex: 0 0 auto; white-space: nowrap; padding: 10px 14px; font-size: 14px; }
#accountFields .text-input { margin-bottom: 12px; }
.auth-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.auth-tab { min-width: 0; white-space: nowrap; padding: 8px 4px; }
.auth-card .primary-button, .auth-card .secondary-button { min-height: 44px; border-radius: 12px; font-weight: 650; white-space: nowrap; }
.auth-card .sms-code-row { margin-bottom: 15px; }
.auth-card .sms-code-row .text-input { margin-bottom: 0; }
.auth-card .sms-code-row button { width: 124px; height: auto; flex-shrink: 0; }
.logout-action { flex: 0 0 auto; white-space: nowrap; }
.logout-action[hidden] { display: none !important; }
@media (max-width: 700px) {
  .top-actions .logout-action { width: auto; min-width: 62px; max-width: none; padding: 8px 10px; font-size: 12px; }
  .auth-card { max-width: 100%; min-width: 0; }
  .auth-tab { font-size: 12px; }
  .auth-card .sms-code-row button { width: 110px; padding: 8px; font-size: 12px; }
}
@media (max-width: 400px) {
  .topbar .brand { gap: 6px; min-width: 0; }
  .topbar .brand strong { font-size: 18px; white-space: nowrap; }
  .topbar .readloom-mark { width: 28px; height: 28px; flex-shrink: 0; }
  .top-actions .account-pill:not(.logout-action):not(.guest-login-action) { padding: 0 6px; }
  .guest-mode .top-actions .guest-login-action { font-size: 11px; padding: 0 6px; }
}
.auth-brand { border:0; background:transparent; padding:0; text-align:left; color:inherit; cursor:pointer; }
.top-actions .logout-action { display:inline-flex; align-items:center; justify-content:center; padding:0 12px; line-height:1; letter-spacing:0; font-family:inherit; text-align:center; }
.top-actions #accountButton { cursor:default; }
@media (min-width:701px) {
  .auth-view { min-height:100dvh; padding-block:16px; overflow:visible; }
  .auth-card { padding:22px 28px; }
  .auth-card .auth-brand { margin-bottom:16px; }
  .auth-card .auth-heading { margin-bottom:14px; }
  .auth-card .auth-heading h1 { font-size:30px; }
  .auth-card .auth-tabs { margin-bottom:14px; }
  .auth-card .text-input { min-height:40px; height:40px; padding:8px 12px; margin-bottom:9px; }
  .auth-card #accountFields .text-input { margin-bottom:9px; }
  .auth-card .sms-code-row { margin-bottom:9px; }
  .auth-card .sms-code-row .text-input { margin-bottom:0; }
  .auth-card .legal-registration-note { margin:8px 0; font-size:11px; }
  .auth-card .auth-hint { margin-top:10px; }
}
@media (max-width:700px) {
  .auth-view { padding:10px; min-height:100dvh; overflow:visible; }
  .auth-card { padding:16px 18px; border-radius:20px; }
  .auth-card .auth-brand { margin-bottom:12px; }
  .auth-card .auth-kicker { display:none; }
  .auth-card .auth-heading { margin-bottom:12px; }
  .auth-card .auth-heading h1 { font-size:25px; margin:0; }
  .auth-card .auth-heading p:last-child { margin-top:5px; font-size:11px; line-height:1.4; }
  .auth-card .auth-tabs { margin-bottom:12px; }
  .auth-card .field-label { font-size:11px; margin-bottom:4px; }
  .auth-card .text-input { height:42px; min-height:42px; padding:9px 11px; font-size:16px; margin-bottom:9px; border-radius:11px; }
  .auth-card #accountFields .text-input { margin-bottom:9px; }
  .auth-card .sms-code-row { margin-bottom:9px; }
  .auth-card .sms-code-row button { min-height:42px; }
  .auth-card .legal-registration-note { margin:8px 0; font-size:10px; line-height:1.4; }
  .auth-card .auth-hint { margin:10px 0 0; font-size:10px; }
  .setup-view .article-list { display:flex; flex-direction:column; gap:0; }
  .setup-view .article-list-item { flex:0 0 auto; margin:0; border:0; border-bottom:1px solid rgba(226,221,211,.55); border-radius:0; background:transparent; }
  .setup-view .article-list-item:last-child { border-bottom:0; }
  .setup-view .article-list-item.current { background:rgba(222,237,229,.65); box-shadow:inset 3px 0 0 var(--green); }
}
/* Give login modes more breathing room without enlarging the registration form. */
.auth-card .auth-tab { min-height:42px; }
.auth-card:not(:has(#registerTab.active)) .text-input { height:48px; min-height:48px; }
.auth-card:not(:has(#registerTab.active)) .sms-code-row button,
.auth-card:not(:has(#registerTab.active)) .auth-submit { min-height:48px; }
@media(min-width:701px) {
  .auth-card:not(:has(#registerTab.active)) { padding-block:30px; }
  .auth-card:not(:has(#registerTab.active)) .auth-heading { margin-bottom:20px; }
  .auth-card:not(:has(#registerTab.active)) .auth-tabs { margin-bottom:20px; }
}
@media(max-width:700px) {
  .auth-card:not(:has(#registerTab.active)) .text-input { height:46px; min-height:46px; }
  .auth-card:not(:has(#registerTab.active)) .sms-code-row button,
  .auth-card:not(:has(#registerTab.active)) .auth-submit { min-height:46px; }
}
@media(max-height:600px) {
  .auth-card .auth-tab { min-height:38px; }
  .auth-card:not(:has(#registerTab.active)) { padding-block:16px; }
  .auth-card:not(:has(#registerTab.active)) .text-input { height:42px; min-height:42px; }
  .auth-card:not(:has(#registerTab.active)) .auth-heading,
  .auth-card:not(:has(#registerTab.active)) .auth-tabs { margin-bottom:12px; }
}
.structure-parts.reading-blocks { display:block; }
.reading-block { padding:14px 0; border-bottom:1px solid var(--line); }
.reading-block:last-child { border-bottom:0; }
.reading-block-text { display:block; font-family:Georgia,serif; font-size:18px; line-height:1.5; font-weight:500; overflow-wrap:anywhere; }
.reading-block-explanation { margin:8px 0 0; font-size:13px; line-height:1.6; color:var(--muted); }
.reading-block-meaning { margin:4px 0 0; font-size:13px; line-height:1.6; color:var(--accent); }


.import-check {
  margin:8px 0;
  border:1px solid #dce7df;
  border-radius:12px;
  background:#f3f7f3;
  color:var(--green, #315d4d);
  max-height:230px;
  min-width:0;
  overflow:auto;
  font-size:12px;
  line-height:1.6;
}
.import-check.has-warnings { border-color:#e6dece; background:#faf7ef; color:#695b40; }
.import-check > summary { padding:9px 12px; cursor:pointer; overflow-wrap:anywhere; }
.import-check-body { padding:0 12px 10px; color:var(--text, #304239); }
.import-check-body p { margin:6px 0; font-size:12px; line-height:1.6; }
.import-check-body ul { margin:8px 0; padding-left:18px; }
.import-check-body .text-button { font-size:12px; padding:2px 5px; min-height:28px; }
.import-preview { max-height:320px; overflow:auto; margin:6px 0 0; padding:8px 8px 8px 28px; border-top:1px solid #e1e6de; }
.import-preview li { padding:6px 0; overflow-wrap:anywhere; font-size:13px; line-height:1.7; border-bottom:1px dashed #e7ebe4; }
.import-preview-text { display:block; }
.import-preview-actions { display:flex; gap:12px; margin-top:2px; }
.import-preview-actions .text-button { font-size:12px; padding:0; }
.import-preview-actions .text-button:disabled { opacity:.35; cursor:default; }
.import-preview-title { margin:12px 0 0; font-size:12px; color:#6b7c74; }
.import-proofread { margin:8px 0; padding:8px 10px; border-radius:8px; background:#f6f3e8; font-size:13px; line-height:1.7; }
.import-proofread p { margin:0; }
.import-proofread-list { margin:6px 0 0; padding-left:18px; }
.import-proofread-list li { padding:3px 0; overflow-wrap:anywhere; }
.import-proofread-required { display:inline-block; padding:0 6px; border-radius:4px; background:#f3dcd4; color:#9a3a22; font-size:12px; line-height:1.6; }

/* Import controls remain reachable when dialogue settings or zoom use more room. */
@media (min-width:901px) {
  #appShell #setupView:not(.has-articles) .setup-workspace {
    width:100%;
    max-width:none;
    margin-inline:0;
    grid-template-columns:minmax(0, 1.08fr) minmax(0, .92fr);
  }
  #appShell #setupView:not(.has-articles) .library-panel { order:0; }
  #appShell #setupView:not(.has-articles) .article-list,
  #appShell #setupView:not(.has-articles) .library-search-wrap { display:none; }
  #appShell #setupView:not(.has-articles) .library-empty {
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:14px;
    margin:0;
    padding:28px;
    text-align:center;
    font-size:14px;
    line-height:1.7;
  }
  #appShell #setupView:not(.has-articles) .library-empty::before {
    content:"从第一篇文章开始";
    color:var(--accent);
    font-size:22px;
    font-weight:600;
  }
}
@media (min-width:701px) and (max-width:900px) {
  #appShell #setupView .setup-workspace {
    display:flex;
    flex-direction:column;
    width:100%;
    max-width:none;
    margin-inline:0;
    overflow-y:auto;
    overscroll-behavior:contain;
  }
  #appShell #setupView .setup-workspace > .library-panel,
  #appShell #setupView .setup-workspace > .import-card { flex:0 0 auto; height:auto; }
  #appShell #setupView .setup-workspace > .library-panel { min-height:240px; }
  #appShell #setupView .setup-workspace > .import-card { min-height:480px; }
}
#appShell #setupView:not([hidden]) .import-card {
  min-width:0;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
  scroll-padding-block:12px;
}
#appShell #setupView .import-card > :not(.textarea-wrap) { flex-shrink:0; }
#appShell #setupView .import-card .textarea-wrap { flex:1 0 88px; min-height:88px; }
#appShell #setupView .import-card #articleText { width:100%; height:100%; min-height:88px; box-sizing:border-box; }
#appShell #setupView .import-card #dialogueSettings { max-width:100%; overflow-wrap:anywhere; }
#appShell #setupView .import-card #dialogueSettings summary { cursor:pointer; font-size:13px; line-height:1.6; }
#appShell #setupView .import-card .import-footer {
  position:static;
  bottom:auto;
  z-index:2;
  flex:0 0 auto;
  flex-wrap:wrap;
  padding-block:10px;
  background:var(--paper, #fffdfa);
}
#appShell #setupView .import-card .import-footer .file-action { flex-wrap:wrap; min-width:0; }
#appShell #setupView .import-card #startButton { flex:0 0 auto; margin-left:auto; white-space:nowrap; }

/* Mobile editor: shrink the text region, never clip the action below it. */
@media (max-width:700px) {
  body:has(#appShell:not([hidden]) #setupView.mobile-editing:not([hidden])),
  body:has(#setupView.mobile-editing:not([hidden])) #appShell:not([hidden]) {
    height:var(--editor-visible-height, 100dvh);
    min-height:0;
  }
  #appShell #setupView.mobile-editing .import-card {
    flex:1 1 0;
    height:auto;
    min-height:0;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    scroll-padding-bottom:16px;
  }
  #appShell #setupView.mobile-editing .import-card > :not(.textarea-wrap) { flex-shrink:0; }
  #appShell #setupView.mobile-editing .textarea-wrap {
    flex:1 0 80px;
    height:80px;
    min-height:80px;
    margin-bottom:0;
  }
  #appShell #setupView.mobile-editing #articleText {
    flex:1 1 0;
    width:100%;
    height:100%;
    min-height:0;
    overflow-y:auto;
    box-sizing:border-box;
  }
  #appShell #setupView.mobile-editing #startButton {
    flex:none;
    min-height:46px;
    white-space:nowrap;
  }
}

/* Inline sense-group analysis keeps the original sentence intact. */
#focusText.sense-analysis .word-token,
#immersiveText.sense-analysis .word-token { opacity: 1; color: #93998f; background: none; box-shadow: none; border-radius: 0; -webkit-text-fill-color: currentColor; transition: color .15s; }
#focusText.sense-analysis .word-token.sense-active,
#immersiveText.sense-analysis .word-token.sense-active { color: #294d3b; background: none; box-shadow: none; }
.sense-analysis .sense-phrase { color: #294d3b; background: #eaf0df; padding-block: .07em; border-radius: .15em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
body.sense-analysis-mode #focusTranslation,
body.sense-analysis-mode #immersiveTranslation { white-space: pre-line; line-height: 1.7; }
body.sense-analysis-mode #focusTranslation { max-height: 190px; overflow-y: auto; }
body.sense-analysis-mode .article-translation-actions,
body.sense-analysis-mode #mergeButton,
body.sense-analysis-mode #splitButton { display: none !important; }
body.sense-analysis-mode #grammarButton::after { content: ' · 退出'; }
.immersive-view .sense-analysis .sense-phrase { background: rgba(183, 219, 143, .16); }
#immersiveText.sense-analysis .word-token { color: rgba(240, 242, 231, .65); }
#immersiveText.sense-analysis .word-token.sense-active { color: #f0f2e7; }
@media (prefers-reduced-motion: reduce) { .sense-analysis .word-token { transition: none; } }
body.sense-analysis-mode #appShell #practiceView .focus-translation-row { height: clamp(110px, 18dvh, 170px); min-height: 0; flex-shrink: 0; }
body.sense-analysis-mode #appShell #practiceView .focus-card #focusTranslation { height: 100%; max-height: 100%; overflow-y: auto; margin: 0; padding-block: 6px; box-sizing: border-box; }
body.sense-analysis-mode #appShell #practiceView .record-card { display: none; }

/* Preparation follows the current reading window, rather than the whole library. */
.preparation-status { flex: 0 0 auto; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:8px 14px; border:1px solid #d8e4d9; border-radius:12px; color:#385b45; background:#f2f7ee; font-size:12px; line-height:1.5; }
.preparation-status[hidden] { display:none; }
#preparationText { white-space:pre-line; }
#preparationRetry { flex:none; padding:6px 9px; border:1px solid #b5cbb8; border-radius:8px; background:white; color:inherit; cursor:pointer; }
@media(max-width:700px) { .preparation-status { padding:6px 10px; gap:6px; font-size:11px; } }

/* Keep preparation in the background without showing its progress banner. */
#preparationStatus { display: none !important; }
/* Expressions use the same reading palette as the practice page. */
.sentence-sidebar, .sidebar-pane { display:flex; flex-direction:column; flex:1; min-height:0; }
.sidebar-pane[hidden] { display:none; }
.sidebar-tabs { display:flex; flex:none; gap:4px; margin:10px 17px 0; padding:4px; border-radius:12px; background:#f0f0e9; }
.sidebar-tabs button { flex:1; border:0; border-radius:9px; padding:9px 6px; color:#7b837b; background:transparent; cursor:pointer; font:inherit; font-size:13px; }
.sidebar-tabs button[aria-selected="true"] { background:#fffdf8; color:#305d4e; box-shadow:0 1px 4px #263d2710; }
.sidebar-tabs button:focus-visible { outline:2px solid #305d4e; outline-offset:2px; }
.sidebar-expression-tools { padding:10px 17px 0; flex:none; }
.sidebar-expression-tools .text-input { width:100%; margin:0 0 8px; padding:10px 12px; font-size:13px; }
.sidebar-expression-tools #expressionsFind { font-size:12px; padding:4px 0; }
/* The toolbar only held the removed 新增句子 button; drop the empty strip above the list. */
#sidebarSentences .sentence-list-toolbar { display:none; }
#sidebarSentences #sentenceListToggle { display:none; }
#expressionsList { flex:1; min-height:0; overflow-y:auto; padding:0 17px 15px; overscroll-behavior:contain; }
#expressionsStatus, .expressions-empty { color:#7b837b; font-size:12px; }
#expressionsStatus { margin:4px 0 8px; }
.expression-card { display:block; width:100%; padding:11px 10px; margin:2px 0; border:0; border-bottom:1px solid #e5e0d6; border-radius:10px; background:transparent; text-align:left; cursor:pointer; font:inherit; font-size:13px; color:inherit; }
.expression-card:hover { background:#f0f4ed; }
.expression-card > span { display:block; overflow-wrap:anywhere; }
.expression-card-title { margin-bottom:5px; color:#2e5948; font-size:17px; font-weight:600; line-height:1.4; }
.expression-card-meaning, .expression-card-usage { line-height:1.55; }
.expression-card-usage { margin-top:4px; font-size:12px; color:#7b837b; }
.expression-category { display:inline-block; margin-left:7px; padding:1px 5px; border-radius:5px; background:#edf1e5; color:#66816c; font-size:10px; font-weight:400; vertical-align:middle; }
.expression-card-source { margin:0 0 5px; font-size:12px; color:#7b837b; line-height:1.5; }
.expression-group { cursor:default; }
.expression-group-head { border:0; padding:0; width:100%; background:transparent; text-align:left; color:inherit; font:inherit; cursor:pointer; }
.expression-example { display:block; width:100%; margin-top:7px; padding:7px 8px; border:0; border-left:2px solid #d7e3d7; border-radius:6px; background:transparent; color:inherit; text-align:left; cursor:pointer; font:inherit; }
.expression-example:hover { background:#f0f4ed; }
.expression-example.active { border-left-color:#305d4e; background:#d6e6dd; }
.expression-example span { display:block; line-height:1.5; }
.expression-example-source { color:#305d4e; font-size:13px; }
.expression-example-meaning { color:#7b837b; font-size:12px; margin-top:3px; }
.expression-example:focus-visible, .expression-group-head:focus-visible { outline:2px solid #305d4e; outline-offset:2px; }
.group-sentence-nav { display:flex; align-items:center; justify-content:space-between; padding:8px 17px; color:#7b837b; font-size:12px; }
.group-sentence-nav button { padding:4px 12px; font-size:22px; }
#sidebarGroupList { flex:1; min-height:0; overflow-y:auto; padding:0 17px 15px; overscroll-behavior:contain; }
.sense-group-card { display:block; width:100%; margin:3px 0; padding:12px 10px; border:0; border-bottom:1px solid #e5e0d6; border-radius:10px; background:transparent; text-align:left; color:inherit; font:inherit; cursor:pointer; }
.sense-group-card:hover { background:#f0f4ed; }
.sense-group-card.active { background:#e5efea; border-color:transparent; }
.sense-group-card > span { display:block; }
.sense-group-number { color:#7b837b; font-size:10px; margin-bottom:5px; }
.sense-group-text { color:#305d4e; font-size:16px; line-height:1.5; }
.sense-group-meaning { color:#7b837b; font-size:12px; line-height:1.6; margin-top:5px; }
.sense-group-card:focus-visible { outline:2px solid #305d4e; outline-offset:-2px; }
@media(max-width:700px) { #mobileSheetBody #sidebarGroupList { overflow:visible; } }
.expression-card.active { background:#e5efea; border-color:transparent; }
.expression-card:focus-visible { outline:2px solid #305d4e; outline-offset:-2px; }
#focusText.expression-analysis .word-token, #immersiveText.expression-analysis .word-token { color:#8a9189; opacity:1; background:none; box-shadow:none; -webkit-text-fill-color:currentColor; }
.expression-highlight { background:#eaf0df; padding-block:.07em; border-radius:.15em; box-decoration-break:clone; -webkit-box-decoration-break:clone; }
#focusText.expression-analysis .expression-highlight .word-token, #immersiveText.expression-analysis .expression-highlight .word-token { color:#294d3b; }
.expression-focus-mode #translationEditButton { display:none; }
#immersiveText.expression-analysis .word-token { color:#bec9bc; }
.expression-card-meaning { color: #355d4f; }
@media(max-width:700px) {
 .article-panel > .sentence-sidebar { display:none; }
 #mobileSheetBody > .sentence-sidebar { min-height:45dvh; }
 #mobileSheetBody #expressionsList { overflow:visible; }
 #mobileSheetBody .sidebar-tabs { margin-top:0; }
}

/* Separate the current sense group's translation from its structural explanation. */
body.sense-analysis-mode .sense-detail { display:block; white-space:normal; text-align:left; }
body.sense-analysis-mode .sense-detail-label { display:block; font:500 11px/1.5 system-ui,sans-serif; letter-spacing:.06em; color:#7b8982; margin-bottom:4px; }
body.sense-analysis-mode .sense-detail-content { display:block; }
body.sense-analysis-mode .sense-detail-meaning .sense-detail-content { font-size:19px; line-height:1.6; color:#305d4e; }
body.sense-analysis-mode .sense-detail-structure { margin-top:14px; padding-top:12px; border-top:1px solid #e8e8df; }
body.sense-analysis-mode .sense-detail-structure .sense-detail-content { font-size:14px; line-height:1.7; color:#738079; }
body.sense-analysis-mode #appShell #practiceView .focus-translation-row { height:clamp(150px,23dvh,210px); }
body.sense-analysis-mode #immersiveTranslation .sense-detail-label { color:inherit; opacity:.6; }
body.sense-analysis-mode #immersiveTranslation .sense-detail-content { color:inherit; }
@media(max-width:600px) {
 body.sense-analysis-mode .sense-detail-meaning .sense-detail-content { font-size:17px; }
 body.sense-analysis-mode .sense-detail-structure { margin-top:10px; padding-top:8px; }
}

/* Shared compact translation + contextual note across all learning modes. */
#focusTranslation.learning-details, #immersiveTranslation.learning-details { white-space:normal; text-align:left; }
.learning-full-translation { display:block; font-size:18px; line-height:1.65; color:#526b60; }
.learning-full-translation mark.translation-quote { background:#f1e6c4; color:#24453a; border-radius:3px; padding:0 2px; }
.learning-note { display:block; margin-top:12px; padding:10px 0 0; border-top:1px solid #e7e8df; line-height:1.65; }
.learning-note-title { display:inline; margin-right:10px; font:600 13px/1.6 system-ui,sans-serif; color:#305d4e; }
.learning-note-meaning { display:inline; font-size:15px; color:#526b60; }
.learning-note-usage { display:block; margin-top:4px; font-size:13px; line-height:1.65; color:#7a837c; }
.learning-note-usage:empty { display:none; }
#appShell #practiceView .focus-translation-row,
body.sense-analysis-mode #appShell #practiceView .focus-translation-row { height:clamp(140px,21dvh,190px); min-height:0; flex-shrink:0; }
#appShell #practiceView .focus-card #focusTranslation.learning-details { height:100%; max-height:100%; overflow-y:auto; margin:0; padding-block:6px; box-sizing:border-box; }
#immersiveTranslation.learning-details .learning-full-translation,
#immersiveTranslation.learning-details .learning-note-title,
#immersiveTranslation.learning-details .learning-note-meaning,
#immersiveTranslation.learning-details .learning-note-usage { color:inherit; }
@media(max-width:600px) {
 .learning-full-translation { font-size:16px; }
 .learning-note { margin-top:9px; padding-top:8px; }
 .learning-note-meaning { font-size:14px; }
}

body.sense-analysis-mode #appShell #practiceView .record-card { display:block; }

/* One shared reading scroller prevents translation/recording from squeezing English. */
#appShell #practiceView .focus-card { display:flex; flex-direction:column; gap:10px; min-width:0; }
#appShell #practiceView .focus-reading { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; padding-right:8px; }
#appShell #practiceView .focus-reading #focusText { flex:none; height:auto; min-height:0; max-height:none; overflow:visible; margin:4px 0 16px; font-size:clamp(24px,2.2vw,36px); line-height:1.42; }
#appShell #practiceView .focus-reading .focus-translation-row { display:flex; align-items:flex-start; flex:none; height:auto; min-height:0; max-height:none; margin:0 0 12px; }
#appShell #practiceView .focus-reading #focusTranslation,
#appShell #practiceView #focusReading #focusTranslation.learning-details { flex:1; height:auto; min-height:0; max-height:none; overflow:visible; padding:0; margin:0; }
#appShell #practiceView .focus-card .transport { flex:none; margin-top:0; padding-top:4px; }
#appShell #practiceView .focus-card .playback-status-row { display:flex; align-items:center; justify-content:space-between; gap:4px 10px; flex:none; min-height:24px; padding-top:6px; }
#appShell #practiceView #recordCard { display:grid; grid-template-columns:minmax(120px,1fr) 64px minmax(230px,1.25fr); align-items:center; gap:12px; padding:10px 18px; min-height:0; }
#appShell #practiceView #recordCard .record-copy .card-kicker { display:none; }
#appShell #practiceView #recordCard .record-copy h3 { margin:0; font-size:17px; }
#appShell #practiceView #recordCard #recordHelp { font-size:11px; margin:4px 0 0; }
#appShell #practiceView #recordCard .record-center { min-height:0; gap:2px; }
#appShell #practiceView #recordCard .record-button { width:46px; height:46px; min-height:46px; }
#appShell #practiceView #recordCard .recording-actions { gap:6px; }
#appShell #practiceView #recordCard .recording-actions button { min-height:32px; padding-block:5px; }
@media(min-width:701px) {
 #appShell #practiceView .focus-card { flex:1 1 auto; height:auto; min-height:0; overflow:hidden; padding:14px 20px; }
 #appShell #practiceView .practice-layout { display:grid; grid-template-columns:320px minmax(0,1fr); gap:18px; }
 #appShell #practiceView .article-panel { position:static; width:100%; }
 #appShell #practiceView .practice-stage { overflow:hidden; }
 #appShell #practiceView .stage-toolbar { min-height:56px; padding-block:7px; }
 #appShell #practiceView .stage-footer { min-height:28px; }
}
@media(min-width:701px) and (max-width:1100px) {
 #appShell #practiceView .practice-layout { grid-template-columns:250px minmax(0,1fr); gap:14px; }
 #appShell #practiceView .article-panel { width:250px; }
 #appShell #practiceView #recordCard { grid-template-columns:52px minmax(0,1fr); padding:8px 12px; gap:8px; }
 #appShell #practiceView #recordCard .record-copy { display:none; }
 #appShell #practiceView #recordCard .record-center { grid-column:1; grid-row:1; }
 #appShell #practiceView #recordCard .recording-actions { grid-column:2; grid-row:1; width:100%; }
 #appShell #practiceView #recordHelp { display:none; }
}
@media(min-width:701px) and (max-height:700px) {
 #appShell #practiceView .focus-card { min-height:0; }
 #appShell #practiceView #recordHelp { display:none; }
 #appShell #practiceView #recordCard { padding-block:6px; }
 #appShell #practiceView .stage-label, #appShell #practiceView .shortcut-hint { display:none; }
}
@media(max-width:700px) {
 #appShell #practiceView .focus-card { flex:1 1 0; height:auto; min-height:0; max-height:none; overflow:hidden; padding:14px; }
 #appShell #practiceView .focus-reading { overflow-y:auto; min-height:0; padding-right:4px; -webkit-overflow-scrolling:touch; }
 #appShell #practiceView .focus-reading #focusText { font-size:clamp(23px,5.5vw,30px); }
 #appShell #practiceView .focus-reading .focus-translation-row { flex-direction:column; gap:8px; }
 #appShell #practiceView #recordCard { grid-template-columns:1fr 56px; padding:10px 14px; }
 #appShell #practiceView #recordCard .recording-actions { grid-column:1 / -1; }
 #appShell #practiceView #recordHelp { display:none; }
}

/* Quiet, theme-matched scrolling and balanced type in immersive reading. */
#immersiveView { padding:clamp(18px,4dvh,42px) clamp(20px,5vw,80px); gap:clamp(10px,1.6dvh,18px); }
#immersiveView #immersiveText { width:100%; max-width:1200px; justify-self:center; font-size:clamp(28px,4.5vw,64px); line-height:1.35; margin:0; padding-inline:12px; }
#immersiveView #immersiveTranslation { width:min(100%,900px); max-width:900px; justify-self:center; max-height:28dvh; padding-right:12px; box-sizing:border-box; font-size:17px; line-height:1.6; }
#immersiveView .learning-full-translation { font-size:17px; line-height:1.6; }
#immersiveView .learning-note { margin-top:10px; padding-top:8px; border-color:rgba(236,239,226,.12); }
#immersiveView .learning-note-usage { font-size:12px; }
#immersiveView #immersiveText, #immersiveView #immersiveTranslation { scrollbar-width:thin; scrollbar-color:rgba(219,229,214,.25) transparent; }
#immersiveView #immersiveText::-webkit-scrollbar, #immersiveView #immersiveTranslation::-webkit-scrollbar { width:5px; height:5px; }
#immersiveView #immersiveText::-webkit-scrollbar-track, #immersiveView #immersiveTranslation::-webkit-scrollbar-track { background:transparent; }
#immersiveView #immersiveText::-webkit-scrollbar-thumb, #immersiveView #immersiveTranslation::-webkit-scrollbar-thumb { background:rgba(219,229,214,.25); border-radius:8px; }
#immersiveView #immersiveText::-webkit-scrollbar-button, #immersiveView #immersiveTranslation::-webkit-scrollbar-button { display:none; width:0; height:0; }
#immersiveView #immersiveText:hover, #immersiveView #immersiveTranslation:hover { scrollbar-color:rgba(219,229,214,.45) transparent; }
@media(max-width:700px) {
 #immersiveView #immersiveText { font-size:clamp(24px,6vw,40px); padding-inline:4px; }
 #immersiveView #immersiveTranslation { max-height:30dvh; font-size:15px; }
 #immersiveView .learning-full-translation { font-size:15px; }
}

/* Reserve one stable caption region while highlights advance within a sentence. */
#immersiveView #immersiveTranslation:not([hidden]) { height:clamp(110px,25dvh,240px); max-height:28dvh; }
#immersiveView .word-token { transition:none; }

.learning-note-title:empty { display:none; }

/* Pointer focus stays quiet; keyboard focus remains visible in the app theme. */
:where(#appShell, #immersiveView) :is(button, a, [role="button"], [role="tab"]):focus:not(:focus-visible) { outline:none; }
:where(#appShell, #immersiveView) :is(button, a, [role="button"], [role="tab"]):focus-visible { outline:2px solid #6d927e; outline-offset:3px; }
#immersiveView :is(button, a, [role="button"]):focus-visible { outline-color:#a4bca9; }

/* The reading viewport owns content overflow in all three learning modes. */
#appShell #practiceView #recordCard, #appShell #practiceView .stage-footer { flex-shrink:0; }
#appShell #practiceView .focus-reading { scrollbar-color:#b5c5b9 transparent; }
#appShell #practiceView .focus-reading::-webkit-scrollbar { width:4px; }
#appShell #practiceView .focus-reading::-webkit-scrollbar-thumb { background:#b5c5b9; border-radius:8px; }
#appShell #practiceView .focus-reading::-webkit-scrollbar-track { background:transparent; }
#appShell #practiceView .focus-reading::-webkit-scrollbar-button { display:none; }
/* A solid active-word marker also works in embedded WebKit without text clipping. */
.focus-text .word-token.speaking { background:#e8eedc; color:#244f40; -webkit-text-fill-color:currentColor; border-radius:4px; box-shadow:none; }
.immersive-text .word-token.speaking, .immersive-text .word-token.speaking.paused { background:rgba(185,211,160,.19); color:#f0eee6; -webkit-text-fill-color:currentColor; border-radius:4px; }
@media(max-width:700px) {
 #appShell #practiceView .practice-stage { overflow:hidden; }
 #appShell #practiceView .focus-card .playback-status-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:4px 10px; }
 #appShell #practiceView .focus-card .playback-status-row .continuous-controls { margin:0; padding:0; border:0; }
 #appShell #practiceView #recordCard { margin-top:6px; gap:6px; padding:8px 12px; }
 #appShell #practiceView .stage-footer { margin-top:4px; }
}
@media(max-height:480px) {
 #appShell #practiceView .focus-card { gap:6px; padding-block:8px; }
 #appShell #practiceView .focus-card-top { display:none; }
 #appShell #practiceView .stage-toolbar { min-height:42px; padding-block:3px; }
 #appShell #practiceView .stage-footer { min-height:22px; }
 #appShell #practiceView #recordCard { padding-block:4px; }
}

@media(max-width:700px) {
 #appShell #practiceView .focus-card .audio-state { display:flex; margin:0; font-size:10px; }
 #appShell #practiceView .focus-card .continuous-controls { font-size:11px; }
}

#appShell #practiceView .playback-status-row .audio-state { margin:0; padding:0; }
#appShell #practiceView .playback-status-row .continuous-controls { margin:0; padding:0; border:0; }

@media(max-height:480px) and (min-width:701px) {
 #appShell .topbar { min-height:52px; height:52px; padding-block:4px; }
 #appShell #practiceView .stage-toolbar .select-control > span { display:none; }
 #appShell #practiceView .stage-toolbar .speed-control { display:flex; flex-direction:row; align-items:center; width:180px; }
 #appShell #practiceView .stage-toolbar .speed-control > span { white-space:nowrap; }
 #appShell #practiceView .stage-toolbar .speed-control input { min-width:70px; }
 #appShell #practiceView .focus-card .playback-status-row { margin-top:0; padding-top:0; min-height:22px; }
 #appShell #practiceView .stage-footer button { min-height:24px; padding-block:3px; }
}
/* Mobile practice controls and the shared learning-list dialog. */
@media (max-width: 700px) {
  #appShell #practiceView #recordCard {
    grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
  }
  #appShell #practiceView #recordCard .record-copy { grid-column: 1; grid-row: 1; min-width: 0; }
  #appShell #practiceView #recordCard .record-copy h3 { font-size: 14px; overflow-wrap: anywhere; }
  #appShell #practiceView #recordCard .record-center { grid-column: 2; grid-row: 1; justify-self: center; }
  #appShell #practiceView #recordCard .recording-actions { grid-column: 1 / -1; grid-row: 2; }

  #mobileSheet[data-content="sentenceSidebar"] {
    position: fixed;
    inset: 0;
    margin: auto;
    box-sizing: border-box;
    width: min(560px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    height: min(720px, calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 14px 12px;
    overflow: hidden;
  }
  #mobileSheet[data-content="sentenceSidebar"][open] { display: flex; flex-direction: column; }
  #mobileSheet[data-content="sentenceSidebar"] .mobile-sheet-head { flex: none; margin-bottom: 10px; }
  #mobileSheet[data-content="sentenceSidebar"] #mobileSheetBody {
    flex: 1; min-height: 0; max-height: none; overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain; scrollbar-width: thin;
  }
  #mobileSheet[data-content="sentenceSidebar"] #sentenceSidebar { min-height: 100%; min-width: 0; }
  #mobileSheet[data-content="sentenceSidebar"] .sidebar-tabs {
    position: sticky; top: 0; z-index: 2; margin: 0 0 8px;
    background: #f0f0e9; isolation: isolate;
  }
  #mobileSheet[data-content="sentenceSidebar"] .sidebar-tabs button { min-width: 0; min-height: 44px; padding-inline: 3px; font-size: 12px; }
  #mobileSheet[data-content="sentenceSidebar"] .sidebar-pane { flex: none; overflow: visible; }
  #mobileSheet[data-content="sentenceSidebar"] :is(.sentence-list, #sidebarGroupList, #expressionsList) {
    flex: none; height: auto; max-height: none; overflow: visible; padding-inline: 4px;
  }
  #mobileSheet[data-content="sentenceSidebar"] :is(.sidebar-expression-tools, .group-sentence-nav, .sentence-list-toolbar) { padding-inline: 4px; }
  #mobileSheet[data-content="sentenceSidebar"] :is(.sentence-item, .sense-group-text, .expression-card-title) { overflow-wrap: anywhere; }
}


/* Related spans use paint only: do not change line breaks or playback geometry. */
#focusText.sense-analysis .word-token.sense-related { color:#557562; text-decoration:underline; text-decoration-color:#b2c7b7; text-underline-offset:.16em; }
#immersiveText.sense-analysis .word-token.sense-related { color:#b4cbb8; text-decoration:underline; text-decoration-color:#819c89; text-underline-offset:.16em; }
.sense-guidance { display:block; margin-top:6px; font-size:14px; line-height:1.75; color:#52675b; }
.sense-guidance { overflow-wrap:anywhere; }
#immersiveTranslation .sense-guidance { color:inherit; }

/* ---------- Import status line (setup page) ---------- */
.import-status { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:10px; padding:9px 12px; border:1px solid #dfe7e1; border-radius:10px; background:#f3f8f4; color:#305d4e; font-size:13px; line-height:1.5; }
.import-status.is-warning { border-color:#eadfc8; background:#faf6ec; color:#6b5a36; }
.import-status.is-blocked { border-color:#efcfc4; background:#fbefea; color:#9a3a22; }
.import-status-text { min-width:0; overflow-wrap:anywhere; }
.import-status-open { flex:none; font-size:13px; font-weight:600; white-space:nowrap; }

/* ---------- Import review window ---------- */
body.import-review-open { overflow:hidden; }
.import-review { position:fixed; inset:0; z-index:40; display:grid; place-items:center; padding:24px; }
.import-review[hidden] { display:none; }
.import-review-backdrop { position:absolute; inset:0; background:rgba(23, 32, 27, .38); }
.import-review-card { position:relative; display:flex; flex-direction:column; width:min(1120px, 100%); height:min(820px, 100%); border-radius:16px; background:#fdfcf8; box-shadow:0 24px 70px rgba(23, 32, 27, .28); overflow:hidden; outline:none; }
.import-review-head { display:flex; align-items:flex-start; gap:12px; padding:18px 22px 12px; border-bottom:1px solid #e7ebe4; }
.import-review-back { display:none; flex:none; font-size:14px; padding:4px 0; }
.import-review-heading { flex:1; min-width:0; }
.import-review-kicker { margin:0; color:#5d7a6c; font-size:11px; font-weight:700; letter-spacing:.14em; }
.import-review-heading h3 { margin:2px 0 4px; font-family:Georgia, "Times New Roman", serif; font-size:22px; line-height:1.25; overflow-wrap:anywhere; }
.import-review-summary { margin:0; color:#6b7c74; font-size:13px; }
.import-review-x { flex:none; width:34px; height:34px; border:0; border-radius:50%; background:transparent; color:#55645c; font-size:16px; cursor:pointer; }
.import-review-x:hover { background:#eef2ee; }
.import-review-tabs { display:flex; gap:6px; padding:10px 22px 0; }
.import-review-tabs button { border:1px solid transparent; border-bottom:0; border-radius:8px 8px 0 0; padding:7px 14px; background:transparent; color:#5f6f67; font:inherit; font-size:14px; cursor:pointer; }
.import-review-tabs button.is-active { border-color:#e1e7e1; background:#fff; color:#1f4f3f; font-weight:600; }
.import-review-text-tab { display:none; }
.import-review-body { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0, 1.05fr) minmax(0, 1fr); border-top:1px solid #e1e7e1; }
.import-review-text { overflow:auto; padding:18px 22px 28px; border-right:1px solid #e7ebe4; white-space:pre-wrap; overflow-wrap:anywhere; font-family:Georgia, "Times New Roman", serif; font-size:16px; line-height:1.8; color:#26332c; background:#fff; }
.import-review-panel { overflow:auto; padding:14px 18px 28px; background:#fbfaf6; }
.review-mark { border-radius:3px; padding:0 1px; cursor:pointer; background:transparent; color:inherit; }
.review-mark.is-required { text-decoration:underline wavy #d0533c; text-underline-offset:4px; background:#fbe9e3; }
.review-mark.is-optional { text-decoration:underline dashed #c99a3d; text-underline-offset:4px; background:#fbf3df; }
.is-flash { animation:review-flash 1.2s ease; }
@keyframes review-flash { 0%, 40% { box-shadow:0 0 0 3px rgba(31, 111, 82, .35); } 100% { box-shadow:0 0 0 0 rgba(31, 111, 82, 0); } }
.review-note { margin:4px 0 12px; color:#55645c; font-size:13px; line-height:1.6; }
.review-note.is-loading { color:#6b5a36; }
.review-note.is-ok { color:#1f6f52; font-weight:600; }
.review-bulk .text-button { font-weight:600; }
.review-hint { margin:10px 0 0; padding:9px 12px; border-radius:10px; background:#f2f4f1; color:#4d5c55; font-size:13px; line-height:1.6; }
.review-issue { margin:0 0 10px; padding:12px 14px; border:1px solid #e3e8e2; border-left:4px solid #c99a3d; border-radius:10px; background:#fff; cursor:pointer; }
.review-issue.is-required { border-left-color:#d0533c; }
.review-issue-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.review-tag { display:inline-block; padding:1px 7px; border-radius:999px; background:#f7ecd4; color:#7a5a1a; font-size:12px; line-height:1.6; }
.review-issue.is-required .review-tag { background:#f6ddd5; color:#9a3a22; }
.review-tag.is-long { margin-top:4px; background:#eef1ed; color:#5f6f67; }
.review-type { color:#6b7c74; font-size:12px; }
.review-issue-context { margin:0 0 6px; color:#55645c; font-family:Georgia, "Times New Roman", serif; font-size:14px; line-height:1.6; overflow-wrap:anywhere; }
.review-issue-context mark { background:#fbe9e3; color:inherit; border-radius:3px; padding:0 2px; }
.review-change { margin:0; font-size:15px; overflow-wrap:anywhere; }
.review-change del { color:#9a3a22; text-decoration-thickness:1px; }
.review-change ins { color:#1f6f52; text-decoration:none; font-weight:600; }
.review-reason { margin:4px 0 0; color:#6b7c74; font-size:12px; }
.review-issue-actions { display:flex; gap:8px; margin-top:10px; }
.review-issue-actions button { min-height:34px; padding:6px 16px; font-size:13px; }
.review-sentences { margin:0; padding:0; list-style:none; counter-reset:review; }
.review-sentence { position:relative; margin:0 0 8px; padding:10px 12px 10px 40px; border:1px solid #e3e8e2; border-radius:10px; background:#fff; counter-increment:review; cursor:pointer; }
.review-sentence::before { content:counter(review); position:absolute; left:12px; top:11px; color:#9aa79f; font-size:12px; font-variant-numeric:tabular-nums; }
.review-sentence p { margin:0; font-family:Georgia, "Times New Roman", serif; font-size:15px; line-height:1.65; overflow-wrap:anywhere; }
.review-sentence-actions { display:none; gap:14px; margin-top:6px; }
.review-sentence:hover .review-sentence-actions, .review-sentence.is-active .review-sentence-actions { display:flex; }
.review-sentence-actions .text-button { padding:2px 0; font-size:13px; }
.review-sentence-actions .text-button:disabled { opacity:.35; cursor:default; }
.import-review-foot { display:flex; align-items:center; gap:12px; padding:12px 22px; border-top:1px solid #e1e7e1; background:#fdfcf8; }
.import-review-status { flex:1; color:#55645c; font-size:13px; }
.import-review-undo { display:flex; align-items:center; gap:4px; color:#305d4e; font-size:13px; }
.import-review-undo[hidden] { display:none; }
.import-review-start { min-height:42px; padding:0 22px; }
.import-review-start:disabled { opacity:.55; cursor:not-allowed; }

/* Phones: full screen, one column, original text becomes a tab */
@media (max-width: 760px) {
  .import-review { padding:0; place-items:stretch; }
  .import-review-card { width:100%; height:100%; height:100dvh; border-radius:0; box-shadow:none; }
  .import-review-head { padding:12px 16px 8px; align-items:center; padding-top:max(12px, env(safe-area-inset-top)); }
  .import-review-back { display:inline-flex; }
  .import-review-x { display:none; }
  .import-review-heading h3 { font-size:17px; }
  .import-review-kicker { display:none; }
  .import-review-tabs { padding:8px 12px; gap:4px; }
  .import-review-tabs button { flex:1; border:0; border-radius:8px; padding:8px 4px; background:#eef2ee; font-size:13px; }
  .import-review-tabs button.is-active { background:#1f4f3f; color:#fff; }
  .import-review-text-tab { display:block; }
  .import-review-body { display:block; overflow:hidden; border-top:0; }
  .import-review-text, .import-review-panel { height:100%; border-right:0; padding:12px 14px 24px; }
  .import-review[data-view="text"] .import-review-panel { display:none; }
  .import-review:not([data-view="text"]) .import-review-text { display:none; }
  .import-review-foot { flex-wrap:wrap; padding:10px 14px; padding-bottom:max(10px, env(safe-area-inset-bottom)); }
  .import-review-status { flex-basis:100%; order:-1; font-size:12px; }
  .import-review-undo { order:0; }
  .import-review-start { flex:1; min-height:46px; font-size:15px; }
  .review-issue-actions button { flex:1; min-height:42px; font-size:14px; }
  .review-sentence-actions { gap:18px; }
  .review-sentence-actions .text-button { padding:6px 0; font-size:14px; }
}
