:root {
  color-scheme: light;
  --ink: #172133;
  --muted: #4c5b70;
  --line: #dbe2eb;
  --surface: #fff;
  --background: #f3f6fa;
  --accent: #F28C28;
  --accent-ink: #783600;
  --accent-soft: #fff1e2;
  font: 16px/1.5 system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 2.5vw, 1.85rem); line-height: 1.2; letter-spacing: -.03em; }
h2 { font-size: 1.1rem; letter-spacing: -.016em; }
h3 { font-size: .95rem; }
p + p { margin-top: .5rem; }
a { color: #854008; overflow-wrap: anywhere; }
button, select, input { font: inherit; }
button, select { min-height: 38px; border: 1px solid #cbd5e2; border-radius: 8px; background: white; color: var(--ink); padding: .35rem .75rem; }
button { cursor: pointer; font-size: .875rem; font-weight: 650; }
button:hover, .suggestion[aria-selected="true"] { background: var(--accent-soft); border-color: #bc6324; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #a14b05; outline-offset: 2px; }
input[type="checkbox"], input[type="range"] { accent-color: #a54a06; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem clamp(1rem, 3vw, 2.5rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: .75rem; align-items: center; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px; background: var(--accent); color: #442100; font-size: 1.6rem; }
.brand-name { color: var(--accent-ink); font-weight: 750; font-size: .8rem; }
.toolbar, .language-control, .dataset-strip, main, footer { margin-inline: auto; width: min(96%, 1720px); }
.toolbar { display: flex; gap: .85rem; align-items: end; margin-top: 1rem; }
.toolbar label { display: block; font-size: .875rem; font-weight: 700; margin-bottom: .25rem; }
.dataset-control { flex: 0 0 155px; }
select { width: 100%; height: 44px; }
.search { position: relative; flex: 1; max-width: 700px; }
.searchbox { display: flex; align-items: center; gap: .5rem; background: white; border: 1px solid #cbd5e2; border-radius: 8px; padding-inline: .7rem; }
.searchbox > span { font-size: 1.4rem; }
.search input { border: 0; background: transparent; height: 42px; width: 100%; min-width: 0; }
#suggestions { position: absolute; inset: calc(100% + 5px) 0 auto; z-index: 5; max-height: min(50vh, 420px); overflow: auto; background: white; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 24px #18233c25; }
.suggestion { display: block; padding: .55rem .8rem; cursor: pointer; overflow-wrap: anywhere; }
.dataset-strip { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding-block: .8rem; }
.badge { border: 1px solid #d1dbe7; border-radius: 8px; padding: .22rem .55rem; background: #fff; font-size: .81rem; font-weight: 650; overflow-wrap: anywhere; }
.badge.good { background: #e0f4e9; color: #174d33; border-color: #a7d9bc; }
.badge.caution { background: #fff1c9; color: #634502; border-color: #dfc478; }
main { display: grid; grid-template-columns: minmax(210px, .84fr) minmax(0, 2.38fr) minmax(245px, 1fr); align-items: start; gap: .85rem; }
.left { display: grid; gap: .85rem; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 1rem; min-width: 0; }
.panel h2 { margin-bottom: .55rem; }
.muted { color: var(--muted); font-size: .875rem; }
.section-heading, .graph-heading { display: flex; align-items: start; justify-content: space-between; gap: .6rem; }
.graph-heading h2 { margin: 0; overflow-wrap: anywhere; }
.graph-heading button { flex-shrink: 0; }
.intro { padding: 1.15rem; border-radius: 10px; background: var(--accent-soft); border: 1px solid #ebc8a7; }
.intro h2 { font-size: clamp(1.15rem, 2vw, 1.6rem); line-height: 1.25; }
.intro button { margin-top: .7rem; }
.primary { background: var(--accent); border-color: #b96313; color: #27180d; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(107px, 1fr)); gap: .55rem; margin-block: .9rem; }
.stat { background: #f4f7fb; border: 1px solid #e0e7ef; padding: .55rem .65rem; border-radius: 8px; }
.stat strong { font-size: 1.35rem; display: block; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .8rem; }
.chain, .rankings { margin-top: .9rem; }
.chain-list { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .4rem; max-height: 14rem; overflow: auto; }
.chain-list button { min-height: 30px; padding: .2rem .4rem; font-size: .8rem; overflow-wrap: anywhere; text-align: left; }
.rankings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.rankings > section { background: #f8fafc; border: 1px solid var(--line); padding: .65rem; border-radius: 8px; }
.rankings ol, .node-list { margin: .4rem 0 0; padding-left: 1.35rem; }
.node-list li { margin-bottom: .25rem; }
.node-link { border: none; background: transparent; min-height: 28px; padding: .15rem .3rem; text-align: left; overflow-wrap: anywhere; }
.graph-controls, .legend, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.graph-controls { padding-block: .65rem; }
.graph-controls label, .toggle { display: flex; gap: .35rem; align-items: center; font-size: .875rem; }
.graph-controls input[type=range] { width: 76px; margin: 0; }
output { font-variant-numeric: tabular-nums; font-weight: 750; }
.graph-stage { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: radial-gradient(#cfd9e5 1px, #f7f9fc 1px) 0 0 / 17px 17px; }
#graph { height: clamp(360px, 60vh, 780px); touch-action: none; }
.zoom-controls { display: flex; gap: .25rem; position: absolute; bottom: .5rem; right: .5rem; }
.zoom-controls button { box-shadow: 0 1px 4px #17213320; }
#tooltip { position: absolute; pointer-events: none; background: #182439; color: white; padding: .4rem .6rem; border-radius: 6px; font-size: .8rem; max-width: min(260px, 80%); overflow-wrap: anywhere; z-index: 1; }
.legend { margin-top: .65rem; font-size: .78rem; color: var(--muted); max-height: 6rem; overflow: auto; }
.legend span { display: inline-flex; align-items: center; gap: .28rem; }
.swatch { width: .75rem; height: .75rem; border: 1px solid #65728a; border-radius: 3px; flex: 0 0 .75rem; }
.notice, .warning { color: #664004; background: #fff1ce; border-radius: 7px; padding: .45rem .6rem; margin-block: .45rem; font-size: .85rem; }
#path-content ol { max-height: 54vh; overflow: auto; }
#simulation-panel p, #simulation-results section, .detail-section { margin-top: .65rem; }
.detail-title { overflow-wrap: anywhere; font-size: 1.2rem; margin-block: .35rem; }
.detail-code { color: var(--accent-ink); font-weight: 750; font-size: .85rem; overflow-wrap: anywhere; }
.detail-section ul { margin-top: .3rem; padding-left: 1.2rem; overflow-wrap: anywhere; }
.detail-meta { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); font-size: .85rem; overflow-wrap: anywhere; }
.detail-meta dt, .detail-meta dd { border-bottom: 1px solid var(--line); margin: 0; padding: .25rem; }
.detail-meta dt { color: var(--muted); font-weight: 650; }
footer { padding: 1.2rem 0; color: var(--muted); font-size: .8rem; }
dialog { width: min(740px, 94vw); max-height: 86vh; padding: 1.1rem; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
dialog::backdrop { background: #13203488; }
dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; padding: .6rem; background: var(--background); }
dialog details { margin-top: .65rem; }
dialog summary { cursor: pointer; font-weight: 650; }
.tabs, #close-details { display: none; }
@media (max-width: 960px) {
  .masthead { padding: .65rem .75rem; }
  .masthead button { font-size: .77rem; }
  .dataset-control { flex-basis: 118px; }
  .tabs { display: flex; justify-content: center; gap: .3rem; margin: 0 auto .65rem; width: 96%; }
  .tabs button { flex: 1; padding-inline: .2rem; }
  .tabs button[aria-pressed=true] { background: var(--accent-soft); border-color: #a95412; }
  main { display: block; }
  #workspace[data-tab=graph] .left, #workspace[data-tab=details] .left,
  #workspace[data-tab=path] #simulation-panel, #workspace[data-tab=simulation] #path-panel,
  #workspace:not([data-tab=graph]) .central, #workspace:not([data-tab=details]) #details-panel { display: none; }
  #details-panel { position: fixed; bottom: 0; inset-inline: 0; z-index: 4; max-height: 72dvh; overflow: auto; box-shadow: 0 -8px 30px #18233c28; border-radius: 16px 16px 0 0; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  #close-details { display: block; }
  #graph { height: max(350px, 52dvh); }
}
@media (max-width: 430px) {
  .panel { padding: .7rem; }
  .brand-mark { display: none; }
  .rankings { grid-template-columns: 1fr; }
}
#path-content li { content-visibility: auto; contain-intrinsic-block-size: auto 29px; }

.language-control { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; margin-top: .5rem; }
.language-control .toggle { font-weight: 600; }
.language-control p { margin: 0; font-size: .82rem; }
