:root {
  --ink: #111111;
  --paper: #f3f0e8;
  --paper-2: #e7e2d6;
  --white: #fffef9;
  --acid: #d7ff42;
  --orange: #ff6846;
  --blue: #335dff;
  --green: #23a463;
  --muted: #6e6a61;
  --line: #171717;
  --soft-line: rgba(17, 17, 17, 0.16);
  --mono: "IBM Plex Mono", monospace;
  --sans: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: var(--acid); color: var(--ink); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 clamp(18px, 3vw, 48px);
  border-bottom: 2px solid var(--line);
  background: rgba(243, 240, 232, 0.94);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; width: max-content; }
.brand__badge {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); border-radius: 2px;
  font: 600 11px var(--mono);
}
.brand__name { font-size: 14px; font-weight: 800; letter-spacing: -.03em; }
.topbar__meta { display: flex; align-items: center; gap: 10px; font: 500 9px var(--mono); letter-spacing: .08em; }
.topbar__dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; }
.topbar__jump { justify-self: end; font: 600 10px var(--mono); border-bottom: 1px solid var(--ink); padding-bottom: 3px; }

.hero { padding: 28px clamp(18px, 3vw, 48px) 0; }
.hero__label {
  display: flex; justify-content: space-between; padding: 11px 0 14px;
  border-bottom: 1px solid var(--ink); font: 500 9px var(--mono); letter-spacing: .08em;
}
.hero__grid {
  min-height: min(720px, calc(100vh - 144px));
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, .5fr);
  gap: clamp(32px, 6vw, 110px); align-items: end; padding: 50px 0 44px;
}
.eyebrow { margin: 0 0 22px; font: 600 10px var(--mono); letter-spacing: .11em; }
.hero h1 {
  margin: 0; font-size: clamp(66px, 11vw, 190px); line-height: .77;
  letter-spacing: -.085em; font-weight: 800;
}
.hero h1 span {
  color: var(--blue); -webkit-text-stroke: 1px var(--blue);
}
.hero__note {
  align-self: end; padding: 20px; border: 2px solid var(--ink); background: var(--acid);
  box-shadow: 8px 8px 0 var(--ink);
}
.hero__note-number { font: 600 10px var(--mono); }
.hero__note p { margin: 58px 0 28px; font-size: 14px; line-height: 1.55; font-weight: 600; }
.hero__note a { display: inline-block; font: 600 10px var(--mono); border-bottom: 1px solid var(--ink); padding-bottom: 4px; }
.hero__ticker { overflow: hidden; margin: 0 calc(clamp(18px, 3vw, 48px) * -1); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: var(--orange); }
.hero__ticker-track {
  width: max-content; display: flex; align-items: center; gap: 22px; padding: 13px 0;
  font: 600 11px var(--mono); animation: ticker 28s linear infinite;
}
.hero__ticker-track i { font-style: normal; }
@keyframes ticker { to { transform: translateX(-50%); } }

.lab-section, .library-section { padding: 100px clamp(18px, 3vw, 48px); }
.section-head { display: grid; grid-template-columns: 280px 1fr; gap: 40px; margin-bottom: 46px; }
.section-head > div { display: flex; align-items: baseline; gap: 14px; }
.section-head__index { font: 600 12px var(--mono); color: var(--blue); }
.section-head__label { font: 500 9px var(--mono); letter-spacing: .1em; }
.section-head h2 { margin: 0; font-size: clamp(36px, 5vw, 76px); line-height: .92; letter-spacing: -.055em; }

.lab-window { border: 2px solid var(--ink); background: var(--white); box-shadow: 10px 10px 0 var(--ink); }
.lab-window__topline {
  min-height: 44px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 16px; border-bottom: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 500 8px var(--mono); letter-spacing: .1em;
}
.lab-window__topline > span:last-child { justify-self: end; color: var(--acid); }
.window-dots { display: flex; gap: 6px; }
.window-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--paper); opacity: .5; }
.window-dots span:first-child { background: var(--orange); opacity: 1; }

