:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --panel: #ffffff;
  --ink: #182230;
  --muted: #667085;
  --line: #d7dce5;
  --soft-line: #eceff4;
  --blue: #245da8;
  --teal: #08746f;
  --green: #13804f;
  --amber: #b54708;
  --red: #b42318;
  --purple: #6941c6;
  --shadow: 0 16px 36px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.top-actions,
.navigation {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.mark-button,
.choice-button,
.confidence-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 750;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.ghost-button,
.mark-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.primary-button:hover,
.ghost-button:hover,
.mark-button:hover,
.choice-button:hover,
.confidence-button:hover {
  transform: translateY(-1px);
}

.mark-button[aria-pressed="true"] {
  border-color: #f2b94b;
  background: #fff4d6;
  color: #8a4b00;
}

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

.metric-tile {
  min-height: 118px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric-tile strong {
  display: block;
  margin: 7px 0 3px;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1;
}

.metric-tile span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.heat-tile {
  border-color: rgba(181, 71, 8, 0.25);
  background: linear-gradient(135deg, #fff, #fff7ed);
}

.controls {
  display: grid;
  grid-template-columns: 140px 150px minmax(240px, 1fr) 140px minmax(220px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

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

.control-group select:focus,
.control-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 93, 168, 0.16);
}

.result-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 18px;
  background: #fbfffe;
  border: 1px solid rgba(8, 116, 111, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-strip h2 {
  margin-bottom: 6px;
}

.result-strip p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.result-highlights {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: min(430px, 42%);
}

.result-highlights span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.topic-panel,
.question-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topic-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--soft-line);
}

.panel-title span {
  min-width: 34px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff4ff;
  color: var(--blue);
  text-align: center;
  font-weight: 800;
}

.topic-list {
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 8px;
}

.topic-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.topic-row:hover,
.topic-row.active {
  border-color: var(--line);
  background: #f9fafb;
}

.topic-rank {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8f3f1;
  color: var(--teal);
  font-weight: 850;
}

.topic-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  font-weight: 800;
}

.topic-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.topic-score {
  align-self: start;
  color: var(--amber);
  font-weight: 850;
}

.mini-track {
  grid-column: 2 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef0f4;
}

.mini-track span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.practice-panel {
  min-width: 0;
}

.question-card {
  padding: 22px;
}

.question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

#questionTitle {
  font-size: clamp(1.15rem, 2vw, 1.65rem);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.chip.priority-p0 {
  border-color: rgba(180, 35, 24, 0.24);
  background: #fff1f0;
  color: var(--red);
}

.chip.priority-p1 {
  border-color: rgba(181, 71, 8, 0.24);
  background: #fff7ed;
  color: var(--amber);
}

.chip.priority-p2 {
  border-color: rgba(36, 93, 168, 0.24);
  background: #eff4ff;
  color: var(--blue);
}

.question-progress {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

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

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--amber));
}

.question-text {
  max-height: 55vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-area {
  margin-top: 18px;
}

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

.choice-button {
  min-height: 58px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
}

.choice-button.correct {
  border-color: rgba(19, 128, 79, 0.35);
  background: #ecfdf3;
  color: var(--green);
}

.choice-button.incorrect {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff1f0;
  color: var(--red);
}

.choice-button.muted {
  color: var(--muted);
}

.essay-title {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.reference-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.outline-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.essay-original {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.confidence-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.confidence-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.confidence-button.active {
  border-color: rgba(8, 116, 111, 0.32);
  background: #e8f3f1;
  color: var(--teal);
}

.feedback {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 8px;
  font-weight: 750;
}

.feedback.good {
  background: #ecfdf3;
  color: var(--green);
}

.feedback.bad {
  background: #fff1f0;
  color: var(--red);
}

.feedback.neutral {
  background: #eff4ff;
  color: var(--blue);
}

.navigation {
  justify-content: flex-end;
  margin-top: 18px;
}

.empty-state {
  padding: 44px 24px;
  text-align: center;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .wide-control,
  .search-control {
    grid-column: span 2;
  }

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

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

  .result-highlights {
    justify-content: flex-start;
    min-width: 0;
  }

  .topic-panel {
    position: static;
    max-height: none;
  }

  .topic-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 360px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 16px;
  }

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

  .top-actions,
  .navigation,
  .confidence-row,
  .choice-grid,
  .metrics,
  .controls,
  .topic-list {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .navigation {
    display: grid;
  }

  .wide-control,
  .search-control {
    grid-column: auto;
  }

  .question-card {
    padding: 16px;
  }

  .question-head {
    flex-direction: column;
  }

  .mark-button,
  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
