:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f0f4f2;
  --text: #17211d;
  --muted: #5f6b66;
  --line: #d9e0dc;
  --accent: #166c5c;
  --accent-strong: #0d4f43;
  --danger: #9c2e35;
  --success: #176947;
  --focus: #0f6eff;
  --shadow: 0 18px 45px rgba(23, 33, 29, 0.11);
  --red: #ff3b30;
  --green: #22c55e;
  --blue: #2563eb;
  --radius: 8px;
  --content: 1080px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
}

body {
  margin: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

ruby {
  ruby-position: over;
}

rt {
  color: var(--muted);
  font-size: 0.5em;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

button rt,
.button rt,
.button-secondary rt,
.nav-links rt {
  font-size: 0.55em;
}

.button ruby,
.button-secondary ruby,
.button-ghost ruby {
  position: relative;
  top: -0.14em;
}

.button rt {
  color: currentColor;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100% - 32px, var(--content));
  margin: 0 auto;
  padding: 18px 0;
}

.brand-link,
.back-link {
  font-weight: 800;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--accent-strong);
  font-size: 0.94rem;
}

.nav-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  text-underline-offset: 0.2em;
}

.nav-ruby-word {
  display: inline-grid;
  grid-template-rows: auto auto;
  row-gap: 3px;
  justify-items: center;
  align-items: center;
  line-height: 1;
}

.nav-plain-word {
  display: inline-grid;
  grid-template-rows: auto auto;
  row-gap: 3px;
  justify-items: center;
  align-items: center;
  line-height: 1;
}

.nav-plain-word::before {
  content: "";
  height: 0.55em;
}

.nav-ruby-reading {
  color: var(--muted);
  font-size: 0.55em;
  font-weight: 700;
  line-height: 1;
}

.nav-ruby-base,
.nav-plain-base {
  display: block;
  line-height: 1;
  border-bottom: 1px solid color-mix(in srgb, currentColor 42%, transparent);
  padding-bottom: 2px;
  transition: border-color 160ms ease, color 160ms ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a:hover .nav-ruby-base,
.nav-links a:hover .nav-plain-base,
.nav-links a:focus-visible .nav-ruby-base,
.nav-links a:focus-visible .nav-plain-base {
  border-bottom-color: currentColor;
}

.page-main {
  flex: 1;
}

.section {
  width: min(100% - 32px, var(--content));
  margin: 0 auto;
  padding: 42px 0;
}

.section + .section {
  padding-top: 16px;
}

.section-narrow {
  width: min(100% - 32px, 760px);
}

.guide-page .page-header,
.guide-page .section-narrow,
.guide-page .page-footer {
  width: min(100% - 32px, 760px);
}

.hero {
  position: relative;
  min-height: calc(100svh - 68px);
  display: grid;
  align-items: center;
  overflow: clip;
  background:
    linear-gradient(110deg, #07130f 0%, #10241e 54%, #f7f8f5 54%, #f7f8f5 100%);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(to top, rgba(247, 248, 245, 0.98), rgba(247, 248, 245, 0));
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, var(--content));
  margin: 0 auto;
  padding: 48px 0 86px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 0.75fr);
  gap: 40px;
  align-items: center;
}

.hero-copy {
  max-width: 560px;
  color: #ffffff;
  animation: rise-in 520ms ease-out both;
}

.hero-kicker {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
}

