:root {
  --ink: #263238;
  --muted: #667085;
  --paper: #fffdf7;
  --cream: #fff6d9;
  --orange: #ff7b54;
  --orange-dark: #d94f2b;
  --blue: #3976d2;
  --line: #e7e2d7;
  --shadow: 0 12px 32px rgba(75, 61, 31, .10);
}

html {
  scroll-padding-top: 126px;
}

body {
  max-width: none;
  margin: 0;
  padding: 94px 18px 50px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 7%, rgba(255, 211, 102, .30) 0 80px, transparent 82px),
    radial-gradient(circle at 95% 20%, rgba(116, 192, 252, .20) 0 110px, transparent 112px),
    linear-gradient(180deg, #fff8df 0, #f7fbff 480px, #fffdf8 100%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 18px;
  line-height: 1.82;
  -webkit-font-smoothing: antialiased;
}

body.large-type {
  font-size: 20px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -70px;
  z-index: 999;
  padding: 10px 16px;
  border-radius: 0 0 12px 12px;
  color: #fff;
  background: #263238;
}

.skip-link:focus {
  top: 0;
}

.book-shell {
  width: min(100%, 980px);
  margin: 0 auto;
}

.topnav {
  display: block;
  padding: 10px 18px 0;
  white-space: normal;
  background: rgba(255, 255, 255, .96);
  border-bottom: 0;
  box-shadow: 0 5px 24px rgba(52, 43, 20, .10);
  backdrop-filter: blur(12px);
}

.nav-main {
  display: flex;
  width: min(100%, 1240px);
  min-height: 46px;
  margin: 0 auto 9px;
  align-items: center;
  gap: 12px;
}

.topnav .logo {
  display: inline-flex;
  min-width: max-content;
  padding: 5px 13px 5px 3px;
  align-items: center;
  border-right: 2px dashed #ffd166;
  color: var(--orange-dark);
  font-size: 17px;
  font-weight: 900;
  text-decoration: none;
}

