:root {
  --bg: #f2efe7;
  --paper: #fffdf8;
  --paper-2: #f8f5ed;
  --paper-3: #fbfaf5;
  --ink: #20302c;
  --muted: #6c7b75;
  --faint: #96a19c;
  --teal: #1f5b54;
  --teal-dark: #173f3a;
  --teal-deep: #102f2c;
  --teal-soft: #e7f0ec;
  --orange: #c46f31;
  --orange-soft: #f8eadc;
  --line: #dedfd7;
  --line-strong: #c9cfc4;
  --danger: #a53e2d;
  --danger-soft: #f9e9e4;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius: 12px;
  --shadow-lg: 0 24px 60px rgba(29, 43, 38, 0.09);
  --shadow-md: 0 12px 30px rgba(29, 43, 38, 0.07);
  --font-sans: "Microsoft YaHei", "Noto Sans SC", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-math: "Cambria Math", "Times New Roman", Georgia, "Microsoft YaHei", serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1000px 420px at 90% -10%, rgba(196, 111, 49, 0.11), transparent 60%),
    radial-gradient(900px 520px at -10% 4%, rgba(31, 91, 84, 0.11), transparent 58%),
    linear-gradient(180deg, #f5f2ea 0%, var(--bg) 42%, #efebe1 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.3;
  background-image: radial-gradient(rgba(31, 91, 84, 0.14) 0.55px, transparent 0.55px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, #000, transparent 60%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid rgba(32, 48, 44, 0.08);
  background: rgba(250, 248, 241, 0.68);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 18px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  border-radius: 14px;
  color: #fffaf0;
  background: linear-gradient(150deg, #245f57, #143d38);
  box-shadow: 0 8px 20px rgba(23, 63, 58, 0.22);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  line-height: 1;
  padding-top: 2px;
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #dc9b5e;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-kicker {
  color: var(--orange);
  font-size: 0.59rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  white-space: nowrap;
}

.brand-name {
  margin-top: 3px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.header-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.header-note::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 91, 84, 0.11);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ece9df;
}

.lang-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.lang-btn:hover {
  color: var(--teal-dark);
}

.lang-btn[aria-pressed="true"] {
  color: var(--teal-dark);
  background: var(--paper);
  box-shadow: 0 2px 7px rgba(29, 43, 38, 0.11);
}

/* ---------- hero ---------- */
.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 34px 26px;
  flex: 1;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  padding: 40px 0 30px;
}

.hero-copy {
  max-width: 790px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 13px;
  color: var(--orange);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(196, 111, 49, 0.12);
}

.hero h1 {
  margin: 0;
  color: var(--teal-deep);
  font-size: clamp(2.05rem, 3.4vw, 3.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.11;
}

.hero-subtitle {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.75;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  padding-bottom: 5px;
}

.stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid rgba(31, 91, 84, 0.13);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.63);
  font-size: 0.7rem;
  white-space: nowrap;
}

.stat-num {
  color: var(--teal);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.stat-chip-accent {
  border-color: rgba(196, 111, 49, 0.22);
  background: rgba(248, 234, 220, 0.75);
}

.stat-chip-accent .stat-num {
  color: var(--orange);
}

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

.settings-panel,
.preview-panel {
  border: 1px solid rgba(32, 48, 44, 0.1);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}

.settings-panel {
  position: static;
  padding: 23px;
}

#settingsForm {
  display: block;
}

.settings-scroll {
  display: block;
}

.panel-heading {
  padding-bottom: 8px;
}

.panel-kicker {
  margin: 0 0 7px;
  color: var(--orange);
  font-size: 0.59rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.panel-title-row,
.preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.preview-head h2 {
  margin: 0;
  color: var(--teal-deep);
  font-size: 1.28rem;
  letter-spacing: -0.025em;
}

.reset-btn {
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
}

.reset-btn:hover {
  color: var(--orange);
  border-color: rgba(196, 111, 49, 0.45);
}

.panel-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.6;
}

.setting-section {
  border-top: 1px solid var(--line);
  padding: 17px 0 16px;
}

.setting-section:last-of-type {
  padding-bottom: 4px;
}

.setting-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 11px;
}

.section-index {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  margin-top: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--faint);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.setting-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.setting-title-wrap h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.89rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.setting-meta {
  color: var(--faint);
  font-size: 0.63rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- tags ---------- */
.tag-grid {
  display: grid;
  gap: 8px;
}

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

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

.tag {
  position: relative;
  display: block;
  min-width: 0;
}

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

.tag-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 47px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease,
    box-shadow 160ms ease, transform 160ms ease;
}

