:root {
  --cream: #f5eee2;
  --paper: #fffdf9;
  --ink: #1b2524;
  --muted: #69716e;
  --coral: #e8795a;
  --coral-dark: #c9593d;
  --line: #cfc5b6;
  --shadow: 0 20px 60px rgba(52, 43, 32, 0.12);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: ui-rounded, "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.65;
}

button, input, summary { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: white;
  border-radius: 10px;
}
.skip-link:focus { top: 16px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  max-width: 1240px;
  margin: 0 auto;
  min-height: 70px;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--cream);
  background: var(--ink);
  font-size: 24px;
  transform: rotate(-12deg);
}

.brand strong { display: block; font-size: 17px; letter-spacing: .04em; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .18em; }

.header-actions { display: flex; align-items: center; gap: 16px; }
.quiet-header-button {
  padding: 7px 3px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-size: 12px;
  cursor: pointer;
}
.quiet-header-button:hover { color: var(--ink); border-bottom-color: currentColor; }

main { max-width: 1240px; margin: 0 auto; padding: 6px 32px 110px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.experience-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: minmax(580px, 820px) minmax(300px, 380px);
  justify-content: center;
  gap: 28px;
  align-items: start;
}

.science-paper {
  position: relative;
  width: 100%;
  min-height: 0;
  padding: clamp(28px, 4vw, 56px);
  background: var(--paper);
  border: 1px solid rgba(27,37,36,.15);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.science-paper::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(27,37,36,.13);
  pointer-events: none;
}

.paper-topline {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.mode-switch { display: flex; background: #f1ede6; border-radius: 10px; padding: 3px; }
.mode-switch button { border: 0; background: transparent; padding: 6px 9px; border-radius: 8px; font-size: 10px; cursor: pointer; }
.mode-switch button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 2px 8px rgba(44,38,28,.1); font-weight: 800; }

.science-paper h2 {
  margin: 22px auto 0;
  max-width: 92%;
  text-align: center;
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: clamp(30px, 4.1vw, 52px);
  line-height: 1.18;
  letter-spacing: .02em;
}

.card-illustration {
  position: relative;
  flex: none;
  width: 100%;
  min-height: 0;
  margin: 14px 0 12px;
  overflow: visible;
}
.card-illustration img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) contrast(1.1);
  mix-blend-mode: multiply;
}

.story-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  counter-reset: story;
}
.story-steps li {
  min-height: 112px;
  padding: 13px 12px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  font-family: "Kaiti SC", "STKaiti", serif;
  font-size: clamp(12px, 1.35vw, 16px);
  line-height: 1.5;
  counter-increment: story;
}
.story-steps li::before {
  content: counter(story);
  width: 22px;
  height: 22px;
  margin: 0 6px 4px 0;
  display: inline-grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font: 800 11px/1 ui-rounded, sans-serif;
}

.paper-footer { display: flex; justify-content: space-between; margin-top: 10px; font-size: 9px; font-weight: 800; letter-spacing: .12em; }

.science-paper.mode-image .story-steps { display: none; }
.science-paper.mode-image .card-illustration { margin-top: 18px; }

