/* ============================================================
   कारक · Karaka — site design system
   "The digital pothi" — a manuscript that computes.
   Static CSS, no build step. Light manuscript theme only.
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */

:root {
  --paper: #faf7f0;
  --paper-raise: #fffdf8;
  --paper-deep: #f3eee1;
  --ink: #1c1410;
  --ink-soft: rgba(28, 20, 16, 0.74);
  --ink-faint: rgba(28, 20, 16, 0.46);
  --brick: #9b4a3f;
  --brick-deep: #7a352c;
  --brick-wash: rgba(155, 74, 63, 0.07);
  --gold: #b98a2f;
  --gold-soft: rgba(185, 138, 47, 0.55);
  --line: #e8e0d2;

  --font-display: 'Rozha One', 'Noto Serif Devanagari', serif;
  --font-body: 'Martel', 'Noto Serif Devanagari', serif;
  --font-code: 'Noto Sans Devanagari', 'JetBrains Mono', monospace;

  --nav-h: 4rem;
  --maxw: 71rem;
  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(28, 20, 16, 0.05), 0 12px 32px -18px rgba(28, 20, 16, 0.22);
}

/* ── Reset & base ───────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain — site-wide, non-interactive */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='280'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 0.6em;
  color: var(--ink);
}

p { margin: 0 0 1.1em; }

a {
  color: var(--brick);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-soft);
  transition: color 0.18s ease, border-color 0.18s ease;
}
a:hover { color: var(--brick-deep); border-bottom-color: var(--gold); }

code, pre, kbd {
  font-family: var(--font-code);
  font-size: 0.92em;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection { background: rgba(185, 138, 47, 0.25); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Navigation (sticky, go.dev style) ──────────────────── */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 247, 240, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-nav .nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--nav-h);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1.5rem;
}

.nav-mark {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
  border-bottom: none;
  letter-spacing: 0.01em;
}
.nav-mark:hover { color: var(--brick); border-bottom: none; }
.nav-mark .danda { color: var(--gold); margin-left: 0.06em; }

.nav-links {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  padding: 0 0.9rem;
  border-bottom: none;
  color: var(--ink-soft);
  white-space: nowrap;
}
.nav-link:hover { color: var(--brick-deep); border-bottom: none; }

.nav-link .deva {
  font-size: 1.02rem;
  line-height: 1.4;
}
.nav-link .latin {
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  line-height: 1;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: -1px;
  height: 2px;
  background: transparent;
  transition: background 0.18s ease;
}
.nav-link:hover::after { background: var(--line); }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"]::after { background: var(--brick); }

.nav-toggle {
  display: none;
  align-self: center;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--brick); color: var(--brick); }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 32px -20px rgba(28, 20, 16, 0.3);
    padding: 0.25rem 0 0.5rem;
  }
  .nav-links.open { display: flex; }
  .nav-link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 1.5rem;
  }
  .nav-link::after { display: none; }
  .nav-link[aria-current="page"] {
    border-left: 3px solid var(--brick);
    padding-left: calc(1.5rem - 3px);
    background: var(--brick-wash);
  }
  .nav-link .latin { font-size: 0.6rem; }
}

/* ── Danda section divider ──────────────────────────────── */

.danda-rule {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.danda-rule::before,
.danda-rule::after {
  content: '';
  flex: 1;
  border-top: 3px double var(--line);
}
.danda-rule > span {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold);
  line-height: 1;
  transform: translateY(-0.1em);
  user-select: none;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.4;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--brick);
  background: var(--brick);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
}
.btn:hover { background: var(--brick-deep); border-color: var(--brick-deep); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn .latin { font-size: 0.72em; opacity: 0.85; letter-spacing: 0.06em; }
.btn[disabled] { opacity: 0.55; cursor: progress; }

.btn-ghost {
  background: transparent;
  color: var(--brick);
  border-color: rgba(155, 74, 63, 0.45);
}
.btn-ghost:hover { background: var(--brick-wash); color: var(--brick-deep); }

.btn-small { padding: 0.35rem 0.9rem; font-size: 0.83rem; }

a.btn, a.btn-ghost { border-bottom-width: 1px; }

/* ── Editor / run components (karaka-ui) ────────────────── */

.kr-card {
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.kr-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(243, 238, 225, 0.6), rgba(243, 238, 225, 0.15));
}

.kr-card-title {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
.kr-card-title .deva {
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-soft);
  margin-right: 0.4em;
}

.kr-editor {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.7;
  padding: 0.9rem 1.1rem;
  resize: vertical;
  min-height: 8rem;
  caret-color: var(--brick);
  tab-size: 2;
}
.kr-editor:focus { outline: none; }
.kr-card:focus-within { border-color: rgba(155, 74, 63, 0.4); }

