:root {
  --ink: #17224b;
  --muted: #5f6883;
  --paper: #f7f5ee;
  --white: #fffef9;
  --navy: #12235d;
  --navy-deep: #0b1640;
  --lemon: #f0df57;
  --lemon-soft: #fff6b6;
  --cyan: #63d5dc;
  --cyan-soft: #dcf6f4;
  --line: #d8d9d3;
  --error: #a13b45;
  --shadow: 0 16px 40px rgba(21, 37, 86, .09);
  --radius: 22px;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-synthesis: none;
  line-height: 1.55;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 84% 8%, rgba(99, 213, 220, .16), transparent 22rem),
    var(--paper);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.site-header,
main,
.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  gap: 24px;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(18, 35, 93, .18);
  border-radius: 12px 12px 12px 3px;
  color: var(--navy);
  background: var(--lemon);
  font-family: Georgia, serif;
  font-size: 25px;
  line-height: 1;
  transform: rotate(-8deg);
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  font-weight: 800;
  letter-spacing: -.03em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: .73rem;
  letter-spacing: .08em;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--muted);
  font-size: .86rem;
}

.top-nav a {
  text-decoration: none;
}

.top-nav a:hover {
  color: var(--navy);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(380px, .97fr);
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  padding: 56px 0 72px;
}

.eyebrow,
.card-number {
  margin: 0 0 10px;
  color: #53629b;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
}

h1,
h2,
p,
figure {
  margin-top: 0;
}

h1,
h2 {
  color: var(--navy);
  letter-spacing: -.045em;
}

h1 {
  max-width: 680px;
  margin-bottom: 20px;
  font-size: clamp(2.8rem, 6vw, 5.25rem);
  line-height: .99;
}

h1 em {
  color: #a89918;
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-style: normal;
}

.intro-lead {
  max-width: 570px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
}

.intro-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 530px;
  color: var(--muted);
  font-size: .8rem;
}

.note-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: .46em;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(99, 213, 220, .17);
}

.intro-art {
  position: relative;
  min-width: 0;
  margin: 0;
}

.intro-art::before {
  position: absolute;
  inset: 8% 3% 14% 5%;
  z-index: -1;
  border-radius: 52% 42% 48% 40%;
  background: rgba(240, 223, 87, .34);
  content: "";
  transform: rotate(-4deg);
}

.intro-art img {
  display: block;
  width: 100%;
  border: 1px solid rgba(18, 35, 93, .14);
  border-radius: 31px 12px 31px 12px;
  box-shadow: var(--shadow);
  mix-blend-mode: multiply;
}

.intro-art figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: .72rem;
}

.state-panel {
  display: grid;
  grid-template-columns: minmax(200px, .75fr) minmax(0, 1.25fr);
  gap: 18px 30px;
  align-items: center;
  padding: 24px 28px;
  border: 1px solid rgba(18, 35, 93, .14);
  border-radius: var(--radius);
  background: var(--navy);
  color: #f9f8ef;
  box-shadow: var(--shadow);
}

.state-panel h2 {
  margin: 0 0 5px;
  color: #fffef9;
  font-size: 1.25rem;
  letter-spacing: -.025em;
}

.state-panel .eyebrow {
  margin-bottom: 6px;
  color: var(--cyan);
}

.panel-description {
  margin: 0;
  color: rgba(255, 254, 249, .7);
  font-size: .8rem;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid rgba(18, 35, 93, .24);
  border-radius: 999px;
  color: var(--navy);
  background: #fffef9;
  font-size: .8rem;
  font-weight: 750;
  transition: background-color .18s ease, transform .18s ease;
}

.button:hover {
  background: #eef1ff;
  transform: translateY(-1px);
}

.button-primary {
  border-color: var(--lemon);
  background: var(--lemon);
}

.button-cyan {
  border-color: var(--cyan);
  background: var(--cyan);
}

.button-quiet {
  color: #fffef9;
  border-color: rgba(255, 255, 255, .24);
  background: transparent;
}

.button-quiet:hover {
  color: var(--navy);
  background: #fffef9;
}

.storage-status {
  grid-column: 1 / -1;
  min-height: 1.3em;
  margin: 0;
  color: rgba(255, 254, 249, .72);
  font-size: .77rem;
}

