/* Word Explorer — paper-and-ink instrument, aligned with the linlab.ai landing page (light only, like the landing). */
:root {
  color-scheme: light;
  --paper: oklch(0.93 0.004 110);
  --paper-bright: oklch(0.965 0.003 110);
  --surface: oklch(0.895 0.005 110);
  --ink: oklch(0.17 0.005 110);
  --ink-muted: oklch(0.45 0.006 110);
  --hairline: oklch(0.76 0.005 110);
  --hairline-soft: oklch(0.84 0.005 110);
  /* Pigments: vermilion for the result, indigo for "+", ochre for "−". */
  --vermilion: oklch(0.55 0.17 32);
  --indigo: oklch(0.45 0.09 245);
  --ochre: oklch(0.58 0.11 65);
  --focus: var(--ink);
  --sans: "Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gutter: clamp(1rem, 2.4vw, 2.6rem);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-underline-offset: 4px; text-decoration-color: var(--hairline); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: progress; opacity: .55; }
:focus-visible { outline: 1.5px solid var(--focus); outline-offset: 4px; }
::selection { background: color-mix(in oklch, var(--vermilion) 28%, transparent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.panel-label, .reading, .readings, .stage-reading, .rank-note, .record-status, .step-labels button, .scene-legend, .model-picker {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 450;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Header — same rhythm as the landing page. */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding: clamp(.9rem, 1.6vw, 1.4rem) var(--gutter);
  border-bottom: 1px solid var(--hairline-soft);
}
.brand { display: flex; align-items: baseline; gap: .6rem; white-space: nowrap; }
.wordmark { font-size: 1.02rem; font-weight: 650; letter-spacing: -.025em; text-decoration: none; }
.wordmark span, .crumb { color: var(--ink-muted); font-weight: 480; }
.product { font-size: 1.02rem; font-weight: 500; letter-spacing: -.02em; }
/* Step switch shared with linlab.ai/tokenizer/ (same markup there, styled with that page's own tokens). */
.steps { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--ink); }
.step { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: .1rem .75rem; padding: .7rem var(--gutter); color: var(--ink); text-decoration: none; transition: background .15s, color .15s; }
.step + .step { border-left: 1px solid var(--ink); }
.step:hover { background: var(--paper-bright); }
.step-n { grid-row: span 2; font: 500 .75rem var(--mono); letter-spacing: .05em; color: var(--ink-muted); }
.step-name { font-size: 1.2rem; font-weight: 560; letter-spacing: -.02em; line-height: 1.2; }
.step-desc { font: 450 .66rem var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); }
.step[aria-current="page"] { background: var(--ink); color: var(--paper); }
.step[aria-current="page"] .step-n, .step[aria-current="page"] .step-desc { color: color-mix(in oklch, var(--paper) 70%, transparent); }
.readings { display: flex; align-items: center; gap: clamp(.9rem, 2vw, 2rem); }
.model-picker { display: flex; align-items: center; gap: .5rem; }
.model-picker select {
  appearance: none;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  padding: .3rem 1.4rem .3rem .55rem;
  font: inherit;
  color: var(--ink);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 10px) 52%, calc(100% - 6px) 52%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.status { display: flex; align-items: center; gap: .5rem; }
.status-dot { width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in oklch, var(--ink-muted) 16%, transparent); animation: breathe 4s ease-in-out infinite; }
.status.is-online .status-dot { background: var(--ink); }
.status.is-offline { color: var(--vermilion); }
.status.is-offline .status-dot { animation: none; }
@keyframes breathe { 0%, 100% { opacity: .42; } 50% { opacity: 1; } }