.kr-card-foot {
  border-top: 1px solid var(--line);
}

.kr-out-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem 0.1rem;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.kr-out {
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.7;
  padding: 0.35rem 1.1rem 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.6rem;
}

.kr-out .out-line {
  display: block;
  animation: kr-line-in 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

.kr-out .out-empty {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.8rem;
}

/* Bilingual diagnostic — manuscript margin note */
.kr-error {
  border-left: 3px solid var(--brick);
  background: var(--brick-wash);
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 0.6rem 0.9rem;
  margin: 0.4rem 0;
  white-space: pre-wrap;
  word-break: break-word;
  animation: kr-line-in 0.4s ease both;
}
.kr-error .kr-error-note {
  display: block;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.74rem;
  color: var(--ink-faint);
  margin-top: 0.3rem;
}

/* ── The signature: अभिलेख trace cascade ────────────────── */

.kr-trace {
  font-family: var(--font-code);
  font-size: 0.8rem;
  line-height: 1.75;
  padding: 0.4rem 1.1rem 0.9rem;
}

.trace-rec {
  position: relative;
  margin-left: calc(var(--depth, 0) * 1.4rem);
  padding: 0.1rem 0 0.1rem 0.8rem;
  border-left: 2px solid var(--brick);
  animation: kr-rec-in 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
  word-break: break-word;
}
.trace-rec + .trace-rec { margin-top: 0.2rem; }

.trace-rec[data-kind="builtin"] { border-left-color: var(--line); }
.trace-rec[data-kind="builtin"] .trace-name { color: var(--ink-faint); }
.trace-rec[data-kind="niyama"] { border-left-color: var(--gold); }
.trace-rec[data-kind="niyama"] .trace-name { color: var(--brick-deep); font-weight: 600; }

.trace-name { color: var(--ink); }
.trace-roles { color: var(--ink-soft); }
.trace-arrow { color: var(--gold); }
.trace-result { color: var(--brick-deep); }
.trace-result.is-dosha { color: var(--brick); font-weight: 600; }
.trace-evidence { color: var(--gold); }

.trace-empty {
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-body);
  font-size: 0.8rem;
}

@keyframes kr-rec-in {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
@keyframes kr-line-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── Page-load reveal ───────────────────────────────────── */

.reveal {
  animation: kr-reveal 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--r, 0) * 110ms);
}
@keyframes kr-reveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Scroll-triggered reveal (only when JS present) */
html.js .reveal-io {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.3, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
html.js .reveal-io.is-in { opacity: 1; transform: none; }

/* ── Hero ───────────────────────────────────────────────── */

.hero {
  position: relative;
  overflow: hidden;
  padding: 4.5rem 0 4rem;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}
.hero-bg span {
  position: absolute;
  font-family: var(--font-display);
  color: var(--ink);
  white-space: nowrap;
  line-height: 1;
  will-change: transform;
}
.hero-bg .w1 { top: -4%;    left: -4%;   font-size: 13rem; opacity: 0.055; animation: drift-a 76s ease-in-out infinite alternate; }
.hero-bg .w2 { top: 56%;    left: 8%;    font-size: 10rem; opacity: 0.05;  animation: drift-b 88s ease-in-out infinite alternate; }
.hero-bg .w3 { top: 8%;     right: -8%;  font-size: 12rem; opacity: 0.06;  animation: drift-c 64s ease-in-out infinite alternate; }
.hero-bg .w4 { bottom: -10%; right: 4%;  font-size: 9.5rem; opacity: 0.055; animation: drift-a 90s ease-in-out infinite alternate-reverse; }
.hero-bg .w5 { bottom: 14%; left: 30%;   font-size: 8.5rem; opacity: 0.045; animation: drift-b 70s ease-in-out infinite alternate-reverse; }
.hero-bg .w6 { top: 30%;    right: 26%;  font-size: 7.5rem; opacity: 0.05;  animation: drift-c 82s ease-in-out infinite alternate-reverse; }

@keyframes drift-a { from { transform: translate(0, 0); }       to { transform: translate(56px, -38px); } }
@keyframes drift-b { from { transform: translate(0, 0); }       to { transform: translate(-48px, 30px); } }
@keyframes drift-c { from { transform: translate(0, 0); }       to { transform: translate(34px, 46px); } }

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3.5rem;
  align-items: start;
}

.hero-title {
  font-size: clamp(4.2rem, 9vw, 6.8rem);
  line-height: 1.1;
  margin: 0 0 0.5rem;
  letter-spacing: 0.005em;
}
.hero-title .danda { color: var(--gold); font-size: 0.55em; vertical-align: 0.18em; margin-left: 0.08em; }

.hero-sub {
  font-family: var(--font-body);
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brick);
  font-weight: 600;
  margin: 0 0 1.6rem;
}