.hero h1,
.page-title {
  margin: 0;
  font-size: clamp(2.35rem, 8vw, 5.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p {
  margin: 20px 0 0;
  max-width: 34rem;
  font-size: 1.08rem;
}

.hero-visual {
  display: grid;
  gap: 14px;
  justify-items: center;
  color: var(--text);
  animation: rise-in 620ms ease-out both;
}

.light-mixer {
  width: min(100%, 410px);
  aspect-ratio: 1;
  display: block;
  overflow: visible;
  filter: saturate(1.05) drop-shadow(0 24px 46px rgba(23, 33, 29, 0.14));
}

.light-mixer-backdrop {
  fill: rgba(255, 255, 255, 0.2);
}

.light-mixer-glow {
  opacity: 0.92;
}

.hero-actions,
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.button,
.button-secondary,
.button-ghost {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.button {
  background: var(--accent);
  color: #ffffff;
}

.button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.button-secondary {
  background: #ffffff;
  color: var(--text);
  border-color: var(--line);
}

.button-secondary:hover,
.button-ghost:hover {
  transform: translateY(-1px);
  border-color: #98aaa3;
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.section-heading {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 4vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.section-copy,
.muted {
  color: var(--muted);
}

.section-copy {
  max-width: 42rem;
  margin: 0;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}

.feature-row-light {
  border: 0;
  background: transparent;
  gap: 20px;
}

.feature-row-light .feature-item {
  border-top: 1px solid var(--line);
  background: transparent;
  padding: 20px 0 0;
}

.feature-item {
  background: var(--surface);
  padding: 24px;
}

.feature-item h2,
.feature-item h3 {
  margin: 0 0 8px;
  font-size: 1.18rem;
  line-height: 1.25;
}

.feature-item p {
  margin: 0;
  color: var(--muted);
}

.guide-section {
  display: grid;
  gap: 0;
  padding-top: 0;
}

.lesson-hero {
  padding-top: 50px;
  padding-bottom: 20px;
}

.lesson-hero .page-title {
  max-width: 760px;
  font-size: clamp(2.5rem, 6vw, 4.75rem);
  line-height: 1.04;
}

.lesson-hero .section-copy {
  max-width: 36rem;
  margin-top: 20px;
  font-size: 1.03rem;
  line-height: 1.95;
}

.guide-block {
  padding: 22px 0 24px;
  border-top: 1px solid var(--line);
}

.guide-block h2 {
  margin: 0 0 12px;
  font-size: clamp(1.35rem, 2vw, 1.6rem);
  line-height: 1.25;
}

.guide-block p {
  max-width: 43rem;
  margin: 0;
  line-height: 2;
}

.guide-block p + p {
  margin-top: 10px;
}

.simulator-intro {
  padding-top: 26px;
  padding-bottom: 12px;
}

.simulator-workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(340px, 1.02fr);
  gap: 20px 24px;
  align-items: start;
  padding-top: 14px;
}

.simulator-result-area,
.simulator-control-area,
.simulator-learning-area {
  display: grid;
  gap: 14px;
}

.simulator-result-area {
  position: sticky;
  top: 18px;
  grid-column: 1;
  grid-row: 1 / 4;
  align-content: start;
}

.simulator-control-area {
  grid-column: 2;
  grid-row: 1;
}

.simulator-learning-area {
  grid-column: 2;
  grid-row: 2;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

.panel-pad {
  padding: 22px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 1.16rem;
}

.control-panel {
  padding: 20px 22px;
}

.color-swatch {
  min-height: clamp(240px, 22vw, 320px);
  display: grid;
  place-items: end start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: #000000;
  box-shadow: 0 10px 32px rgba(23, 33, 29, 0.12);
  transition: background-color 180ms ease;
}

.swatch-label {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  color: #17211d;
}

.swatch-label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.swatch-label strong {
  font-size: 1.25rem;
  font-weight: 900;
}

.control-stack,
.stack {
  display: grid;
  gap: 12px;
}

.channel-control {
  --channel-color: var(--accent);
  display: grid;
  grid-template-columns: minmax(76px, 0.34fr) minmax(128px, 0.42fr) minmax(0, 1fr) auto auto;
  gap: 8px 10px;
  align-items: center;
  position: relative;
  padding: 16px 0 15px 18px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.channel-control:first-child {
  padding-top: 8px;
}

.channel-control:last-child {
  border-bottom: 0;
  padding-bottom: 8px;
}

.channel-control::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 999px;
  background: var(--channel-color);
}

.channel-control[data-channel="r"] {
  --channel-color: var(--red);
}

.channel-control[data-channel="g"] {
  --channel-color: var(--green);
}

.channel-control[data-channel="b"] {
  --channel-color: var(--blue);
}

.channel-control.is-disabled {
  --channel-color: #96a09b;
}

.channel-heading {
  display: grid;
  gap: 2px;
}

.channel-name {
  font-weight: 900;
}

.channel-state {
  color: var(--muted);
  font-size: 0.85rem;
}

.channel-values {
  display: flex;
  align-items: baseline;
  gap: 0;
}

.channel-value {
  display: inline-grid;
  gap: 1px;
  min-width: 0;
  padding: 0 12px 0 0;
}

.channel-value + .channel-value {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.channel-value small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.channel-value strong {
  font-size: 1.04rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.channel-slider {
  --level: 0%;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
}

.channel-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--channel-color) 0 var(--level), #dce3df var(--level) 100%);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.08);
}

.channel-slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border: 3px solid var(--channel-color);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(23, 33, 29, 0.18);
}

.channel-slider::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--channel-color) 0 var(--level), #dce3df var(--level) 100%);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.08);
}

.channel-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--channel-color);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(23, 33, 29, 0.18);
}