.tag:hover .tag-inner {
  border-color: rgba(31, 91, 84, 0.38);
  box-shadow: 0 5px 16px rgba(31, 91, 84, 0.07);
}

.tag input:focus-visible + .tag-inner {
  outline: 3px solid rgba(196, 111, 49, 0.34);
  outline-offset: 2px;
}

.tag input:checked + .tag-inner {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf7;
  box-shadow: 0 6px 16px rgba(31, 91, 84, 0.17);
}

.tag-symbol {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  border: 1px solid rgba(31, 91, 84, 0.2);
  border-radius: 8px;
  color: var(--teal);
  background: var(--teal-soft);
  font-family: var(--font-math);
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1;
}

.tag-symbol-frac {
  font-size: 1.1rem;
}

.tag input:checked + .tag-inner .tag-symbol {
  border-color: rgba(255, 255, 255, 0.32);
  color: #fffdf7;
  background: rgba(255, 255, 255, 0.13);
}

.tag-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.79rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-check {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-left: auto;
  border-radius: 50%;
  color: var(--teal);
  background: rgba(31, 91, 84, 0.09);
  font-size: 0.58rem;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 150ms ease, transform 150ms ease;
}

.tag input:checked + .tag-inner .tag-check {
  color: var(--teal);
  background: #fffdf7;
  opacity: 1;
  transform: scale(1);
}

.op-tag .tag-inner {
  min-height: 45px;
}

.op-symbol {
  width: 23px;
  flex: 0 0 23px;
  color: var(--teal);
  font-family: var(--font-math);
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.op-symbol sup {
  font-size: 0.54em;
  line-height: 0;
}

.tag input:checked + .tag-inner .op-symbol {
  color: #fffdf7;
}

.tag-meta {
  color: var(--faint);
  font-size: 0.58rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag input:checked + .tag-inner .tag-meta {
  color: rgba(255, 255, 255, 0.65);
}

.op-tag .tag-name {
  font-size: 0.75rem;
}

/* ---------- range / count ---------- */
.range-control + .range-control {
  margin-top: 9px;
}

.range-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.71rem;
}

.number-input {
  width: 62px;
  height: 31px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.number-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 91, 84, 0.11);
}

.slider {
  --fill: 20%;
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--teal) 0 var(--fill), #e5e6de var(--fill) 100%);
}

.slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: #e5e6de;
}

.slider::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--teal);
}

.slider::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -5px;
  appearance: none;
  -webkit-appearance: none;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 2px 7px rgba(23, 63, 58, 0.25);
}

.slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 2px 7px rgba(23, 63, 58, 0.25);
}

.slider:focus-visible {
  outline: 3px solid rgba(196, 111, 49, 0.28);
  outline-offset: 3px;
  border-radius: 999px;
}

.field-note {
  margin: 9px 0 0;
  color: var(--faint);
  font-size: 0.65rem;
  line-height: 1.55;
}

/* ---------- segmented ---------- */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
}

.segment {
  position: relative;
  display: block;
  min-width: 0;
}

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

