/* ========== 智能组卷 设计系统 ========== */
:root {
  --paper: #F7F4ED;
  --paper-deep: #EFEBE0;
  --ink: #131C2B;
  --ink-2: #4A5568;
  --ink-3: #8A93A6;
  --line: #E3DDCF;
  --indigo: #2F4BDE;
  --indigo-hover: #2740C4;
  --night: #101E3F;
  --night-text: #EDEFF7;
  --night-sub: #9AA7C7;
  --cinnabar: #DF4B36;
  --cinnabar-bg: #FBEFEC;
  --amber: #E9A23B;
  --bamboo: #2E9E6B;
  --grape: #7C4DBE;
  --serif: 'Noto Serif SC', serif;
  --sans: 'Noto Sans SC', sans-serif;
  --grotesk: 'Space Grotesk', monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(47, 75, 222, 0.18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C9CFDA; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
a { color: inherit; text-decoration: none; }
button { font-family: var(--sans); cursor: pointer; border: none; background: none; }
input { font-family: var(--sans); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.paper-container { max-width: 860px; margin: 0 auto; }

/* ========== Navbar ========== */
.navbar {
  position: sticky; top: 0; z-index: 50;
  height: 64px;
  background: rgba(247, 244, 237, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.3s;
}
.navbar.scrolled { box-shadow: 0 4px 16px rgba(19, 28, 43, 0.06); }
.navbar .container { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-brand img { width: 28px; height: 28px; }
.nav-brand .brand-name { font-family: var(--serif); font-size: 20px; font-weight: 900; }
.nav-brand .brand-sub {
  font-family: var(--grotesk); font-size: 10px; letter-spacing: 0.18em; color: var(--ink-3);
}
.nav-links { display: flex; gap: 32px; }
.nav-links a {
  position: relative; padding: 4px 0; font-size: 15px; font-weight: 500;
  color: var(--ink-2); transition: color 0.2s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); }
.nav-links a.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 2px; border-radius: 999px; background: var(--indigo);
}
.nav-cta {
  height: 40px; padding: 0 20px; border-radius: 12px;
  background: var(--indigo); color: #fff; font-size: 15px; font-weight: 700;
  transition: all 0.2s;
}
.nav-cta:hover { background: var(--indigo-hover); transform: translateY(-1px); }
.nav-cta:active { transform: scale(0.97); }
.nav-menu-btn { display: none; font-size: 24px; color: var(--ink); }
.mobile-menu { display: none; border-top: 1px solid var(--line); background: var(--paper); padding: 16px 24px; }
.mobile-menu a { display: block; padding: 10px 0; font-size: 15px; font-weight: 500; color: var(--ink-2); }
@media (max-width: 768px) {
  .nav-links, .nav-cta { display: none; }
  .nav-menu-btn { display: block; }
  .mobile-menu.open { display: block; }
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 28px; border-radius: 12px;
  font-size: 15px; font-weight: 700; transition: all 0.2s;
}
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-hover); transform: translateY(-2px); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent; border: 1.5px solid var(--line); color: var(--ink);
}
.btn-ghost:hover { border-color: var(--indigo); color: var(--indigo); }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-icon { width: 18px; height: 18px; vertical-align: -3px; }

/* ========== 卡片 ========== */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 1px 2px rgba(19,28,43,.05), 0 8px 24px rgba(19,28,43,.06);
}
.card-hover { transition: all 0.25s; }
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px -12px rgba(16,30,63,.18);
}