.concepts {
  display: grid;
  gap: 24px;
  padding: 40px 0 0;
}

.concept-card {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 4vw, 40px);
  overflow: hidden;
  border: 1px solid rgba(18, 35, 93, .13);
  border-radius: var(--radius);
  background: rgba(255, 254, 249, .87);
  box-shadow: 0 10px 30px rgba(21, 37, 86, .045);
}

.concept-card::after {
  position: absolute;
  top: -86px;
  right: -54px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(99, 213, 220, .13);
  content: "";
  pointer-events: none;
}

.card-triangle::after,
.card-similarity::after {
  background: rgba(240, 223, 87, .18);
}

.card-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.card-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.05rem);
}

.card-number {
  margin-bottom: 6px;
  color: #5e6ca4;
}

.concept-tag {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(18, 35, 93, .15);
  border-radius: 999px;
  color: var(--navy);
  background: var(--cyan-soft);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .04em;
}

.card-triangle .concept-tag,
.card-similarity .concept-tag {
  background: var(--lemon-soft);
}

.card-intro {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 14px 0 24px;
  color: var(--muted);
  font-size: .93rem;
}

.formula {
  color: var(--navy);
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-style: italic;
  font-weight: 700;
}

.explorer-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr);
  gap: clamp(22px, 5vw, 58px);
  align-items: center;
}

.compact-explorer {
  grid-template-columns: minmax(0, 1.1fr) minmax(290px, .9fr);
}

.visual-panel {
  min-width: 0;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(229, 243, 244, .68), rgba(255, 254, 249, .25));
}

.math-svg {
  display: block;
  width: 100%;
  max-width: 620px;
  height: auto;
  margin-inline: auto;
  overflow: visible;
}

.math-svg .grid-line {
  stroke: #d6e2e5;
  stroke-width: 1;
}

.math-svg .axis {
  stroke: #73809b;
  stroke-width: 1.5;
}

.math-svg .axis-label,
.math-svg .svg-label {
  fill: #596682;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.math-svg .curve {
  fill: none;
  stroke: var(--navy);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.math-svg .curve-shadow {
  fill: none;
  stroke: rgba(99, 213, 220, .45);
  stroke-linecap: round;
  stroke-width: 8;
}

.math-svg .vertex-halo {
  fill: rgba(240, 223, 87, .38);
}

.math-svg .vertex {
  cursor: grab;
  fill: var(--lemon);
  stroke: var(--navy);
  stroke-width: 3;
}

.math-svg .vertex-hit-area {
  cursor: grab;
  fill: transparent;
  pointer-events: all;
  touch-action: none;
}

.math-svg .vertex:active {
  cursor: grabbing;
}

.math-svg .triangle-base {
  fill: rgba(99, 213, 220, .27);
  stroke: var(--navy);
  stroke-linejoin: round;
  stroke-width: 3;
}

.math-svg .triangle-scaled {
  fill: rgba(240, 223, 87, .38);
  stroke: var(--navy);
  stroke-linejoin: round;
  stroke-width: 3;
}

.math-svg .right-angle {
  fill: none;
  stroke: var(--navy);
  stroke-width: 2;
}

.math-svg .dimension {
  stroke: #41517f;
  stroke-dasharray: 4 4;
  stroke-width: 1.5;
}

.math-svg .circle-fill {
  fill: rgba(99, 213, 220, .23);
  stroke: var(--navy);
  stroke-width: 3;
}

.math-svg .radius-line {
  stroke: var(--navy);
  stroke-width: 2.5;
}

.drag-hint,
.diagram-caption {
  margin: 5px 8px 0;
  color: var(--muted);
  font-size: .76rem;
}

.drag-hint span {
  color: #b49f15;
}

.controls-panel {
  min-width: 0;
}

.control-row + .control-row {
  margin-top: 22px;
}

.control-label-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

label {
  color: var(--navy);
  font-size: .87rem;
  font-weight: 800;
}

output {
  color: var(--navy);
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-size: 1.12rem;
  font-weight: 700;
}

.paired-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--navy);
}

input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid #b9bfd0;
  border-radius: 9px;
  color: var(--navy);
  background: #fffef9;
  font-size: 16px;
}