.lab-toolbar {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) 1fr 1fr auto;
  gap: 0; border-bottom: 2px solid var(--ink); background: var(--paper-2);
}
.toolbar-field, .toolbar-actions { min-height: 82px; padding: 13px 16px; border-right: 1px solid var(--ink); }
.toolbar-field label { display: flex; justify-content: space-between; margin-bottom: 12px; font: 600 8px var(--mono); letter-spacing: .09em; }
.toolbar-field label strong { color: var(--blue); }
.toolbar-field select {
  width: 100%; min-height: 38px; border: 1px solid var(--ink); border-radius: 0;
  background: var(--white); color: var(--ink); padding: 0 10px; font: 600 11px var(--mono); outline: none;
}
.toolbar-field input[type="range"], .timeline-wrap input[type="range"] {
  width: 100%; height: 4px; margin: 8px 0 0; appearance: none; background: var(--ink); cursor: pointer;
}
.toolbar-field input[type="range"]::-webkit-slider-thumb, .timeline-wrap input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border: 2px solid var(--ink); background: var(--acid); border-radius: 50%;
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; border-right: 0; }
.btn {
  min-height: 40px; padding: 0 14px; border: 2px solid var(--ink); background: var(--white);
  color: var(--ink) !important; font: 700 9px var(--mono); letter-spacing: .05em; cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); background: var(--acid); }

.custom-row, .search-row {
  display: grid; grid-template-columns: 130px minmax(160px, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 12px 16px; border-bottom: 2px solid var(--ink); background: var(--acid);
}
.custom-row label, .search-row label { font: 600 8px var(--mono); }
.custom-row input, .search-row input {
  min-height: 38px; border: 2px solid var(--ink); background: var(--white); color: var(--ink); padding: 0 10px; outline: none;
}
.custom-row button, .search-row button {
  min-height: 38px; border: 2px solid var(--ink); background: var(--ink); color: var(--white); padding: 0 14px; font: 600 9px var(--mono); cursor: pointer;
}
.custom-row small, .search-row small { font: 500 8px var(--mono); }

.lab-main { display: grid; grid-template-columns: minmax(0, 1fr) 280px; min-height: 610px; }
.visual-stage { min-width: 0; border-right: 2px solid var(--ink); }
.stage-head {
  min-height: 92px; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--ink);
}
.stage-head__tiny { display: block; margin-bottom: 6px; font: 500 8px var(--mono); letter-spacing: .1em; color: var(--muted); }
.stage-head h3 { margin: 0; font-size: clamp(24px, 3vw, 42px); line-height: 1; letter-spacing: -.05em; }
.complexity-pill { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--ink); background: var(--paper); font: 600 9px var(--mono); }
.complexity-pill span { color: var(--muted); }
.complexity-pill strong { color: var(--blue); }

.bars-wrap { position: relative; min-height: 360px; padding: 48px 28px 30px; overflow: hidden; }
.bars-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(17,17,17,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(17,17,17,.08) 1px, transparent 1px); background-size: 34px 34px; }
.bars { position: relative; z-index: 2; height: 290px; display: flex; align-items: flex-end; gap: clamp(4px, .7vw, 10px); }
.bar {
  position: relative; flex: 1 1 0; min-width: 5px; height: var(--h); max-width: 70px;
  background: var(--ink); border: 2px solid var(--ink); transition: height .28s ease, background .18s ease, transform .22s ease;
}
.bar::before {
  content: attr(data-value); position: absolute; left: 50%; top: -24px; transform: translateX(-50%);
  font: 600 8px var(--mono); color: var(--ink);
}
.bar::after {
  content: attr(data-index); position: absolute; left: 50%; bottom: -23px; transform: translateX(-50%);
  font: 500 7px var(--mono); color: var(--muted);
}
.bar.is-compare { background: var(--orange); transform: translateY(-8px); }
.bar.is-pivot { background: var(--blue); }
.bar.is-done { background: var(--green); }
.bar.is-found { background: var(--acid); box-shadow: inset 0 0 0 3px var(--ink); }
.bar.is-muted { opacity: .22; }