/* ========== 学段胶囊 ========== */
.stage-segment { display: flex; border-radius: 999px; background: var(--paper-deep); padding: 4px; }
.stage-segment button {
  border-radius: 999px; padding: 10px 40px; font-size: 16px; font-weight: 700;
  color: var(--ink-2); transition: all 0.25s;
}
.stage-segment button:hover { color: var(--ink); }
.stage-segment button.active { color: #fff; box-shadow: 0 4px 12px rgba(19,28,43,.15); }

/* ========== 学科卡 ========== */
.subject-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1024px) { .subject-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .subject-grid { grid-template-columns: repeat(2, 1fr); } }
.subject-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  text-align: left; box-shadow: 0 1px 2px rgba(19,28,43,.05), 0 8px 24px rgba(19,28,43,.06);
  transition: all 0.25s; animation: fadeUp 0.5s var(--ease) both;
}
.subject-card:hover { transform: translateY(-4px); box-shadow: 0 16px 48px -12px rgba(16,30,63,.18); }
.subject-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.subject-card .name { font-family: var(--serif); font-size: 20px; font-weight: 700; margin-top: 16px; }
.subject-card .count { font-family: var(--grotesk); font-size: 14px; color: var(--ink-3); margin-top: 4px; }
.subject-card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  border-radius: 999px; background: var(--paper-deep); color: var(--ink-2);
  padding: 2px 10px; font-size: 12px;
}

/* ========== 步进器 ========== */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--ink-2); font-size: 18px; line-height: 1; transition: background 0.2s;
}
.stepper button:hover { background: var(--paper-deep); }
.stepper .val {
  width: 44px; text-align: center; font-family: var(--grotesk); font-size: 18px; font-weight: 700;
}

/* ========== 表单 ========== */
.form-input {
  height: 44px; width: 100%; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); padding: 0 16px; font-size: 15px; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--indigo); }
.form-label { font-size: 14px; font-weight: 500; color: var(--ink-2); display: block; margin-bottom: 8px; }

/* 滑杆 */
input[type="range"] { width: 100%; height: 6px; appearance: none; border-radius: 999px; background: var(--paper-deep); outline: none; }
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid currentColor; cursor: pointer;
  box-shadow: 0 1px 4px rgba(19,28,43,.2);
}

/* 难度比例条 */
.ratio-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; }
.ratio-bar span { transition: width 0.3s; }

/* ========== 试卷纸 ========== */
.paper-sheet {
  background: #fff; border-radius: 8px; position: relative;
  box-shadow: 0 2px 4px rgba(19,28,43,.06), 0 40px 90px -24px rgba(16,30,63,.28);
}
.paper-sheet::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(90deg, var(--indigo), var(--cinnabar));
}
.paper-inner { padding: 48px 64px; }
@media (max-width: 640px) { .paper-inner { padding: 32px 24px; } }

.paper-head { border-bottom: 2px solid var(--ink); padding-bottom: 24px; text-align: center; position: relative; }
.paper-school { font-size: 14px; letter-spacing: 0.3em; color: var(--ink-2); }
.paper-title { font-family: var(--serif); font-size: 28px; font-weight: 900; line-height: 1.4; margin-top: 12px; }
.paper-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; margin-top: 16px; font-size: 14px; color: var(--ink-2); }
.paper-meta .score-num { font-family: var(--grotesk); font-weight: 700; color: var(--cinnabar); }
.paper-id-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  max-width: 420px; margin: 20px auto 0; font-size: 14px; color: var(--ink-2); text-align: left;
}
.paper-id-row div { border-bottom: 1px dashed var(--ink-3); padding-bottom: 4px; }
.binding-line {
  position: absolute; left: -24px; top: 0; height: 100%; display: flex; align-items: flex-start;
}
.binding-line::before { content: ''; height: 90%; border-left: 1px dashed var(--ink-3); }
.binding-line span {
  margin-left: 8px; font-size: 12px; letter-spacing: 0.5em; color: var(--ink-3);
  writing-mode: vertical-rl;
}
@media (max-width: 900px) { .binding-line { display: none; } }

.paper-section { margin-top: 40px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--line); padding-bottom: 12px;
  font-family: var(--serif); font-size: 18px; font-weight: 700;
}
.section-head .sub { font-size: 14px; font-weight: 400; color: var(--ink-2); margin-left: 12px; }

