:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #fbfcfe;
  --surface-strong: #ffffff;
  --ink: #202633;
  --muted: #647084;
  --line: #dbe2eb;
  --blue: #2f63b7;
  --blue-soft: #e7effb;
  --green: #24745f;
  --green-soft: #e5f4ef;
  --coral: #b65850;
  --coral-soft: #f8e8e5;
  --amber: #9a6a22;
  --amber-soft: #f4ead8;
  --shadow: 0 18px 42px rgba(38, 49, 66, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #edf2f7;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.brand-block p,
.section-heading p,
.queue-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.focus-card {
  border: 1px solid #d8e1eb;
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 14px;
}

.focus-kicker,
.mission-label {
  display: block;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}

.focus-card strong {
  display: block;
  line-height: 1.35;
}

.focus-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field-label {
  display: block;
  color: #494f5a;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 7px;
}

.select,
.input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #ccd6e2;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.select:focus,
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 157, 0.16);
}

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

.stat {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  padding: 12px;
}

.stat span {
  display: block;
  font-size: 27px;
  font-weight: 800;
}

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

.stat.accent span {
  color: var(--coral);
}

.control-group {
  min-width: 0;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.button {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 14px;
  min-height: 42px;
  font-weight: 700;
}

.button.ghost {
  width: 100%;
  border: 1px solid #ccd6e2;
  background: transparent;
  color: #4c5563;
}

.button.primary {
  width: 100%;
  background: var(--blue);
  color: #fff;
}

.button.compact {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}

.button.fit {
  width: auto;
  white-space: nowrap;
}

.link-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 12px 14px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: var(--blue);
  color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.section-heading h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mission-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 14px;
}

.mission-strip > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 18px;
  box-shadow: var(--shadow);
}

.mission-strip h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.mission-strip p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.mission-metrics div {
  display: grid;
  align-content: center;
  min-height: 78px;
  border-left: 4px solid var(--blue);
  padding-left: 12px;
}

.mission-metrics strong {
  font-size: 30px;
  line-height: 1;
}

.mission-metrics span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.learning-loop {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.loop-step {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 12px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
}

.loop-step span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef3f8;
  color: var(--muted);
  font-weight: 900;
  grid-row: span 2;
}

.loop-step strong {
  font-size: 14px;
}

.loop-step small {
  color: var(--muted);
  font-size: 12px;
}

.loop-step.active {
  border-color: rgba(47, 99, 183, 0.45);
  background: var(--blue-soft);
}

.loop-step.active span {
  background: var(--blue);
  color: #fff;
}

.loop-step.done {
  border-color: rgba(36, 116, 95, 0.35);
  background: var(--green-soft);
}

.loop-step.done span {
  background: var(--green);
  color: #fff;
}

.segmented {
  display: inline-flex;
  border: 1px solid #ccd6e2;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
}