/* Workspace: controls | observation stage | readings. */
.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(230px, 280px);
  max-width: 1880px;
  margin: 0 auto;
  min-height: calc(100svh - 126px);
}
.explore-panel, .results-panel { padding: clamp(1.2rem, 2vw, 2rem) var(--gutter); }
.explore-panel { border-right: 1px solid var(--hairline-soft); }
.results-panel { border-left: 1px solid var(--hairline-soft); }
.visual-panel { min-width: 0; padding: clamp(1.2rem, 2vw, 2rem) clamp(1rem, 2.2vw, 2.4rem) 1.6rem; display: flex; flex-direction: column; }

.mode-tabs { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--hairline-soft); margin-bottom: 1.6rem; }
.mode-tabs button { border: 0; background: none; padding: 0 0 .7rem; margin-bottom: -1px; border-bottom: 1px solid transparent; color: var(--ink-muted); font-size: .9rem; }
.mode-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.mode-tabs button:hover { color: var(--ink); }

h1 { font-size: clamp(1.25rem, 1.6vw, 1.5rem); font-weight: 520; line-height: 1.45; letter-spacing: -.02em; margin-bottom: 1.5rem; text-wrap: balance; }
.term-field { margin-bottom: 1rem; }
.term-field label { display: flex; align-items: center; gap: .55rem; font-size: .82rem; color: var(--ink-muted); margin-bottom: .4rem; }
.term-key { display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; font: 500 .8rem/1 var(--mono); color: var(--paper); background: var(--ink); }
.term-b .term-key { background: var(--indigo); }
.term-c .term-key { background: var(--ochre); }
.autocomplete { position: relative; }
.autocomplete input {
  width: 100%;
  min-height: 46px;
  padding: .6rem .8rem;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: var(--paper-bright);
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: -.01em;
  caret-color: var(--vermilion);
}
.autocomplete input::placeholder { color: var(--ink-muted); font-size: .85rem; }
.autocomplete input:hover { border-color: var(--ink-muted); }
.autocomplete input:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.term-b input:focus { border-color: var(--indigo); box-shadow: inset 0 -2px 0 var(--indigo); }
.term-c input:focus { border-color: var(--ochre); box-shadow: inset 0 -2px 0 var(--ochre); }
.suggest-menu { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow: auto; padding: 4px; background: var(--paper-bright); border: 1px solid var(--ink); box-shadow: 4px 4px 0 color-mix(in oklch, var(--ink) 10%, transparent); }
.suggest-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .45rem .6rem; font-size: .92rem; overflow-wrap: anywhere; }
.suggest-menu button:hover, .suggest-menu button[aria-selected="true"] { background: var(--surface); }

.primary { width: 100%; min-height: 46px; margin-top: .4rem; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-weight: 520; letter-spacing: .01em; transition: background .15s, color .15s; }
.primary:hover:not(:disabled) { background: transparent; color: var(--ink); }
.form-note { font-size: .82rem; color: var(--ink-muted); margin-top: 1rem; }

.error { margin-top: 1rem; padding: .8rem .9rem; border: 1px solid var(--vermilion); border-left-width: 3px; color: var(--ink); font-size: .85rem; overflow-wrap: anywhere; }
.error p { color: var(--ink-muted); margin-top: .3rem; }
.error button { margin: .5rem .35rem 0 0; padding: .2rem .55rem; border: 1px solid var(--hairline); background: none; font-size: .85rem; }
.error button:hover { border-color: var(--ink); }

.recommendations { margin-top: 2rem; border-top: 1px solid var(--hairline-soft); padding-top: 1.2rem; }
.recommendations > summary { display: flex; justify-content: space-between; gap: .5rem; list-style: none; cursor: pointer; margin-bottom: .6rem; }
.recommendations > summary::-webkit-details-marker { display: none; }
.recommendation { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--hairline-soft); background: none; padding: .7rem 0 .7rem .9rem; position: relative; }
.recommendation::before { content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 5px; margin-top: -3px; border: 1px solid var(--hairline); transform: rotate(45deg); transition: background .15s, border-color .15s; }
.recommendation:hover::before, .recommendation[aria-pressed="true"]::before { background: var(--vermilion); border-color: var(--vermilion); }
.preset-equation { display: block; font: 450 .85rem/1.5 var(--mono); letter-spacing: -.01em; overflow-wrap: anywhere; }
.preset-title { display: block; font-size: .78rem; color: var(--ink-muted); }
.source-note { font-size: .75rem; color: var(--ink-muted); margin-top: 1.6rem; }