.operation-card {
  position: absolute; z-index: 4; left: 28px; top: 20px; min-width: 240px; max-width: 380px;
  padding: 12px 14px; border: 2px solid var(--ink); background: var(--white); box-shadow: 5px 5px 0 var(--ink);
}
.operation-card span { display: block; font: 600 7px var(--mono); letter-spacing: .1em; color: var(--muted); }
.operation-card strong { display: block; margin-top: 4px; font-size: 15px; }
.operation-card p { margin: 5px 0 0; font-size: 11px; line-height: 1.4; }

.transport {
  min-height: 88px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--paper-2);
}
.play-button {
  min-width: 160px; min-height: 54px; display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  border: 2px solid var(--ink); background: var(--acid); color: var(--ink); cursor: pointer; box-shadow: 5px 5px 0 var(--ink);
  font: 800 12px var(--mono); letter-spacing: .08em; transition: transform .15s ease, box-shadow .15s ease;
}
.play-button:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.play-button.is-playing { background: var(--orange); }
.play-button__icon { font-size: 13px; }
.transport__secondary, .transport__reset {
  min-height: 44px; border: 2px solid var(--ink); background: var(--white); color: var(--ink); cursor: pointer; font: 700 10px var(--mono);
}
.transport__secondary { width: 44px; }
.transport__reset { padding: 0 14px; margin-left: 8px; }
.transport__secondary:hover, .transport__reset:hover { background: var(--ink); color: var(--white); }

.timeline-wrap { padding: 14px 20px 18px; }
.timeline-meta { display: flex; justify-content: space-between; font: 500 8px var(--mono); }
.timeline-wrap input[type="range"] { margin-top: 12px; }

.inspector { background: var(--paper); }
.inspector__head {
  min-height: 52px; display: flex; justify-content: space-between; align-items: center; padding: 0 14px;
  border-bottom: 1px solid var(--ink); font: 600 8px var(--mono); letter-spacing: .08em;
}
.metric-stack { display: grid; grid-template-columns: 1fr; }
.metric-card { padding: 17px 14px; border-bottom: 1px solid var(--ink); }
.metric-card span { display: block; font: 500 7px var(--mono); letter-spacing: .1em; color: var(--muted); }
.metric-card strong { display: block; margin-top: 6px; font-size: 32px; line-height: 1; letter-spacing: -.05em; }
.legend, .complexity-table { padding: 18px 14px; border-bottom: 1px solid var(--ink); }
.legend__title { display: block; margin-bottom: 12px; font: 600 8px var(--mono); letter-spacing: .09em; }
.legend > div { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 10px; }
.legend-dot { width: 10px; height: 10px; display: inline-block; border: 1px solid var(--ink); background: var(--ink); }
.legend-dot--compare { background: var(--orange); }
.legend-dot--pivot { background: var(--blue); }
.legend-dot--done { background: var(--green); }
.complexity-table dl { margin: 0; }
.complexity-table dl div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px dashed rgba(17,17,17,.24); }
.complexity-table dt, .complexity-table dd { margin: 0; font: 600 8px var(--mono); }
.complexity-table dd { color: var(--blue); }