.hero-thesis {
  font-size: 1.18rem;
  line-height: 1.95;
  color: var(--ink);
  max-width: 32em;
  margin-bottom: 1.2rem;
}

.hero-sutra {
  font-family: var(--font-display);
  font-size: 1.12rem;
  color: var(--ink-soft);
  line-height: 2;
  margin-bottom: 2.2rem;
}
.hero-sutra .danda { color: var(--gold); }

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

@media (max-width: 940px) {
  .hero { padding-top: 3rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero-bg .w2, .hero-bg .w5 { display: none; }
}

/* ── Sections / feature panels ──────────────────────────── */

.section { padding: 4.5rem 0; }
.section-tight { padding: 3.25rem 0; }

.section-kicker {
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.section-title {
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  margin-bottom: 0.4em;
}
.section-title .danda { color: var(--gold); }

.feature {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 3rem;
  align-items: start;
  padding: 3.4rem 0;
}
.feature + .feature { border-top: 1px solid var(--line); }
.feature.flip .feature-copy { order: 2; }
.feature.flip .feature-demo { order: 1; }

.feature-copy h3 {
  font-size: 1.55rem;
  margin-bottom: 0.5em;
}
.feature-copy h3 .latin {
  display: block;
  font-family: var(--font-body);
  font-size: 0.6em;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-top: 0.3em;
}
.feature-copy p { color: var(--ink-soft); font-size: 0.98rem; }
.feature-copy .gloss {
  font-size: 0.85rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--line);
  padding-left: 0.9rem;
}
.feature-copy .gloss b { color: var(--brick); font-weight: 600; }

@media (max-width: 880px) {
  .feature { grid-template-columns: 1fr; gap: 1.6rem; padding: 2.6rem 0; }
  .feature.flip .feature-copy { order: 1; }
  .feature.flip .feature-demo { order: 2; }
}

/* ── Transliteration callout ────────────────────────────── */

.translit-band {
  background: var(--paper-deep);
  border-top: 3px double var(--line);
  border-bottom: 3px double var(--line);
  padding: 3.5rem 0;
}

.translit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.translit-demo {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.translit-input {
  font-family: var(--font-code);
  font-size: 1.05rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raise);
  color: var(--ink);
  width: 100%;
}
.translit-input:focus { outline: none; border-color: var(--brick); }

.translit-out {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.4;
  color: var(--brick);
  min-height: 1.4em;
  word-break: break-word;
}

.translit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.translit-chips button {
  font-family: var(--font-code);
  font-size: 0.78rem;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.translit-chips button:hover { border-color: var(--brick); color: var(--brick); }

@media (max-width: 880px) {
  .translit-grid { grid-template-columns: 1fr; gap: 1.8rem; }
}

/* ── Getting started strip ──────────────────────────────── */

.start-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.start-code {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 2;
  overflow-x: auto;
  box-shadow: var(--shadow-card);
  margin: 0;
}
.start-code .ps1 { color: var(--gold); user-select: none; }
.start-code .cmt { color: rgba(250, 247, 240, 0.45); }

@media (max-width: 880px) {
  .start-strip { grid-template-columns: 1fr; gap: 1.6rem; }
}

/* ── Footer ─────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: 2.2rem 0 2.6rem;
  font-size: 0.85rem;
  color: var(--ink-faint);
}
.site-footer .foot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.site-footer .foot-mark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink-soft);
}
.site-footer .foot-mark .danda { color: var(--gold); }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--brick); }
.site-footer .foot-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; }

/* ── Toolbar (play / repl pages) ────────────────────────── */

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1.1rem;
  padding: 1.1rem 0 1rem;
}
.tool-row .spacer { flex: 1; }

.tool-label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  user-select: none;
}
.tool-label input[type="checkbox"] {
  accent-color: var(--brick);
  width: 0.95rem;
  height: 0.95rem;
  cursor: pointer;
}

.tool-select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  max-width: 100%;
  cursor: pointer;
}
.tool-select:focus { outline: none; border-color: var(--brick); }

.tool-hint {
  font-size: 0.74rem;
  color: var(--ink-faint);
  font-style: italic;
}

.kr-status {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: var(--font-code);
  min-height: 1.2em;
}
.kr-status.ok { color: var(--gold); }
.kr-status.err { color: var(--brick); }

/* ── Play page layout ───────────────────────────────────── */

.play-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1.4rem;
  align-items: stretch;
  padding-bottom: 3rem;
}

.play-grid .kr-card { display: flex; flex-direction: column; }
.play-grid .kr-editor { flex: 1; min-height: 24rem; }

.pane-tabs {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.pane-tab {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-faint);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.pane-tab:hover { color: var(--brick); }
.pane-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--brick);
}

