:root {
  --bg: #e6ebe8;
  --bg-deep: #d5ddd8;
  --ink: #14201a;
  --ink-soft: #3d4f45;
  --muted: #6a7a70;
  --panel: rgba(255, 252, 247, 0.82);
  --panel-solid: #fffdf8;
  --line: rgba(20, 32, 26, 0.12);
  --accent: #b84a1b;
  --accent-deep: #8f3410;
  --teal: #1f6f64;
  --cell: #f4f1ea;
  --cell-hot: #f0d3c0;
  --shadow: 0 24px 60px rgba(20, 32, 26, 0.08);
  --radius: 18px;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 12% -10%, #f7f3e8 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #c9ddd6 0%, transparent 50%),
    linear-gradient(165deg, #eef2ee 0%, var(--bg) 45%, #dfe8e2 100%);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

a { color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--accent-deep); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  max-width: 1180px;
  margin: 0 auto;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.links {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.92rem;
}

.links a { color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.links a:hover { color: var(--accent); }
.links a[aria-current="page"] { color: var(--accent-deep); }

.pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.hero {
  min-height: calc(100vh - 5.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem 0 3rem;
  animation: rise 0.9s ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--teal);
}

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 14vw, 8.5rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-weight: 400;
}

.lede {
  max-width: 36rem;
  margin: 1.1rem 0 1.8rem;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.lede em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink);
}

.prompt-panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  animation: rise 1s 0.1s ease-out both;
}

textarea {
  width: 100%;
  border: 0;
  resize: vertical;
  min-height: 7rem;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  outline: none;
  padding: 0.4rem 0.5rem;
}

.prompt-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.toggles { display: flex; gap: 1rem; flex-wrap: wrap; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.toggle.muted { color: var(--muted); }

.toggle input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.run {
  appearance: none;
  border: 0;
  background: var(--ink);
  color: #f7f3ea;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.run:hover { background: var(--accent-deep); transform: translateY(-1px); }
.run:disabled { opacity: 0.55; cursor: wait; transform: none; }

.run-spin {
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(247, 243, 234, 0.25);
  border-top-color: #f7f3ea;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
  animation: rise 1.05s 0.18s ease-out both;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.65);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chip:hover, .chip.active {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: #fff;
}

.results {
  margin-top: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  animation: rise 0.55s ease-out both;
}

.results-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 400;
}

.results-head p {
  margin: 0.5rem 0 1.4rem;
  color: var(--ink-soft);
  max-width: 46rem;
  line-height: 1.5;
}

.viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: start;
}

.grid-wrap {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  overflow: auto;
  box-shadow: var(--shadow);
}

.y-label, .x-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0.2rem 0 0.55rem;
}

.x-label { margin-top: 0.7rem; margin-bottom: 0; }

.grid {
  display: grid;
  gap: 2px;
  width: max-content;
  min-width: 100%;
}

.grid.compact { margin-top: 0.5rem; }

.cell {
  appearance: none;
  border: 0;
  background: var(--cell);
  min-width: 4.2rem;
  height: 1.85rem;
  padding: 0 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 3px;
  transition: background 0.12s ease, outline 0.12s ease;
}

.cell:hover { background: var(--cell-hot); }
.cell.selected {
  outline: 2px solid var(--accent);
  background: #f6c9ae;
  z-index: 1;
}

.cell.head {
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  cursor: default;
  height: auto;
  min-height: 2.4rem;
  writing-mode: horizontal-tb;
  white-space: pre-wrap;
  line-height: 1.15;
  text-align: left;
  padding: 0.2rem;
}

.cell.ylab {
  background: transparent;
  color: var(--muted);
  cursor: default;
  min-width: 2.4rem;
  text-align: right;
  padding-right: 0.4rem;
}

.cell.final { background: #dcebe4; font-weight: 500; }
.cell.stale {
  opacity: 0.28;
  color: var(--muted);
  background: transparent;
}
.cell.changed {
  background: #f0d3c0;
  font-weight: 500;
}
.cell.stale.selected,
.cell.changed.selected {
  opacity: 1;
}

.detail {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 1rem;
}

.detail h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
}

.detail-meta {
  margin: 0.45rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.topk {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.topk li {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  background: var(--bg);
}

.topk .rank { color: var(--muted); }
.topk .token { color: var(--ink); font-weight: 500; }
.topk .score { color: var(--teal); font-size: 0.75rem; }

.logit-block {
  margin-top: 1.4rem;
  padding: 1rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.logit-block h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.35rem;
}

.about {
  margin-top: 3.5rem;
  max-width: 42rem;
}

.about h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  margin: 0 0 0.7rem;
}

.about p {
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 1rem;
}

.about code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: rgba(255, 253, 248, 0.8);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; }
  .detail { position: static; }
  .hero { min-height: auto; padding-top: 1.5rem; }
  .logo { font-size: clamp(3.6rem, 18vw, 5.5rem); }
  .showcase-layout { grid-template-columns: 1fr; }
}

/* —— Showcase —— */
.showcase-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.showcase-hero {
  padding: 1.5rem 0 1.2rem;
  animation: rise 0.7s ease-out both;
}

.showcase-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 4.5rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
}

.showcase-meta {
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.showcase-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}

.showcase-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: sticky;
  top: 1rem;
}

.showcase-item {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: var(--font-body);
  color: var(--ink);
}

.showcase-item strong {
  font-size: 0.95rem;
  font-weight: 600;
}

.showcase-item span {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.showcase-item:hover,
.showcase-item.active {
  border-color: var(--accent);
  background: var(--panel-solid);
}

.showcase-viewer {
  animation: rise 0.45s ease-out both;
}

.prompt-preview {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--ink-soft);
  max-height: 9rem;
  overflow: auto;
}

.showcase-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.95rem;
}