/* Center: equation and observation stage. */
.visual-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.visual-top h2 { font-weight: 450; }
.equation { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: .1em .45em; min-height: 3.2rem; font-size: clamp(1.5rem, 2.6vw, 2.5rem); font-weight: 380; letter-spacing: -.035em; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.equation .operator, .equation .arrow { color: var(--ink-muted); font-weight: 300; }
.equation .add { color: var(--indigo); }
.equation .subtract { color: var(--ochre); }
.equation .answer { color: var(--vermilion); font-weight: 480; }

/* Sized so equation, stage, playback controls and the step caption fit one screen. */
.stage { position: relative; flex: none; height: clamp(300px, calc(100svh - 392px), 640px); margin-top: .8rem; }
.stage-canvas { position: absolute; inset: 1px; overflow: hidden; cursor: grab; touch-action: none; background:
  radial-gradient(circle at 50% 45%, var(--paper-bright), var(--paper) 70%); }
.stage-canvas:active { cursor: grabbing; }
.stage-canvas:focus-visible { outline-offset: -4px; }
.stage-canvas canvas { display: block; width: 100%; height: 100%; }
.corner { position: absolute; z-index: 2; width: 1.4rem; height: 1.4rem; pointer-events: none; opacity: .75; }
.corner::before, .corner::after { content: ""; position: absolute; background: var(--ink-muted); }
.corner::before { width: 100%; height: 1px; }
.corner::after { width: 1px; height: 100%; }
.corner--nw { top: 0; left: 0; }
.corner--ne { top: 0; right: 0; transform: rotate(90deg); }
.corner--sw { bottom: 0; left: 0; transform: rotate(-90deg); }
.corner--se { bottom: 0; right: 0; transform: rotate(180deg); }
.stage-reading { position: absolute; z-index: 3; font-size: .62rem; pointer-events: none; }
.stage-reading--nw { top: .7rem; left: 2rem; }
.stage-reading--ne { top: .7rem; right: 2rem; color: var(--ink); }
.stage-reading--sw { bottom: .7rem; left: 2rem; }
.stage-reading--se { bottom: .45rem; right: 1.6rem; pointer-events: auto; }
.quiet { border: 0; background: none; padding: .3rem .4rem; }
.quiet:hover { color: var(--ink); }
/* Small badge instead of a full cover: the previous result stays visible while the next one loads. */
.scene-loading { position: absolute; z-index: 4; top: .55rem; left: 50%; transform: translateX(-50%); padding: .2rem .6rem; border: 1px solid var(--hairline); background: var(--paper-bright); font: .62rem var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); pointer-events: none; }
.stage-canvas canvas { transition: opacity .22s ease-out; }
.visual-panel[aria-busy="true"] .stage-canvas canvas { opacity: .5; transition-duration: .12s; }

.scene-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-top: 1rem; padding: .9rem 0; border-top: 1px solid var(--hairline-soft); text-transform: none; letter-spacing: .01em; font-size: .72rem; }
.swatch { display: inline-block; vertical-align: middle; width: 18px; height: 2px; margin-right: .45rem; background: var(--swatch); }
.swatch.dashed { height: 0; background: none; border-top: 1px dashed var(--ink-muted); }
.swatch.dot { width: 7px; height: 7px; border-radius: 50%; }
.swatch.arc { width: 14px; height: 7px; background: none; border: 1.5px solid var(--swatch); border-bottom: 0; border-radius: 14px 14px 0 0; }
.swatch.dashed { border-top-color: var(--vermilion); }

