:root {
  --bg: #F7F3EA;
  --card: #FFFDF8;
  --text: #2F2A25;
  --secondary: #6F665C;
  --border: #E3D8C8;
  --accent: #C86B3C;
  --label: #8A7A6A;
  --soft-accent: #F4E1D5;
  --shadow: 0 18px 42px rgba(79, 62, 43, 0.11);
  --small-shadow: 0 8px 22px rgba(79, 62, 43, 0.08);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--text);
  background: var(--bg);
  font-family: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, .66), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(247, 243, 234, 0) 42%),
    var(--bg);
}

button,
a {
  color: inherit;
  font: inherit;
}

.page {
  width: min(1000px, calc(100vw - 28px));
  min-height: 600px;
  margin: 12px auto;
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 253, 248, .78);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.kicker,
.module-tag,
.zone-label {
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0;
}

.subtitle {
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: clamp(14px, 1.6vw, 16px);
  line-height: 1.5;
}

.module-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 12px;
}

.module-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--secondary);
  text-decoration: none;
  box-shadow: 0 6px 15px rgba(79, 62, 43, .05);
  transition: background .22s var(--ease), border-color .22s var(--ease), transform .22s var(--ease);
}

.module-link:hover,
.module-link.active {
  border-color: #D5B99F;
  background: #FCF4E8;
  color: var(--text);
  transform: translateY(-1px);
}

.module-link span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #B8A993;
  border-radius: 999px;
  background: #F3E9DC;
  color: #5D4D3B;
  font-size: 13px;
  font-weight: 800;
}

.module-link.active span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--card);
}

.demo-card,
.summary,
.concept-copy {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--small-shadow);
}

.concept-copy {
  overflow: visible;
  margin-bottom: 12px;
  padding: clamp(13px, 1.8vw, 18px);
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}

.concept-copy p {
  max-width: 900px;
  margin-top: 5px;
  font-size: clamp(14px, 1.45vw, 15.5px);
}

.concept-copy .module-tag + p {
  margin-top: 8px;
}

.js .concept-copy {
  opacity: 0;
  transform: translateY(18px);
  animation: copySlideIn .58s var(--ease) forwards;
}

.demo-card {
  padding: clamp(14px, 2vw, 18px);
}

.demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

h2 {
  margin-top: 4px;
  font-size: clamp(21px, 2.3vw, 28px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: 0;
}

.play {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #FFF9EF;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 13px;
  font-weight: 700;
  transition: transform .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}

.play:hover {
  border-color: #D0B89E;
  background: #FCF0E2;
  transform: translateY(-1px);
}

.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.visual,
.explain {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #FFFDF8, #FBF5EC);
}

.visual {
  position: relative;
  min-height: 258px;
  padding: 18px;
  overflow: hidden;
}

.explain {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 18px;
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.explain strong {
  color: var(--text);
  font-family: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}

.explain em {
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}

.input-sentence {
  color: var(--text);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.2;
}

.analysis-zone {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  min-height: 108px;
  padding: 14px;
  border: 1px dashed #D7C8B6;
  border-radius: 8px;
  background: rgba(247, 243, 234, .78);
}

.zone-label {
  color: var(--label);
  font-size: 10px;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #D6C4AE;
  border-radius: 7px;
  background: #FFF9F0;
  box-shadow: 0 6px 12px rgba(80, 61, 40, .06);
}

.js .is-animating .token-chip {
  opacity: 0;
  transform: translateY(-30px) scale(.96);
  animation: tokenDrop .62s var(--ease) forwards;
}

.js .is-animating .token-chip:nth-child(2) { animation-delay: .12s; }
.js .is-animating .token-chip:nth-child(3) { animation-delay: .24s; }
.js .is-animating .token-chip:nth-child(4) { animation-delay: .36s; }

.context-visual {
  display: grid;
  align-content: center;
  padding-bottom: 92px;
}

.context-sentence {
  position: relative;
  z-index: 2;
  max-width: 650px;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.72;
}

.context-sentence span {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 6px;
}

.clue {
  color: #725D49;
  background: rgba(244, 225, 213, .42);
}

.target-word {
  color: #7E3F27;
  background: var(--soft-accent);
  box-shadow: inset 0 -3px 0 rgba(200, 107, 60, .35);
}

.line-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.line-layer path {
  fill: none;
  stroke: #B89572;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 240;
  stroke-dashoffset: 0;
}

.js .is-animating .line-layer path {
  stroke-dashoffset: 240;
  animation: drawLine .95s var(--ease) forwards;
}

.js .is-animating .line-layer path:nth-child(2) { animation-delay: .14s; }
.js .is-animating .line-layer path:nth-child(3) { animation-delay: .28s; }
.js .is-animating .line-layer path:nth-child(4) { animation-delay: .42s; }

.meaning-card {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 18px;
  width: min(440px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid #D8C6B0;
  border-radius: 8px;
  background: #FFF9EF;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(82, 64, 43, .09);
}

.meaning-card strong {
  font-size: 20px;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 13px;
}

.choice-row span {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 253, 248, .76);
}

.js .is-animating .meaning-card {
  opacity: 0;
  transform: translate(-50%, 10px);
  animation: fadeUp .56s var(--ease) .72s forwards;
}

.source-line {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 248, .8);
  font-size: clamp(20px, 2.5vw, 28px);
}

.prob-list {
  display: grid;
  gap: 10px;
}

.prob-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(140px, .72fr) 46px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 248, .82);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 15px;
}