.code-strip { border-top: 2px solid var(--ink); background: #171717; color: #f8f5ec; }
.code-strip__head { min-height: 40px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.18); font: 500 8px var(--mono); letter-spacing: .08em; }
.code-block { margin: 0; padding: 14px 0; max-height: 260px; overflow: auto; font: 500 10px/1.65 var(--mono); }
.code-line { display: block; min-width: max-content; padding: 0 16px; color: #b9b5aa; border-left: 3px solid transparent; }
.code-line em { display: inline-block; width: 34px; color: #605e59; font-style: normal; }
.code-line.is-active { color: #fff; background: rgba(215,255,66,.08); border-left-color: var(--acid); }
.code-line.is-active em { color: var(--acid); }

.library-section { border-top: 2px solid var(--ink); }
.library-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--ink); border-left: 2px solid var(--ink); }
.library-card {
  min-height: 270px; display: flex; flex-direction: column; align-items: flex-start; padding: 20px;
  border: 0; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: var(--white); text-align: left; cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.library-card:hover { background: var(--acid); }
.library-card--accent { background: var(--blue); color: #fff; }
.library-card--accent:hover { background: var(--orange); color: var(--ink); }
.library-card span { font: 600 8px var(--mono); letter-spacing: .08em; }
.library-card strong { margin: auto 0 10px; font-size: clamp(24px, 3vw, 44px); line-height: .9; letter-spacing: -.055em; }
.library-card small { max-width: 220px; font-size: 10px; line-height: 1.45; }
.library-card b { margin-top: 18px; font: 600 9px var(--mono); }

.footer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; min-height: 130px; padding: 28px clamp(18px,3vw,48px); background: var(--ink); color: var(--paper); font: 500 8px var(--mono); letter-spacing: .08em; }
.footer a { justify-self: end; color: var(--acid); }

@media (max-width: 1100px) {
  .lab-toolbar { grid-template-columns: 1fr 1fr 1fr; }
  .toolbar-actions { grid-column: 1 / -1; border-top: 1px solid var(--ink); }
  .lab-main { grid-template-columns: minmax(0, 1fr) 230px; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar__meta { display: none; }
  .hero__grid { min-height: auto; grid-template-columns: 1fr; align-items: start; }
  .hero__note { max-width: 420px; }
  .hero__note p { margin-top: 34px; }
  .section-head { grid-template-columns: 1fr; gap: 18px; }
  .lab-toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar-field--algorithm { grid-column: 1 / -1; }
  .toolbar-actions { grid-column: 1 / -1; }
  .lab-main { grid-template-columns: 1fr; }
  .visual-stage { border-right: 0; }
  .inspector { border-top: 2px solid var(--ink); }
  .metric-stack { grid-template-columns: repeat(3, 1fr); }
  .metric-card { border-right: 1px solid var(--ink); }
  .custom-row, .search-row { grid-template-columns: 1fr auto; }
  .custom-row label, .search-row label, .custom-row small, .search-row small { grid-column: 1 / -1; }
  .footer { grid-template-columns: 1fr; }
  .footer a { justify-self: start; }
}

@media (max-width: 560px) {
  .topbar { height: 62px; padding: 0 14px; }
  .topbar__jump { font-size: 8px; }
  .hero { padding-left: 14px; padding-right: 14px; }
  .hero h1 { font-size: clamp(58px, 18vw, 94px); }
  .hero__ticker { margin-left: -14px; margin-right: -14px; }
  .lab-section, .library-section { padding: 76px 14px; }
  .lab-window { box-shadow: 5px 5px 0 var(--ink); }
  .lab-window__topline { grid-template-columns: auto 1fr; gap: 12px; }
  .lab-window__topline > span:nth-child(2) { display: none; }
  .lab-window__topline > span:last-child { justify-self: end; }
  .lab-toolbar { grid-template-columns: 1fr; }
  .toolbar-field, .toolbar-actions { border-right: 0; border-bottom: 1px solid var(--ink); }
  .toolbar-field--algorithm, .toolbar-actions { grid-column: 1; }
  .toolbar-actions { flex-wrap: wrap; }
  .btn { flex: 1 1 130px; }
  .stage-head { align-items: flex-start; gap: 12px; }
  .bars-wrap { min-height: 330px; padding-left: 12px; padding-right: 12px; }
  .bars { height: 250px; gap: 3px; }
  .bar::before { font-size: 6px; }
  .bar::after { display: none; }
  .operation-card { left: 12px; right: 12px; min-width: 0; max-width: none; }
  .transport { flex-wrap: wrap; }
  .play-button { order: -1; flex-basis: calc(100% - 20px); }
  .transport__reset { margin-left: 0; }
  .metric-stack { grid-template-columns: 1fr; }
  .metric-card { border-right: 0; }
  .library-grid { grid-template-columns: 1fr; }
  .library-card { min-height: 220px; }
  .custom-row, .search-row { grid-template-columns: 1fr; }
  .custom-row label, .search-row label, .custom-row small, .search-row small { grid-column: 1; }
}

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