/* ============================================================
   AI 数学应用题生成器 · 复古胶片风
   主色 #4db030 / 辅助 #4abf7e / 强调 #d52ac2 / 背景 #f9fbf8
   胶片颗粒噪点 + 暗角 + 暖色叠层
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary:  #4db030;
  --c-secondary:#4abf7e;
  --c-accent:   #d52ac2;
  --c-bg:       #f9fbf8;
  --c-card:     #ffffff;
  --c-text:     #1f2c1b;
  --c-text-2:   #637a5c;
  --c-line:     #dde6db;

  --radius: 8px;

  --font-title: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, 'Times New Roman', serif;
  --font-body:  system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;

  --shadow:    0 12px 34px rgba(31, 44, 27, .10);
  --shadow-sm: 0 4px 14px rgba(31, 44, 27, .06);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--c-text);
  background-color: var(--c-bg);
  /* 复古作业纸网格 */
  background-image:
    linear-gradient(rgba(77, 176, 48, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 176, 48, .035) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  line-height: 1.65;
}

img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- 胶片氛围三层叠层 ---------- */
.fx-grain {
  position: fixed; inset: -60%; width: 220%; height: 220%;
  pointer-events: none; z-index: 60; opacity: .5;
  mix-blend-mode: overlay; background-repeat: repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
}
.fx-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 55;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(74, 60, 18, .20) 100%);
}
.fx-warm {
  position: fixed; inset: 0; pointer-events: none; z-index: 54;
  background: linear-gradient(160deg, rgba(255, 214, 150, .07), rgba(213, 42, 194, .03) 55%, rgba(255, 196, 150, .06));
  mix-blend-mode: multiply;
}

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 + 胶片齿孔 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(249, 251, 248, .9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--c-line);
}
.filmstrip {
  height: 26px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #4a4a46, #2b2b28);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .08);
}
.filmstrip::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 12px 13px, #121212 3.4px, transparent 3.9px);
  background-size: 24px 26px;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { font-size: 28px; filter: sepia(.4) saturate(1.2); }
.brand-text strong {
  font-family: var(--font-title); font-size: 18px; letter-spacing: .5px; display: block; line-height: 1.3;
}
.brand-text small { color: var(--c-text-2); font-size: 12px; letter-spacing: 1.5px; }
.site-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none; color: var(--c-text-2);
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid transparent; font-size: 14px; transition: .2s;
}
.site-nav a:hover { color: var(--c-primary); background: #fff; border-color: var(--c-line); transform: translateY(-1px); }
.site-nav a[aria-current="page"] {
  color: #fff; background: var(--c-primary); border-color: var(--c-primary); font-weight: 600;
  box-shadow: 0 4px 12px rgba(77, 176, 48, .3);
}

/* ---------- 首屏（相框） ---------- */
.hero { padding: 34px 20px 8px; }
.hero-frame {
  position: relative; border: 1px solid var(--c-line);
  border-radius: var(--radius); background: var(--c-card);
  box-shadow: var(--shadow); overflow: hidden;
}
.hero-frame::before, .hero-frame::after {
  content: ""; position: absolute; width: 26px; height: 26px; z-index: 1;
}
.hero-frame::before { top: 12px; left: 12px; border-top: 3px solid var(--c-primary); border-left: 3px solid var(--c-primary); }
.hero-frame::after  { bottom: 12px; right: 12px; border-bottom: 3px solid var(--c-primary); border-right: 3px solid var(--c-primary); }
.hero-inner { padding: 44px 36px 38px; text-align: center; position: relative; }
.hero-stamp {
  position: absolute; top: 18px; right: 20px;
  font-family: var(--font-title); color: var(--c-text-2); font-size: 12px; letter-spacing: 1px;
  border: 1px dashed var(--c-line); border-radius: 6px; padding: 4px 10px; transform: rotate(3deg);
  background: rgba(249, 251, 248, .7);
}
.hero-title {
  font-family: var(--font-title); font-size: clamp(30px, 5vw, 52px);
  font-weight: 800; letter-spacing: 2px; line-height: 1.15;
}
.hero-title .accent { color: var(--c-accent); position: relative; }
.hero-title .accent::after {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: -4px; height: 5px;
  background: rgba(213, 42, 194, .18); transform: rotate(-1deg); border-radius: 3px;
}
.hero-sub { color: var(--c-text-2); margin-top: 16px; font-size: 16px; letter-spacing: .5px; }
.hero-tags { display: flex; justify-content: center; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-bg); border: 1px solid var(--c-line);
  color: var(--c-text-2); border-radius: var(--radius);
  padding: 6px 12px; font-size: 13px;
}
.tag b { color: var(--c-text); }