.sub-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.sub-toggle button {
  font-family: var(--font-body);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  background: none;
  border: 0;
  color: var(--ink-faint);
  padding: 0.22rem 0.6rem;
  cursor: pointer;
}
.sub-toggle button[aria-pressed="true"] {
  background: var(--brick);
  color: var(--paper);
}

.kr-pane {
  flex: 1;
  overflow: auto;
  min-height: 18rem;
}

.kr-jsonl {
  margin: 0;
  padding: 0.6rem 1.1rem 1rem;
  font-size: 0.72rem;
  line-height: 1.8;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink-soft);
}

@media (max-width: 940px) {
  .play-grid { grid-template-columns: 1fr; }
  .play-grid .kr-editor { min-height: 16rem; }
  .kr-pane { min-height: 12rem; }
}

/* ── REPL page ──────────────────────────────────────────── */

.repl-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h) - 11.5rem);
  min-height: 26rem;
}

.repl-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  font-family: var(--font-code);
  font-size: 0.86rem;
  line-height: 1.8;
}

.repl-entry { margin-bottom: 0.15rem; word-break: break-word; }
.repl-entry .prompt { color: var(--gold); user-select: none; margin-right: 0.5em; }
.repl-entry.echo { color: var(--ink); }
.repl-entry.out { white-space: pre-wrap; animation: kr-line-in 0.35s ease both; animation-delay: calc(var(--i, 0) * 40ms); }
.repl-entry.value { color: var(--brick-deep); animation: kr-line-in 0.35s ease both; }
.repl-entry.value .arrow { color: var(--gold); margin-right: 0.5em; }
.repl-entry.note {
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-align: center;
  margin: 0.6rem 0;
}

.repl-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-top: 1px solid var(--line);
  padding: 0.65rem 1.2rem;
  background: linear-gradient(to bottom, rgba(243, 238, 225, 0.5), rgba(243, 238, 225, 0.1));
}
.repl-prompt {
  font-family: var(--font-code);
  font-size: 0.9rem;
  color: var(--gold);
  white-space: nowrap;
  user-select: none;
}
.repl-input {
  flex: 1;
  font-family: var(--font-code);
  font-size: 0.9rem;
  background: transparent;
  border: 0;
  color: var(--ink);
  caret-color: var(--brick);
  padding: 0.2rem 0;
}
.repl-input:focus { outline: none; }