.segment-inner {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 8px;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.segment:hover .segment-inner {
  color: var(--teal);
}

.segment input:focus-visible + .segment-inner {
  outline: 3px solid rgba(196, 111, 49, 0.3);
  outline-offset: 1px;
}

.segment input:checked + .segment-inner {
  color: #fffdf7;
  background: var(--teal);
  box-shadow: 0 3px 10px rgba(31, 91, 84, 0.18);
}

.segment-num {
  font-family: var(--font-math);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1;
}

.segment-unit {
  font-size: 0.61rem;
  font-weight: 600;
  opacity: 0.85;
}

.count-row {
  margin-bottom: 3px;
}

.count-value {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
}

.count-value strong {
  color: var(--teal);
  font-family: var(--font-math);
  font-size: 1.18rem;
  line-height: 1;
}

.count-value span {
  font-size: 0.68rem;
}

/* ---------- generate / export actions ---------- */
.settings-footnote {
  margin: 8px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.65rem;
  line-height: 1.5;
}

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 51px;
  border: 1px solid var(--teal);
  border-radius: 12px;
  color: #fffdf7;
  background: linear-gradient(150deg, #24655c, var(--teal-dark));
  box-shadow: 0 10px 22px rgba(23, 63, 58, 0.2);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.generate-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(150deg, #2a6f65, #173f3a);
  box-shadow: 0 14px 28px rgba(23, 63, 58, 0.24);
}

.generate-btn:active {
  transform: translateY(0);
}

.generate-btn-compact {
  width: auto;
  min-height: 39px;
  gap: 7px;
  padding: 5px 13px 5px 7px;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(23, 63, 58, 0.16);
  font-size: 0.75rem;
}

.generate-btn-compact .btn-icon {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
}

.generate-btn-compact .btn-icon svg {
  width: 14px;
  height: 14px;
}

.generate-btn-ghost {
  display: none;
  min-height: 44px;
  margin-top: 11px;
  border-color: rgba(31, 91, 84, 0.34);
  color: var(--teal);
  background: transparent;
  box-shadow: none;
  font-size: 0.78rem;
}

.generate-btn-ghost:hover {
  color: #fffdf7;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(23, 63, 58, 0.16);
}

.ghost-arrow {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1;
}

@media (min-width: 981px) {
  .generate-btn-ghost {
    display: flex;
  }
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

/* ---------- preview ---------- */
.preview-panel {
  min-height: 720px;
  padding: 23px 23px 0;
  display: flex;
  flex-direction: column;
}

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

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

.preview-title-row {
  justify-content: flex-start;
  gap: 10px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid rgba(31, 91, 84, 0.13);
  border-radius: 999px;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 0.64rem;
  font-weight: 700;
  white-space: nowrap;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 5px 12px 5px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--teal);
  background: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease,
    opacity 150ms ease;
}

.export-btn .btn-icon {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
  background: var(--teal-soft);
}

.export-btn .btn-icon svg {
  width: 14px;
  height: 14px;
}

.export-btn:hover:not(:disabled) {
  border-color: rgba(31, 91, 84, 0.45);
  background: var(--teal-soft);
  box-shadow: 0 6px 15px rgba(31, 91, 84, 0.08);
}

.export-btn:disabled {
  color: var(--faint);
  background: #f6f4ed;
  opacity: 0.72;
}

.export-btn:disabled .btn-icon {
  background: #ecebe5;
}

.preview-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 14px 0 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.55;
}

.export-hint {
  margin: 0;
  color: var(--faint);
  font-size: 0.64rem;
  text-align: right;
  white-space: nowrap;
}

.error-box {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(165, 62, 45, 0.22);
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.74rem;
  line-height: 1.55;
}

.error-box[hidden] {
  display: none;
}

/* ---------- answer checking ---------- */
.answer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 13px;
  padding: 11px 0 5px;
}

.answer-tip {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.55;
}

.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 5px 13px 5px 7px;
  border: 1px solid var(--orange);
  border-radius: 10px;
  color: #fffdf7;
  background: var(--orange);
  box-shadow: 0 6px 14px rgba(196, 111, 49, 0.18);
  font-size: 0.74rem;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease,
    opacity 150ms ease;
}

.check-btn .btn-icon {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
  background: rgba(255, 255, 255, 0.18);
}

.check-btn .btn-icon svg {
  width: 14px;
  height: 14px;
}

.check-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #ad5e27;
  box-shadow: 0 9px 19px rgba(196, 111, 49, 0.23);
}

.check-btn:disabled {
  border-color: var(--line);
  color: var(--faint);
  background: #f2f0e9;
  box-shadow: none;
  opacity: 0.7;
}

.check-btn:disabled .btn-icon {
  background: #e4e3dd;
}

.score-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(31, 91, 84, 0.16);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(231, 240, 236, 0.8), rgba(255, 253, 248, 0.95));
  animation: card-in 280ms ease both;
}

.score-ring {
  --score: 0%;
  --score-color: var(--teal);
  position: relative;
  display: grid;
  place-items: center;
  width: 57px;
  height: 57px;
  flex: 0 0 57px;
  border-radius: 50%;
  background: conic-gradient(var(--score-color) var(--score), #dfe6df 0);
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--paper);
}

.score-ring strong {
  position: relative;
  z-index: 1;
  color: var(--teal);
  font-family: var(--font-math);
  font-size: 0.95rem;
  line-height: 1;
}

.score-info {
  flex: 1;
  min-width: 0;
}

.score-label {
  display: block;
  color: var(--orange);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.score-text {
  margin: 2px 0 7px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.45;
}

.score-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6df;
}

#scoreFill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 380ms ease;
}

.score-panel.is-low {
  border-color: rgba(196, 111, 49, 0.2);
  background: linear-gradient(135deg, rgba(248, 234, 220, 0.75), rgba(255, 253, 248, 0.95));
}

