:root {
  --ink: #17212b;
  --muted: #627181;
  --line: #dce5e8;
  --canvas: #f4f7f5;
  --paper: #ffffff;
  --navy: #16324f;
  --navy-deep: #0e2439;
  --teal: #1b857c;
  --teal-soft: #e1f2ef;
  --gold: #c78b2a;
  --gold-soft: #fff4df;
  --red: #b54242;
  --red-soft: #fdecec;
  --green: #21744e;
  --green-soft: #e7f5ed;
  --shadow: 0 18px 48px rgba(19, 44, 61, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 82% 8%, rgba(27, 133, 124, 0.08), transparent 28rem),
    linear-gradient(180deg, #f8faf9 0%, var(--canvas) 44%, #eef4f2 100%);
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

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

h1,
h2,
h3 {
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.96;
  margin-bottom: 1.2rem;
}

h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  margin-bottom: 0.6rem;
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}

p {
  line-height: 1.72;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(118deg, rgba(14, 36, 57, 0.97), rgba(19, 60, 71, 0.88)),
    repeating-linear-gradient(45deg, transparent 0, transparent 28px, rgba(255, 255, 255, 0.025) 29px, transparent 30px);
}

.login-card {
  width: min(440px, 100%);
  padding: clamp(30px, 6vw, 54px);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.28);
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border-radius: 20px 20px 20px 4px;
  color: #fff;
  background: linear-gradient(145deg, var(--teal), #2a9c8f);
  box-shadow: 0 14px 30px rgba(27, 133, 124, 0.26);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 2rem;
  font-weight: 700;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 14px 14px 14px 3px;
  font-size: 1.25rem;
  box-shadow: none;
}

.login-intro {
  color: var(--muted);
  margin-bottom: 28px;
}

.privacy-note {
  color: #7a8792;
  font-size: 0.76rem;
  line-height: 1.6;
  margin: 24px 0 0;
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #354451;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfdbde;
  border-radius: 12px;
  color: var(--ink);
  background: #fbfcfc;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input,
select {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  padding: 13px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(27, 133, 124, 0.1);
}

.button {
  min-height: 43px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.84rem;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.button.primary {
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(27, 133, 124, 0.2);
}

.button.primary:hover {
  background: #16746d;
}

.button.secondary {
  color: var(--navy);
  border-color: #bcd1d1;
  background: var(--teal-soft);
}

.button.ghost {
  color: var(--navy);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.button.light {
  color: var(--navy-deep);
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.button.wide {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.text-button {
  border: 0;
  padding: 0;
  color: var(--teal);
  background: transparent;
  font-weight: 800;
  font-size: 0.82rem;
}

.form-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--red);
  font-size: 0.8rem;
}

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

.app-shell > * {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 26px 18px 20px;
  color: #e9f2f3;
  background:
    radial-gradient(circle at 8% 0%, rgba(54, 167, 155, 0.22), transparent 15rem),
    var(--navy-deep);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.02rem;
}

.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: #90a8b5;
  font-size: 0.7rem;
}

.nav {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 0;
  border-radius: 13px;
  color: #b9cbd3;
  background: transparent;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.nav-item span {
  font-size: 0.88rem;
  font-weight: 800;
}

.nav-item small {
  color: #738d9b;
  font-size: 0.68rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.055);
}

.nav-item.active {
  color: #fff;
  background: rgba(46, 159, 146, 0.22);
}

.nav-item.active small {
  color: #9ed7cf;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #93a9b3;
  font-size: 0.75rem;
}

.sidebar-foot .text-button {
  color: #9ed7cf;
}

.main {
  width: 100%;
  min-width: 0;
  max-width: 1500px;
  overflow-x: hidden;
  padding: 34px clamp(22px, 4vw, 56px) 70px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.topbar h2 {
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.view-section {
  animation: fade-up 220ms ease-out;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: clamp(25px, 4vw, 42px);
  border-radius: 26px;
  color: #fff;
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 255, 255, 0.18), transparent 18rem),
    linear-gradient(125deg, #153a54, #1b857c);
  box-shadow: 0 22px 55px rgba(20, 75, 84, 0.18);
}

.hero-card .eyebrow {
  color: #a8ded6;
}

.hero-card h3 {
  max-width: 740px;
  margin: 0;
  color: #fff;
  font-size: clamp(1.25rem, 2.6vw, 1.85rem);
  line-height: 1.45;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.stat-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  padding: 20px;
  border: 1px solid rgba(212, 224, 226, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.stat-card strong {
  display: block;
  color: var(--navy);
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  letter-spacing: -0.05em;
}

.stat-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 18px 0;
}

.panel {
  padding: clamp(20px, 3vw, 28px);
  border: 1px solid rgba(219, 228, 230, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

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

.panel-head h3 {
  margin-bottom: 0;
}

.panel-note {
  color: var(--muted);
  font-size: 0.72rem;
}

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

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 15px;
  border: 1px solid #e0e8e9;
  border-radius: 14px;
  background: #fbfcfc;
}

.list-item strong {
  display: block;
  font-size: 0.88rem;
}

.list-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.list-item .metric {
  color: var(--navy);
  font-size: 1rem;
  font-weight: 900;
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  border: 1px dashed #cedbdc;
  border-radius: 15px;
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.6;
}

.mastery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.mastery-item {
  padding: 15px;
  border: 1px solid #e0e8e9;
  border-radius: 14px;
  background: #fbfcfc;
}

.mastery-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.mastery-item strong {
  font-size: 0.86rem;
}

.mastery-item small {
  color: var(--muted);
  font-size: 0.7rem;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeee;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2a9c8f, #79bcb3);
}

.bar-track.weak span {
  background: linear-gradient(90deg, #c47b2d, #e1ad57);
}

.section-intro {
  margin-bottom: 22px;
}

.section-intro.split {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.section-intro p {
  max-width: 760px;
  color: var(--muted);
  margin-bottom: 0;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 18px;
}

.mode-card {
  display: grid;
  gap: 6px;
  min-height: 170px;
  padding: 24px;
  border: 1px solid #d7e1e2;
  border-radius: 21px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  box-shadow: 0 12px 35px rgba(23, 52, 71, 0.055);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mode-card:hover {
  transform: translateY(-3px);
  border-color: #8fc9c2;
  box-shadow: 0 18px 38px rgba(23, 52, 71, 0.1);
}

.mode-number {
  color: var(--teal);
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.07em;
}

.mode-card strong {
  font-size: 1rem;
}

.mode-card small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.chapter-card {
  padding: 17px;
  border: 1px solid #e0e8e9;
  border-radius: 16px;
  background: #fbfcfc;
}

.chapter-card h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.chapter-card p {
  min-height: 2.7em;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.chapter-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.76rem;
}

.inline-field select,
.inline-field input {
  width: auto;
  min-width: 125px;
  min-height: 39px;
}

.session-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.session-top h3 {
  margin-bottom: 10px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 2px 0 20px;
  border-radius: 999px;
  background: #dfe9e7;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #65b8ae);
  transition: width 240ms ease;
}

.question-card {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid #dbe5e6;
  border-radius: 27px;
  background: #fff;
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.tag.neutral {
  color: #647581;
  background: #edf1f2;
}

.question-card h2 {
  font-size: clamp(1.3rem, 3vw, 1.85rem);
  line-height: 1.55;
  margin-bottom: 28px;
}

.answer-options {
  display: grid;
  gap: 11px;
}

.option-button {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px 17px;
  border: 1px solid #d8e2e3;
  border-radius: 14px;
  color: var(--ink);
  background: #fbfcfc;
  text-align: left;
  line-height: 1.6;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.option-button:hover {
  border-color: #8bc6be;
  transform: translateY(-1px);
}

.option-button.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.option-button .option-key {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--teal);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 900;
}

.fill-answer {
  min-height: 54px;
  font-size: 1.05rem;
}

.hint-box,
.feedback-box,
.upload-preview {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 14px;
  line-height: 1.65;
  font-size: 0.86rem;
}

.hint-box {
  color: #765313;
  border: 1px solid #ebd29e;
  background: var(--gold-soft);
}

.feedback-box.correct {
  color: #185a3d;
  border: 1px solid #b9dec8;
  background: var(--green-soft);
}

.feedback-box.incorrect {
  color: #762f2f;
  border: 1px solid #eac0c0;
  background: var(--red-soft);
}

.feedback-box strong {
  display: block;
  margin-bottom: 5px;
}

.error-type-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.error-chip {
  padding: 6px 9px;
  border: 1px solid #dcc3c3;
  border-radius: 999px;
  color: #7d3a3a;
  background: #fff;
  font-size: 0.7rem;
}

.error-chip.selected {
  color: #fff;
  background: #a84b4b;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 25px;
}

.summary-hero {
  padding: 30px;
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(125deg, var(--navy), #206a6a);
}

.summary-hero h2 {
  margin-bottom: 8px;
}

.summary-hero p {
  margin-bottom: 0;
  color: #c8dcdf;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.report-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 1.2rem;
  color: #3d4a55;
  font-size: 0.86rem;
  line-height: 1.65;
}

.ai-report {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid #c9dedb;
  border-radius: 17px;
  background: linear-gradient(135deg, #f4fbf9, #f4f7ff);
}

.ai-report h3 {
  margin-bottom: 12px;
}

.materials-layout {
  align-items: start;
}

.upload-preview {
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  color: #495861;
  background: #f6f8f8;
  border: 1px solid #dfe7e8;
}

.review-tools {
  display: flex;
  gap: 9px;
  align-items: center;
}

.review-tools select {
  min-width: 220px;
}

.question-review {
  padding: 16px;
  border: 1px solid #dde6e7;
  border-radius: 15px;
  background: #fbfcfc;
}

.question-review header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 10px;
}

.question-review h4 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.question-review footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.status-pill.configured {
  color: var(--green);
  background: var(--green-soft);
}

.status-pill.unconfigured {
  color: #8b5b18;
  background: var(--gold-soft);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 48px));
  padding: 13px 17px;
  border-radius: 13px;
  color: #fff;
  background: var(--navy-deep);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.82rem;
  line-height: 1.5;
}

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 20px;
  }

  .sidebar-brand {
    padding-bottom: 14px;
  }

  .nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 105px;
  }

  .sidebar-foot {
    margin-top: 12px;
    padding-top: 12px;
  }

  .main {
    padding-top: 26px;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 20px 15px 50px;
  }

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

  .top-actions {
    width: 100%;
  }

  .top-actions .button {
    flex: 1;
  }

  .hero-card,
  .section-intro.split,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-card {
    gap: 20px;
  }

  .hero-card .button {
    width: 100%;
  }

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

  .two-column,
  .report-grid {
    grid-template-columns: 1fr;
  }

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

  .mode-card {
    min-height: 128px;
  }

  .review-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .review-tools select {
    min-width: 0;
  }

  .question-actions {
    flex-wrap: wrap;
  }

  .question-actions .button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .login-shell {
    padding: 14px;
  }

  .login-card {
    padding: 28px 21px;
    border-radius: 22px;
  }

  .stat-grid,
  .stat-grid.compact {
    grid-template-columns: 1fr 1fr;
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .question-card {
    padding: 21px 16px;
    border-radius: 20px;
  }
}
