:root {
  color-scheme: light;
  --ink: #173b36;
  --body: #243c37;
  --muted: #52655f;
  --accent: #28665b;
  --line: #d7ded6;
  --paper: #fff;
  --wash: #f7f7f2;
  --soft: #eef3ec;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--wash); color: var(--body); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.65; }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; }
button { min-height: 44px; padding: .62rem .95rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
button:hover { background: #20574d; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--paper); border-color: #b6c8bd; color: var(--accent); }
button.secondary:hover { background: var(--soft); border-color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.wrap { max-width: 1260px; margin: auto; padding: 0 30px; }
.skip-link { position: absolute; left: 20px; top: -80px; z-index: 2; padding: 12px; background: var(--paper); color: var(--ink); }
.skip-link:focus { top: 12px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 25px 0; border-bottom: 1px solid var(--line); font-size: .83rem; }
.page-header > a:last-child { text-decoration: none; }
.page-header > a:last-child:hover { text-decoration: underline; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-family: Georgia, "Times New Roman", serif; font-size: 1.17rem; letter-spacing: -.025em; }
.brand-portrait { width: 43px; height: 43px; border-radius: 50%; object-fit: cover; object-position: 50% 28%; border: 1px solid #cbd5c9; }
main { padding: 46px 0 28px; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: .7rem; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0 0 18px; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 4.7vw, 3.6rem); font-weight: 400; line-height: 1.12; letter-spacing: -.045em; }
h2 { margin: 0; color: var(--ink); font-size: 1.06rem; font-weight: 600; line-height: 1.35; }
.intro { max-width: 765px; margin: 0 0 15px; color: var(--muted); font-size: 1.04rem; line-height: 1.75; }
.privacy-note { margin: 0 0 32px; color: var(--muted); font-size: .8rem; }

.explorer { display: flex; flex-direction: column; gap: 23px; }
.panel { padding: 23px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 36px; width: 100%; font-size: .87rem; }
.controls > fieldset { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin: 0; }
.controls > fieldset legend { grid-column: 1 / -1; }
.controls form fieldset { margin: 0; }
fieldset { min-width: 0; margin: 0 0 26px; padding: 0; border: 0; }
legend { margin-bottom: 17px; padding: 0; color: var(--ink); font-size: .95rem; font-weight: 650; }
.parameter { margin-bottom: 22px; }
.parameter:last-child { margin-bottom: 0; }
.parameter label { display: block; margin-bottom: 8px; font-weight: 550; line-height: 1.5; }
output { float: right; min-width: 3.6ch; margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--soft); color: var(--accent); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }
input[type=range] { display: block; width: 100%; height: 28px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.coordinate-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 13px; }
.coordinate-fields label { color: var(--ink); font-weight: 550; }
input[type=number] { display: block; width: 100%; min-width: 0; min-height: 44px; margin-top: 5px; padding: 7px 9px; border: 1px solid #99afa2; border-radius: 6px; background: var(--paper); color: var(--body); }
#add-point { width: 100%; margin-top: 15px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.button-row button { flex: 1; font-size: .77rem; white-space: nowrap; }
.action-status { min-height: 1.65em; margin: 15px 0 0; color: var(--accent); font-size: .8rem; }
.action-status.error { color: #9d3545; }

.results { min-width: 0; width: 100%; }
.plot-panel { padding: 23px 23px 19px; }
.plot-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#observation-count { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
#plot-container { width: 100%; margin-top: 15px; overflow: hidden; }
#plot { display: block; width: 100%; height: auto; touch-action: manipulation; cursor: crosshair; user-select: none; }
.grid-line { stroke: #e7ece4; stroke-width: 1; }
.axis-line { stroke: #97aba0; stroke-width: 1; }
.axis-text { fill: var(--muted); font-family: system-ui, sans-serif; font-size: 12px; }
.axis-label { fill: var(--ink); font-family: system-ui, sans-serif; font-size: 13px; }
.density-band { fill: var(--accent); }
.interval-boundary { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 5 5; opacity: .55; }
.sample-function { fill: none; stroke-width: 1.3; stroke-linejoin: round; opacity: .7; }
.sample-color-0 { stroke: #626d9b; }
.sample-color-1 { stroke: #9a597e; }
.sample-color-2 { stroke: #4f807d; }
.sample-color-3 { stroke: #787363; }
.posterior-mean { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.observation { fill: var(--ink); stroke: var(--paper); stroke-width: 1.7; cursor: pointer; }
.point-target { fill: transparent; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 9px 18px; margin: 5px 0 0; padding: 0; color: var(--muted); font-size: .73rem; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; }
.key { display: inline-block; width: 18px; height: 10px; flex-shrink: 0; }
.mean-key { height: 0; border-top: 3px solid var(--accent); }
.sample-key { height: 0; border-top: 1.5px solid #626d9b; }
.plot-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .8rem; }
.plot-toolbar button { font-size: .78rem; }
.sample-toggle { display: flex; align-items: center; gap: 7px; min-height: 44px; cursor: pointer; }
.sample-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.sample-count { width: 145px; }
.density-key { height: 14px; background: linear-gradient(to bottom, #fff, #a3c5bb, #fff); }
.band-key { height: 0; border-top: 1px dashed var(--accent); opacity: .65; }
.point-key { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.interval-note { max-width: 750px; margin-top: 16px; font-size: .75rem; }
.model-summary { min-height: 2.8em; margin: 17px 0; padding: 0 3px; color: var(--muted); font-size: .82rem; line-height: 1.75; }

.data-panel { margin: 12px 0; padding: 17px 21px; }
summary { min-height: 26px; color: var(--ink); font-size: .87rem; font-weight: 550; cursor: pointer; }
summary::marker { color: var(--accent); }
details[open] summary { margin-bottom: 15px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .79rem; font-variant-numeric: tabular-nums; }
caption { padding: 0 0 11px; color: var(--muted); font-size: .74rem; text-align: left; }
th, td { padding: 10px 7px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink); font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
td button { min-height: 36px; padding: 4px 10px; font-size: .74rem; }
.explanation { max-width: 855px; margin: 32px 0 18px; color: var(--muted); font-size: .88rem; }
.formula { color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; overflow-wrap: anywhere; }
.notice { padding: 20px; border: 1px solid var(--line); background: var(--paper); }
footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 27px 0 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
footer a { color: var(--ink); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 850px) {
  .explorer { gap: 16px; }
  .controls { gap: 24px; grid-template-columns: 1fr 1fr; }
  .controls > fieldset { display: block; }
  .panel { padding: 19px; }
  .wrap { padding: 0 22px; }
  .plot-panel { padding: 19px 12px; }
  .controls { font-size: .83rem; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 17px; }
  main { padding-top: 32px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 19px; }
  .controls > fieldset { grid-row: span 3; margin: 0; }
  .controls form fieldset { margin: 0; }
  .button-row { align-self: start; }
  .controls > .hint, .action-status { grid-column: 2; margin: 0; }
  .coordinate-fields { margin-top: 8px; }
  .results { margin-top: 5px; }
  .privacy-note { margin-bottom: 25px; }
  .plot-panel { padding: 20px 10px; }
  .plot-heading, #plot-help, .legend, .interval-note { margin-left: 8px; margin-right: 8px; }
  .plot-toolbar { margin-left: 8px; margin-right: 8px; }
}
@media (max-width: 430px) {
  .controls { display: block; }
  .controls > fieldset { margin-bottom: 26px; }
  .controls form fieldset { margin-bottom: 19px; }
  .controls > .hint, .action-status { margin-top: 13px; }
  .page-header { gap: 15px; padding: 21px 0; font-size: .78rem; }
  .brand { gap: 9px; font-size: 1.08rem; }
  .brand-portrait { width: 38px; height: 38px; }
  .legend { gap: 9px 12px; }
  th, td { padding: 10px 5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