.nav-links {
  display: flex;
  min-width: 0;
  flex: 1;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.topnav .nav-links a {
  display: inline-flex;
  min-height: 34px;
  padding: 4px 11px;
  align-items: center;
  flex: none;
  border: 1.5px solid #e9e4d8;
  border-radius: 999px;
  color: #4c5258;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.topnav .nav-links a:hover,
.topnav .nav-links a:focus-visible,
.topnav .nav-links a.active {
  color: #9f3b20;
  background: #fff1e8;
  border-color: #ffb28f;
  transform: translateY(-1px);
  box-shadow: none;
  outline: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.nav-actions button,
.download-button,
.answer-toggle,
.complete-button,
.back-to-top {
  min-height: 38px;
  padding: 7px 12px;
  border: 0;
  border-radius: 12px;
  color: #41464b;
  background: #f5f1e8;
  font: 800 13px/1.2 inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.nav-actions button:hover,
.nav-actions button:focus-visible,
.download-button:hover,
.download-button:focus-visible,
.answer-toggle:hover,
.answer-toggle:focus-visible,
.complete-button:hover,
.complete-button:focus-visible,
.back-to-top:hover,
.back-to-top:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(47, 42, 30, .12);
  outline: 3px solid rgba(255, 174, 66, .28);
}

#printButton {
  color: #fff;
  background: var(--orange);
}

.download-button {
  color: #fff;
  background: #3b7fc4;
}

.progress-label {
  min-width: max-content;
  padding: 5px 9px;
  border-radius: 9px;
  color: #21633d;
  background: #e7f8ed;
  font-size: 12px;
  font-weight: 900;
}

.scroll-track {
  height: 4px;
  margin: 0 -18px;
  overflow: hidden;
  background: #f2eee4;
}

.scroll-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 99px 99px 0;
  background: linear-gradient(90deg, #ff7b54, #ffd166, #46b881);
}

.cover {
  position: relative;
  overflow: hidden;
  padding: 42px 28px 34px;
  border: 0;
  border-radius: 34px;
  background:
    radial-gradient(circle at 15% 18%, rgba(255,255,255,.85) 0 48px, transparent 50px),
    radial-gradient(circle at 89% 14%, rgba(255,255,255,.72) 0 70px, transparent 72px),
    linear-gradient(145deg, #ffe8c2 0%, #fff8d6 48%, #dff4ff 100%);
  box-shadow: var(--shadow);
}

.cover::before,
.cover::after {
  position: absolute;
  display: block;
  color: rgba(67, 89, 112, .15);
  font-weight: 900;
  transform: rotate(-11deg);
  content: "2 + 3 = 5";
}

.cover::before {
  top: 22px;
  left: 25px;
  font-size: 17px;
}

.cover::after {
  right: 28px;
  bottom: 26px;
  font-size: 15px;
  content: "7 × 8 = 56";
  transform: rotate(8deg);
}

.eyebrow {
  position: relative;
  z-index: 1;
  width: max-content;
  margin: 0 auto 8px;
  padding: 5px 14px;
  border: 1.5px solid rgba(147, 91, 32, .16);
  border-radius: 99px;
  color: #92501f;
  background: rgba(255, 255, 255, .72);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
}

.cover .emoji {
  position: relative;
  z-index: 1;
  font-size: clamp(44px, 8vw, 72px);
  filter: drop-shadow(0 6px 0 rgba(255,255,255,.75));
}

h1 {
  position: relative;
  z-index: 1;
  margin: 8px 0 4px;
  color: #cf482b;
  font-size: clamp(31px, 5vw, 46px);
  letter-spacing: 1px;
  text-shadow: 0 3px 0 rgba(255,255,255,.9);
}

.cover .sub {
  color: #4e6072;
  font-size: 20px;
}

.cover .meta {
  max-width: 700px;
  margin: 18px auto 0;
  color: #57616a;
  font-size: 15px;
  line-height: 1.75;
}

.badges {
  position: relative;
  z-index: 1;
  gap: 8px;
}

.badge {
  padding: 6px 13px;
  border: 1.5px solid rgba(222, 151, 40, .28);
  color: #875019;
  background: rgba(255,255,255,.82);
  font-size: 13px;
  box-shadow: 0 3px 8px rgba(102, 82, 38, .05);
}

.passport {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 570px);
  margin: 20px auto 0;
  padding: 9px 13px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 15px;
  color: #4c5358;
  background: rgba(255, 255, 255, .74);
  font-size: 13px;
  font-weight: 900;
}

.passport-dots {
  display: flex;
  gap: 7px;
}

.passport-dot {
  width: 18px;
  height: 18px;
  border: 2px solid #d1ccc0;
  border-radius: 50%;
  color: transparent;
  background: #fff;
}

.passport-dot.done {
  border-color: #318762;
  color: #fff;
  background: #46b881;
}

.method[style] {
  margin-top: 26px !important;
}

.grownup-note {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #5e4b30;
  background: rgba(255, 255, 255, .72);
  font-size: 14px;
}

.tocrow {
  position: relative;
  min-height: 76px;
  padding: 12px 18px;
  border: 1.5px solid #eae5da;
  border-radius: 18px;
  box-shadow: 0 5px 16px rgba(50, 43, 30, .05);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.tocrow::after {
  margin-left: auto;
  color: #9aa1a6;
  font-size: 22px;
  content: "→";
}

.tocrow:hover,
.tocrow:focus-visible {
  border-color: #ffb28f;
  box-shadow: 0 9px 22px rgba(80, 57, 25, .10);
  transform: translateY(-2px);
  outline: none;
}

.tocrow .tname {
  color: #343b40;
  font-size: 18px;
}

.tocrow .tdesc {
  color: #75808a;
  font-size: 13px;
}

.unit-head {
  position: relative;
  margin-top: 50px;
  padding: 19px 23px;
  border-radius: 24px;
  box-shadow: 0 10px 24px rgba(57, 61, 64, .12);
  scroll-margin-top: 126px;
}

.unit-head .uno {
  width: 58px;
  height: 58px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .07);
}

.unit-head .uname {
  font-size: 27px;
}

.unit-head .usub {
  font-size: 14px;
}

.story,
.know,
.method,
.think,
.life,
.smart,
.solve,
.warn,
.song,
.ex,
.todo,
.q,
.ans {
  padding: 17px 20px;
  border-width: 0;
  border-left-width: 5px;
  border-radius: 16px;
  box-shadow: 0 5px 16px rgba(48, 43, 31, .055);
}

.story { border-left-color: #9b72d9; }
.know { border-left-color: #f1bd24; }
.method { border-left-color: #55a7e8; }
.think { border-left-color: #ea78a0; }
.life { border-left-color: #62b877; }
.smart { border-left-color: #f39a48; }
.solve { border: 2px dashed #bbc2c7; box-shadow: none; }
.warn { border-left-color: #ea6b6b; }
.song { border-left-color: #e3b51c; }
.ex { border-left-color: #85b94d; }
.todo { border-left-color: #40b89e; }
.q { border-left-color: #5daae4; }
.ans { border: 2px dashed #c5ccd1; box-shadow: none; }

.story .t,
.know .t,
.method .t,
.think .t,
.life .t,
.smart .t,
.solve .t,
.warn .t,
.song .t,
.ex .t,
.todo .t,
.ans .t {
  margin-bottom: 5px;
  font-size: 1.03em;
}

.blk {
  margin: 24px 0 8px;
  padding: 7px 18px;
  border-radius: 13px 13px 13px 4px;
  font-size: 16px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .08);
}

.figbox {
  border: 1.5px solid #e4e8eb;
  box-shadow: 0 5px 14px rgba(40, 45, 48, .05);
}

table {
  overflow: hidden;
  border-radius: 12px;
  font-size: 15px;
}

th,
td {
  border-width: 1.5px;
}

.answer-wrap {
  margin: 9px 0 14px;
}

.answer-toggle {
  color: #216a53;
  background: #e6f7ef;
}

.js .answer-wrap .ans[hidden] {
  display: none;
}

.answer-wrap .ans {
  margin-top: 9px;
}

.unit-checkpoint {
  display: flex;
  margin: 22px 0 34px;
  padding: 16px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 2px dashed #f2b966;
  border-radius: 18px;
  color: #745020;
  background: #fff8e7;
}

.unit-checkpoint strong {
  display: block;
  color: #563919;
}

.unit-checkpoint small {
  color: #806a4c;
}

.complete-button {
  min-width: max-content;
  color: #fff;
  background: #ef874d;
}

.complete-button.done {
  background: #3aa675;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 500;
  max-width: min(340px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 2px solid rgba(255, 255, 255, .65);
  border-radius: 16px;
  color: #fff;
  background: #2f8060;
  box-shadow: 0 12px 28px rgba(20, 52, 40, .23);
  font-weight: 800;
  transform: translateY(130%);
  transition: transform .22s ease;
}

.toast.show {
  transform: translateY(0);
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  width: 46px;
  height: 46px;
  padding: 0;
  color: #fff;
  background: #425b76;
  box-shadow: 0 8px 20px rgba(24, 43, 63, .2);
  opacity: 0;
  pointer-events: none;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.site-footer {
  width: min(100%, 980px);
  margin: 22px auto 0;
  padding: 16px;
  color: #798189;
  text-align: center;
  font-size: 13px;
}

@media (max-width: 980px) {
  body {
    padding-top: 140px;
  }

  html {
    scroll-padding-top: 174px;
  }

  .nav-main {
    flex-wrap: wrap;
    gap: 7px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    flex: 0 0 100%;
  }

  .nav-actions {
    margin-left: auto;
  }

  .unit-head {
    scroll-margin-top: 174px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 132px 9px 30px;
    font-size: 17px;
    line-height: 1.76;
  }

  body.large-type {
    font-size: 19px;
  }

  html {
    scroll-padding-top: 154px;
  }

  .topnav {
    padding: 8px 10px 0;
  }

  .topnav .logo {
    font-size: 15px;
  }

  .progress-label {
    display: none;
  }

  .nav-actions button {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .download-button {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .nav-links {
    gap: 5px;
  }

  .topnav .nav-links a {
    min-height: 31px;
    padding: 3px 9px;
    font-size: 12px;
  }

  .scroll-track {
    margin: 0 -10px;
  }

  .cover {
    padding: 30px 14px 25px;
    border-radius: 23px;
  }

  .cover .emoji {
    font-size: 43px !important;
    letter-spacing: -4px;
  }

  .cover .sub {
    font-size: 17px;
  }

  .passport {
    flex-direction: column;
    gap: 6px;
  }

  .passport-dot {
    width: 16px;
    height: 16px;
  }

  .tocrow {
    min-height: 68px;
  }

  .tocrow::after {
    display: none;
  }

  .unit-head {
    margin-top: 38px;
    padding: 14px !important;
    scroll-margin-top: 154px;
  }

  .unit-head .uname {
    font-size: 21px !important;
  }

  .story,
  .know,
  .method,
  .think,
  .life,
  .smart,
  .solve,
  .warn,
  .song,
  .ex,
  .todo,
  .q,
  .ans {
    padding: 14px 15px;
  }

  .unit-checkpoint {
    align-items: stretch;
    flex-direction: column;
  }

  .complete-button {
    width: 100%;
  }

  .back-to-top {
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

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

  html {
    scroll-padding-top: 0;
  }

  body,
  body.large-type {
    max-width: none;
    margin: 0;
    padding: 0;
    color: #222;
    background: #fff;
    font-size: 10.2pt;
    line-height: 1.55;
  }

  .topnav,
  .skip-link,
  .back-to-top,
  .toast,
  .site-footer,
  .unit-checkpoint,
  .answer-toggle {
    display: none !important;
  }

  .book-shell {
    width: 100%;
    max-width: none;
  }

  .cover {
    min-height: 0;
    padding: 18mm 12mm 12mm;
    border: 2pt solid #f1b3a8;
    border-radius: 8mm;
    background: #fff9e6;
    box-shadow: none;
    break-inside: avoid;
  }

  .cover .emoji {
    font-size: 40pt;
  }

  h1 {
    font-size: 25pt;
  }

  .cover .sub {
    font-size: 13pt;
  }

  .cover .meta {
    font-size: 9pt;
  }

  .badge {
    padding: 3pt 8pt;
    font-size: 8.2pt;
  }

  .passport {
    padding: 5pt 9pt;
    font-size: 8.5pt;
  }

  .passport-dot {
    width: 12pt;
    height: 12pt;
  }

  .method[style] {
    margin-top: 8mm !important;
  }

  .tocrow {
    display: inline-flex;
    width: calc(50% - 5pt);
    min-height: 0;
    margin: 2pt 1pt;
    padding: 5pt 9pt;
    box-shadow: none;
    vertical-align: top;
  }

  .tocrow::after {
    display: none;
  }

  .tocrow .tno {
    width: 28pt;
    height: 28pt;
    font-size: 13pt;
  }

  .tocrow .tname {
    font-size: 10.5pt;
  }

  .tocrow .tdesc {
    font-size: 8pt;
  }

  .unit-head {
    margin: 0 0 6pt;
    padding: 9pt 13pt;
    border-radius: 12pt;
    box-shadow: none;
    break-before: page;
    page-break-before: always;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .unit-head .uno {
    width: 34pt;
    height: 34pt;
    font-size: 16pt;
    box-shadow: none;
  }

  .unit-head .uname {
    font-size: 16pt;
  }

  .unit-head .usub {
    font-size: 8.5pt;
  }

  .unit-head .uemoji {
    font-size: 22pt;
  }

  .story,
  .know,
  .method,
  .think,
  .life,
  .smart,
  .solve,
  .warn,
  .song,
  .ex,
  .todo,
  .q,
  .ans {
    margin: 5pt 0;
    padding: 7pt 10pt;
    border-radius: 8pt;
    box-shadow: none;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .answer-wrap {
    margin: 5pt 0;
  }

  .answer-wrap .ans,
  .js .answer-wrap .ans[hidden] {
    display: block !important;
  }

  .answer-wrap::after {
    display: block;
    height: 42mm;
    margin-top: 7mm;
    padding: 5mm 6mm;
    border: 1pt dashed #b8c2ca;
    border-radius: 4mm;
    color: #62717d;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 10mm,
      #dfe5e9 10.2mm,
      transparent 10.4mm
    );
    font-size: 10pt;
    font-weight: 700;
    content: "✎ 我的草稿区：画一画、列一列、检查一下";
    break-inside: avoid-page;
  }

  main:has(#u6[data-print-visible="true"]) .answer-wrap::after,
  main:has(#u7[data-print-visible="true"]) .answer-wrap::after {
    display: none;
  }

  .blk {
    margin: 9pt 0 4pt;
    padding: 4pt 10pt;
    border-radius: 10pt;
    font-size: 9.5pt;
    box-shadow: none;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .blk + *,
  div:has(> .blk) + * {
    break-before: avoid-page;
    page-break-before: avoid;
  }

  .figrow {
    margin: 6pt 0;
    gap: 7pt;
  }

  .figbox {
    padding: 6pt 8pt;
    box-shadow: none;
  }

  .figbox svg {
    max-height: 48mm;
  }

  table {
    margin: 6pt 0;
    font-size: 8.5pt;
  }

  th,
  td {
    padding: 5pt 7pt;
  }

  tr,
  .tocrow,
  .figbox {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .end {
    margin-top: 10pt;
    min-height: 235mm;
    padding: 24mm 14mm;
    border: 2pt solid #d9c9ed;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: none;
  }
}