.repl-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  padding: 0.8rem 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
}
.repl-hints .chip {
  font-family: var(--font-code);
  font-size: 0.76rem;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.repl-hints .chip:hover { border-color: var(--brick); color: var(--brick); }

/* ── 404 ────────────────────────────────────────────────── */

.err-page {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem 5rem;
}
.err-code {
  font-family: var(--font-display);
  font-size: clamp(4rem, 12vw, 7rem);
  color: var(--brick);
  line-height: 1.1;
  margin: 0 0 1.4rem;
}
.err-diag {
  display: inline-block;
  text-align: left;
  border-left: 3px solid var(--brick);
  background: var(--brick-wash);
  font-family: var(--font-code);
  font-size: 0.92rem;
  line-height: 1.8;
  padding: 0.8rem 1.2rem;
  margin-bottom: 2rem;
}

/* ── Toast ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.84rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Editor upgrade — syntax highlighting, टीका margin, value chips,
   live affordances. Swift-Playgrounds interaction, manuscript skin.
   ============================================================ */

/* ── Syntax highlight layer ─────────────────────────────────
   A transparent-text textarea sits over a synced <pre> mirror.
   Both MUST share identical typography (font, size, line-height,
   padding, tab-size, wrapping) for the layers to register. */

.kr-hl-wrap {
  position: relative;
  display: block;
}
/* On the play page the editor must fill the card; make the wrapper and the
   textarea inside it flex to fill .play-editor-wrap's column. */
.play-editor-wrap .kr-hl-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.play-editor-wrap .kr-hl-wrap > .kr-editor { flex: 1; }

.kr-hl,
.kr-hl-input {
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.7;
  padding: 0.9rem 1.1rem;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  border: 0;
  margin: 0;
}

.kr-hl {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: auto;
  pointer-events: none;
  color: var(--ink);
  background: transparent;
}
.kr-hl code { font: inherit; white-space: inherit; word-break: inherit; }

/* The textarea: transparent text over the mirror, caret + selection visible. */
.kr-hl-input {
  position: relative;
  z-index: 1;
  background: transparent;
  -webkit-text-fill-color: transparent;
  color: transparent;
  caret-color: var(--brick);
}
.kr-hl-input::selection { background: rgba(185, 138, 47, 0.28); -webkit-text-fill-color: transparent; }
.kr-hl-input::-moz-selection { background: rgba(185, 138, 47, 0.28); }

/* Token palette — manuscript ink/brick/gold/teal/green/sepia. */
.hl-keyword { color: var(--brick); }
.hl-role    { color: var(--gold); font-weight: 600; }   /* the six कारक — signature */
.hl-const   { color: #2f6b6b; }                          /* deep teal / ink-blue */
.hl-string  { color: #5c7a4a; }                          /* muted manuscript green */
.hl-string-escape { color: #8a9b3f; }
.hl-interp  { color: var(--brick-deep); font-weight: 600; } /* {…} braces as exprs */
.hl-comment { color: rgba(124, 96, 64, 0.72); font-style: italic; } /* faded sepia */
.hl-number  { color: #9a6a2f; }                          /* gold-brown */
.hl-op      { color: var(--ink-soft); }
.hl-punct   { color: var(--ink-soft); }
.hl-ident   { color: var(--ink); }

/* ── Value chips (margin, output, REPL echo, trace cascade) ── */

.kr-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font-family: var(--font-code);
  font-size: 0.92em;
  line-height: 1.3;
  padding: 0.04em 0.5em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-raise);
  color: var(--ink);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-num  { color: #8a5e29; border-color: rgba(154, 106, 47, 0.35); background: rgba(185, 138, 47, 0.08); }
.chip-plain { color: var(--ink); }
.chip-coll { font-feature-settings: "tnum"; color: var(--ink-soft); background: var(--paper-deep); }
.chip-nil  { color: var(--ink-faint); font-style: italic; border-style: dashed; background: transparent; }

.chip-bool { font-weight: 600; }
.chip-bool.is-true  { color: #4a6b3a; border-color: rgba(74, 107, 58, 0.5); background: rgba(74, 107, 58, 0.1); }
.chip-bool.is-false { color: var(--brick); border-color: rgba(155, 74, 63, 0.45); background: transparent; }

.chip-verdict { font-weight: 600; }
.chip-verdict.verdict-yes   { color: #3f6b34; border-color: rgba(63, 107, 52, 0.55); background: rgba(63, 107, 52, 0.12); }
.chip-verdict.verdict-no    { color: var(--brick); border-color: rgba(155, 74, 63, 0.5); background: var(--brick-wash); }
.chip-verdict.verdict-maybe { color: #9a6a2f; border-color: var(--gold-soft); background: rgba(185, 138, 47, 0.1); }

.chip-evidence {
  font-size: 0.82em;
  font-weight: 400;
  color: var(--ink-faint);
  font-style: italic;
}

.chip-dosha {
  color: var(--brick);
  font-weight: 600;
  border-color: var(--brick);
  background: var(--brick-wash);
  border-left-width: 3px;
  border-radius: 3px;
  white-space: normal;
}

/* ── The टीका results margin ────────────────────────────────
   Right rail aligned to the editor's lines. Chips sit absolutely
   at (line-1)*lineHeight; a faint brick connector reaches left. */

.play-editor-wrap { position: relative; display: flex; flex: 1; min-height: 0; }
.play-editor-wrap .kr-hl-wrap { flex: 1; }

.kr-tika {
  position: relative;
  flex: 0 0 15rem;
  max-width: 40%;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background:
    repeating-linear-gradient(
      to right,
      transparent, transparent 0,
      transparent
    ),
    var(--paper-deep);
}
.kr-tika::before {
  content: 'टीका';
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--gold);
  opacity: 0.7;
  z-index: 2;
  pointer-events: none;
}
.kr-tika[data-empty] { background: var(--paper-deep); }

.tika-inner { position: relative; width: 100%; }

.tika-slot {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-left: 1.1rem;
  padding-right: 0.6rem;
}

.tika-note {
  position: relative;
  display: flex;
  align-items: center;
}
.tika-connector {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0.8rem;
  height: 0;
  border-top: 1px dashed var(--brick);
  opacity: 0.5;
}
.tika-note .kr-chip { font-size: 0.78rem; }
.tika-note[data-kind="niyama"] .tika-connector { border-top-style: solid; border-top-color: var(--gold); opacity: 0.65; }

.tika-cascade {
  animation: kr-rec-in 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* Mobile / narrow: the rail collapses into an inline list under the editor. */
.kr-tika-mobile {
  display: none;
  border-top: 1px solid var(--line);
  padding: 0.5rem 1.1rem 0.8rem;
}
.kr-tika-mobile .tika-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-code);
  font-size: 0.78rem;
  padding: 0.12rem 0;
}
.kr-tika-mobile .tika-row .ln {
  color: var(--ink-faint);
  min-width: 2.2rem;
  text-align: right;
  user-select: none;
}

@media (max-width: 940px) {
  .play-editor-wrap { flex-direction: column; }
  .kr-tika { display: none; }
  .kr-tika-mobile.has-notes { display: block; }
}

/* ── Live affordances: running shimmer + gold underline sweep ── */

.btn.is-running { position: relative; overflow: hidden; }
.btn.is-running::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(250, 247, 240, 0.35) 50%,
    transparent 80%
  );
  transform: translateX(-100%);
  animation: kr-shimmer 1.1s linear infinite;
}
@keyframes kr-shimmer { to { transform: translateX(100%); } }

.kr-sweep {
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  height: 1.7em;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(to bottom, transparent, rgba(185, 138, 47, 0.16), transparent);
  border-bottom: 2px solid var(--gold);
  transform-origin: left center;
  animation: kr-sweep 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes kr-sweep {
  from { clip-path: inset(0 100% 0 0); opacity: 0.9; }
  to   { clip-path: inset(0 0 0 0); opacity: 0; }
}

/* ============================================================
   उदाहरणानि · Examples — card grid into the playground.
   ============================================================ */

.examples-page { padding: 3rem 1.5rem 2rem; }
.examples-head { margin-bottom: 2.5rem; }

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.3rem;
  margin-bottom: 3rem;
}

.ex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.3rem 1.4rem 1.2rem;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.ex-card:hover {
  border-color: var(--brick);
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(28, 20, 16, 0.06), 0 18px 40px -20px rgba(28, 20, 16, 0.3);
}

/* The faint oversized glyph in the corner — the manuscript flourish. */
.ex-glyph {
  position: absolute;
  top: -0.5rem;
  right: 0.4rem;
  font-family: var(--font-display);
  font-size: 5.5rem;
  line-height: 1;
  color: var(--brick);
  opacity: 0.07;
  pointer-events: none;
  user-select: none;
}
.ex-card:hover .ex-glyph { opacity: 0.12; }

.ex-num {
  font-family: var(--font-code);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 500;
}
.ex-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.15;
  color: var(--ink);
  position: relative;
}
.ex-latin {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.ex-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-soft);
  flex: 1;
}

.ex-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.ex-badge {
  font-family: var(--font-body);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.ex-badge-trace { color: var(--gold); border-color: var(--gold-soft); background: rgba(185, 138, 47, 0.1); }
.ex-badge-cli { color: var(--brick); border-color: rgba(155, 74, 63, 0.4); background: var(--brick-wash); }

.ex-open {
  margin-top: 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brick);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ex-card:hover .ex-open, .ex-card:focus-visible .ex-open { opacity: 1; transform: none; }

.examples-foot { color: var(--ink-soft); font-size: 0.95rem; }

@media (max-width: 560px) {
  .examples-grid { grid-template-columns: 1fr; }
  .ex-open { opacity: 1; transform: none; } /* no hover on touch */
}

/* ============================================================
   लेखाः · Docs — rendered guide + behavior reference.
   Generated by build-docs.mjs; styled here. Article + sticky TOC.
   ============================================================ */

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 3rem;
  align-items: start;
  padding: 2.5rem 1.5rem 4rem;
}

.docs-article {
  min-width: 0;
  font-size: 1rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

.docs-article h1 {
  font-size: clamp(2.1rem, 4.2vw, 2.9rem);
  margin: 0 0 1rem;
  color: var(--ink);
}
.docs-article h1 .danda { color: var(--gold); font-size: 0.6em; vertical-align: 0.1em; }
.docs-article h2 {
  font-size: clamp(1.5rem, 3vw, 1.95rem);
  margin: 2.6rem 0 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.docs-article h3 {
  font-size: 1.28rem;
  margin: 1.9rem 0 0.6rem;
  color: var(--ink);
}
.docs-article h4 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.4rem;
  color: var(--brick-deep);
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Heading anchor — the faint # that appears on hover. */
.docs-article :is(h1, h2, h3, h4) { position: relative; scroll-margin-top: calc(var(--nav-h) + 1rem); }
.docs-article .anchor {
  position: absolute;
  left: -1.2rem;
  border: 0;
  color: var(--gold-soft);
  opacity: 0;
  font-family: var(--font-code);
  font-weight: 400;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.docs-article :is(h1, h2, h3, h4):hover .anchor { opacity: 1; }
.docs-article .anchor:hover { color: var(--brick); }

.docs-article p { margin: 0 0 1.05em; }
.docs-article strong, .docs-article b { color: var(--ink); font-weight: 600; }
.docs-article em { font-style: italic; color: var(--ink); }
.docs-article a { color: var(--brick); }

.docs-article :not(pre) > code {
  font-family: var(--font-code);
  font-size: 0.86em;
  background: var(--brick-wash);
  color: var(--brick-deep);
  padding: 0.05em 0.34em;
  border-radius: 3px;
  word-break: break-word;
}

.docs-article ul, .docs-article ol { margin: 0 0 1.1em; padding-left: 1.4rem; }
.docs-article li { margin: 0.2em 0; }
.docs-article li > ul, .docs-article li > ol { margin: 0.3em 0 0.4em; }
.docs-article ul { list-style: none; }
.docs-article ul > li { position: relative; }
.docs-article ul > li::before {
  content: '॰';
  position: absolute;
  left: -1.1rem;
  color: var(--gold);
}

/* Section divider rendered from a Markdown --- rule. */
.docs-rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.4rem 0;
}
.docs-rule::before, .docs-rule::after { content: ''; flex: 1; border-top: 3px double var(--line); }
.docs-rule > span { font-family: var(--font-display); color: var(--gold); font-size: 1rem; line-height: 1; user-select: none; }

/* Code blocks with a copy button. */
.code-block { position: relative; margin: 0 0 1.3rem; }
.code-block pre {
  margin: 0;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.7;
  box-shadow: var(--shadow-card);
}
.code-block pre code { font: inherit; color: var(--ink); white-space: pre; }
/* bash/json/plain blocks read as a terminal slab. */
.code-block pre.lang-bash, .code-block pre.lang-sh, .code-block pre.lang-shell {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.code-block pre.lang-bash code, .code-block pre.lang-sh code, .code-block pre.lang-shell code { color: var(--paper); }
.code-block pre.lang-json { background: var(--paper-deep); }

.copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  font-family: var(--font-body);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.18rem 0.5rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--brick); border-color: var(--brick); }
.copy-btn.copied { color: var(--gold); border-color: var(--gold); opacity: 1; }
.copy-btn .latin { letter-spacing: 0.08em; }

/* Tables. */
.table-wrap { overflow-x: auto; margin: 0 0 1.3rem; }
.docs-article table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.docs-article th, .docs-article td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.docs-article th {
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.docs-article tbody tr:last-child td { border-bottom: 0; }
.docs-article td code { white-space: nowrap; }

/* Prev / next pager. */
.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.docs-pager a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  max-width: 48%;
}
.docs-pager a:hover { border-color: var(--brick); }
.docs-pager .pager-next { text-align: right; align-items: flex-end; }
.docs-pager .dir { font-family: var(--font-display); color: var(--brick); font-size: 1.05rem; }
.docs-pager .lbl { font-size: 0.78rem; color: var(--ink-faint); }

/* Sticky right TOC. */
.docs-toc {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
  align-self: start;
  font-size: 0.84rem;
  max-height: calc(100vh - var(--nav-h) - 3rem);
  overflow-y: auto;
}
.docs-toc .toc-head {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 0 0 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.docs-toc li { margin: 0; }
.docs-toc a {
  display: block;
  padding: 0.22rem 0 0.22rem 0.85rem;
  margin-left: -1px;
  border: 0;
  border-left: 2px solid transparent;
  color: var(--ink-soft);
  line-height: 1.4;
}
.docs-toc a:hover { color: var(--brick); }
.docs-toc a.is-active { color: var(--brick); border-left-color: var(--brick); font-weight: 600; }
.docs-toc .toc-3 a { padding-left: 1.7rem; font-size: 0.92em; color: var(--ink-faint); }
.docs-toc .toc-3 a:hover, .docs-toc .toc-3 a.is-active { color: var(--brick); }

@media (max-width: 940px) {
  .docs-layout { grid-template-columns: 1fr; gap: 1rem; }
  .docs-toc { display: none; }
  .docs-article .anchor { display: none; }
}

/* ── Docs landing (two cards) ───────────────────────────── */

.docs-home { padding: 3rem 0 2rem; }
.docs-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
  margin: 2rem 0 3rem;
}
.docs-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.6rem 1.7rem;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.18s ease, transform 0.12s ease;
}
.docs-card:hover { border-color: var(--brick); transform: translateY(-2px); }
.docs-card .card-deva {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--ink);
  line-height: 1.1;
}
.docs-card .card-latin {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.docs-card p { color: var(--ink-soft); font-size: 0.94rem; margin: 0.2rem 0 0; line-height: 1.7; }
.docs-card .card-more { color: var(--brick); font-size: 0.86rem; font-weight: 600; margin-top: auto; padding-top: 0.6rem; }

@media (max-width: 760px) {
  .docs-cards { grid-template-columns: 1fr; }
}

/* ============================================================
   यात्रा · Tour — go.dev split: lesson prose left, live editor right.
   Reuses .kr-card / .play-editor-wrap / .kr-tika / .kr-tika-mobile.
   ============================================================ */

.tour-main { padding-bottom: 0; }

.tour-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
  align-items: stretch;
  min-height: calc(100vh - var(--nav-h) - 3.2rem);
  padding: 1.4rem 0 1.6rem;
}

/* ── Left: the manuscript lesson ─────────────────────────── */

.tour-lesson {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tour-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}
.tour-dot {
  width: 1.55rem;
  height: 1.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--ink-faint);
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tour-dot:hover { border-color: var(--brick); color: var(--brick); }
.tour-dot.is-current {
  border-color: var(--brick);
  background: var(--brick);
  color: var(--paper);
  font-weight: 600;
}
.tour-dot.is-done { color: var(--brick); border-color: rgba(155, 74, 63, 0.4); }
.tour-dot.is-done::after { content: '·'; }

.tour-eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.tour-eyebrow .latin { color: var(--ink-faint); }

.tour-title {
  font-size: clamp(1.9rem, 3.6vw, 2.5rem);
  line-height: 1.2;
  margin: 0 0 1rem;
}
.tour-title .danda { color: var(--gold); }

/* The prose body — manuscript reading column. */
.tour-prose {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--ink-soft);
  max-width: 38em;
}
.tour-prose p { margin: 0 0 1em; }
.tour-prose strong, .tour-prose b { color: var(--ink); font-weight: 600; }
.tour-prose em { font-style: italic; color: var(--ink); }
.tour-prose code {
  font-family: var(--font-code);
  font-size: 0.86em;
  background: var(--brick-wash);
  color: var(--brick-deep);
  padding: 0.05em 0.32em;
  border-radius: 3px;
}
.tour-prose a { color: var(--brick); }
.tour-prose kbd {
  font-family: var(--font-code);
  font-size: 0.78em;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  color: var(--ink);
}
.tour-prose .gloss {
  font-size: 0.88rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--line);
  padding-left: 0.9rem;
  margin: 0 0 1em;
}
.tour-prose .gloss b { color: var(--brick); font-weight: 600; }