.parent-guide {
  position: sticky;
  top: 90px;
  padding: 26px;
  background: #243331;
  color: #f9f3e9;
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(25, 34, 32, .18);
}
.guide-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.guide-heading .eyebrow { color: #f0a68e; }
.guide-heading h2 { margin: 0; font-family: "Songti SC", serif; font-size: 27px; }
.guide-icon { font-size: 28px; }
.guide-block { margin-top: 20px; }
.guide-block h3, .guide-details summary { margin: 0 0 7px; font-size: 12px; letter-spacing: .08em; }
.guide-block p, .guide-details p, .guide-details li { margin: 0; color: #dce1dc; font-size: 13px; line-height: 1.75; }
#parent-script { white-space: pre-line; }
.answer-block { padding: 15px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.13); border-radius: 15px; }
.answer-block p { color: white; font-weight: 700; }
.guide-details { border-top: 1px solid rgba(255,255,255,.14); padding: 15px 0 0; margin-top: 15px; }
.guide-details summary { cursor: pointer; font-weight: 800; }
.guide-details ul { margin: 8px 0 0; padding-left: 19px; }
.guide-details li + li { margin-top: 7px; }
.guide-details strong { color: white; }

.action-dock {
  position: sticky;
  z-index: 19;
  bottom: 16px;
  width: min(760px, calc(100% - 24px));
  margin: 22px auto 0;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(70px, .6fr) minmax(70px, .6fr) minmax(180px, 1.7fr) minmax(70px, .6fr) minmax(70px, .6fr);
  gap: 7px;
  border: 1px solid rgba(27,37,36,.16);
  border-radius: 20px;
  background: rgba(255,253,249,.92);
  box-shadow: 0 14px 40px rgba(46,39,30,.16);
  backdrop-filter: blur(18px);
}
.action-dock button { border: 0; cursor: pointer; }
.primary-action {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: white;
  background: var(--coral);
  border-radius: 13px;
  transition: background .2s ease, transform .2s ease;
}
.primary-action:hover { background: var(--coral-dark); transform: translateY(-1px); }
.primary-action > span:first-child { font-size: 27px; }
.primary-action strong { font-size: 14px; }
.icon-action {
  min-height: 53px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: transparent;
  border-radius: 12px;
  font-size: 11px;
}
.icon-action:hover { background: var(--cream); }
.icon-action > span:first-child { font-size: 21px; line-height: 1; }
.icon-action[aria-pressed="true"] > span:first-child { color: var(--coral-dark); }

.modal-dialog { max-height: 90vh; padding: 28px; color: #f9f3e9; background: #243331; border: 0; border-radius: 22px; }
.modal-dialog[open] { animation: help-dialog-in .22s cubic-bezier(.2,.8,.2,1) both; }
.modal-dialog[open]::backdrop { background: rgba(16,24,23,.62); backdrop-filter: blur(4px); animation: help-backdrop-in .2s ease-out both; }
.modal-dialog.closing { animation: help-dialog-out .16s ease-in both; }
.modal-dialog.closing::backdrop { animation: help-backdrop-out .16s ease-in both; }
.modal-dialog form { position: sticky; top: 0; display: flex; justify-content: flex-end; }
.modal-dialog form button { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.18); color: white; background: rgba(255,255,255,.08); border-radius: 50%; cursor: pointer; }
.modal-dialog .eyebrow { color: #f0a68e; }
.modal-dialog h2 { margin: 10px 0 8px; font-family: "Songti SC", serif; font-size: 29px; line-height: 1.35; }
.help-dialog { width: min(520px, calc(100% - 24px)); }
.help-intro { margin: 0; color: #cdd5d1; font-size: 13px; }
.help-steps { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 16px; }
.help-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.help-steps li > span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; font-size: 11px; }
.help-steps strong, .help-steps small { display: block; }
.help-steps small { margin-top: 2px; color: #cdd5d1; line-height: 1.6; }
.help-note { margin: 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); color: #cdd5d1; font-size: 12px; }

.history-dialog { width: min(720px, calc(100% - 24px)); }
.history-intro { margin: 0; color: #cdd5d1; font-size: 13px; }
.history-columns { margin-top: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.history-columns section { min-width: 0; }
.history-columns h3 { margin: 0 0 9px; font-size: 12px; letter-spacing: .08em; }
.history-columns h3 span { margin-left: 4px; color: #aebbb5; font-weight: 500; }
.history-list { max-height: 330px; overflow: auto; display: grid; align-content: start; gap: 8px; }
.history-card { width: 100%; padding: 12px 13px; color: white; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; text-align: left; cursor: pointer; }
.history-card:hover { background: rgba(255,255,255,.11); }
.history-card span, .history-card strong { display: block; }
.history-card span { color: #aebbb5; font-size: 10px; letter-spacing: .05em; }
.history-card strong { margin-top: 3px; font-family: "Songti SC", serif; font-size: 15px; line-height: 1.45; }
.history-empty { min-height: 72px; margin: 0; padding: 16px; color: #aebbb5; background: rgba(255,255,255,.04); border: 1px dashed rgba(255,255,255,.14); border-radius: 12px; font-size: 12px; line-height: 1.65; }

@keyframes help-dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes help-dialog-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(.985); }
}
@keyframes help-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes help-backdrop-out { from { opacity: 1; } to { opacity: 0; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 100;
  max-width: calc(100% - 30px);
  padding: 10px 15px;
  color: white;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .experience-grid { grid-template-columns: minmax(0, 760px); }
  .parent-guide { position: static; }
}

@media (max-width: 760px) {
  .site-header { min-height: 70px; padding: 14px 18px; }
  main { padding: 0 14px 100px; }
  .experience-grid { margin-top: 2px; }
  .science-paper { min-height: 0; padding: 24px 20px 26px; border-radius: 5px; }
  .science-paper::before { inset: 9px; }
  .paper-topline { align-items: flex-start; }
  .mode-switch { max-width: 151px; overflow: hidden; }
  .mode-switch button { padding: 6px 7px; }
  .science-paper h2 { max-width: 100%; font-size: 32px; }
  .card-illustration { height: auto; min-height: 0; }
  .story-steps { grid-template-columns: 1fr; }
  .story-steps li { min-height: 0; font-size: 14px; }
  .parent-guide { display: block; padding: 23px 20px; border-radius: 18px; }
  .action-dock {
    width: calc(100% - 18px);
    bottom: 8px;
    grid-template-columns: .62fr .62fr 1.45fr .62fr .62fr;
    padding: 6px;
    border-radius: 16px;
  }
  .primary-action { padding: 8px 6px; gap: 6px; }
  .primary-action > span:first-child { font-size: 22px; }
  .primary-action strong { font-size: 12px; }
  .icon-action { min-height: 48px; font-size: 9px; }
  .icon-action > span:first-child { font-size: 18px; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  .science-paper { padding: 22px 17px 24px; }
  .category-pill { max-width: 145px; font-size: 9px; }
  .science-paper h2 { font-size: 28px; }
  .action-dock { grid-template-columns: .58fr .58fr 1.38fr .58fr .58fr; }
  .icon-action span:last-child { font-size: 8px; }
  .header-actions { gap: 10px; }
  .modal-dialog { padding: 22px; }
  .history-columns { grid-template-columns: 1fr; }
  .history-list { max-height: 210px; }
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { width: 210mm; height: 297mm; background: white !important; }
  .skip-link,
  .site-header,
  .parent-guide,
  .action-dock,
  dialog,
  .toast { display: none !important; }
  main, .experience-grid { display: block; width: 210mm; height: 297mm; margin: 0; padding: 0; }
  body * { visibility: hidden !important; }
  .science-paper, .science-paper * { visibility: visible !important; }
  .science-paper {
    position: absolute;
    inset: 0;
    width: 210mm;
    height: 297mm;
    min-height: 0;
    aspect-ratio: auto;
    padding: 8mm 9mm 7mm;
    background: var(--cream) !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    isolation: isolate;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .science-paper::before { display: none; }
  .mode-switch { display: none; }
  .science-paper h2 { font-size: 26pt; margin-top: 3mm; }
  .paper-footer { margin-top: 1mm; }

  .science-paper.mode-image {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  .science-paper.mode-image .card-illustration {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 2mm 0 0;
  }
  .science-paper.mode-image .card-illustration img { width: 100%; height: 100%; object-fit: contain; }

  .science-paper.mode-text {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  }
  .science-paper.mode-text .paper-topline,
  .science-paper.mode-text h2,
  .science-paper.mode-text .paper-footer { width: 100%; }
  .science-paper.mode-text .card-illustration {
    grid-row: 3;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 2mm 0 0;
  }
  .science-paper.mode-text .card-illustration img { width: 100%; height: 100%; object-fit: contain; }
  .science-paper.mode-text .story-steps {
    grid-row: 4;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 1fr;
    gap: 3mm;
    margin-top: 2mm;
  }
  .science-paper.mode-text .story-steps li { min-height: 31mm; padding: 3mm; font-size: 9.5pt; }
  .science-paper.mode-text .paper-footer { grid-row: 5; }

  .science-paper .card-illustration img {
    background: transparent;
    mix-blend-mode: multiply;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
