@font-face {
  font-family: "Zalando Sans";
  src: url("./assets/zalando-sans.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #fafafa;
  --paper: #fff;
  --ink: #202123;
  --outline: #b9bdc1;
  --grid: rgb(60 139 176 / 15%);
  --signal: #3C8BB0;
  --focus: var(--signal);
  --muted: #7a838b;
  font-family: "Zalando Sans", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
.site-header { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; align-items: center; justify-content: space-between; height: 36px; }
.ab-mark { display: inline-flex; align-items: center; justify-content: center; height: 36px; color: var(--ink); text-decoration: none; font-family: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif; font-size: 25px; line-height: 1; letter-spacing: -.04em; }
.ab-mark:focus-visible { outline: 2px solid var(--focus); outline-offset: 5px; }
.sound-toggle { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #8d969e; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
.sound-toggle:hover { background: #edf0f2; color: #4e606e; }
.sound-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sound-off, .sound-toggle[aria-pressed="false"] .sound-waves { display: none; }
.sound-toggle[aria-pressed="false"] .sound-off { display: block; }

.workspace, .site-header { width: calc(100% - 96px); max-width: 1312px; margin-inline: auto; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 5vw, 80px);
  min-height: 100svh;
  padding: 96px 0 64px;
}

.paper-shell {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  box-shadow: 0 38px 88px -28px rgb(34 41 48 / 24%), 0 12px 36px -18px rgb(34 41 48 / 15%);
}
.paper {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  height: 100%;
  border: 1px solid var(--outline);
  border-radius: 22px;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: calc(100% / 28) calc(100% / 28);
  background-position: -0.5px -0.5px;
}

#drawing {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 21px;
  touch-action: none;
  cursor: none;
  outline: none;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.paper:has(#drawing:focus-visible:not([data-focus-source="pointer"])) { outline: 2px solid var(--focus); outline-offset: 6px; }
.brush-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--brush-size, 50px);
  height: var(--brush-size, 50px);
  border: 1px solid rgb(29 36 42 / 37%);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 70%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}
.brush-cursor.is-eraser { background: rgb(255 255 255 / 30%); border-color: rgb(29 36 42 / 52%); }
.tool-area { position: absolute; left: 50%; bottom: clamp(12px, 4.5cqi, 26px); transform: translateX(-50%); z-index: 2; }

.glass {
  background: linear-gradient(145deg, rgb(255 255 255 / 79%), rgb(247 248 250 / 57%));
  border: 1px solid rgb(255 255 255 / 92%);
  box-shadow:
    0 12px 34px -10px rgb(43 51 62 / 21%),
    0 2px 6px rgb(43 51 62 / 5%),
    inset 0 0 0 1px rgb(155 164 175 / 16%),
    inset 0 2px 2px rgb(255 255 255 / 96%),
    inset 0 -1px 2px rgb(151 159 171 / 9%);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
}

.tools {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(4px, 1.38cqi, 8px);
  width: clamp(116px, 27.2cqi, 158px);
  height: clamp(58px, 14.1cqi, 82px);
  padding: clamp(5px, 1.38cqi, 8px) clamp(8px, 2.06cqi, 12px) 0;
  border-radius: clamp(22px, 5cqi, 29px);
  overflow: hidden;
}
.tool {
  --tool-rest: clamp(6px, 1.38cqi, 8px);
  --tool-hover: 2px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 0 0 clamp(42px, 9.3cqi, 54px);
  height: clamp(52px, 12.4cqi, 72px);
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: transparent;
  cursor: pointer;
  outline-offset: -4px;
  touch-action: manipulation;
}
.tool::before {
  content: "";
  position: absolute;
  inset: 9px 0 7px;
  border-radius: 18px;
  background: rgb(56 65 76 / 5%);
  opacity: 0;
  transition: opacity 160ms ease;
}
.tool.is-active::before { opacity: 1; }
.tool svg { position: relative; width: auto; height: clamp(52px, 12.4cqi, 72px); transform: translateY(var(--tool-rest)); transition: transform 220ms cubic-bezier(.2,.7,.3,1); filter: drop-shadow(1px 2px 2px rgb(0 0 0 / 9%)); }
.tool.is-active { --tool-rest: 0px; }
.tool:hover svg { transform: translateY(calc(var(--tool-rest) - var(--tool-hover))); }
.tool:active svg { transform: translateY(calc(var(--tool-rest) + 2px)); }
.tool:disabled { cursor: wait; opacity: .45; }
.tool:focus-visible, .size-option:focus-visible { outline: 2px solid var(--focus); }
.tools.is-clearing { animation: clear-pulse 400ms ease; }

.thickness {
  position: absolute;
  bottom: calc(clamp(58px, 14.1cqi, 82px) + 12px);
  left: 50%;
  display: flex;
  gap: 2px;
  padding: 6px;
  border-radius: 24px;
  transform: translateX(-50%);
  animation: reveal 160ms ease-out;
}
.size-option { display: grid; place-items: center; width: clamp(32px, 6.9cqi, 40px); height: clamp(32px, 6.9cqi, 40px); padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; }
.size-option span { display: block; width: var(--dot-size); height: var(--dot-size); background: #242426; border-radius: 50%; }
.size-option:hover { background: rgb(0 0 0 / 4%); }
.size-option[aria-pressed="true"] { border-color: rgb(57 65 74 / 23%); background: rgb(255 255 255 / 48%); }

.network-panel { position: relative; min-width: 0; padding-block: 8px; transition: opacity 260ms ease; }
body[data-entry="active"] .network-panel { opacity: .22; }
.network-visualization, .activation-section { position: relative; }
.output-summary { margin-bottom: 48px; }
/* Equal cell pitch in all four heatmaps; four identical gaps; a compact output column. */
.layer-strip { --map-height: clamp(128px, 11.5vw, 156px); --layer-gap: clamp(16px, 1.5vw, 22px); display: grid; grid-template-columns: 28fr 32fr 16fr 16fr 18px; column-gap: var(--layer-gap); }
.layer { position: relative; margin: 0; min-width: 0; }
.map-stage { position: relative; display: flex; align-items: center; height: var(--map-height); }
.layer-arrow { position: absolute; left: calc(100% + var(--layer-gap) / 2); top: 50%; width: 12px; height: 12px; transform: translate(-50%, -50%); opacity: .28; pointer-events: none; }
.activation-map { display: block; width: 100%; height: auto; cursor: crosshair; outline: none; }
@media (hover: none), (pointer: coarse) { .activation-map { cursor: default; } }
.activation-map:focus-visible { outline: 1px solid var(--focus); outline-offset: 4px; }
.layer figcaption { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 16px; }
.layer-count { font-size: 18px; font-weight: 430; line-height: 1; letter-spacing: -.4px; color: #545f68; font-variant-numeric: tabular-nums; }
.layer-name { color: #939ba2; font-size: 10px; letter-spacing: .1px; white-space: nowrap; }
.output-neurons { display: grid; width: 100%; gap: 3px; }
.output-neuron { display: grid; grid-template-columns: 7px 1ch; align-items: center; justify-content: start; gap: 5px; color: #a2abb2; font-size: 9px; line-height: 10px; font-variant-numeric: tabular-nums; }
.output-neuron i { display: block; width: 7px; height: 7px; border-radius: 2px; background: var(--neuron-color, #eceff2); transition: background-color 140ms ease; }
.output-neuron.is-winner { color: var(--signal); font-weight: 650; }
.output-neuron.is-winner i { outline: 1px solid rgb(60 139 176 / 25%); outline-offset: 2px; }
.output-bars { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: clamp(6px, .8vw, 12px); }
.output-column { --score: 0; --bar-height: 115px; position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 10px; min-width: 0; padding: 0; border: 0; background: transparent; color: #929ca4; cursor: pointer; font-variant-numeric: tabular-nums; }
.bar-track { position: relative; display: block; height: var(--bar-height); background: linear-gradient(100deg, #e4e9ec, #f2f5f6 48%, #e9edef); overflow: hidden; border-radius: 10px; box-shadow: inset 2px 2px 4px rgb(42 65 78 / 12%), inset -2px -2px 4px rgb(255 255 255 / 90%), 0 1px 0 #fff; }
.bar-fill { position: absolute; bottom: 0; left: 0; right: 0; height: calc(var(--score) * 100%); background: var(--bar-color, var(--signal)); box-shadow: inset 1px 1px 1px rgb(255 255 255 / 28%), inset -1px -1px 1px rgb(22 66 87 / 16%); }
.bar-digit { font-size: 15px; line-height: 1; font-weight: 430; transition: color 150ms ease; }
.bar-value { display: block; align-self: center; height: 14px; line-height: 14px; white-space: nowrap; font-size: 10px; opacity: 0; color: var(--signal); pointer-events: none; transition: opacity 140ms ease; }
.output-column:hover .bar-value, .output-column:focus-visible .bar-value, .output-column.is-winner .bar-value, .output-column.is-inspected .bar-value { opacity: 1; }
.output-column:hover .bar-track { background: linear-gradient(100deg, #dce4e8, #edf3f5 48%, #e1e9ed); }
.output-column.is-winner { color: var(--signal); }
.output-column.is-winner .bar-digit { font-weight: 650; }
.output-column:focus-visible { outline: 1px solid var(--focus); outline-offset: 5px; border-radius: 3px; }
.neuron-tip { position: absolute; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 10px 13px; background: rgb(255 255 255 / 97%); border: 1px solid #e1e6ea; border-radius: 9px; box-shadow: 0 6px 24px rgb(29 45 60 / 8%); transform: translateX(-50%); white-space: nowrap; pointer-events: none; }
#neuron-tip-label { color: #707d88; font-size: 11px; }
#neuron-tip-value { color: var(--signal); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.entry-cover { position: absolute; inset: 0; z-index: 4; display: flex; padding: clamp(24px, 8cqi, 56px); overflow: hidden; border-radius: inherit; background: #0d1012; color: #fafafa; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 7%); opacity: 1; transition: opacity 260ms ease; }
.entry-cover.is-leaving { opacity: 0; pointer-events: none; }
.entry-welcome { display: flex; flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 24px; opacity: 1; transition: opacity 240ms ease; }
.entry-cover:not([data-phase="welcome"]) .entry-welcome { opacity: 0; pointer-events: none; }
.entry-welcome h1 { margin: 0; font-size: clamp(28px, 8.4cqi, 56px); font-weight: 480; letter-spacing: -.055em; line-height: 1.06; }
.entry-welcome p { max-width: 25em; margin: clamp(16px, 4cqi, 28px) 0 0; color: #aab0b4; font-size: clamp(14px, 2.7cqi, 18px); font-weight: 410; line-height: 1.5; letter-spacing: -.15px; }
.entry-button { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; gap: 16px; min-height: 48px; padding: 14px 20px; border: 0; border-radius: 30px; background: #f7f8f8; color: #191c1e; font-size: 14px; line-height: 20px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease, transform 140ms ease; }
.entry-button:hover { background: color-mix(in srgb, var(--signal) 15%, white); transform: translateY(-1px); }
.entry-button:active { transform: translateY(1px); }
.entry-button:focus-visible { outline: 2px solid color-mix(in srgb, var(--signal) 38%, white); outline-offset: 5px; }
.entry-loading { position: absolute; inset: clamp(24px, 8cqi, 56px); min-width: 0; opacity: 0; pointer-events: none; transition: opacity 240ms ease 120ms; }
.entry-cover:not([data-phase="welcome"]) .entry-loading { opacity: 1; pointer-events: auto; }
.entry-loading h2 { position: absolute; bottom: calc(50% + 13cqi); margin: 0; font-size: clamp(20px, 4.6cqi, 30px); font-weight: 450; letter-spacing: -.8px; }
.loading-network { position: absolute; left: clamp(24px, 8cqi, 56px); right: clamp(24px, 8cqi, 56px); top: 63%; transform: translateY(-50%); display: grid; grid-template-columns: 28fr 32fr 16fr 16fr 2fr; align-items: center; gap: clamp(8px, 2cqi, 14px); transition: top 480ms cubic-bezier(.22, 1, .36, 1); pointer-events: none; }
.entry-cover:not([data-phase="welcome"]) .loading-network { top: 50%; }
.loading-map { width: 100%; height: auto; }
.loading-status { position: absolute; top: calc(50% + 13cqi); right: 0; }
#load-error { position: absolute; bottom: 62px; margin: 0; color: #abb8c1; font-size: 13px; line-height: 1.5; }
#load-percent { color: color-mix(in srgb, var(--signal) 16%, white); font-size: clamp(22px, 5cqi, 32px); line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
#entry-retry { position: absolute; bottom: 0; }

@media (max-width: 400px) {
  .entry-welcome h1 { font-size: 24px; }
  .entry-welcome p { margin-top: 12px; font-size: 12px; line-height: 1.4; }
  .entry-button { min-height: 44px; padding: 12px 18px; }
  .loading-network { top: 59%; }
}

@keyframes reveal { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes clear-pulse { 50% { filter: brightness(.93); } }

@media (max-width: 1180px) and (min-width: 981px) {
  .site-header { width: calc(100% - 64px); }
  .workspace { width: calc(100% - 64px); grid-template-columns: 1.08fr 1fr; gap: 40px; }
  .output-summary { margin-bottom: 40px; }
  .output-column { --bar-height: 96px; }
}
@media (max-width: 980px) {
  .site-header { width: calc(100% - 64px); max-width: 600px; }
  .workspace { width: calc(100% - 64px); max-width: 600px; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 64px; padding: 96px 0 72px; }
  .network-panel { padding-inline: 8px; }
  .layer-strip { --map-height: 156px; }
}
@media (max-width: 560px) {
  .site-header { width: calc(100% - 40px); }
  .workspace { width: calc(100% - 40px); gap: 44px; padding: 96px 0 64px; }
  .paper, .paper-shell { border-radius: 18px; }
  #drawing { border-radius: 17px; }
  .network-panel { padding-inline: 0; }
  .layer-strip { --map-height: 112px; --layer-gap: 12px; }
  .layer-count { font-size: 16px; }
  .layer-name { font-size: 9px; }
  .output-summary { margin-bottom: 40px; }
  .output-neurons { gap: 1px; }
  .output-neuron { gap: 4px; font-size: 8px; }
  .bar-value { font-size: 9px; }
  .output-column { --bar-height: 100px; }
}
@media (max-width: 360px) { .bar-value { font-size: 8px; } }
@media (pointer: coarse) { #drawing { cursor: crosshair; } .brush-cursor { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
@media (prefers-reduced-transparency: reduce) { .glass { background: #f4f5f6; backdrop-filter: none; -webkit-backdrop-filter: none; } }
