:root {
  color-scheme: light;
  --paper: #EFE9E5;
  --ink: #1E1512;
  --muted: #675953;
  --green: #8C3324;
  --line: #E8DFDA;
  --night: #0c1b20;
  --night-soft: #182d32;
  font-family: Geist, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
}

button { font: inherit; }

.page-shell {
  width: min(100% - 40px, 880px);
  margin: 0 auto;
  padding: 50px 0 36px;
}

.page-header { margin-bottom: 28px; }
.rd-main.page-shell { width: 100%; min-width: 0; margin: 0; padding: 0; }
.rd-main .page-header { padding: clamp(24px, 4vw, 40px); background: #FFFFFF; border-radius: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.11em; }
h1, h2 { margin: 0; font-family: inherit; font-weight: 600; }
h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); letter-spacing: -0.035em; }
.intro { max-width: 600px; margin: 10px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.55; }

.control-panel {
  margin-bottom: 18px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
}
.control-heading h2 { font-size: 1.2rem; }
.control-heading p { margin: 7px 0 16px; color: var(--muted); font-size: 0.9rem; }
.entry-row { display: flex; align-items: end; gap: 12px; }
.entry-field { flex: 1; min-width: 0; }
.entry-field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.84rem; font-weight: 650; }
.entry-field input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #9ea698;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 1rem ui-monospace, Consolas, monospace;
}
.entry-field input[aria-invalid="true"] { border-color: #a53d37; }
.secondary-button, .example-button { min-height: 44px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf7; color: var(--ink); cursor: pointer; }
.secondary-button { min-width: 76px; padding: 8px 14px; }
.secondary-button:hover, .example-button:hover { border-color: var(--green); background: #f1f4ec; }
.secondary-button:focus-visible, .example-button:focus-visible, .sector-option:focus-within { outline: 3px solid #d29635; outline-offset: 2px; }
.input-feedback { min-height: 24px; margin: 8px 0 12px; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.input-feedback.is-error { color: #8c2f2a; }
.examples h3 { margin: 0 0 8px; font-size: 0.9rem; }
.example-list { display: flex; flex-wrap: wrap; gap: 8px; }
.example-button { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; padding: 7px 11px; text-align: left; }
.example-button code { color: var(--green); font-size: 0.83rem; }
.example-warning { color: #8c4b00; font-size: 0.76rem; font-weight: 700; }
.sector-picker { margin: 16px 0 0; padding: 12px 14px 10px; border: 1px solid var(--line); border-radius: 10px; }
.sector-picker[hidden] { display: none; }
.sector-picker legend { padding: 0 5px; font-size: 0.88rem; font-weight: 700; }
.sector-options { display: flex; flex-wrap: wrap; gap: 6px; }
.sector-option { display: inline-flex; min-height: 44px; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 7px; cursor: pointer; }
.sector-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--green); }
.sector-note { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }

.search-panel {
  margin-bottom: 18px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
}
.search-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.search-heading h2 { font-size: 1.2rem; }
.search-heading > p { max-width: 300px; margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.search-panel > label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.84rem; font-weight: 650; }
.search-panel > input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #9ea698;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 1rem ui-monospace, Consolas, monospace;
}
.search-panel > input:focus-visible { outline: 3px solid #d29635; outline-offset: 2px; }
.search-help, .search-status { margin: 7px 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.light-results { max-height: 310px; overflow: auto; margin: 8px 0 4px; padding: 0; border: 1px solid var(--line); border-radius: 9px; list-style: none; }
.light-results[hidden], .light-detail[hidden] { display: none; }
.light-result { min-height: 54px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.light-result:last-child { border-bottom: 0; }
.light-result[aria-selected="true"], .light-result:hover { background: #edf2e9; }
.light-result:focus-visible { outline: 3px solid #d29635; outline-offset: -3px; }
.light-result-name { display: block; font-weight: 700; }
.light-result-summary { display: block; margin-top: 2px; color: var(--muted); font-size: 0.79rem; line-height: 1.4; }
.light-result-kind { color: #7c4d18; font-weight: 700; }
.light-detail { margin-top: 13px; padding: 15px 0 1px; border-top: 1px solid var(--line); }
.light-detail h3 { margin: 0 0 5px; font-family: inherit; font-size: 1.22rem; }
.light-detail-code { margin: 0 0 4px; color: var(--green); font-family: ui-monospace, Consolas, monospace; font-size: 1rem; font-weight: 700; }
.light-detail-note { margin: 0 0 10px; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.light-facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 9px 0 0; font-size: 0.82rem; line-height: 1.45; }
.light-facts dt { color: var(--muted); font-weight: 650; }
.light-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.light-map-link { display: inline-flex; min-height: 44px; align-items: center; margin-top: 5px; color: var(--green); font-size: 0.86rem; font-weight: 700; }
.light-map-link:focus-visible { outline: 3px solid #d29635; outline-offset: 2px; }

.simulator-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf7;
  box-shadow: 0 14px 42px rgb(34 39 31 / 7%);
}

.pattern-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
}
.pattern-heading h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
.pattern-heading code { color: var(--ink); font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }

.play-button {
  min-width: 96px;
  min-height: 44px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--green);
  color: white;
  cursor: pointer;
}
.play-button:hover { background: #254632; }
.play-button:focus-visible { outline: 3px solid #d29635; outline-offset: 3px; }

.night-stage {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px);
  grid-template-rows: auto 1fr auto;
  align-items: center;
  min-height: 315px;
  padding: 26px 30px 20px;
  background: radial-gradient(ellipse at 55% 35%, #1b353b 0%, var(--night) 68%);
  color: #eef2e9;
}
.stage-copy { align-self: start; }
.stage-copy .eyebrow { color: #a9c5a8; }
.stage-hint { max-width: 320px; margin: 0; color: #c4d0c9; font-size: 0.9rem; line-height: 1.5; }
.slowed-status { margin: 10px 0 0; color: #ffe2a2; font-size: 0.86rem; font-weight: 700; }
.fast-safety { max-width: 345px; margin-top: 9px; color: #eef2e9; font-size: 0.82rem; line-height: 1.45; }
.fast-safety[hidden], .slowed-status[hidden] { display: none; }
.fast-safety label { display: flex; min-height: 44px; align-items: center; gap: 8px; cursor: pointer; }
.fast-safety input { flex: 0 0 auto; width: 18px; height: 18px; margin: 1px 0 0; accent-color: #c7dcae; }
.fast-safety input:focus-visible { outline: 3px solid #d29635; outline-offset: 3px; }
.lamp-frame { display: grid; place-items: center; min-height: 176px; }
.lamp-svg { display: block; width: 132px; height: 132px; overflow: visible; }
.lamp-halo { fill: var(--lamp-color, #fff7db); opacity: 0; transition: opacity 40ms ease-out; filter: blur(12px); }
.lamp-core { fill: var(--lamp-color, #fff7db); opacity: 0.08; transition: opacity 40ms ease-out; }
.lamp-svg[data-lit="true"] .lamp-halo { opacity: calc(var(--lamp-level, 1) * 0.6); }
.lamp-svg[data-lit="true"] .lamp-core { opacity: var(--lamp-level, 1); }
.strip-block { grid-column: 1 / -1; align-self: end; }
.strip-caption { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: #d1dbd3; font-size: 0.82rem; }
.pattern-strip { display: flex; width: 100%; height: 16px; overflow: hidden; border: 1px solid #607075; border-radius: 5px; background: #050d10; }
.pattern-run { min-width: 1px; height: 100%; }
.pattern-on { background: var(--run-color, #fff7db); box-shadow: 0 0 9px var(--run-color, #fff7db); }
.pattern-off { background: #071216; }
.navigation-note { grid-column: 1 / -1; justify-self: end; margin: 13px 0 0; color: #c4d0c9; font-size: 0.75rem; }

.explanation { min-height: 70px; margin: 0; padding: 21px 28px 24px; color: var(--ink); font-size: 1rem; line-height: 1.6; }
.page-footer { display: grid; gap: 16px; margin-top: 20px; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.page-footer p, .page-footer h2, .page-footer h3 { margin: 0; }
.about-section h2, .source-attribution h2 { margin-bottom: 5px; color: var(--ink); font-family: inherit; font-size: 1.16rem; font-weight: 600; }
.timing-caveat { padding: 10px 12px; border-left: 3px solid var(--green); background: #fffdf7; color: var(--ink); }
.notation-help { border: 1px solid var(--line); border-radius: 10px; background: #fffdf7; }
.notation-help summary { display: flex; min-height: 44px; align-items: center; padding: 8px 12px; color: var(--ink); font-weight: 700; cursor: pointer; }
.notation-help summary:focus-visible, .source-attribution a:focus-visible { outline: 3px solid #d29635; outline-offset: 2px; }
.notation-help p { padding: 0 12px 11px; }
.footer-navigation-note { color: var(--ink); }
.source-attribution ul { display: grid; gap: 2px; margin: 5px 0; padding: 0; list-style: none; }
.source-attribution li { display: grid; min-height: 44px; grid-template-columns: minmax(190px, 1fr) minmax(170px, auto) auto; align-items: center; gap: 3px 9px; }
.source-attribution li > [data-source-name] { color: var(--ink); font-weight: 650; }
.source-attribution a { display: inline-flex; min-height: 44px; align-items: center; color: var(--green); font-weight: 650; }
#source-attribution-status { min-height: 20px; margin: 0; font-size: 0.78rem; }

@media (max-width: 620px) {
  .page-shell { width: min(100% - 28px, 880px); padding-top: 30px; }
  .control-panel { padding: 18px 16px; }
  .search-panel { padding: 18px 16px; }
  .search-heading { align-items: start; flex-direction: column; gap: 7px; }
  .search-heading > p { max-width: none; }
  .source-attribution li { grid-template-columns: 1fr; gap: 0; }
  .entry-row { align-items: stretch; gap: 8px; }
  .entry-row .secondary-button { align-self: end; }
  .example-list { gap: 7px; }
  .example-button { flex: 1 1 calc(50% - 7px); justify-content: flex-start; }
  .pattern-heading { padding: 20px; }
  .play-button { min-width: 84px; }
  .night-stage { grid-template-columns: 1fr 116px; min-height: 290px; padding: 22px 20px 17px; }
  .lamp-svg { width: 108px; height: 108px; }
  .explanation { padding: 18px 20px 21px; }
}

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