.segment {
  min-width: 68px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: var(--blue);
  color: #fff;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.flashcard,
.review-panel,
.table-wrap,
.guide-doc {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flashcard {
  min-height: 520px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  outline: none;
}

.flashcard:focus {
  box-shadow: 0 0 0 3px rgba(49, 95, 157, 0.18), var(--shadow);
}

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.card-meta-group {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stage-new {
  background: var(--blue-soft);
  color: var(--blue);
}

.stage-learning,
.stage-weak {
  background: var(--coral-soft);
  color: var(--coral);
}

.stage-growing {
  background: var(--amber-soft);
  color: var(--amber);
}

.stage-mature {
  background: var(--green-soft);
  color: var(--green);
}

.table-stage {
  min-height: 24px;
}

.timecode {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.card-face {
  display: none;
  margin: auto 0;
}

.card-face.visible {
  display: block;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.card-face h3 {
  margin: 0;
  font-size: 56px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.card-face dl {
  margin: 0;
  display: grid;
  gap: 18px;
}

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

.answer-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 112px;
  background: var(--surface);
}

.card-face dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 5px;
}

.card-face dd {
  margin: 0;
  font-size: 20px;
  line-height: 1.55;
}

.flip-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.review-panel {
  min-height: 520px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.schedule-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 13px;
}

.schedule-card strong,
.micro-coach strong {
  display: block;
  font-size: 13px;
}

.schedule-card p,
.micro-coach p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.micro-coach {
  border: 1px solid rgba(36, 116, 95, 0.22);
  border-radius: var(--radius);
  background: var(--green-soft);
  padding: 13px;
}

.micro-coach .button {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.review-status {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  height: 10px;
  background: #ebe6dc;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 200ms ease;
}

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

.rating {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  color: var(--ink);
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease;
}

.rating:hover:not(:disabled) {
  border-color: #aab8ca;
  transform: translateY(-1px);
}

.rating span {
  display: block;
  font-weight: 900;
  font-size: 18px;
}

.rating small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.rating.again span {
  color: var(--coral);
}

.rating.hard span {
  color: var(--amber);
}

.rating.good span {
  color: var(--green);
}

.rating.easy span {
  color: var(--blue);
}

.rating:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.next-box {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.output-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.output-box p {
  margin: 0 0 9px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.output-box textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid #ccd6e2;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.5;
  outline: none;
  margin-bottom: 10px;
}

.output-box textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 99, 183, 0.14);
}

.next-box strong {
  display: block;
  font-size: 13px;
}

.next-box p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.coach-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.lesson-rail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 140px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.rail-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.rail-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lesson-list {
  overflow: auto;
  padding: 8px;
}

.lesson-list-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
  align-items: center;
}

.lesson-list-item:hover,
.lesson-list-item.active {
  border-color: rgba(47, 99, 183, 0.24);
  background: var(--blue-soft);
}

.lesson-list-item strong,
.lesson-list-item small {
  display: block;
  overflow-wrap: anywhere;
}

.lesson-list-item strong {
  font-size: 14px;
  line-height: 1.3;
}

.lesson-list-item small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.35;
}

.lesson-list-item em {
  align-self: start;
  border-radius: 999px;
  background: #edf2f7;
  color: #4f5968;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 7px;
  white-space: nowrap;
}

.lesson-workspace {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.lesson-hero,
.lesson-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.lesson-hero {
  padding: 24px;
}

.lesson-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.lesson-hero h3 {
  margin: 0;
  font-size: 42px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.lesson-hero p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

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

.lesson-panel {
  padding: 16px;
}

.lesson-panel p {
  margin: 8px 0 0;
  color: #394150;
  line-height: 1.6;
}

.panel-kicker {
  display: block;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.panel-title-row h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.script-panel {
  background: #f8fbff;
}

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

.script-step {
  border: 1px solid #d8e1eb;
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 12px;
  min-height: 136px;
}

.script-step > span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 10px;
}

.script-step strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.script-step p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag-cloud span {
  border: 1px solid #ccd6e2;
  border-radius: 999px;
  background: var(--surface);
  color: #394150;
  padding: 6px 9px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chunk-list,
.response-list,
.srs-list {
  display: grid;
  gap: 10px;
}

.chunk-item,
.response-item,
.srs-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 13px;
}

.chunk-item span,
.response-item span,
.srs-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 5px;
}

.chunk-item strong,
.response-item strong,
.srs-item strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chunk-item p,
.srs-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.practice-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.output-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid #ccd6e2;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.5;
  outline: none;
  margin: 10px 0;
}

.output-panel textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 99, 183, 0.14);
}

.prompt-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 2px;
}

.prompt-tools button {
  border: 1px solid #ccd6e2;
  border-radius: 999px;
  background: var(--surface);
  color: #3d4654;
  min-height: 34px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 800;
}

.prompt-tools button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 150px);
}

.mastery-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mastery-strip div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  min-height: 72px;
  padding: 12px;
}

.mastery-strip strong {
  display: block;
  font-size: 24px;
}

.mastery-strip span {
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #4b5563;
  font-size: 12px;
  z-index: 1;
}

td {
  line-height: 1.45;
  font-size: 14px;
}

.expression-cell {
  font-weight: 800;
  color: var(--ink);
}

.due-label {
  color: var(--coral);
  font-weight: 800;
}

.ok-label {
  color: var(--green);
  font-weight: 800;
}

.guide-doc {
  padding: 22px 26px;
  max-width: 1080px;
  line-height: 1.7;
}

.guide-doc h1,
.guide-doc h2,
.guide-doc h3 {
  line-height: 1.25;
}

.guide-doc h1 {
  font-size: 28px;
}

.guide-doc h2 {
  margin-top: 34px;
  font-size: 22px;
}

.guide-doc h3 {
  margin-top: 24px;
  font-size: 18px;
}

.guide-doc p {
  color: #383d48;
}

.guide-doc table {
  min-width: 0;
  margin: 14px 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.guide-doc th {
  position: static;
}

.guide-doc code {
  background: #eef3f8;
  border-radius: 5px;
  padding: 2px 5px;
}

.guide-doc pre {
  overflow: auto;
  background: #242832;
  color: #f5f7fb;
  border-radius: var(--radius);
  padding: 16px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #242832;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

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

  .sidebar {
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .review-layout {
    grid-template-columns: 1fr;
  }

  .coach-layout {
    grid-template-columns: 1fr;
  }

  .lesson-rail {
    max-height: 360px;
  }

  .mission-strip {
    grid-template-columns: 1fr;
  }

  .learning-loop,
  .mastery-strip,
  .lesson-grid,
  .practice-layout,
  .script-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flashcard,
  .review-panel {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .coach-actions {
    width: 100%;
    justify-content: stretch;
  }

  .coach-actions .button {
    flex: 1 1 96px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
  }

  .flashcard {
    padding: 20px;
  }

  .card-face h3 {
    font-size: 34px;
  }

  .lesson-hero {
    padding: 20px;
  }

  .lesson-hero h3 {
    font-size: 32px;
  }

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

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

  .learning-loop,
  .mastery-strip,
  .mission-metrics,
  .lesson-grid,
  .practice-layout,
  .script-steps {
    grid-template-columns: 1fr;
  }
}