/* ---------- 控制面板 ---------- */
.controls { padding: 28px 20px 6px; }
.controls.compact { max-width: 860px; margin: 0 auto; }
.controls-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px;
}
.control {
  background: var(--c-card); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.control > label {
  font-size: 13px; color: var(--c-text-2); letter-spacing: 1px;
  display: block; margin-bottom: 10px;
}
.control > label small { opacity: .75; font-size: 11px; letter-spacing: 0; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #fff; border: 1px solid var(--c-line); color: var(--c-text);
  border-radius: var(--radius); padding: 8px 13px; font-size: 14px;
  transition: all .18s; user-select: none;
}
.chip:hover { border-color: var(--c-primary); transform: translateY(-1px); }
.chip.active {
  background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px rgba(77, 176, 48, .35);
}
.chip.active[data-accent] {
  background: var(--c-accent); border-color: var(--c-accent);
  box-shadow: 0 3px 10px rgba(213, 42, 194, .35);
}

/* ---------- 按钮 ---------- */
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 18px 20px 6px; }
.btn {
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 12px 20px; font-size: 15px; font-weight: 600;
  transition: transform .15s, box-shadow .15s, background .2s, border-color .2s;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn-lg { padding: 14px 30px; font-size: 17px; }
.btn-primary {
  background: var(--c-accent); color: #fff;
  box-shadow: 0 6px 16px rgba(213, 42, 194, .35);
}
.btn-primary:hover { background: #c023b0; transform: translateY(-2px); box-shadow: 0 10px 22px rgba(213, 42, 194, .4); }
.btn-secondary {
  background: var(--c-primary); color: #fff;
  box-shadow: 0 6px 16px rgba(77, 176, 48, .3);
}
.btn-secondary:hover { background: #429a29; transform: translateY(-2px); }
.btn-ghost { background: #fff; color: var(--c-text); border-color: var(--c-line); }
.btn-ghost:hover { border-color: var(--c-primary); color: var(--c-primary); transform: translateY(-2px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 结果卡片 ---------- */
.results { padding: 12px 20px 60px; scroll-margin-top: 96px; }
.results-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 12px 0 22px;
}
.results-head h2 { font-family: var(--font-title); font-size: 22px; }
.results-head .meta { color: var(--c-text-2); font-size: 14px; font-weight: 400; }
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px;
}
.card { background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--radius); box-shadow: var(--shadow-sm); position: relative; }
.prob {
  padding: 20px 18px 16px;
  transform: rotate(var(--rot, 0deg));
  transition: transform .2s, box-shadow .2s;
  animation: fadeUp .5s both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.prob:hover { transform: rotate(0) translateY(-4px); box-shadow: var(--shadow); z-index: 2; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px) rotate(var(--rot, 0deg)); }
  to   { opacity: 1; transform: translateY(0) rotate(var(--rot, 0deg)); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.tape {
  position: absolute; top: -12px; left: 50%; width: 92px; height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(213, 42, 194, .12);
  border-left: 1px dashed rgba(213, 42, 194, .45);
  border-right: 1px dashed rgba(213, 42, 194, .45);
  opacity: .95;
}
.prob-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.prob-no {
  font-family: var(--font-title); width: 36px; height: 36px; flex: none;
  border-radius: 50%; background: var(--c-bg); border: 1px solid var(--c-line);
  display: grid; place-items: center; font-size: 15px; font-weight: 700; color: var(--c-primary);
}
.prob-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini-tag {
  font-size: 11px; color: var(--c-text-2); border: 1px solid var(--c-line);
  border-radius: 6px; padding: 2px 7px; background: var(--c-bg);
}
.prob-text { font-size: 16px; line-height: 1.85; margin-bottom: 12px; }
details { margin-top: 2px; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.btn-line {
  display: inline-block; font-size: 13px; color: var(--c-accent);
  border: 1px dashed rgba(213, 42, 194, .5); border-radius: var(--radius);
  padding: 6px 12px; transition: .2s;
}
summary:hover .btn-line { background: rgba(213, 42, 194, .06); }
details[open] .btn-line { background: var(--c-accent); color: #fff; border-style: solid; }
.ans { margin-top: 14px; border-top: 1px dashed var(--c-line); padding-top: 12px; animation: fadeIn .25s ease; }
.ans-num { font-family: var(--font-title); font-size: 18px; margin-bottom: 8px; }
.ans-num b { color: var(--c-accent); font-size: 26px; font-weight: 800; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { position: relative; padding-left: 22px; margin: 4px 0; color: var(--c-text-2); font-size: 14px; line-height: 1.7; }
.steps li::before { content: "✓"; position: absolute; left: 0; color: var(--c-secondary); font-weight: 700; }

/* ---------- 在线练习 ---------- */
.quiz-wrap { max-width: 760px; margin: 0 auto; padding: 30px 20px 60px; }
.quiz-stage { padding: 28px 26px; transform: rotate(-.2deg); }
.quiz-progress {
  height: 12px; background: var(--c-bg); border: 1px solid var(--c-line);
  border-radius: 999px; overflow: hidden; margin-bottom: 20px;
}
.quiz-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--c-secondary), var(--c-primary));
  transition: width .4s ease; border-radius: 999px;
}
.quiz-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; color: var(--c-text-2); font-size: 14px; }
.score-chip { background: var(--c-bg); border: 1px solid var(--c-line); border-radius: 999px; padding: 4px 12px; }
.score-chip b { color: var(--c-accent); }
#quizQ { font-size: 19px; line-height: 1.9; margin-bottom: 20px; font-family: var(--font-title); }
.quiz-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quiz-input {
  flex: 1; min-width: 160px;
  border: 1.5px solid var(--c-line); border-radius: var(--radius);
  padding: 12px 16px; font-size: 17px; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.quiz-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(77, 176, 48, .15); }
.quiz-feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); font-size: 15px; animation: fadeIn .3s ease; }
.quiz-feedback.ok { background: rgba(77, 176, 48, .1); border: 1px solid var(--c-secondary); color: #2c6b1d; }
.quiz-feedback.no { background: rgba(213, 42, 194, .08); border: 1px solid rgba(213, 42, 194, .4); color: var(--c-accent); }
.quiz-feedback .fb-ans { font-weight: 700; }
#quizNext { margin-top: 14px; }
.quiz-done { text-align: center; padding: 44px 26px; }
.stamp {
  display: inline-block; font-family: var(--font-title); font-size: 22px;
  border: 3px solid var(--c-accent); color: var(--c-accent);
  border-radius: 6px; padding: 8px 22px; transform: rotate(-4deg);
  box-shadow: inset 0 0 0 1px #fff;
}
.stamp b { font-size: 30px; }
.quiz-done h2 { font-family: var(--font-title); margin: 22px 0 6px; font-size: 26px; }
.quiz-done p { color: var(--c-text-2); }
.quiz-done .btn { margin-top: 22px; }

/* ---------- 打印预览 ---------- */
.print-toolbar { max-width: 900px; margin: 0 auto; padding: 28px 20px 6px; }
.print-toolbar .controls-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.toolbar-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 18px 0 4px; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--c-text-2); }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--c-accent); cursor: pointer; }
.papers { max-width: 900px; margin: 0 auto; padding: 20px 20px 60px; }
.paper {
  width: 210mm; min-height: 297mm; background: #fff;
  margin: 0 auto 26px; padding: 18mm 16mm;
  box-shadow: 0 10px 30px rgba(31, 44, 27, .12); position: relative;
  page-break-after: always;
}
.paper:last-child { page-break-after: auto; }
.paper-head { border-bottom: 2px solid var(--c-primary); padding-bottom: 12px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.paper-title { font-family: var(--font-title); font-size: 24px; font-weight: 800; color: var(--c-text); }
.paper-meta { font-size: 12px; color: #777; text-align: right; line-height: 1.9; }
.pq { display: flex; gap: 10px; margin-bottom: 18px; font-size: 15px; line-height: 1.95; color: #222; }
.pq-num { font-family: var(--font-title); color: var(--c-primary); font-weight: 700; flex: none; }
.blank { display: inline-block; min-width: 74px; border-bottom: 1px dotted #999; text-align: center; }
.answer-key {
  width: 210mm; margin: 0 auto 26px; background: #fff;
  box-shadow: 0 10px 30px rgba(31, 44, 27, .12);
  padding: 16mm; page-break-before: always; page-break-after: always;
}
.key-title { font-family: var(--font-title); color: var(--c-accent); font-size: 18px; margin-bottom: 14px; border-left: 4px solid var(--c-accent); padding-left: 10px; }
.key-item { margin-bottom: 11px; font-size: 13.5px; line-height: 1.8; color: #333; }
.key-item b { color: var(--c-accent); }
.key-item .ksteps { color: #666; font-size: 12.5px; }

/* ---------- 页脚 ---------- */
.site-footer { margin-top: 40px; padding: 30px 20px 40px; text-align: center; color: var(--c-text-2); font-size: 13px; border-top: 1px solid var(--c-line); }
.site-footer p { margin: 4px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 680px) {
  .header-inner { flex-direction: column; gap: 10px; }
  .hero-inner { padding: 30px 18px; }
  .hero-stamp { position: static; display: inline-block; margin-bottom: 14px; transform: rotate(1deg); }
  .cards { grid-template-columns: 1fr; }
  .quiz-actions { flex-direction: column; }
  .quiz-actions .btn { width: 100%; }
  .paper-head { flex-direction: column; align-items: flex-start; }
  .paper-meta { text-align: left; }
}

/* ---------- 打印 ---------- */
@media print {
  body { background: #fff !important; background-image: none !important; }
  .fx-grain, .fx-vignette, .fx-warm, .site-header, .site-footer, .print-toolbar, .no-print { display: none !important; }
  .papers { max-width: none; padding: 0; }
  .paper, .answer-key { box-shadow: none; margin: 0; }
  .paper { page-break-after: always; }
  .paper:last-child { page-break-after: auto; }
}