.animation-controls { padding-top: .8rem; }
.timeline { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 1rem; }
.play-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .4rem .9rem; font-size: .85rem; border: 1px solid var(--ink); white-space: nowrap; }
.play-button { min-width: 84px; background: var(--ink); color: var(--paper); }
.play-button svg { width: 14px; height: 14px; fill: currentColor; }
.play-button:hover { background: transparent; color: var(--ink); }
.ghost-button { background: transparent; border-color: var(--hairline); color: var(--ink); }
.ghost-button:hover:not(:disabled) { border-color: var(--ink); }
.ghost-button.is-recording { border-color: var(--vermilion); color: var(--vermilion); }
.track { min-width: 0; padding-top: 6px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: linear-gradient(to right, var(--ink) var(--fill, 100%), var(--hairline) var(--fill, 100%)); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--hairline); }
input[type="range"]::-moz-range-progress { height: 1px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -5px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
.step-labels { display: flex; justify-content: space-between; gap: .5rem; }
.step-labels button { border: 0; background: none; padding: .2rem 0; font-size: .62rem; }
.step-labels button.active { color: var(--vermilion); }
.step-labels button:hover { color: var(--ink); }
.step-caption { margin-top: .6rem; min-height: 1.6em; font-size: .95rem; letter-spacing: -.01em; color: var(--ink); }
.record-status { margin-top: .6rem; text-transform: none; letter-spacing: .01em; font-size: .72rem; }
.record-status:empty { display: none; }
.record-download { display: inline-block; margin-top: .4rem; font-size: .85rem; color: var(--vermilion); }
.projection-note { margin-top: .4rem; max-width: 72ch; font-size: .78rem; line-height: 1.75; color: var(--ink-muted); }

/* Right: results. */
.best-result { padding: .4rem 0 1.4rem; border-bottom: 1px solid var(--hairline-soft); overflow-wrap: anywhere; }
.best-result > span { font-size: .78rem; color: var(--ink-muted); }
.best-result strong { display: block; margin: .3rem 0 .8rem; font-size: clamp(2rem, 2.8vw, 2.7rem); font-weight: 450; line-height: 1.1; letter-spacing: -.04em; color: var(--vermilion); }
.best-result > div { display: flex; align-items: baseline; gap: .6rem; }
#best-score { font: 450 1.3rem/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.score-unit { font-size: .75rem; color: var(--ink-muted); }

.model-comparison { padding: 1.1rem 0; border-bottom: 1px solid var(--hairline-soft); }
.model-comparison h3 { margin-bottom: .6rem; font-weight: 450; }
.model-comparison table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .85rem; }
.model-comparison th { padding: 0 0 .35rem; text-align: left; font-weight: 400; font-size: .72rem; color: var(--ink-muted); }
.model-comparison th:first-child { width: 26%; }
.model-comparison th:last-child { width: 30%; }
.model-comparison td { padding: .3rem 0; border-top: 1px solid var(--hairline-soft); overflow-wrap: anywhere; }
.model-comparison td:last-child, .model-comparison th:last-child { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.model-comparison tr.is-current td { color: var(--vermilion); }
.model-comparison p { margin-top: .6rem; font-size: .72rem; color: var(--ink-muted); line-height: 1.7; }

.rank-note { margin: 1.1rem 0 .3rem; text-transform: none; letter-spacing: .01em; font-family: var(--sans); font-size: .75rem; }
.ranking { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranking li { counter-increment: rank; }
.ranking button { position: relative; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; align-items: baseline; gap: .4rem; width: 100%; padding: .55rem 0 .65rem; border: 0; background: none; text-align: left; font-size: .95rem; }
.ranking button::before { content: counter(rank, decimal-leading-zero); font: .66rem var(--mono); color: var(--ink-muted); }
.rank-word { overflow-wrap: anywhere; }
.rank-score { font: .75rem var(--mono); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.rank-bar { position: absolute; left: 2rem; bottom: 0; height: 1px; width: calc((100% - 2rem) * var(--score)); background: var(--hairline); transition: width .4s cubic-bezier(.16, 1, .3, 1); }
.ranking li:first-child .rank-bar { background: var(--vermilion); }
.ranking button:hover .rank-word { color: var(--vermilion); }

.reading-note { margin-top: 1.6rem; padding-top: 1.1rem; border-top: 1px solid var(--hairline-soft); }
.reading-note h3 { font-weight: 450; margin-bottom: .5rem; }
.reading-note p { font-size: .8rem; line-height: 1.75; color: var(--ink-muted); margin-top: .5rem; }

/* Medium: results move under the stage. */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); }
  .explore-panel { grid-row: 1 / 3; }
  .results-panel { grid-column: 2; border-left: 0; border-top: 1px solid var(--hairline-soft); display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr); gap: 0 2rem; align-content: start; }
  .results-panel > .visual-top, .model-comparison, .reading-note { grid-column: 1 / -1; }
  .best-result { border-bottom: 0; }
  .reading-exp { display: none; }
}

