:root {
  --pine: #1f3d2b;
  --moss: #3a6b45;
  --leaf: #6fa36a;
  --cream: #f4e7c8;
  --paper: #fff6df;
  --ink: #2a1a12;
  --bark: #7a4a28;
  --berry: #c44b2b;
  --gold: #e3a12b;
  --chalk: #eef6d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(227, 161, 43, 0.18), transparent 28%),
    linear-gradient(180deg, #6d8a55 0%, #3f5c3a 42%, #2a4030 100%);
}

.site-switch {
  display: flex;
  flex-wrap: wrap;
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 0;
  border: 3px solid #d8b56a;
  border-radius: 18px;
  overflow: hidden;
  background: #2a4030;
}

.site-switch a {
  flex: 1 1 80px;
  min-width: 0;
  text-align: center;
  padding: 10px 8px;
  color: #f7eed4;
  text-decoration: none;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.02rem;
}

.site-switch a.on {
  background: #3a6b45;
}

.wrap {
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 48px;
}

header {
  color: #f7eed4;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 rgba(31, 61, 43, 0.35);
}

.subtitle {
  margin: 8px 0 0;
  font-size: 1.05rem;
  opacity: 0.92;
}

.grade {
  margin: 8px 0 0;
  color: #e3a12b;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
}

.grade span {
  margin-left: 8px;
  letter-spacing: 0;
  color: #f7eed4;
  opacity: 0.88;
  font-size: 0.95rem;
}

.back {
  margin: 0 0 10px;
  font-size: 1rem;
}

.back a {
  color: #f7eed4;
  text-decoration: none;
  border-bottom: 1px dashed rgba(247, 238, 212, 0.45);
}

.sheet {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 18%),
    var(--paper);
  border: 4px solid #d8b56a;
  border-radius: 28px;
  box-shadow: 0 18px 0 rgba(31, 61, 43, 0.18);
  padding: 22px 22px 26px;
  position: relative;
  overflow: hidden;
}

.sheet::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(122, 74, 40, 0.18);
  border-radius: 20px;
  pointer-events: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.92rem;
}

select, button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

select {
  background: var(--cream);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: inset 0 0 0 2px rgba(122, 74, 40, 0.18);
  color: var(--ink);
  min-width: 132px;
}

button {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--moss);
  color: #f7eed4;
  box-shadow: 0 4px 0 #24462d;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #24462d; }
button.ghost {
  background: #efe0b5;
  color: var(--bark);
  box-shadow: 0 4px 0 #c9ae6d;
}
button.berry {
  background: var(--berry);
  box-shadow: 0 4px 0 #8a2f18;
}

.board {
  position: relative;
  z-index: 1;
  background: linear-gradient(160deg, #35553a, #243826 70%);
  color: var(--chalk);
  border-radius: 22px;
  padding: 22px 20px 18px;
  min-height: 220px;
  box-shadow: inset 0 0 0 6px #1b2b1e;
}

.eqs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 18px;
  font-family: "Fredoka", "ZCOOL KuaiLe", sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
}

.eqs.stack {
  grid-template-columns: 1fr;
}

.eq {
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 10px 14px;
  letter-spacing: 0.04em;
}

.hint {
  margin: 14px 0 0;
  opacity: 0.86;
  font-size: 0.98rem;
}

.answers {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  margin: 18px 0 14px;
}

.answers.cols-1 { grid-template-columns: minmax(160px, 280px); }
.answers.cols-2 { grid-template-columns: repeat(2, 1fr); }
.answers.cols-3 { grid-template-columns: repeat(3, 1fr); }

.letter-box {
  background: var(--cream);
  border-radius: 18px;
  padding: 12px 10px 14px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(122, 74, 40, 0.16);
}

