:root {
  color-scheme: light;
  --ink: #172235;
  --muted: #526077;
  --accent: #3543a7;
  --line: #dce2ed;
  --paper: #fff;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: #f7f8fc;
  line-height: 1.75;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { color: #202875; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #526ae3; outline-offset: 3px; }
h1, h2, h3 { line-height: 1.35; }
h1 { margin: 0; font-size: clamp(2rem, 4.7vw, 3.15rem); letter-spacing: -.04em; }
h2 { font-size: 1.35rem; margin: 0 0 .8rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; top: .5rem; left: .5rem; z-index: 2; padding: .5rem 1rem; background: white; }
.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.masthead-inner { margin: auto; max-width: 1480px; min-height: 72px; padding: .7rem clamp(1rem, 3vw, 2.5rem); display: grid; grid-template-columns: 194px minmax(0, 430px) 1fr; gap: 1.15rem; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: .7rem; justify-self: start; color: var(--ink); font-size: 1.35rem; font-weight: 750; letter-spacing: -.045em; text-decoration: none; }
.brand-accent { color: var(--accent); }
.brand-mark { width: 30px; height: 30px; padding: 6px; display: flex; align-items: end; gap: 3px; border-radius: 7px; background: #3440a1; }
.brand-mark i { width: 4px; height: 6px; background: #fff; border-radius: 1px; }
.brand-mark i:nth-child(2) { height: 11px; opacity: .8; }
.brand-mark i:nth-child(3) { height: 16px; opacity: .65; }
.search-bar { display: flex; min-width: 0; }
.search-bar input { width: 100%; min-width: 0; min-height: 42px; padding: .4rem .75rem; color: var(--ink); background: #f7f8fc; border: 1px solid #cbd3e3; border-right: 0; border-radius: 7px 0 0 7px; }
.search-bar button { flex: 0 0 auto; padding: .35rem .85rem; color: #fff; background: var(--accent); border: 1px solid var(--accent); border-radius: 0 7px 7px 0; }
.search-bar button:hover { background: #283485; }
.random-link, .sidebar-toggle { justify-self: end; font-size: .95rem; font-weight: 650; white-space: nowrap; }
.sidebar-toggle { display: none; }

.layout { max-width: 1480px; margin: auto; min-height: calc(100vh - 72px); display: grid; grid-template-columns: clamp(182px, 17.5vw, 232px) minmax(0, 1fr); }
.sidebar { padding: 2rem clamp(1rem, 2.2vw, 1.85rem); border-right: 1px solid var(--line); }
.sidebar nav { display: grid; gap: .07rem; }
.nav-home, .nav-link { display: flex; align-items: center; gap: .55rem; padding: .38rem .68rem; color: var(--ink); border-radius: 6px; text-decoration: none; }
.nav-home { font-weight: 680; }
.nav-heading { margin: 1.25rem 0 .15rem .68rem; color: var(--muted); font-size: .79rem; font-weight: 700; }
.nav-link:hover, .nav-home:hover, .is-active { color: #28359a; background: #e8ecfb; }
.nav-marker { flex: 0 0 7px; height: 7px; border-radius: 50%; background: var(--genre); }
.search { --genre: #526ae3; }
.sort { --genre: #a24c88; }
.graph { --genre: #167960; }
.dp { --genre: #a66923; }
.main { min-width: 0; padding: clamp(1.35rem, 4vw, 3.25rem); background: var(--paper); }
.footer { display: flex; flex-wrap: wrap; gap: .45rem 1.25rem; margin-top: clamp(3rem, 8vw, 6rem); padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.footer span { margin-right: auto; }

.hero { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: center; gap: clamp(1.5rem, 3vw, 3rem); margin-bottom: clamp(2.75rem, 6vw, 4.5rem); }
.hero-copy p { max-width: 30em; margin: 1.1rem 0; color: var(--muted); }
.hero-link { font-weight: 700; }
.hero-demo { min-width: 0; padding: clamp(.9rem, 2vw, 1.45rem); border-radius: 14px; background: #20285a; color: #f5f6ff; }
.hero-demo-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.hero-demo-heading h2 { margin-bottom: .55rem; font-size: 1.18rem; }
.hero-demo .demo-caption { color: #e4e8ff; }
.hero-demo .demo-search-info { color: #e4e8ff; }
.hero-demo .demo-selection { color: #e4e8ff; }
.hero-demo .demo-comparisons { color: #e4e8ff; }
.hero-demo button { color: #f5f6ff; background: #303b74; border-color: #6e79ac; }
.hero-demo button:hover:not(:disabled) { color: #fff; background: #41508d; }
.hero-demo .play-button { color: #20285a; background: #e1e6ff; border-color: #e1e6ff; }
.hero-demo .demo-counter { color: #e2e6fa; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.section-heading p { color: var(--muted); font-size: .9rem; }
.category-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.category-card { min-width: 0; padding: 1.2rem 1.35rem; background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; }
.category-line { display: block; width: 2rem; height: 3px; border-radius: 3px; background: var(--genre); margin-bottom: .65rem; }
.category-english, .english-name { margin: 0 0 .36rem; color: var(--muted); font-size: .86rem; }
.category-card h3 { margin: .15rem 0 .55rem; font-size: 1.25rem; }
.category-card h3 a { color: var(--ink); }
.category-card > p:not(.category-english) { color: var(--muted); }
.category-card ul, .link-list { margin: .5rem 0 0; padding-left: 1.25rem; }
.category-card li::marker, .link-list li::marker { color: var(--muted); }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: .3rem .65rem; margin: 0 0 1.2rem; color: var(--muted); font-size: .88rem; }
.article, .entry-list, .reference { max-width: 850px; }
.article-ad { max-width: 850px; margin-top: 2rem; }
.ad-label { margin: 0 0 .25rem; color: var(--muted); font-size: .8rem; visibility: hidden; }
.article-ad:has(.adsbygoogle[data-ad-status="filled"]) .ad-label { visibility: visible; }
.article-ad:has(.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.article-header { padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.article-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1.2rem; }
.article-year { display: inline-flex; align-items: baseline; gap: .4rem; margin-left: auto; white-space: nowrap; font-size: .88rem; }
.article-year span { color: var(--muted); font-size: .8rem; }
.lede { margin: .9rem 0 0; color: var(--muted); max-width: 49em; }
.reading { margin-top: 1.8rem; }
.reference { margin-top: 0; }
.reading > p { max-width: 49em; }
.article-demo { padding: clamp(.8rem, 2.3vw, 1.35rem); background: #f3f5fc; border: 1px solid var(--line); border-radius: 10px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1.1rem; }
.facts > div { min-width: 0; padding: .65rem .85rem; background: #f5f7fb; border-radius: 6px; }
.facts > div:last-child { grid-column: span 2; }
.facts dt { font-weight: 650; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
pre { margin: 0 0 1rem; padding: 1rem; overflow: auto; border-radius: 8px; color: #f4f6ff; background: #222a4b; tab-size: 4; }
code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .92rem; }
.entry-list, .timeline, .glossary { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.entry-list li, .timeline > div, .glossary > div { padding: 1.05rem 0; border-top: 1px solid var(--line); }
.entry-list h2, .timeline h2 { margin: 0 0 .3rem; }
.entry-list p, .timeline p { margin-bottom: .4rem; }
.timeline-links { display: flex; flex-wrap: wrap; gap: .2rem .8rem; }
.timeline > div { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: .75rem; }
.timeline dt, .glossary dt { font-weight: 700; }
.timeline dd, .glossary dd { margin: 0; }
.glossary div:target, .timeline div:target { background: #edf0ff; }

.demo-stage { min-width: 0; }
.demo-caption { min-height: 3.5em; margin: .55rem 0 .75rem; color: #37445e; line-height: 1.6; }
.demo-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.demo-controls button { padding: .25rem .53rem; min-height: 36px; border: 1px solid #c5cde0; border-radius: 6px; background: var(--paper); color: #293557; font-size: .87rem; white-space: nowrap; }
.demo-controls button:hover:not(:disabled) { background: #e8ecfc; }
.demo-controls button:disabled { opacity: .62; }
.demo-controls .play-button { border-color: var(--accent); color: white; background: var(--accent); flex: 0 0 5rem; min-inline-size: 0; }
.demo-controls .play-button:hover { color: #24327a; }
.demo-counter { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .84rem; }
.demo-search-info:not([hidden]) { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15rem .65rem; margin-bottom: .45rem; font-size: .87rem; }
.demo-search-info strong { font-size: 1rem; }
.demo-selection { display: grid; align-content: start; gap: .18rem; min-height: 4rem; margin-top: .55rem; font-size: .86rem; line-height: 1.45; color: var(--muted); }
.demo-selection > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; }
.demo-selection code { color: var(--ink); background: #f5f6ff; padding: .08rem .32rem; border-radius: 4px; font-size: .85rem; font-weight: 750; }
.demo-selection .selection-value { color: #5e3910; background: #f9d999; }
.demo-comparisons:not([hidden]) { display: flex; align-items: center; align-content: start; flex-wrap: wrap; gap: .25rem .4rem; min-height: 2.2rem; margin-top: .65rem; color: var(--muted); font-size: .87rem; }
.comparison-check { display: inline-block; white-space: nowrap; padding: .2rem .45rem; border: 1px solid #d1d8e7; border-radius: 5px; background: #fff; color: #26334c; font-weight: 750; }
.comparison-check .is-false { color: #a13143; }
.comparison-check .is-true { color: #126347; }
.comparison-match { padding: .18rem .48rem; border-radius: 5px; background: #cbeedc; color: #124c3e; }
.comparison-help { margin: .65rem 0 0; color: var(--muted); font-size: .9rem; }
.array { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: clamp(.16rem, .65vw, .42rem); align-items: end; min-height: 85px; max-width: 560px; padding: 0; margin: 0; list-style: none; }
.array li { display: grid; place-items: center; min-width: 0; min-height: 2.4rem; height: var(--bar); background: #e0e6f9; border: 1px solid #abb8e5; border-radius: 5px 5px 2px 2px; color: #25346e; font-size: clamp(.81rem, 1.7vw, 1.04rem); font-weight: 750; font-variant-numeric: tabular-nums; transition: height .2s, background-color .2s; }
.array .active { color: #fff; background: #374ab3; border-color: #5570e7; }
.array .done { color: #124c3e; background: #bfead9; border-color: #69baa1; }
.array .muted { color: #4a5873; background: #e9edf6; border-color: #c7d0e5; }
.array .pivot { color: #5e3910; background: #f9d999; border-color: #d3a35b; }
.array .range-endpoint { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.array.search-array { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(2rem, 1fr)); align-items: stretch; min-height: 0; }
.array.search-array li { height: auto; min-height: 2rem; border-radius: 5px; }
.hero-demo .array .muted { background: #384579; border-color: #6473a6; color: #f0f2fc; }
[data-demo="binary-search"] .search-array li { min-height: 2.4rem; font-size: 1rem; }
.graph-canvas { display: block; width: 100%; max-width: 630px; height: clamp(190px, 34vw, 295px); background: #fff; border: 1px solid #dce2ed; border-radius: 7px; }
.graph-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.graph-comparison h2 { margin: 0 0 .45rem; font-size: 1rem; }
.graph-comparison .graph-canvas { height: clamp(170px, 22vw, 230px); }
.visit-order { margin: .4rem 0; font-size: .87rem; color: var(--muted); }
.heap-array { margin-top: .65rem; }
.merge-output { display: flex; align-items: center; gap: .3rem; min-height: 2.25rem; margin: .65rem 0 0; color: #37445e; font-size: .87rem; }
.merge-output span { display: inline-grid; place-items: center; min-width: 1.6rem; padding: .05rem .16rem; color: #124c3e; background: #d9f0e7; border-radius: 4px; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.dp-table { border-collapse: collapse; table-layout: fixed; min-width: 320px; width: min(100%, 540px); text-align: center; font-variant-numeric: tabular-nums; background: #fff; }
.dp-table :is(th, td) { height: 2.1rem; border: 1px solid #cfd7ea; padding: .15rem; }
.dp-table th { background: #e6ebfc; }
.dp-table .dp-active { color: #fff; background: #374ab3; font-weight: 700; }
.dp-table .dp-source { background: #e1f1eb; color: #124c3e; }

@media (max-width: 1020px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-demo { max-width: 600px; }
}
@media (max-width: 760px) {
  .masthead-inner { grid-template-columns: minmax(0, 1fr) auto auto; gap: .7rem; }
  .search-bar { grid-column: 1 / -1; grid-row: 2; }
  .random-link { grid-column: 2; grid-row: 1; }
  .sidebar-toggle { display: inline-block; grid-column: 3; grid-row: 1; padding: .25rem .55rem; border: 1px solid #b7c1d8; border-radius: 6px; background: #fff; color: var(--ink); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: .65rem 1rem; border: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar nav .nav-heading { grid-column: span 2; }
  body[data-sidebar-open="false"] .sidebar { display: none; }
}
@media (max-width: 475px) {
  .graph-comparison { gap: .45rem; }
  .graph-comparison h2, .graph-comparison .visit-order { font-size: .8rem; }
  .merge-output { flex-wrap: wrap; }
  .category-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline > div { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
}
@media (max-width: 405px) {
  [data-demo="binary-search"] .demo-comparisons { min-height: 4.6rem; }
  .demo-selection { min-height: 4.65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