.step-button {
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 1.25rem;
  font-weight: 900;
}

.step-button:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.toggle-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.toggle-row input {
  appearance: none;
  position: relative;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #dce3df;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.toggle-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(23, 33, 29, 0.18);
  transition: transform 150ms ease;
}

.toggle-row input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle-row input:checked::before {
  transform: translateX(16px);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preset-button,
.example-button,
.choice-button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.preset-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px;
}

.preset-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preset-button:hover,
.example-button:hover,
.choice-button:hover {
  transform: translateY(-1px);
  border-color: #98aaa3;
}

.preset-button.is-active,
.choice-button.is-selected {
  border-color: var(--accent);
  background: #e7f4ef;
}

.example-button small,
.preset-button small {
  display: block;
  color: var(--muted);
}

.notice {
  min-height: 24px;
  color: var(--success);
  font-weight: 800;
}

.notice:empty {
  display: none;
}

.share-menu {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.share-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.share-option {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.share-option:hover {
  transform: translateY(-1px);
  border-color: #98aaa3;
  background: var(--surface-soft);
}

.quiz-shell {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 72px;
}

.quiz-page .page-header,
.quiz-page .quiz-shell,
.quiz-page .page-footer {
  width: min(100% - 32px, 760px);
}

.quiz-kicker {
  margin: 0 0 16px;
  color: var(--accent);
}

.quiz-progress {
  color: var(--muted);
  font-weight: 800;
}

.quiz-question {
  margin: 8px 0 18px;
  font-size: clamp(1.45rem, 5vw, 2.35rem);
  line-height: 1.18;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button {
  font-weight: 800;
}

.choice-button.is-correct {
  border-color: var(--success);
  background: #e6f4ed;
}

.choice-button.is-wrong {
  border-color: var(--danger);
  background: #fae9eb;
}

.result-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.result-box h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.result-box p {
  margin: 0;
}

.page-footer {
  width: min(100% - 32px, var(--content));
  margin: 0 auto;
  padding: 34px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 820px) {
  .hero {
    min-height: auto;
    background:
      linear-gradient(155deg, #07130f 0%, #17302a 70%, #f7f8f5 70%);
  }

  .hero-inner {
    grid-template-columns: 1fr;
    padding: 56px 0 72px;
  }

  .hero-visual {
    display: none;
  }

  .feature-row,
  .simulator-workbench {
    grid-template-columns: 1fr;
  }

  .simulator-workbench {
    gap: 16px;
    padding-top: 6px;
  }

  .simulator-result-area,
  .simulator-control-area,
  .simulator-learning-area {
    grid-column: auto;
    grid-row: auto;
  }

  .simulator-result-area {
    display: contents;
    position: static;
  }

  .simulator-learning-area {
    display: contents;
  }

  .simulator-learning-area > .panel {
    grid-column: auto;
    grid-row: auto;
  }

  .color-swatch {
    order: 1;
  }

  .simulator-control-area {
    order: 2;
  }

  .simulator-result-area > .panel {
    order: 3;
  }

  .simulator-learning-area > * {
    order: 3;
  }

  .channel-control {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .channel-heading,
  .channel-values,
  .channel-slider,
  .toggle-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .page-header {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding: 12px 0;
  }

  .brand-link,
  .back-link {
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
  }

  .brand-link {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-links {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 8px;
    font-size: 0.88rem;
  }

  .nav-links a {
    min-height: 32px;
  }

  .section {
    padding: 32px 0;
  }

  .simulator-intro {
    padding-top: 14px;
    padding-bottom: 4px;
  }

  .simulator-intro .section-heading {
    font-size: 1.75rem;
  }

  .simulator-intro .section-copy {
    line-height: 1.5;
  }

  .control-panel {
    padding: 16px;
  }

  .control-panel .panel-title {
    margin-bottom: 8px;
    font-size: 1.05rem;
  }

  .control-stack {
    gap: 0;
  }

  .lesson-hero {
    padding-top: 30px;
    padding-bottom: 18px;
  }

  .lesson-hero .page-title {
    font-size: clamp(2.2rem, 10.5vw, 2.75rem);
    line-height: 1.07;
  }

  .lesson-hero .section-copy {
    margin-top: 16px;
    font-size: 1rem;
    line-height: 1.9;
  }

  .guide-block {
    padding: 20px 0 22px;
  }

  .guide-block h2 {
    margin-bottom: 12px;
    font-size: 1.35rem;
  }

  .hero-actions,
  .actions {
    flex-direction: column;
  }

  .button,
  .button-secondary,
  .button-ghost {
    width: 100%;
  }

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

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

  .share-options {
    grid-template-columns: 1fr;
  }

  .color-swatch {
    min-height: clamp(124px, 34vw, 150px);
  }

  .swatch-label {
    min-height: 42px;
    padding: 7px 10px;
  }

  .swatch-label strong {
    font-size: 1.12rem;
  }

  .channel-control {
    grid-template-columns: minmax(56px, auto) minmax(88px, 0.45fr) minmax(0, 1fr) 40px 40px;
    gap: 6px 8px;
    padding: 10px 0 10px 14px;
  }

  .channel-control:first-child {
    padding-top: 4px;
  }

  .channel-control:last-child {
    padding-bottom: 4px;
  }

  .channel-control::before {
    top: 12px;
    bottom: 12px;
  }

  .channel-heading {
    grid-column: 1;
    grid-row: 1;
  }

  .channel-values {
    grid-column: 2;
    grid-row: 1;
    gap: 0;
  }

  .channel-value {
    padding-right: 8px;
  }

  .channel-value + .channel-value {
    padding-left: 8px;
  }

  .channel-value small {
    font-size: 0.66rem;
  }

  .channel-value strong {
    font-size: 0.95rem;
  }

  .channel-slider {
    grid-column: 1 / 4;
    grid-row: 2;
    height: 32px;
  }

  .step-button {
    width: 40px;
    height: 40px;
  }

  .toggle-row {
    grid-column: 3 / 6;
    grid-row: 1;
    justify-content: flex-end;
    gap: 8px;
    font-size: 0.82rem;
  }
}

@media (max-width: 360px) {
  .brand-link,
  .back-link {
    font-size: 0.88rem;
  }

  .nav-links {
    gap: 6px;
    font-size: 0.82rem;
  }
}

@media (max-width: 560px) and (max-height: 720px) {
  .simulator-page .page-header {
    padding: 8px 0;
  }

  .simulator-intro {
    padding-top: 8px;
    padding-bottom: 2px;
  }

  .simulator-intro .section-heading {
    font-size: 1.58rem;
  }

  .simulator-intro .section-copy {
    font-size: 0.94rem;
    line-height: 1.42;
  }

  .simulator-workbench {
    gap: 10px;
  }

  .color-swatch {
    min-height: 96px;
    padding: 14px;
  }

  .swatch-label {
    min-height: 36px;
    padding: 5px 9px;
  }

  .swatch-label span {
    font-size: 0.72rem;
  }

  .swatch-label strong {
    font-size: 1.04rem;
  }

  .control-panel {
    padding: 12px 16px;
  }

  .control-panel .panel-title {
    margin-bottom: 4px;
  }

  .channel-control {
    gap: 4px 8px;
    padding: 8px 0 8px 14px;
  }

  .channel-control::before {
    top: 10px;
    bottom: 10px;
  }

  .channel-slider {
    height: 28px;
  }
}