.letter-box b {
  display: block;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.letter-box input {
  width: 100%;
  border: 0;
  background: #fffaf0;
  border-radius: 12px;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  padding: 8px 4px;
  box-shadow: inset 0 0 0 2px rgba(122, 74, 40, 0.16);
}

.letter-box.ok { box-shadow: 0 4px 0 #3a6b45; }
.letter-box.bad { box-shadow: 0 4px 0 #c44b2b; }

.status {
  position: relative;
  z-index: 1;
  min-height: 1.6em;
  font-size: 1.15rem;
}

.howto {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  background: rgba(255, 246, 223, 0.7);
  border-radius: 16px;
  padding: 8px 14px;
}

.howto summary {
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.1rem;
}

.howto ol {
  margin: 8px 0 6px;
  padding-left: 1.3em;
}

.print-area { display: none; }

.board { min-height: 140px; }
.q-meta { margin: 0 0 10px; font-size: 0.95rem; opacity: 0.8; }
.en {
  font-family: "Fredoka", "PingFang SC", sans-serif;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
}
.figure {
  position: relative;
  z-index: 1;
  margin: 16px 0 4px;
  background: #fffaf0;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 4px 0 rgba(122, 74, 40, 0.14);
}
.stem-img {
  display: block;
  width: 100%;
  max-height: none;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  image-rendering: auto;
}
.stem-svg {
  display: block;
  width: min(100%, 520px);
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
}
.opt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  margin-top: 10px;
  color: #2a1a12;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
}
.opt-row .opt {
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: inset 0 0 0 2px rgba(122, 74, 40, 0.14);
}
.answers.cols-5 { grid-template-columns: repeat(5, 1fr); }
.letter-box { cursor: pointer; }
.letter-box .choice-text {
  display: block;
  font-family: "Fredoka", "PingFang SC", sans-serif;
  font-size: 1.05rem;
  line-height: 1.35;
  min-height: 1.4em;
  padding: 0 4px;
}
.letter-box.picked {
  box-shadow: 0 4px 0 #3a6b45;
  outline: 3px solid #3a6b45;
}
.orig-panel {
  position: relative;
  z-index: 1;
  margin: 10px 0 4px;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 4px 0 rgba(122, 74, 40, 0.14);
}
.orig-panel[hidden] { display: none !important; }
.orig-label {
  margin: 0 0 8px;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  color: var(--bark);
}
.orig-panel img {
  display: block;
  width: 100%;
  max-height: none;
  object-fit: contain;
  image-rendering: auto;
}
@media (max-width: 700px) {
  .answers.cols-5 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .answers.cols-2, .answers.cols-3 { grid-template-columns: 1fr 1fr; }
  header { display: block; }
}

@media print {
  body { background: white; }
  .wrap { width: 100%; margin: 0; }
  header, .toolbar, .board, .answers, .status, .sheet, .site-switch { display: none !important; }
  .print-area { display: block; color: #111; }
  .print-item {
    break-inside: avoid;
    border: 2px solid #333;
    padding: 14px 16px 18px;
    margin-bottom: 16px;
    border-radius: 8px;
  }
  .print-item h3 { margin: 0 0 8px; }
  .print-eq { font-size: 1.2rem; margin: 4px 0; font-family: "Fredoka", sans-serif; }
  .print-blanks { margin-top: 10px; letter-spacing: 0.08em; }
}

/* Parametric diagrams and optional post-answer spatial exploration. */
.cube-svg { display:block; width:100%; max-width:400px; max-height:320px; margin:auto; }
.cube-pair { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; max-width:720px; margin:12px auto; align-items:center; }
.cube-pair > * { min-width:0; }
.choice-text { display:block; min-width:0; overflow-wrap:anywhere; }
.choice-text svg { display:block; width:100%; max-height:170px; height:auto; }
.figure-note { font-size:.9rem; text-align:center; }
.cube-lesson { border:2px solid #bad3b2; border-radius:16px; padding:16px; margin-top:16px; }
.cube-lesson[hidden] { display:none; }
.cube-lesson h3 { margin-top:0; }
.button-rotation {
  color: #243028;
  background: #fffaf0;
  border: 2px solid #bad3b2;
  border-radius: 16px;
  padding: 12px 14px;
  margin-top: 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  overflow-x: clip;
}
.button-rotation h3 { margin: 0 0 8px; font-size: 1.15rem; color: var(--pine); }
.button-rotation-static { margin: 0 0 10px; }
.button-rotation-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  max-width: 100%;
}
.button-rotation-card { flex: 1 1 200px; min-width: 0; max-width: 100%; margin: 0; }
.button-rotation-card figcaption { margin-top: 4px; text-align: center; font-weight: 700; color: var(--moss); }
.button-rotation svg {
  display: block;
  width: min(240px, 100%) !important;
  max-width: min(240px, 100%) !important;
  height: auto;
  margin: 0 auto;
}
.button-rotation-dial {
  max-width: 100%;
  transform-origin: 50% 50%;
  transition: transform 280ms ease;
}
.button-rotation-dial:focus-visible {
  outline: 3px solid var(--moss);
  border-radius: 50%;
  outline-offset: 4px;
}
.button-rotation-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; max-width: 100%; }
.button-rotation-status { min-height: 1.4em; margin: 10px 0 0; font-weight: 700; color: var(--pine); }
.button-rotation-print-original { display: none; }
.cube-turns { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
.cube-turns button[aria-pressed="true"] { background:#cce6c5; }
.blender-panel img { display:block; width:100%; height:auto; }
.blender-panel img[hidden] { display:none; }
.blender-panel p { text-align:center; margin:0; }
.print-choices { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
.print-choice svg { width:100%; max-height:120px; }
.figure svg { max-width:100%; height:auto; }
@media (max-width:560px) {
  .answers.cols-5 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .cube-pair { gap:8px; }
  .letter-box { min-width:0; }
  .button-rotation { padding: 10px; }
  .button-rotation-card { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .button-rotation-dial { transition: none; }
}
@media print {
  .button-rotation-controls,
  .button-rotation-status,
  .button-rotation-dial { display: none !important; }
  .button-rotation-print-original { display: block !important; }
  .button-rotation { break-inside: avoid; }
}
@media print {
  .cube-lesson { display:none!important; }
  .print-item { break-inside:avoid; }
  .print-item .cube-svg { max-height:170px; }
  .print-item .blender-panel img { max-height:170px; width:auto; max-width:100%; margin:auto; }
  .print-choices svg { max-height:100px; }
}

.source-question-link { display:inline-block; padding:6px 0; margin:0 0 8px; color:var(--bark); font:600 .93rem/1.45 "PingFang SC",sans-serif; text-underline-offset:3px; }
.board .source-question-link { color:var(--chalk); }
.source-question-link[hidden] { display:none; }

body.review-mode .site-switch,
body.review-mode .wrap {
  width: min(1480px, calc(100% - 24px));
}
body.review-mode .sheet {
  overflow: visible;
}
body.review-mode .review-scroll-hint {
  display: none;
  margin: 0 0 8px;
  color: var(--bark);
  font-weight: 700;
}
@media (min-width: 900px) {
  body.review-mode .toolbar {
    position: sticky;
    top: 0;
    z-index: 6;
    margin-bottom: 12px;
    padding: 8px 0 10px;
    background: var(--paper);
  }
}
body.review-mode .review-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
body.review-mode .review-compare {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  gap: 16px;
  align-items: start;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
body.review-mode .review-col {
  min-width: 0;
  background: rgba(255, 250, 240, 0.72);
  border-radius: 18px;
  padding: 10px 10px 12px;
}
body.review-mode .review-col-label {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--bark);
}
body.review-mode .review-scan-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
body.review-mode .review-scan-open {
  color: var(--bark);
  font-weight: 700;
  white-space: nowrap;
  text-underline-offset: 3px;
}
body.review-mode .review-scan-open[hidden],
body.review-mode .review-scan-empty[hidden] { display: none; }
body.review-mode .review-scan-empty {
  margin: 8px 0 0;
  color: var(--bark);
}
body.review-mode .review-scan .orig-panel {
  margin: 0;
}
body.review-mode .review-scan .orig-label { display: none; }
body.review-mode .review-ai .board { min-height: 0; }
body.review-mode .answers.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
body.review-mode .letter-box { min-width: 0; }
body.review-mode .letter-box .choice-text { overflow-wrap: anywhere; }
body.review-mode #sourceQuestionLink { display: none; }
body.review-mode #reviewBtn[aria-pressed="true"] {
  background: var(--pine);
  color: #f7eed4;
  box-shadow: 0 4px 0 #14281b;
}
@media (max-width: 899px) {
  body.review-mode .review-scroll-hint { display: block; }
  body.review-mode .review-compare {
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    gap: 12px;
    padding-bottom: 6px;
  }
  body.review-mode .review-col {
    flex: 0 0 min(440px, calc(100% - 36px));
    width: min(440px, calc(100% - 36px));
    max-width: calc(100% - 36px);
    scroll-snap-align: start;
  }
  body.review-mode .answers.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print {
  .review-stage { display: none !important; }
}