input[aria-invalid="true"] {
  border-color: var(--error);
  background: #fff5f4;
}

.input-error {
  min-height: 1.25em;
  margin: 5px 0 0;
  color: var(--error);
  font-size: .75rem;
}

.result-strip,
.result-feature,
.result-box,
.formula-callout {
  border: 1px solid rgba(18, 35, 93, .14);
  background: rgba(238, 241, 255, .58);
}

.result-strip {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 12px;
  margin-top: 22px;
  padding: 16px;
  border-radius: 14px;
}

.result-strip span,
.result-box span,
.result-feature span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
}

.result-strip strong,
.result-box strong,
.result-feature strong {
  display: block;
  color: var(--navy);
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.result-strip p {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .75rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.result-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-box {
  min-width: 0;
  min-height: 70px;
  padding: 10px;
  border-radius: 11px;
}

.result-box strong {
  margin-top: 3px;
  font-size: 1.1rem;
}

.result-feature {
  margin-top: 22px;
  padding: 17px;
  border-color: rgba(240, 223, 87, .66);
  background: var(--lemon-soft);
  border-radius: 14px;
}

.result-feature strong {
  margin: 2px 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.result-feature small {
  color: var(--muted);
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-size: .86rem;
}

.formula-callout {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-family: Georgia, "Hiragino Mincho ProN", serif;
}

.formula-callout strong {
  color: var(--navy);
  font-size: 1.2rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 24px;
  padding: 72px 0 90px;
}

.guide-card {
  min-width: 0;
  padding: 28px;
  border-top: 3px solid var(--navy);
  background: rgba(255, 254, 249, .62);
}

.guide-card h2 {
  margin-bottom: 20px;
  font-size: 1.35rem;
}

.guide-card ol {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.guide-card li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-size: .9rem;
}

.guide-card li span {
  color: #a89918;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.guide-details dl {
  display: grid;
  gap: 13px;
  margin: 0;
}

.guide-details dl > div {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 13px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.guide-details dt {
  color: var(--navy);
  font-size: .8rem;
  font-weight: 800;
}

.guide-details dd {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .04em;
}

@media (max-width: 880px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 34px;
    padding-top: 35px;
  }

  .intro-copy {
    max-width: 700px;
  }

  .intro-art {
    max-width: 650px;
  }

  .state-panel {
    grid-template-columns: 1fr;
  }

  .state-actions {
    justify-content: flex-start;
  }

  .explorer-grid,
  .compact-explorer {
    grid-template-columns: 1fr;
  }

  .visual-panel {
    max-width: 680px;
  }

  .controls-panel {
    max-width: 680px;
  }

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

@media (max-width: 620px) {
  .site-header,
  main,
  .site-footer {
    width: min(100% - 28px, 1180px);
  }

  .site-header {
    min-height: 74px;
  }

  .top-nav {
    display: none;
  }

  .intro {
    padding-bottom: 42px;
  }

  .intro-art::before {
    transform: none;
  }

  h1 {
    font-size: clamp(2.55rem, 14vw, 4.1rem);
  }

  .state-panel {
    padding: 20px;
  }

  .state-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button {
    width: 100%;
    padding-inline: 8px;
  }

  .concept-card {
    padding: 20px 16px;
    border-radius: 17px;
  }

  .card-heading {
    display: block;
  }

  .concept-tag {
    display: inline-block;
    margin-top: 12px;
  }

  .card-intro {
    font-size: .88rem;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-grid {
    padding: 50px 0 62px;
  }

  .guide-card {
    padding: 22px 18px;
  }

  .guide-details dl > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .site-footer {
    display: grid;
    gap: 5px;
  }
}

@media (max-width: 360px) {
  .site-header,
  main,
  .site-footer {
    width: calc(100% - 20px);
  }

  .paired-input {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 7px;
  }

  .state-actions {
    grid-template-columns: 1fr;
  }

  .result-strip {
    grid-template-columns: 1fr;
  }
}

@media print {
  :root {
    background: #fff;
  }

  body {
    background: #fff;
  }

  .site-header,
  .state-panel,
  .top-nav,
  .intro-art figcaption,
  .drag-hint,
  .no-print {
    display: none !important;
  }

  .intro {
    display: block;
    padding: 20px 0 30px;
  }

  .intro h1 {
    font-size: 2.6rem;
  }

  .intro-lead,
  .intro-note {
    max-width: none;
  }

  .concepts {
    padding-top: 0;
  }

  .concept-card,
  .guide-card {
    break-inside: avoid;
    box-shadow: none;
  }

  .concept-card {
    border-color: #bbb;
  }

  .guide-grid {
    padding: 30px 0;
  }

  .site-footer {
    padding-bottom: 0;
  }
}

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

.article-library {
  margin: 3.5rem 0 1rem;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 1px solid rgba(18, 35, 93, 0.14);
  border-radius: 1.5rem;
  background: linear-gradient(135deg, #f5f8ff, #fffdf1 72%);
}
.article-library-heading { max-width: 46rem; margin-bottom: 1.5rem; }
.article-library-heading h2 { margin: 0.35rem 0; color: #12235d; }
.article-library-heading > p:last-child, .article-library-card > p:last-child { color: #4b5568; line-height: 1.75; }
.article-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.article-library-card { min-width: 0; padding: 1.15rem; border: 1px solid rgba(18, 35, 93, 0.12); border-radius: 1rem; background: #fff; }
.article-library-card h3 { margin: 0.4rem 0; line-height: 1.5; }
.article-library-card h3 a, .article-library-more a { color: #12235d; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
.article-library-kind { margin: 0; color: #52627c; font-size: 0.84rem; font-weight: 700; letter-spacing: 0.04em; }
.article-library-card > p:last-child { margin-bottom: 0; font-size: 0.95rem; }
.article-library-more { margin: 1.25rem 0 0; text-align: right; font-weight: 700; }
@media (max-width: 760px) { .article-library-grid { grid-template-columns: 1fr; } }


/* Stage A: compact first view */
.stage-a-hero h1 { word-break: auto-phrase; }
.stage-a-hero .stage-a-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 1rem 0 0.85rem; padding: 0; list-style: none; counter-reset: stage-a-step; }
.stage-a-hero .stage-a-steps li { display: flex; min-width: 0; gap: 0.5rem; align-items: baseline; counter-increment: stage-a-step; font-size: 0.9rem; line-height: 1.45; }
.stage-a-hero .stage-a-steps li::before { content: counter(stage-a-step, decimal-leading-zero); flex: none; font-size: 0.74rem; font-weight: 800; }
.stage-a-cta { display: inline-flex; min-height: 44px; max-width: 100%; align-items: center; justify-content: center; padding: 0.65rem 1.15rem; border: 1px solid #26383d; border-radius: 999px; background: #fff; color: #18272d; font-weight: 750; line-height: 1.25; text-align: center; text-decoration: none; white-space: nowrap; }
.intro.stage-a-hero { min-height: 0; padding-block: clamp(1.75rem, 4vw, 3.25rem); }
.intro.stage-a-hero h1 { max-width: none; margin-bottom: 0.65rem; font-size: clamp(2rem, 4.2vw, 3.45rem); line-height: 1.12; }
.intro.stage-a-hero .intro-lead { margin-bottom: 0; line-height: 1.55; }
.intro.stage-a-hero .intro-art { max-width: 370px; justify-self: end; }
.intro.stage-a-hero .intro-art img { width: 100%; height: auto; }
@media (max-width: 640px) {
  .intro.stage-a-hero { grid-template-columns: minmax(0, 1fr); gap: 0; padding-block: 22px; }
  .intro.stage-a-hero .intro-art { display: none; }
  .stage-a-hero .stage-a-steps { grid-template-columns: minmax(0, 1fr); gap: 4px; margin-block: 0.75rem; }
  .stage-a-hero .stage-a-steps li { font-size: 0.86rem; }
  .stage-a-hero .stage-a-cta { min-width: 12rem; }
  #tool.state-panel { gap: 0.6rem; padding-block: 0.9rem; }
  #tool > div:first-child .eyebrow { display: none; }
  #tool > div:first-child h2 { margin-block: 0.15rem 0.25rem; font-size: 1.25rem; line-height: 1.25; }
  #tool .panel-description { margin: 0; font-size: 0.88rem; line-height: 1.45; }
}