/* The अभ्यासः · try callout closing each lesson. */
.tour-prose .try {
  border-left: 3px solid var(--gold);
  background: rgba(185, 138, 47, 0.08);
  padding: 0.7rem 1rem;
  border-radius: 0 3px 3px 0;
  margin: 1.4rem 0 0;
  font-size: 0.92rem;
  color: var(--ink);
}
.tour-prose .try b {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

/* ── Footer nav: ‹ पूर्वम् · dropdown · अग्रिमम् › ─────────── */

.tour-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 1.5rem;
  flex-wrap: wrap;
}
.tour-nav .spacer { flex: 1; }
.tour-nav .tool-select {
  font-size: 0.82rem;
  flex: 1 1 6rem;
  width: 100%;
  min-width: 0; /* let the long option labels shrink instead of overflowing */
  max-width: 100%;
  text-overflow: ellipsis;
}
.tour-nav-btn { flex: 0 0 auto; }
.tour-nav-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.86rem;
  background: transparent;
  border: 1px solid rgba(155, 74, 63, 0.4);
  border-radius: var(--radius);
  color: var(--brick);
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tour-nav-btn:hover:not([disabled]) { background: var(--brick-wash); color: var(--brick-deep); border-color: var(--brick); }
.tour-nav-btn[disabled] { opacity: 0.4; cursor: default; }
.tour-nav-btn .latin { font-size: 0.78em; opacity: 0.8; letter-spacing: 0.04em; }

