:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --ink: #243447;
  --muted: #6e7b86;
  --line: #e6dfd2;
  --teal: #6aa6a1;
  --teal-dark: #2f6f6b;
  --gold: #f4c95d;
  --rose: #d96c75;
  --indigo: #596b9f;
  --shadow: 0 18px 42px rgba(61, 54, 43, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  letter-spacing: 0;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
  background: rgba(247, 245, 239, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 16%, transparent 17%),
    radial-gradient(circle at 50% 50%, transparent 0 34%, var(--ink) 35% 62%, transparent 63%),
    var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.05;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(255, 253, 248, 0.8);
  font-size: 12px;
}

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

.hero {
  position: relative;
  overflow: hidden;
  min-height: 250px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 82% 24%, rgba(244, 201, 93, 0.45), transparent 20%),
    linear-gradient(145deg, #fffdf8 0%, #eef5f1 100%);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  max-width: 340px;
  margin-bottom: 12px;
  font-size: 32px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 12px;
  font-size: 19px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.hero p:not(.eyebrow) {
  max-width: 280px;
  color: var(--muted);
  line-height: 1.6;
}

.orbit {
  position: absolute;
  right: -36px;
  bottom: -42px;
  width: 186px;
  height: 186px;
  border: 1px solid rgba(36, 52, 71, 0.16);
  border-radius: 50%;
}

.orbit::before {
  content: "";
  position: absolute;
  inset: 35px;
  border: 1px dashed rgba(36, 52, 71, 0.2);
  border-radius: 50%;
}

.orbit i {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
}

.orbit i:nth-child(1) {
  top: 24px;
  left: 42px;
}

.orbit i:nth-child(2) {
  top: 98px;
  right: 20px;
  background: var(--teal);
}

.orbit i:nth-child(3) {
  left: 65px;
  bottom: 28px;
  background: var(--indigo);
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metrics article,
.section,
.suggestion,
.row-card,
.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  min-height: 112px;
  padding: 16px;
}

.metrics span,
.metrics em,
.muted,
.hint,
.row-card small,
.question-head,
.field span {
  color: var(--muted);
}

.metrics strong {
  display: inline-block;
  margin: 8px 4px 0 0;
  font-size: 36px;
}

.metrics em {
  font-style: normal;
}

.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
}

.suggestion.slim {
  margin-bottom: 12px;
  padding: 14px;
}

.suggestion b,
.suggestion small {
  display: block;
}

.suggestion small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.4;
}

.suggestion strong,
.primary,
.small-button {
  border-radius: 8px;
  background: var(--ink);
  color: white;
}

.suggestion strong {
  flex: 0 0 auto;
  padding: 10px 14px;
}

.section {
  padding: 18px;
}

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

.quiet-list p {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f4f0e8;
}

.subject-grid,
.chapter-list {
  display: grid;
  gap: 10px;
}

.subject-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  box-shadow: var(--shadow);
}

.subject-card a:first-child {
  display: grid;
  gap: 6px;
}

.subject-card span {
  font-weight: 700;
}

.subject-card small {
  color: var(--muted);
}

.page-head {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.page-head h1 {
  margin-bottom: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}

.segmented button {
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f3ea;
  color: var(--ink);
}

.segmented button.active {
  border-color: var(--teal);
  background: #eaf5f2;
  color: var(--teal-dark);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.field select,
.field input,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.6;
}

.paste-box {
  min-height: 260px;
}

.primary,
.secondary,
.soft,
.text-button {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
}

.primary {
  background: var(--ink);
  color: white;
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.5;
}

.secondary {
  border: 1px solid var(--line);
  background: #f7f2e9;
  color: var(--ink);
}

.soft {
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--teal-dark);
}

.text-button {
  padding-inline: 0;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 700;
}

.wide {
  width: 100%;
}

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

.row-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.row-card strong {
  display: block;
  margin-top: 5px;
  line-height: 1.45;
}

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

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.small-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.filter-row {
  display: grid;
  gap: 8px;
}

.filter-row .field {
  margin: 0;
}

.center-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.question-panel h1 {
  font-size: 23px;
  line-height: 1.35;
}

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
}

.options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.45;
}

.option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal-dark);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.result {
  margin-top: 16px;
  padding: 14px;
  line-height: 1.55;
}

.result.correct {
  border-color: rgba(106, 166, 161, 0.45);
  background: #edf8f5;
}

.result.wrong {
  border-color: rgba(217, 108, 117, 0.35);
  background: #fff0ef;
}

.result.neutral {
  background: #f8f3ea;
}

.result-metrics {
  margin-bottom: 12px;
}

.result-metrics strong {
  font-size: 28px;
}

.result p:last-child {
  margin-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(36, 52, 71, 0.25);
}

.modal {
  width: min(100%, 520px);
  max-height: 78vh;
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.close {
  float: right;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f0e8;
  color: var(--ink);
}

.knowledge {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.knowledge p {
  color: var(--muted);
  line-height: 1.65;
}

.empty {
  margin: 0;
  padding: 22px 8px;
  color: var(--muted);
  text-align: center;
}

.timer {
  padding: 6px 9px;
  border-radius: 8px;
  background: #f4f0e8;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.tab {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tab span {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.tab.active {
  color: var(--ink);
  font-weight: 700;
}

.tab.active span {
  background: var(--gold);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 88px;
  left: 18px;
  z-index: 50;
  width: min(calc(100% - 36px), 484px);
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  text-align: center;
  box-shadow: var(--shadow);
}

.upload-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 18px;
  border: 1px dashed var(--teal);
  border-radius: 8px;
  background: #eef8f5;
  color: var(--teal-dark);
  text-align: center;
  cursor: pointer;
}

.upload-box.compact {
  margin-top: 8px;
  padding: 14px;
  background: #fffaf1;
}

.secondary-import {
  background: #fbf8f0;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-box span {
  font-weight: 700;
}

.upload-box small {
  color: var(--muted);
  line-height: 1.4;
}

.import-summary {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f8f3ea;
}

.import-summary p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.preview-list {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.preview-card textarea {
  min-height: 88px;
}

.preview-card .field {
  margin: 8px 0;
}

.settings-block {
  display: grid;
  gap: 12px;
}

.settings-block h2,
.settings-block p {
  margin-bottom: 0;
}

.restore-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2e9;
  color: var(--ink);
  cursor: pointer;
}

.restore-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.review-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.review-card small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.review-card pre {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.pipeline {
  display: grid;
  gap: 10px;
}

.pipeline p {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f4f0e8;
}

.pipeline span {
  color: var(--muted);
  line-height: 1.45;
}

@media (min-width: 700px) {
  .app-shell {
    padding-inline: 0;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .row-card {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}