.score-panel.is-low .score-ring {
  --score-color: var(--orange);
}

.score-panel.is-low .score-ring strong,
.score-panel.is-low .score-label {
  color: var(--orange);
}

.score-panel.is-low #scoreFill {
  background: var(--orange);
}

.score-panel.is-perfect .score-ring {
  --score-color: #2f8a63;
}

.score-panel.is-perfect .score-ring strong {
  color: #2f8a63;
}

.question-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 17px 0 18px;
}

.question-card {
  position: relative;
  min-width: 0;
  padding: 13px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-3);
  overflow: hidden;
  animation: card-in 320ms ease both;
  animation-delay: calc(var(--i, 0) * 25ms);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.question-card::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -26px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(31, 91, 84, 0.035);
  pointer-events: none;
}

.question-card:hover {
  border-color: rgba(31, 91, 84, 0.26);
  box-shadow: 0 9px 22px rgba(29, 43, 38, 0.07);
  transform: translateY(-1px);
}

.question-card.is-correct {
  border-color: rgba(47, 138, 99, 0.42);
  background: #f7fcf9;
}

.question-card.is-wrong {
  border-color: rgba(192, 86, 59, 0.4);
  background: #fdf8f6;
}

.question-card.is-unanswered {
  border-color: rgba(195, 138, 69, 0.35);
  background: #fdfbf6;
}

.q-result {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1;
}

.question-card.is-correct .q-result {
  display: grid;
  background: #2f8a63;
}

.question-card.is-wrong .q-result {
  display: grid;
  background: #c0563b;
}

.question-card.is-unanswered .q-result {
  display: grid;
  background: #bd8b4d;
}

.q-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding-right: 22px;
}

.q-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  color: var(--orange);
  background: var(--orange-soft);
  font-family: var(--font-math);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

.q-expression {
  min-width: 0;
  padding-top: 1px;
  color: var(--ink);
  font-family: var(--font-math);
  font-size: 1.28rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.q-answer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-left: 31px;
}

.q-equals {
  color: var(--faint);
  font-family: var(--font-math);
  font-size: 0.92rem;
  line-height: 1;
}

.answer-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: 1px 3px 2px;
  border: 0;
  border-bottom: 1px dashed #b9c8c1;
  border-radius: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-math);
  font-size: 1.02rem;
  line-height: 1.3;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.answer-input:hover {
  border-bottom-color: #8fa79e;
}

.answer-input:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--teal);
  box-shadow: 0 3px 0 rgba(31, 91, 84, 0.08);
}

.answer-input[aria-invalid="true"] {
  border-bottom-color: #c0563b;
}

.question-card.is-correct .answer-input {
  border-bottom-color: #2f8a63;
}

.question-card.is-wrong .answer-input {
  border-bottom-color: #c0563b;
}

.question-card.is-unanswered .answer-input {
  border-bottom-color: #bd8b4d;
}

/* math typography */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 0.1em;
  font-size: 0.88em;
  line-height: 1;
  transform: translateY(-0.045em);
}

.frac-n {
  min-width: 0.82em;
  padding: 0 0.16em 0.055em;
  border-bottom: 1.5px solid currentColor;
  text-align: center;
}

.frac-d {
  padding: 0.075em 0.16em 0;
  text-align: center;
}

.pow {
  font-size: 0.58em;
  line-height: 0;
  vertical-align: super;
  margin-left: 0.04em;
}

/* ---------- empty state ---------- */
.empty-state {
  flex: 1;
  min-height: 430px;
  margin: 17px 0 18px;
  padding: 40px 24px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  background: rgba(248, 245, 237, 0.6);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-symbols {
  display: flex;
  gap: 8px;
  margin-bottom: 17px;
}

.empty-symbols span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--teal);
  background: var(--paper);
  font-family: var(--font-math);
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(29, 43, 38, 0.04);
}

.empty-state h3 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 1.02rem;
}

.empty-state p {
  max-width: 350px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.65;
}

.preview-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 13px 0 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.65rem;
}

.preview-footer-mark {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 6px;
  color: var(--teal);
  background: var(--teal-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.75rem;
  line-height: 1;
}

/* ---------- footer ---------- */
.site-footer {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 10px 34px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 0.65rem;
}

.footer-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  }

  .hero {
    gap: 26px;
  }

  .header-note {
    display: none;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 22px;
    padding-top: 34px;
  }

  .hero-stats {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .preview-panel {
    min-height: 0;
  }

  .empty-state {
    min-height: 330px;
  }
}