.q-item { border-bottom: 1px dashed var(--line); padding: 20px 0; display: flex; gap: 12px; }
.q-item:last-child { border-bottom: none; }
.q-no { font-family: var(--grotesk); font-weight: 700; margin-top: 2px; }
.q-body { flex: 1; }
.q-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.score-badge {
  border-radius: 999px; background: var(--cinnabar-bg); color: var(--cinnabar);
  padding: 2px 10px; font-family: var(--grotesk); font-size: 12px; font-weight: 700;
}
.diff-dots { display: inline-flex; gap: 4px; }
.diff-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.q-stem { font-size: 15.5px; line-height: 1.9; white-space: pre-wrap; }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; margin-top: 8px; font-size: 15.5px; }
@media (max-width: 640px) { .q-options { grid-template-columns: 1fr; } }
.answer-lines {
  margin-top: 16px; height: 80px; border-radius: 4px;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, var(--line) 35px, var(--line) 36px);
}
.q-actions { margin-top: 12px; display: flex; gap: 16px; }
.link-btn { font-size: 12px; font-weight: 700; }
.link-btn.red { color: var(--cinnabar); }
.link-btn.blue { color: var(--indigo); }
.link-btn:hover { text-decoration: underline; }

.answer-block {
  margin-top: 12px; border-left: 3px solid var(--cinnabar); background: var(--cinnabar-bg);
  border-radius: 0 12px 12px 0; padding: 16px;
}
.answer-block .ab-title { font-family: var(--serif); font-weight: 700; color: var(--cinnabar); }
.answer-block .ab-text { margin-top: 4px; font-size: 15px; line-height: 1.8; white-space: pre-wrap; }
.answer-block .ab-text.gray { color: var(--ink-2); }

.paper-foot { margin-top: 48px; border-top: 2px solid var(--ink); padding-top: 24px; text-align: center; }
.seal {
  display: inline-block; font-family: var(--serif); font-weight: 700; color: var(--cinnabar);
  border: 3px solid var(--cinnabar); border-radius: 8px; padding: 8px 16px; font-size: 18px;
  transform: rotate(-8deg); box-shadow: inset 0 0 8px rgba(223,75,54,.15);
}
.paper-foot .note { margin-top: 16px; font-size: 12px; color: var(--ink-3); }

/* ========== 工具栏 / 提示 ========== */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }
.toolbar .spacer { flex: 1; }
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 100; background: var(--night); color: var(--night-text);
  border-radius: 999px; padding: 10px 20px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(16,30,63,.3);
  animation: fadeDown 0.3s var(--ease);
}
.notice {
  border: 1px solid rgba(233,162,59,.4); background: rgba(233,162,59,.1);
  border-radius: 12px; padding: 10px 16px; font-size: 14px; color: var(--ink-2);
  margin-bottom: 8px;
}

/* ========== 动画 ========== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal, .subject-card { transition: opacity 0.2s !important; animation-duration: 0.2s !important; transform: none !important; }
}

/* 生成仪式遮罩 */
.gen-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(247,244,237,.92); backdrop-filter: blur(6px);
  display: none; flex-direction: column; align-items: center; justify-content: center;
}
.gen-overlay.show { display: flex; }
.gen-icon {
  width: 64px; height: 64px; border-radius: 16px; background: var(--indigo); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-title { margin-top: 24px; font-family: var(--serif); font-size: 24px; font-weight: 700; }
.gen-sub { margin-top: 12px; font-size: 14px; color: var(--ink-2); }

/* ========== 打印 ========== */
@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .paper-sheet { box-shadow: none !important; border-radius: 0 !important; }
  .paper-sheet::before { display: none; }
  .paper-inner { padding: 0; }
  body.print-teacher .answer-block { display: block !important; }
  body.print-student .answer-block { display: none !important; }
  @page { size: A4; margin: 14mm 12mm; }
}