.prob-row.best {
  border-color: #D5A482;
  background: #FFF3E8;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #EFE6D8;
}

.bar {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
}

.prob-row:not(.best) .bar {
  background: #BDA98F;
}

.js .is-animating .bar {
  transform: scaleX(0);
  animation: fillBar .9s var(--ease) forwards;
}

.js .is-animating .prob-row:nth-child(2) .bar { animation-delay: .12s; }
.js .is-animating .prob-row:nth-child(3) .bar { animation-delay: .24s; }

.percent {
  color: var(--secondary);
  font-weight: 800;
  text-align: right;
}

.prob-warning {
  margin-top: 14px;
  color: #7A5B45;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 14px;
}

.pattern-stage {
  position: relative;
  min-height: 188px;
}

.example-stack {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(270px, 48%);
  gap: 8px;
}

.example-card {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #FFF9EF;
  box-shadow: 0 6px 16px rgba(80, 61, 40, .06);
  font-size: 14px;
}

.js .is-animating .example-card {
  opacity: 0;
  transform: translateX(-22px);
  animation: slideIn .55s var(--ease) forwards;
}

.js .is-animating .example-card:nth-child(2) { animation-delay: .12s; }
.js .is-animating .example-card:nth-child(3) { animation-delay: .24s; }
.js .is-animating .example-card:nth-child(4) { animation-delay: .36s; }

.learned-box {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 0;
  width: min(280px, 47%);
  min-height: 136px;
  padding: 14px;
  border: 1px dashed #D3BEA7;
  border-radius: 8px;
  background: rgba(247, 243, 234, .78);
}

.pattern-nodes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.pattern-nodes span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid #D8C6B0;
  border-radius: 7px;
  background: #FFFDF8;
  color: #7A5944;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-weight: 800;
}

.js .is-animating .pattern-nodes span {
  opacity: 0;
  transform: scale(.92);
  animation: popIn .45s var(--ease) .72s forwards;
}

.js .is-animating .pattern-nodes span:nth-child(2) { animation-delay: .86s; }
.js .is-animating .pattern-nodes span:nth-child(3) { animation-delay: 1s; }

.pattern-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 253, 248, .82);
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 14px;
  text-align: center;
}

.flow-arrow {
  color: var(--accent);
  font-weight: 800;
}

.summary {
  margin-top: 14px;
  padding: 12px 16px;
  text-align: center;
}

.summary strong {
  display: block;
  font-size: clamp(16px, 1.8vw, 21px);
  font-weight: 600;
  line-height: 1.35;
}

.summary p {
  max-width: 800px;
  margin: 6px auto 0;
  color: var(--secondary);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

@keyframes tokenDrop {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

@keyframes fadeUp {
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes fillBar {
  to { transform: scaleX(1); }
}

@keyframes slideIn {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
  to { opacity: 1; transform: scale(1); }
}

@keyframes copySlideIn {
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 18px, 1000px);
    min-height: 0;
    margin: 9px auto;
  }

  .module-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .visual {
    min-height: 300px;
  }
}

@media (max-width: 520px) {
  .page {
    border-radius: 0;
  }

  .demo-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .play {
    width: 100%;
  }

  .module-link {
    font-size: 14px;
  }

  .context-visual {
    padding-bottom: 138px;
  }

  .choice-row,
  .prob-row,
  .pattern-flow {
    grid-template-columns: 1fr;
  }

  .percent {
    text-align: left;
  }

  .example-stack,
  .learned-box {
    position: static;
    width: 100%;
  }

  .learned-box {
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