/* Small: one column. */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .site-header { padding: .8rem 1rem; gap: .5rem 1rem; }
  .step { padding: .55rem 1rem; gap: 0 .5rem; }
  .step-name { font-size: 1.05rem; }
  .step-desc { font-size: .56rem; }
  .readings { width: 100%; justify-content: space-between; gap: .6rem; }
  #model-label { display: none; }
  .workspace { display: flex; flex-direction: column; }
  .explore-panel, .results-panel { padding: 1.2rem 1rem; border: 0; }
  .explore-panel { border-bottom: 1px solid var(--hairline-soft); }
  .explore-panel h1 { font-size: 1.15rem; margin-bottom: 1rem; }
  .explore-panel h1 br { display: none; }
  #analogy-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .5rem; }
  #analogy-form h1, #analogy-form .submit { grid-column: 1 / -1; }
  .term-field label { font-size: .72rem; gap: .3rem; }
  .autocomplete input { font-size: 16px; padding: .5rem; }
  .term-field:last-of-type .suggest-menu { left: auto; min-width: 160px; }
  .recommendations { margin-top: 1.2rem; }
  #recommend-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
  .preset-equation { font-size: .72rem; }
  .preset-title { font-size: .7rem; }
  .source-note { display: none; }
  .visual-panel { padding: 1.2rem 1rem; }
  .stage { flex: none; height: 380px; min-height: 380px; }
  .stage-reading--sw { display: none; }
  .stage-reading--nw, .stage-reading--sw { left: 1.6rem; }
  .stage-reading--ne { right: 1.6rem; }
  .timeline { grid-template-columns: auto minmax(0, 1fr); }
  .timeline .ghost-button { grid-column: 1 / -1; justify-self: start; }
  .step-labels button { font-size: .56rem; }
  .results-panel { display: block; border-top: 1px solid var(--hairline-soft); }
  .best-result strong { font-size: 1.9rem; }
  .best-result > div { display: block; }
  .score-unit { display: block; margin-top: .3rem; }
}

/* Press feedback: immediate and small, so frequent clicks never wait on decoration. */
.primary, .play-button, .ghost-button, .recommendation, .ranking button, .step-labels button, .mode-tabs button, .suggest-menu button, .quiet {
  transition: transform .12s ease-out, background .15s, color .15s, border-color .15s;
}
:is(.primary, .play-button, .ghost-button, .recommendation, .ranking button, .step-labels button, .mode-tabs button, .quiet):active:not(:disabled) { transform: scale(.97); }
/* Suggestions fade in from just above the field; they leave instantly. */
.suggest-menu { transition: opacity .15s ease-out, transform .15s ease-out; }
@starting-style { .suggest-menu { opacity: 0; transform: translateY(-4px); } }

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