@media (max-width: 680px) {
  .header-inner,
  .page,
  .site-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .header-inner {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 12px;
    font-size: 24px;
  }

  .brand-kicker {
    font-size: 0.52rem;
  }

  .brand-name {
    font-size: 0.9rem;
  }

  .page {
    padding-bottom: 16px;
  }

  .hero {
    padding: 27px 0 22px;
  }

  .hero h1 {
    font-size: clamp(1.55rem, 6.4vw, 2.1rem);
    letter-spacing: -0.045em;
    line-height: 1.18;
  }

  .hero-subtitle {
    font-size: 0.88rem;
  }

  .stat-chip {
    padding: 7px 9px;
    font-size: 0.64rem;
  }

  .settings-panel,
  .preview-panel {
    border-radius: 18px;
  }

  .settings-panel,
  .preview-panel {
    padding: 18px;
  }

  .preview-panel {
    padding-bottom: 0;
  }

  .question-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .preview-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .generate-btn-compact,
  .export-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .answer-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding-top: 9px;
  }

  .answer-tip {
    max-width: none;
  }

  .check-btn {
    align-self: stretch;
  }

  .score-panel {
    gap: 10px;
    padding: 10px 12px;
  }

  .score-ring {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .export-btn {
    align-self: flex-start;
  }

  .preview-meta-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .export-hint {
    text-align: left;
    white-space: normal;
  }

  .q-expression {
    font-size: 1.18rem;
  }

  .site-footer {
    align-items: flex-start;
    flex-wrap: wrap;
    padding-bottom: 20px;
  }
}

@media (max-width: 420px) {
  .hero-stats {
    gap: 6px;
  }

  .stat-chip {
    flex: 1 1 auto;
    justify-content: center;
  }

  .segment-inner {
    gap: 3px;
  }

  .segment-unit {
    font-size: 0.55rem;
  }
}

@media (max-width: 360px) {
  .type-grid,
  .op-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- print-only PDF ---------- */
#printArea {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 15mm 14mm;
  }

  html,
  body {
    background: #fff !important;
  }

  body {
    color: #000;
    font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body::before,
  #app {
    display: none !important;
  }

  #printArea {
    display: block !important;
    width: 100%;
    color: #000;
  }

  .print-head {
    padding-bottom: 6mm;
    border-bottom: 1px solid #000;
  }

  .print-title {
    margin: 0;
    font-size: 20pt;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .print-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4mm 14mm;
    margin-top: 5mm;
    font-size: 9pt;
    color: #222;
  }

  .print-meta span {
    display: inline-flex;
    gap: 2mm;
    align-items: baseline;
  }

  .print-meta .print-blank {
    display: inline-block;
    min-width: 36mm;
    border-bottom: 0.7pt solid #000;
    height: 3.5mm;
  }

  .print-summary {
    margin: 3mm 0 0;
    font-size: 8.5pt;
    color: #444;
  }

  .print-list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .print-q {
    display: flex;
    align-items: flex-start;
    gap: 3mm;
    padding: 7mm 0 4.5mm;
    border-bottom: 0.5pt solid #b9b9b9;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-num {
    flex: 0 0 8mm;
    padding-top: 0.3mm;
    font-size: 9.5pt;
    font-weight: 700;
    text-align: right;
  }

  .print-expression {
    flex: 0 1 auto;
    max-width: 116mm;
    min-width: 0;
    padding-top: 0.2mm;
    font-family: "Cambria Math", "Times New Roman", Georgia, serif;
    font-size: 13.5pt;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .print-equals {
    flex: 0 0 auto;
    margin-left: 2mm;
    padding-top: 0.2mm;
    font-family: "Cambria Math", "Times New Roman", Georgia, serif;
    font-size: 12pt;
  }

  .print-answer {
    flex: 0 0 43mm;
    height: 5.2mm;
    margin-left: 2mm;
    border-bottom: 0.7pt solid #000;
  }

  .print-foot {
    margin-top: 7mm;
    padding-top: 3mm;
    border-top: 0.5pt solid #b9b9b9;
    color: #555;
    font-size: 8pt;
    text-align: center;
  }

  .print-expression .frac {
    font-size: 0.88em;
    transform: translateY(-0.04em);
  }

  .print-expression .frac-n {
    border-bottom-width: 1pt;
  }

  .print-expression .pow {
    font-size: 0.56em;
  }

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