/* ── Right: the live editor column ───────────────────────── */

.tour-editor {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  height: calc(100vh - var(--nav-h) - 3.2rem);
  min-height: 30rem;
}
.tour-editor .kr-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.tour-editor .play-editor-wrap { flex: 1; min-height: 0; }
.tour-editor .kr-hl-wrap > .kr-editor,
.tour-editor .kr-editor { min-height: 12rem; }

.tour-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
}
.tour-toolbar .spacer { flex: 1; }

/* The result pane below the editor card. */
.tour-result {
  flex: 0 0 auto;
  max-height: 38%;
  margin-top: 1rem;
  overflow: auto;
}
.tour-result .kr-card-head { position: sticky; top: 0; z-index: 1; }
.tour-result .kr-out { min-height: 2.4rem; }

.tour-result .pane-tabs { display: flex; gap: 0.1rem; }

@media (max-width: 980px) {
  .tour-shell { grid-template-columns: 1fr; gap: 1.2rem; min-height: 0; }
  .tour-editor { position: static; height: auto; min-height: 0; }
  .tour-editor .kr-editor { min-height: 18rem; }
  .tour-result { max-height: none; }
}

/* ── Reduced motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-bg span { animation: none !important; }
  .reveal,
  html.js .reveal-io,
  .trace-rec,
  .kr-out .out-line,
  .kr-error,
  .repl-entry.out,
  .repl-entry.value,
  .tika-cascade {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .btn.is-running::after, .kr-sweep { animation: none !important; }
  .kr-sweep { display: none !important; }
}
