/* ==========================================================================
   Khavarzadeh.com — Design System
   Single public stylesheet. Layers: tokens → base → layout → components →
   pages → utilities. RTL-first (Persian), LTR adjustments via [dir="ltr"].
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'dana';
  src: url('../fonts/dana/dana-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'dana';
  src: url('../fonts/dana/dana-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'dana';
  src: url('../fonts/dana/dana-demibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'dana';
  src: url('../fonts/dana/dana-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Ink theme (default) */
  --bg: #0a0d13;
  --bg-2: #0d1118;
  --surface: #11161f;
  --surface-2: #161c28;
  --border: #232b3b;
  --border-soft: #1a2130;
  --text: #e9ecf2;
  --text-2: #aab2c3;
  --text-3: #8f98ac; /* 5.9–6.5:1 on every dark surface (was 4.3–4.9) */
  --accent: #e8a33d;
  --accent-strong: #f3b551;
  --on-accent: #100c04;
  --series-a: #e8a33d; /* بینش / بازار */
  --series-b: #6c9bf2; /* داده / AI  */
  --series-c: #4fd1a5;
  --series-d: #f0708a;
  --series-e: #b58cf6;
  --series-f: #5ad0e6;
  --pos: #4cc38a;
  --neg: #e5484d;
  --grid-line: rgba(233, 236, 242, 0.05);
  --dot-grid: rgba(233, 236, 242, 0.07);
  --scrim: rgba(10, 13, 19, 0.82);
  --focus-ring: #6c9bf2;

  /* type */
  --font-fa: 'dana', 'Vazir', Tahoma, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'dana', monospace;
  --fs-display: clamp(2rem, 1.2rem + 3.2vw, 3.3rem);
  --fs-h2: clamp(1.45rem, 1.1rem + 1.3vw, 2rem);
  --fs-h3: 1.22rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-caption: 0.8125rem;
  --fs-label: 0.6875rem;

  /* spacing rhythm */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 1rem;
  --sp-4: 1.5rem;
  --sp-5: 2.5rem;
  --sp-6: 4rem;
  --section-gap: clamp(3rem, 6vw, 4.75rem);

  /* shape */
  --radius: 10px;
  --radius-sm: 6px;

  /* layout */
  --container: 1160px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  /* motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 180ms;
  --dur: 320ms;
  --dur-slow: 560ms;

  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #faf9f6;
  --bg-2: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --border: #ddd8cc;
  --border-soft: #e7e3d8;
  --text: #191d26;
  --text-2: #4b5468;
  --text-3: #626b80; /* 4.8–5.1:1 on every light surface (was 3.4–3.9) */
  --accent: #9a6a10;
  --accent-strong: #7c540a;
  --on-accent: #ffffff;
  --series-a: #b97f16;
  --series-b: #3767c9;
  --series-c: #1f9a72;
  --series-d: #c8445f;
  --series-e: #7a4fd1;
  --series-f: #1e93aa;
  --pos: #1d7d53;
  --neg: #c53539;
  --grid-line: rgba(25, 29, 38, 0.07);
  --dot-grid: rgba(25, 29, 38, 0.1);
  --scrim: rgba(250, 249, 246, 0.88);
  --focus-ring: #3767c9;
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-fa);
  font-size: var(--fs-body);
  line-height: 2;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.5;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* a component's own display rule would otherwise beat the attribute and
   leave "hidden" elements painted on screen */
[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

figure {
  margin: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: var(--sp-5) 0;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

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

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

.kh-skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  z-index: 200;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top var(--dur-fast) var(--ease);
}

.kh-skip-link:focus-visible {
  top: 1rem;
}

/* --------------------------------------------------------------------------
   4. Layout primitives
   -------------------------------------------------------------------------- */
.kh-container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.kh-section {
  padding-block: calc(var(--section-gap) / 2);
}

.kh-section--band {
  background: var(--bg-2);
  border-block: 1px solid var(--border-soft);
}

/* Section header: mono index + title + baseline rule with axis ticks */
.kh-section-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.kh-section-head__index {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.14em;
  color: var(--accent);
  translate: 0 -0.35rem;
}

.kh-section-head__title {
  font-size: var(--fs-h2);
  white-space: nowrap;
}

.kh-section-head__rule {
  flex: 1;
  align-self: center;
  height: 7px;
  min-width: 3rem;
  background:
    repeating-linear-gradient(
      to left,
      var(--border) 0 1px,
      transparent 1px 2.5rem
    )
    bottom / 100% 5px no-repeat,
    linear-gradient(var(--border), var(--border)) bottom / 100% 1px no-repeat;
}

.kh-section-head__more {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color var(--dur-fast) var(--ease);
}

.kh-section-head__more:hover {
  color: var(--accent);
}

/* Mono kicker label (signature) — latin text; bidi keeps char order,
   block alignment follows the page direction */
.kh-kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
  unicode-bidi: isolate;
}

/* Legend dot: category/meta marker */
.kh-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.kh-dot--b {
  background: var(--series-b);
}

/* Meta line (date · category · reading time) */
.kh-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-meta a:hover {
  color: var(--accent);
}

.kh-meta__sep {
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   5. Buttons & links
   -------------------------------------------------------------------------- */
.kh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.55rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: var(--fs-small);
  line-height: 1.6;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.kh-btn:hover {
  background: var(--accent-strong);
}

.kh-btn:active {
  transform: translateY(1px);
}

.kh-btn--sm {
  min-height: 34px;
  padding: 0.3rem 0.9rem;
  font-size: var(--fs-caption);
}

.kh-btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.kh-btn--ghost:hover {
  background: var(--surface);
  border-color: var(--text-3);
}

/* Arrow link — arrow points inline-forward (start side in RTL) */
.kh-arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: var(--fs-small);
  color: var(--accent);
}

.kh-arrow-link .kh-icon {
  transition: translate var(--dur-fast) var(--ease);
}

.kh-arrow-link:hover .kh-icon {
  translate: -3px 0;
}

[dir='ltr'] .kh-arrow-link:hover .kh-icon {
  translate: 3px 0;
}

/* underline-on-hover text link */
.kh-ulink {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: bottom right;
  transition: background-size var(--dur) var(--ease), color var(--dur-fast) var(--ease);
}

[dir='ltr'] .kh-ulink {
  background-position: bottom left;
}

.kh-ulink:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

/* Inline SVG icon default */
.kh-icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[dir='ltr'] .kh-icon--flip {
  transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   6. Header
   -------------------------------------------------------------------------- */
.kh-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease);
}

/* blur lives on a pseudo-element: backdrop-filter on the header itself would
   turn it into the containing block for the fixed mobile nav overlay */
.kh-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.kh-header.is-scrolled {
  border-bottom-color: var(--border-soft);
}

.kh-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 64px;
}

.kh-brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.4;
  min-width: 0;
}

.kh-brand__name {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text);
}

.kh-brand__tag {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.2em;
  color: var(--text-3);
  direction: ltr;
  unicode-bidi: isolate;
  text-transform: uppercase;
}

.kh-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.8rem);
  margin-inline-start: auto;
}

.kh-nav a {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-2);
  padding: 0.35rem 0.1rem;
  position: relative;
  transition: color var(--dur-fast) var(--ease);
}

.kh-nav a:hover {
  color: var(--text);
}

.kh-nav a[aria-current='page'] {
  color: var(--text);
}

.kh-nav a[aria-current='page']::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

/* live nav item: a small pulsing dot marks the always-fresh section */
.kh-nav__live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.kh-nav__live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pos);
  flex: none;
  animation: kh-live-pulse 2.4s var(--ease) infinite;
}

@keyframes kh-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .kh-nav__live-dot { animation: none; }
}

.kh-header__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Brand + four controls did not fit in 375px: the row was 413px wide and the
   whole page scrolled sideways. The English tagline is the widest thing in
   the row and the only one that says nothing the name does not; on a narrow
   phone it steps aside. */
@media (max-width: 479px) {
  .kh-brand__tag {
    display: none;
  }

  .kh-header__actions {
    gap: 0.1rem;
  }
}

.kh-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-iconbtn:hover {
  color: var(--text);
  background: var(--surface);
}

.kh-lang-link {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  color: var(--text-2);
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-lang-link:hover {
  color: var(--text);
  background: var(--surface);
}

/* theme toggle: show one glyph per theme */
.kh-theme-toggle .kh-icon--sun { display: none; }
.kh-theme-toggle .kh-icon--moon { display: block; }
[data-theme='light'] .kh-theme-toggle .kh-icon--sun { display: block; }
[data-theme='light'] .kh-theme-toggle .kh-icon--moon { display: none; }

/* Mobile nav */
.kh-nav-toggle {
  display: none;
}

@media (max-width: 899px) {
  .kh-nav {
    position: fixed;
    inset: 0;
    z-index: 90;
    flex-direction: column;
    justify-content: center;
    gap: 0.4rem;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
  }

  .kh-nav.is-open {
    opacity: 1;
    visibility: visible;
  }

  .kh-nav a {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
    padding: 0.55rem 1rem;
  }

  .kh-nav a[aria-current='page']::after {
    inset-inline: 1rem;
  }

  .kh-nav-toggle {
    display: inline-flex;
    z-index: 110;
    margin-inline-start: auto;
  }

  .kh-header__actions {
    z-index: 110;
  }

  body.kh-nav-open {
    overflow: hidden;
  }
}

/* --------------------------------------------------------------------------
   7. Hero + correlation visual (signature element)
   -------------------------------------------------------------------------- */
.kh-hero {
  position: relative;
  padding-block: clamp(3.5rem, 9vh, 6.5rem) clamp(3rem, 7vh, 5rem);
  overflow: hidden;
}

.kh-hero::before {
  /* faint dot-grid texture, hero only */
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--dot-grid) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(75% 90% at 50% 10%, #000 0%, transparent 78%);
  mask-image: radial-gradient(75% 90% at 50% 10%, #000 0%, transparent 78%);
  pointer-events: none;
}

.kh-hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.kh-hero__kicker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: var(--sp-4);
}

.kh-hero__kicker .kh-kicker {
  color: var(--accent);
}

.kh-hero__kicker::after {
  content: '';
  width: 3.5rem;
  height: 1px;
  background: var(--border);
}

.kh-hero__title {
  font-size: var(--fs-display);
  line-height: 1.45;
  margin-bottom: var(--sp-4);
}

.kh-hero__title em {
  font-style: normal;
  color: var(--accent);
}

.kh-hero__lede {
  color: var(--text-2);
  max-width: 34rem;
  margin-bottom: var(--sp-5);
}

.kh-hero__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
}

/* Visual panel */
.kh-viz {
  position: relative;
}

/* rotating example caption above the hero chart */
.kh-viz__example {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: var(--sp-2);
  min-height: 1.6rem;
}

.kh-viz__example-text {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-2);
  transition: opacity var(--dur) var(--ease);
}

.kh-viz__example-text.is-switching {
  opacity: 0;
}

#khVizVarA,
#khVizVarB {
  transition: opacity var(--dur) var(--ease);
}

.kh-viz.is-switching #khVizVarA,
.kh-viz.is-switching #khVizVarB {
  opacity: 0;
}

.kh-viz__canvas {
  display: block;
  width: 100%;
  height: clamp(260px, 38vw, 400px);
}

.kh-viz__legend {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.kh-viz__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.kh-viz__legend-item .kh-dot {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.kh-viz__r {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  color: var(--text-3);
  direction: ltr;
  unicode-bidi: isolate;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  transition: color var(--dur) var(--ease);
}

@media (max-width: 899px) {
  .kh-hero__grid {
    grid-template-columns: 1fr;
    gap: var(--sp-5);
  }

  .kh-viz__canvas {
    height: clamp(200px, 52vw, 300px);
  }
}

/* --------------------------------------------------------------------------
   8. Quiet facts row (achievements inside the about block)
   -------------------------------------------------------------------------- */
.kh-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-5);
  margin-top: var(--sp-4);
}

.kh-facts li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: var(--fs-caption);
  color: var(--text-3);
  line-height: 1.8;
  border-inline-start: 2px solid var(--border);
  padding-inline-start: 0.75rem;
}

.kh-facts__value {
  font-weight: 700;
  font-size: var(--fs-small);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* --------------------------------------------------------------------------
   9. Focus areas (services) — editorial numbered rows
   -------------------------------------------------------------------------- */
.kh-focus {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(2rem, 5vw, 4.5rem);
}

.kh-focus__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  padding-block: var(--sp-4);
  border-top: 1px solid var(--border-soft);
}

.kh-focus__num {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  color: var(--accent);
  padding-top: 0.55rem;
  direction: ltr;
}

.kh-focus__title {
  font-size: var(--fs-h3);
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.kh-focus__desc {
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 1.9;
}

.kh-focus__more {
  display: inline-flex;
  margin-top: var(--sp-2);
}

@media (max-width: 899px) {
  .kh-focus {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   10. Experience timeline — cards on a time axis
   -------------------------------------------------------------------------- */
.kh-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--sp-3);
  position: relative;
  padding-top: var(--sp-5);
}

.kh-timeline::before {
  /* the axis the cards hang from */
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 1px;
  background: linear-gradient(
    to left,
    var(--accent) 0%,
    var(--border) 45%,
    var(--border-soft) 100%
  );
}

[dir='ltr'] .kh-timeline::before {
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--border) 45%,
    var(--border-soft) 100%
  );
}

.kh-timeline__item {
  position: relative;
  padding: var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.kh-timeline__item:hover {
  border-color: var(--border);
  transform: translateY(-3px);
}

.kh-timeline__item::before {
  /* connector from the axis into the card */
  content: '';
  position: absolute;
  top: calc(var(--sp-5) * -1);
  inset-inline-start: var(--sp-4);
  width: 1px;
  height: var(--sp-5);
  background: var(--border);
}

.kh-timeline__item::after {
  /* the node on the axis */
  content: '';
  position: absolute;
  top: calc(var(--sp-5) * -1 - 3px);
  inset-inline-start: calc(var(--sp-4) - 3px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
}

/* the current role gets the accent treatment */
.kh-timeline__item.is-current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-soft));
  background: var(--surface-2);
}

.kh-timeline__item.is-current::after {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.kh-timeline__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.kh-timeline__years {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  color: var(--text-3);
  white-space: nowrap;
}

.kh-timeline__item.is-current .kh-timeline__years {
  color: var(--accent);
}

.kh-timeline__now {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.kh-timeline__now::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: kh-live-pulse 2.4s var(--ease) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .kh-timeline__now::before { animation: none; }
}

.kh-timeline__title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: var(--sp-2);
}

.kh-timeline__desc {
  font-size: var(--fs-caption);
  color: var(--text-2);
  line-height: 2;
}

@media (max-width: 640px) {
  .kh-timeline {
    grid-template-columns: 1fr;
    gap: var(--sp-3);
    padding-top: 0;
    padding-inline-start: var(--sp-4);
  }

  .kh-timeline::before {
    inset-inline: auto;
    inset-inline-start: 3px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    height: auto;
    background: linear-gradient(to bottom, var(--accent) 0%, var(--border) 40%, var(--border-soft) 100%);
  }

  .kh-timeline__item::before {
    top: 22px;
    inset-inline-start: calc(var(--sp-4) * -1);
    width: var(--sp-4);
    height: 1px;
  }

  .kh-timeline__item::after {
    top: 19px;
    inset-inline-start: calc(var(--sp-4) * -1 - 3px);
  }

  .kh-timeline__head {
    flex-wrap: wrap;
  }
}

/* --------------------------------------------------------------------------
   11. Stories (insights) — editorial feature + rows
   -------------------------------------------------------------------------- */
.kh-stories {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.kh-story-feature {
  display: block;
}

.kh-story-feature .kh-thumb {
  margin-bottom: var(--sp-4);
}

.kh-story-feature__title {
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem);
  line-height: 1.6;
  margin-bottom: var(--sp-2);
  transition: color var(--dur-fast) var(--ease);
}

.kh-story-feature:hover .kh-story-feature__title {
  color: var(--accent);
}

.kh-story-list {
  display: flex;
  flex-direction: column;
}

.kh-story-row {
  display: block;
  padding-block: var(--sp-4);
  border-top: 1px solid var(--border-soft);
}

.kh-story-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.kh-story-row__title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: var(--sp-1);
  transition: color var(--dur-fast) var(--ease);
}

.kh-story-row:hover .kh-story-row__title {
  color: var(--accent);
}

@media (max-width: 899px) {
  .kh-stories {
    grid-template-columns: 1fr;
  }
}

/* Thumbnail with graceful data-pattern fallback */
.kh-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.kh-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}

a:hover .kh-thumb img {
  transform: scale(1.025);
}

.kh-thumb--sq {
  aspect-ratio: 1 / 1;
}

/* pattern placeholder: dot grid + sparkline */
.kh-thumb--pattern {
  display: flex;
  align-items: flex-end;
  background-image: radial-gradient(var(--dot-grid) 1px, transparent 1px);
  background-size: 22px 22px;
}

.kh-thumb--pattern svg {
  width: 100%;
  height: 55%;
}

.kh-thumb--pattern .kh-thumb__label {
  position: absolute;
  top: 0.9rem;
  inset-inline-start: 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.18em;
  color: var(--text-3);
  direction: ltr;
  unicode-bidi: isolate;
}

/* --------------------------------------------------------------------------
   12. Cards grid (videos / archive)
   -------------------------------------------------------------------------- */
.kh-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--sp-5) var(--sp-4);
}

.kh-card {
  display: block;
}

.kh-card .kh-thumb {
  margin-bottom: var(--sp-3);
}

.kh-card__title {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.8;
  margin-bottom: var(--sp-1);
  transition: color var(--dur-fast) var(--ease);
}

.kh-card:hover .kh-card__title {
  color: var(--accent);
}

/* play badge for videos */
.kh-play-badge {
  position: absolute;
  inset-inline-end: 0.8rem;
  bottom: 0.8rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  border: 1px solid var(--border);
  color: var(--text);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.kh-play-badge svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: none;
  margin-inline-end: -2px;
}

/* --------------------------------------------------------------------------
   13. Clients strip
   -------------------------------------------------------------------------- */
.kh-clients {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3) var(--sp-3);
}

/* logos sit on a small white tile so any brand color stays legible on ink */
.kh-clients__tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  min-width: 118px;
  padding: 0.7rem 1.1rem;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: transform var(--dur-fast) var(--ease);
}

.kh-clients__tile:hover {
  transform: translateY(-2px);
}

.kh-clients img {
  height: 40px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  opacity: 0.75;
  filter: grayscale(1);
  transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
}

.kh-clients__tile:hover img {
  opacity: 1;
  filter: none;
}

/* brands without a logo yet: quiet chip matching the tile height */
.kh-clients__name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  min-width: 118px;
  padding: 0.7rem 1.3rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--fs-small);
  text-align: center;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   14. About block
   -------------------------------------------------------------------------- */
.kh-about {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

.kh-portrait {
  position: relative;
}

.kh-portrait::before {
  /* offset dot-grid frame */
  content: '';
  position: absolute;
  inset: 1.2rem -1.2rem -1.2rem 1.2rem;
  background-image: radial-gradient(var(--dot-grid) 1px, transparent 1px);
  background-size: 14px 14px;
  border-radius: var(--radius);
}

[dir='ltr'] .kh-portrait::before {
  inset: 1.2rem 1.2rem -1.2rem -1.2rem;
}

.kh-portrait img {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 5;
}

.kh-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block: var(--sp-4);
}

.kh-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-caption);
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
}

@media (max-width: 899px) {
  .kh-about {
    grid-template-columns: 1fr;
  }

  .kh-portrait {
    max-width: 330px;
  }
}

/* --------------------------------------------------------------------------
   15. Forms
   -------------------------------------------------------------------------- */
.kh-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: var(--sp-4);
}

.kh-field label {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-2);
}

.kh-input {
  width: 100%;
  min-height: 48px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font: inherit;
  line-height: 1.7;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-input::placeholder {
  color: var(--text-3);
}

.kh-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.kh-input {
  resize: vertical;
  min-height: 140px;
}

/* Django messages */
.kh-alert {
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-small);
}

.kh-alert--success {
  border-inline-start-color: var(--pos);
}

.kh-alert--danger,
.kh-alert--error {
  border-inline-start-color: var(--neg);
}

/* --------------------------------------------------------------------------
   16. Contact block
   -------------------------------------------------------------------------- */
.kh-contact {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.kh-contact__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}

.kh-contact__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kh-contact__item dt {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-contact__item dd {
  margin: 0;
  font-weight: 600;
  direction: ltr;
  unicode-bidi: isolate;
}

/* keep the value visually aligned with its label in both page directions */
[dir='rtl'] .kh-contact__item dd {
  text-align: right;
}

[dir='ltr'] .kh-contact__item dd {
  text-align: left;
}

.kh-contact__item dd a:hover {
  color: var(--accent);
}

.kh-social {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kh-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 899px) {
  .kh-contact {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   17. Footer
   -------------------------------------------------------------------------- */
.kh-footer {
  margin-top: var(--sp-5);
  border-top: 1px solid var(--border-soft);
  background: var(--bg-2);
}

.kh-footer__spark {
  display: block;
  width: 100%;
  height: 46px;
  opacity: 0.7;
}

/* Five children, five tracks. The grid used to declare four — one for the
   identity block and three for link columns — so when a fourth link column
   was added it wrapped to a second row, landed under the identity block on
   the far side, and stretched the footer to twice its height. The identity
   block takes the slack; the link columns share the rest equally, so their
   headings line up whatever the length of their longest link. */
.kh-footer__grid {
  display: grid;
  grid-template-columns: minmax(15rem, 1.7fr) repeat(4, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-5);
  align-items: start;
  padding-block: var(--sp-5);
}

.kh-footer__identity p {
  color: var(--text-2);
  font-size: var(--fs-small);
  max-width: 26rem;
  margin-top: var(--sp-2);
}

.kh-footer__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-top: var(--sp-3);
  direction: ltr;
  justify-content: flex-end;
}

[dir='ltr'] .kh-footer__social {
  justify-content: flex-start;
}

.kh-footer__social a {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.kh-footer__social a:hover {
  color: var(--accent);
}

.kh-footer h4 {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}

.kh-footer__col ul {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.kh-footer__col a {
  font-size: var(--fs-small);
  color: var(--text-2);
}

.kh-footer__col a:hover {
  color: var(--accent);
}

.kh-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-top: 1px solid var(--border-soft);
  padding-block: var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-footer__copy {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
}

/* Tablet: the identity block gets its own row and the four columns stay in
   one line. Phone: two by two — never three and an orphan. */
@media (max-width: 1023px) {
  .kh-footer__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-4) var(--sp-4);
  }

  .kh-footer__identity {
    grid-column: 1 / -1;
  }

  .kh-footer__social {
    justify-content: flex-start;
    direction: inherit;
  }
}

@media (max-width: 639px) {
  .kh-footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   17b. Correlation lab (interactive closing section)
   -------------------------------------------------------------------------- */
.kh-corrlab__head {
  max-width: 44rem;
  margin-bottom: var(--sp-5);
}

.kh-corrlab__title {
  font-size: var(--fs-h2);
  line-height: 1.6;
  margin-top: var(--sp-3);
}

.kh-corrlab__title em {
  font-style: normal;
  color: var(--accent);
  display: block;
}

.kh-corrlab__lede {
  margin-top: var(--sp-3);
  max-width: 38rem;
}

.kh-corrlab__stage {
  position: relative;
}

.kh-corrlab__canvas {
  display: block;
  width: 100%;
  height: clamp(320px, 42vw, 460px);
  cursor: grab;
  touch-action: pan-y;
  border-radius: var(--radius);
}

.kh-corrlab__canvas.is-dragging {
  cursor: grabbing;
}

.kh-corrlab__canvas:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
}

.kh-corrlab__hint {
  position: absolute;
  top: 18%;
  inset-inline-start: 50%;
  translate: 50% 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: 600;
  pointer-events: none;
  animation: kh-hint-nudge 2.2s var(--ease) infinite;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

[dir='ltr'] .kh-corrlab__hint {
  translate: -50% 0;
}

.kh-corrlab__hint.is-hidden {
  opacity: 0;
  visibility: hidden;
}

@keyframes kh-hint-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(7px); }
}

@media (prefers-reduced-motion: reduce) {
  .kh-corrlab__hint {
    animation: none;
  }
}

.kh-corrlab__readout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4) var(--sp-6);
  margin-top: var(--sp-4);
  border-top: 1px solid var(--border-soft);
  padding-top: var(--sp-4);
}

.kh-corrlab__stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kh-corrlab__stat-label {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-corrlab__stat-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  unicode-bidi: isolate;
  text-align: start;
  transition: color var(--dur-fast) var(--ease);
}

.kh-corrlab__stat--main .kh-corrlab__stat-value {
  font-size: 1.9rem;
  font-weight: 700;
}

.kh-corrlab__stat-value--sm {
  font-size: 0.95rem;
}

.kh-corrlab__reset {
  margin-inline-start: auto;
}

.kh-corrlab__note {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-top: var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

@media (max-width: 640px) {
  .kh-lab__readout {
    gap: var(--sp-3) var(--sp-4);
  }

  .kh-lab__stat--main {
    order: -1;
    flex-basis: 100%;
  }

  .kh-lab__reset {
    margin-inline-start: 0;
  }

  .kh-lab__note {
    flex-direction: column;
    gap: 0.2rem;
  }
}

/* --------------------------------------------------------------------------
   18. Page header (inner pages)
   -------------------------------------------------------------------------- */
.kh-page-head {
  padding-block: clamp(2rem, 4.5vw, 3.25rem) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--sp-5);
}

.kh-page-head .kh-kicker {
  display: block;
  margin-bottom: var(--sp-3);
  color: var(--accent);
}

.kh-page-head__title {
  font-size: var(--fs-display);
  line-height: 1.4;
}

.kh-page-head__lede {
  color: var(--text-2);
  max-width: 40rem;
  margin-top: var(--sp-3);
}

/* Filters / search row */
.kh-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.kh-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 230px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding-inline: 0.9rem;
  transition: border-color var(--dur-fast) var(--ease);
}

.kh-search:focus-within {
  border-color: var(--accent);
}

.kh-search input {
  flex: 1;
  min-height: 46px;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
}

.kh-search input:focus {
  outline: none;
}

.kh-search .kh-icon {
  color: var(--text-3);
}

.kh-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.kh-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.2rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--fs-caption);
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-chip:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.kh-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.kh-chip--sm {
  min-height: 28px;
  padding: 0.1rem 0.7rem;
  font-size: 0.72rem;
}

/* --------------------------------------------------------------------------
   19. Article (prose) — CKEditor content
   -------------------------------------------------------------------------- */
.kh-article-head {
  max-width: 46rem;
  margin-inline: auto;
  text-align: center;
  padding-block: clamp(2rem, 5vw, 3.5rem) 0;
}

.kh-article-head__title {
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.5rem);
  line-height: 1.6;
  margin-block: var(--sp-3);
}

.kh-article-head .kh-meta {
  justify-content: center;
}

.kh-article-hero {
  max-width: 52rem;
  margin: var(--sp-5) auto 0;
}

.kh-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  padding-top: var(--sp-5);
}

.kh-article-main {
  min-width: 0;
  max-width: 46rem;
  margin-inline: auto;
  width: 100%;
}

.kh-article-aside {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

@media (max-width: 1023px) {
  .kh-article-layout {
    grid-template-columns: 1fr;
  }

  .kh-article-aside {
    position: static;
    order: 2;
  }
}

.kh-prose {
  font-size: 1.02rem;
  line-height: 2.15;
  color: var(--text);
}

.kh-prose > * + * {
  margin-top: 1.1em;
}

.kh-prose h2,
.kh-prose h3,
.kh-prose h4 {
  margin-top: 2em;
  line-height: 1.7;
}

.kh-prose h2 {
  font-size: 1.45rem;
  padding-inline-start: 0.85rem;
  border-inline-start: 3px solid var(--accent);
}

.kh-prose h3 {
  font-size: 1.2rem;
}

.kh-prose h4 {
  font-size: 1.05rem;
}

.kh-prose a {
  color: var(--series-b);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--series-b) 40%, transparent);
  text-underline-offset: 4px;
}

.kh-prose a:hover {
  text-decoration-color: var(--series-b);
}

.kh-prose img {
  border-radius: var(--radius);
  margin-inline: auto;
  border: 1px solid var(--border-soft);
}

.kh-prose blockquote {
  margin: 1.6em 0;
  padding: var(--sp-3) var(--sp-4);
  border-inline-start: 3px solid var(--series-b);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-2);
}

.kh-prose ul,
.kh-prose ol {
  padding-inline-start: 1.4rem;
}

.kh-prose ul {
  list-style: disc;
}

.kh-prose ol {
  list-style: persian;
}

[dir='ltr'] .kh-prose ol {
  list-style: decimal;
}

.kh-prose li {
  margin-top: 0.4em;
}

.kh-prose li::marker {
  color: var(--accent);
}

.kh-prose pre {
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.8;
}

.kh-prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  direction: ltr;
  unicode-bidi: isolate;
}

.kh-prose pre code {
  background: none;
  padding: 0;
}

.kh-prose .kh-table-wrap,
.kh-prose .table-wrap {
  overflow-x: auto;
  margin-top: 1.1em;
}

.kh-prose table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.8;
}

.kh-prose th,
.kh-prose td {
  border: 1px solid var(--border-soft);
  padding: 0.6rem 0.9rem;
  text-align: start;
}

.kh-prose th {
  background: var(--surface);
  font-weight: 600;
}

.kh-prose iframe,
.kh-prose video {
  max-width: 100%;
  border-radius: var(--radius);
}

.kh-prose hr {
  margin: 2em auto;
  width: 120px;
  border-top: 1px solid var(--border);
}

/* TOC */
.kh-toc {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.kh-toc summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-2);
}

.kh-toc summary::-webkit-details-marker {
  display: none;
}

.kh-toc summary .kh-icon {
  margin-inline-start: auto;
  transition: transform var(--dur-fast) var(--ease);
}

.kh-toc[open] summary .kh-icon {
  transform: rotate(180deg);
}

.kh-toc ol {
  padding: 0 var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  counter-reset: toc;
}

.kh-toc li a {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0;
  font-size: var(--fs-caption);
  color: var(--text-2);
  counter-increment: toc;
  transition: color var(--dur-fast) var(--ease);
}

.kh-toc li a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-3);
  direction: ltr;
}

.kh-toc li a:hover,
.kh-toc li a.is-active {
  color: var(--accent);
}

.kh-toc li[data-level='3'] a {
  padding-inline-start: 1.4rem;
}

/* share row */
.kh-share {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kh-share__label {
  font-size: var(--fs-caption);
  color: var(--text-3);
  margin-inline-end: 0.4rem;
}

/* comments */
.kh-comments {
  margin-top: var(--sp-6);
  border-top: 1px solid var(--border-soft);
  padding-top: var(--sp-5);
}

.kh-comment {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-top: var(--sp-3);
  background: var(--surface);
}

.kh-comment__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-comment__author {
  font-weight: 600;
  color: var(--text);
  font-size: var(--fs-small);
}

.kh-comment p {
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 2;
}

/* comment / django form paragraphs */
.kh-form-django p {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0 0 var(--sp-4);
}

.kh-form-django label {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-2);
}

.kh-form-django input,
.kh-form-django textarea {
  width: 100%;
  min-height: 48px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font: inherit;
  line-height: 1.7;
}

.kh-form-django textarea {
  min-height: 130px;
  resize: vertical;
}

.kh-form-django input:focus,
.kh-form-django textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.kh-form-django .helptext,
.kh-form-django .errorlist {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-form-django .errorlist {
  color: var(--neg);
}

/* related list (aside) */
.kh-mini-list {
  display: flex;
  flex-direction: column;
}

.kh-mini-list a {
  display: block;
  padding-block: var(--sp-3);
  border-top: 1px solid var(--border-soft);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.9;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease);
}

.kh-mini-list a:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.kh-mini-list a:hover {
  color: var(--accent);
}

.kh-aside-title {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

/* breadcrumb */
.kh-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-breadcrumb a:hover {
  color: var(--accent);
}

.kh-breadcrumb__sep {
  opacity: 0.5;
}

.kh-breadcrumb .is-current {
  color: var(--text-2);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* featured split layout on list pages */
.kh-feature-split {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
}

.kh-feature-split .kh-thumb {
  margin-bottom: 0;
}

@media (max-width: 899px) {
  .kh-feature-split {
    grid-template-columns: 1fr;
  }
}

/* publications accordion */
.kh-pubs {
  display: flex;
  flex-direction: column;
}

.kh-pub {
  border-top: 1px solid var(--border-soft);
}

.kh-pub:last-child {
  border-bottom: 1px solid var(--border-soft);
}

.kh-pub summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-1);
  transition: color var(--dur-fast) var(--ease);
}

.kh-pub summary::-webkit-details-marker {
  display: none;
}

.kh-pub summary:hover {
  color: var(--accent);
}

.kh-pub__index {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  color: var(--accent);
  flex: none;
}

.kh-pub__title {
  flex: 1;
  font-weight: 600;
  font-size: var(--fs-small);
  line-height: 1.9;
}

.kh-pub summary .kh-icon {
  align-self: center;
  flex: none;
  color: var(--text-3);
  transition: transform var(--dur-fast) var(--ease);
}

.kh-pub[open] summary .kh-icon {
  transform: rotate(180deg);
}

.kh-pub__body {
  padding: 0 var(--sp-1) var(--sp-4) calc(var(--sp-3) + 1.4rem);
  color: var(--text-2);
  font-size: var(--fs-small);
  line-height: 2;
}

.kh-pub[dir='ltr'] .kh-pub__body {
  padding: 0 calc(var(--sp-3) + 1.4rem) var(--sp-4) var(--sp-1);
  padding-left: calc(var(--sp-3) + 1.4rem);
  padding-right: var(--sp-1);
}

.kh-pub__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-3);
}

/* CTA band */
.kh-cta-band {
  text-align: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: var(--sp-6) var(--sp-4);
}

.kh-cta-band p {
  max-width: 34rem;
  margin-inline: auto;
  margin-top: var(--sp-2);
}

/* status pages (sent / errors) */
.kh-status-page {
  max-width: 34rem;
  margin-inline: auto;
  text-align: center;
  padding-block: clamp(4rem, 12vh, 8rem);
}

.kh-status-page__spark {
  width: 150px;
  height: 55px;
  margin: 0 auto var(--sp-4);
  display: block;
}

.kh-status-page .kh-btn {
  margin-inline: 0.3rem;
  margin-top: 0.5rem;
}

/* audio block in article */
.kh-voice {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
}

.kh-voice audio {
  margin-top: var(--sp-2);
}

/* --------------------------------------------------------------------------
   19b. Shared live-data helpers
   -------------------------------------------------------------------------- */
.kh-live__spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: kh-spin 0.8s linear infinite;
  flex: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .kh-live__spinner { animation-duration: 2.4s; }
}

.kh-live__error-title {
  font-weight: 600;
  color: var(--text);
}

.kh-live__stale {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: var(--fs-label);
  color: var(--text-2);
}

.kh-domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
  margin-top: var(--sp-4);
}
.kh-domain-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start;
  padding: var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
  opacity: 0.7;
}
.kh-domain-card.is-live {
  opacity: 1;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.kh-domain-card.is-live:hover { border-color: var(--text-3); transform: translateY(-1px); }
.kh-domain-card__title { margin: 0.2rem 0 0; font-size: 1rem; font-weight: 700; }
.kh-domain-card__q { margin: 0; font-size: 0.84rem; color: var(--text-2); line-height: 1.8; }
.kh-domain-card__source { margin-top: auto; padding-top: 0.4rem; font-size: 0.7rem; color: var(--text-3); }

.kh-live__note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.7rem;
  margin-top: var(--sp-4);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   19c. Live analysis blocks
   -------------------------------------------------------------------------- */
.kh-lives {
  display: grid;
  /* minmax(0, …): a grid track defaults to min-width:auto, so a wide table
     or canvas inside a card would widen the track past the page instead of
     scrolling inside the card */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
}

.kh-liveblock {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: var(--sp-4);
  min-height: 200px;
}

.kh-liveblock__loading,
.kh-liveblock__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 170px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-small);
}

.kh-liveblock__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.kh-liveblock__title {
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1.5;
}

.kh-liveblock__question {
  margin-top: 0.15rem;
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-liveblock__figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.4;
}

[dir='ltr'] .kh-liveblock__figure {
  align-items: flex-start;
}

.kh-liveblock__value {
  font-size: clamp(1.4rem, 1.1rem + 1.1vw, 1.9rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.kh-liveblock__caption {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-liveblock__change {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-3);
  margin-top: 0.15rem;
}

.kh-liveblock__change.is-up { color: var(--pos); }
.kh-liveblock__change.is-down { color: var(--neg); }

.kh-liveblock__chart-wrap {
  position: relative;
}

.kh-liveblock__chart {
  display: block;
  width: 100%;
  height: clamp(150px, 20vw, 210px);
}

.kh-liveblock__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.kh-liveblock__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.kh-liveblock__legend-dot {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}

.kh-label {
  display: inline-block;
  font-size: var(--fs-caption);
  font-weight: 700;
  color: var(--accent);
}

.kh-liveblock__basis { font-size: var(--fs-caption); color: var(--text-3); font-weight: 400; }

.kh-liveblock__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: var(--sp-3) 0 0;
}
.kh-liveblock__stat {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.kh-liveblock__stat dt { font-size: 0.72rem; color: var(--text-3); margin-bottom: 0.15rem; }
.kh-liveblock__stat dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.kh-picker--inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: var(--sp-3) var(--sp-4); }
.kh-picker--inline .kh-picker__chips { flex: 1; }
.kh-live__instruments { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-bottom: var(--sp-4); }

/* ---- detail page: one indicator, full width, with its tools ------------ */
.kh-lives--single { grid-template-columns: minmax(0, 1fr); }

.kh-liveblock--detail .kh-liveblock__chart-wrap { height: 320px; }
.kh-liveblock--detail .kh-liveblock__chart { height: 100%; }

.kh-liveblock__titlelink {
  color: inherit;
  text-decoration: none;
}
.kh-liveblock__titlelink:hover { color: var(--accent); }

.kh-liveblock__more { white-space: nowrap; }

.kh-page-head--detail .kh-backlink {
  display: inline-block;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-3);
  text-decoration: none;
}
.kh-page-head--detail .kh-backlink:hover { color: var(--text); }
.kh-backlink::before { content: '\2192\00a0'; }
[dir='ltr'] .kh-backlink::before { content: '\2190\00a0'; }
.kh-liveblock__more::after { content: '\00a0\2190'; }
[dir='ltr'] .kh-liveblock__more::after { content: '\00a0\2192'; }

.kh-liveblock__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: var(--sp-3) 0 var(--sp-2);
}
.kh-liveblock__toolbar-label,
.kh-liveblock__toolbar-hint {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.kh-seg__btn:first-child { border-start-start-radius: 999px; border-end-start-radius: 999px; }
.kh-seg__btn:last-child { border-start-end-radius: 999px; border-end-end-radius: 999px; }
.kh-seg__btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; position: relative; z-index: 1; }
.kh-seg__btn {
  padding: 0.3rem 0.85rem;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-caption);
  cursor: pointer;
}
.kh-seg__btn + .kh-seg__btn { border-inline-start: 1px solid var(--border); }
.kh-seg__btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.kh-liveblock__section { margin-top: var(--sp-6); }
.kh-liveblock__section .kh-section-head { margin-bottom: var(--sp-3); }
.kh-liveblock__lede {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-3);
}
.kh-liveblock__method {
  margin-top: var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-3);
  line-height: 1.8;
}

.kh-liveblock__reco {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.kh-liveblock__reco .kh-kicker { display: block; color: var(--accent); margin-bottom: var(--sp-2); }
.kh-liveblock__reco p { margin: 0; line-height: 2; font-size: 1.02rem; }

.kh-liveblock__matrix-wrap {
  height: 340px;
  margin-bottom: var(--sp-4);
}
.kh-liveblock__matrix { width: 100%; height: 100%; display: block; }

/* generic data table */
.kh-table-scroll { overflow-x: auto; max-width: 100%; }
.kh-table-scroll--tall { max-height: 420px; overflow-y: auto; }
.kh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-caption);
  font-variant-numeric: tabular-nums;
}
.kh-table th, .kh-table td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: start;
  white-space: nowrap;
}
.kh-table th {
  position: sticky;
  top: 0;
  background: var(--bg-2);
  color: var(--text-3);
  font-weight: 600;
}
.kh-table td.num, .kh-table th.num { text-align: start; font-variant-numeric: tabular-nums; }

/* sortable tables — any table[data-sortable], wired up by kh.js */
.kh-sortable__th { cursor: pointer; user-select: none; position: relative; padding-inline-end: 1.1em; }
.kh-sortable__th:hover { color: var(--text); }
.kh-sortable__th:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.kh-sortable__th::after {
  content: '⇅'; position: absolute; inset-inline-end: 0.15em; top: 50%; transform: translateY(-50%);
  font-size: 0.8em; opacity: 0.35;
}
.kh-sortable__th.is-sorted-asc::after { content: '↑'; opacity: 0.9; color: var(--series-a); }
.kh-sortable__th.is-sorted-desc::after { content: '↓'; opacity: 0.9; color: var(--series-a); }

.kh-decision td:first-child { font-weight: 600; color: var(--text); }
/* the action column is a sentence, not a number: let it wrap instead of
   pushing the whole table sideways */
.kh-decision td:last-child { white-space: normal; min-width: 11rem; line-height: 1.7; }
.kh-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-inline-end: 0.45rem;
  vertical-align: middle;
}
.kh-badge {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.kh-badge { color: var(--text); border: 1px solid transparent; }
.kh-badge--star     { background: color-mix(in srgb, var(--pos) 24%, var(--surface)); border-color: color-mix(in srgb, var(--pos) 50%, transparent); }
.kh-badge--rising   { background: color-mix(in srgb, var(--series-f) 24%, var(--surface)); border-color: color-mix(in srgb, var(--series-f) 50%, transparent); }
.kh-badge--elevated { background: color-mix(in srgb, var(--series-c) 22%, var(--surface)); border-color: color-mix(in srgb, var(--series-c) 45%, transparent); }
.kh-badge--seasonal { background: color-mix(in srgb, var(--series-a) 26%, var(--surface)); border-color: color-mix(in srgb, var(--series-a) 55%, transparent); }
.kh-badge--peaking  { background: color-mix(in srgb, var(--series-e) 24%, var(--surface)); border-color: color-mix(in srgb, var(--series-e) 50%, transparent); }
.kh-badge--core     { background: color-mix(in srgb, var(--series-b) 22%, var(--surface)); border-color: color-mix(in srgb, var(--series-b) 45%, transparent); }
.kh-badge--niche    { background: color-mix(in srgb, var(--text-3) 18%, var(--surface)); border-color: color-mix(in srgb, var(--text-3) 40%, transparent); }
.kh-badge--cooling  { background: color-mix(in srgb, var(--neg) 24%, var(--surface)); border-color: color-mix(in srgb, var(--neg) 50%, transparent); }
.kh-badge--thin     { background: transparent; border-color: var(--border); color: var(--text-3); }
.kh-why { display: block; font-weight: 400; font-size: 0.72rem; color: var(--text-3); line-height: 1.6; margin-top: 0.15rem; }
.kh-muted { color: var(--text-3); }
.kh-text-label { font-size: var(--fs-label); }
/* relative sizes must not take small print below the smallest label size */
small, sub, sup { font-size: max(0.8333em, var(--fs-label)); }
.kh-up   { color: var(--pos); }
.kh-down { color: var(--neg); }

/* seasonality strip: one row per product, twelve Jalali months */
.kh-season { display: grid; gap: 0.45rem; }
.kh-season__row {
  display: grid;
  grid-template-columns: 8.5rem repeat(12, 1fr);
  gap: 3px;
  align-items: center;
}
.kh-season__label { font-size: var(--fs-caption); color: var(--text-2); }
.kh-season__cell {
  height: 26px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--series-a) calc(var(--heat) * 100%), var(--surface));
  border: 1px solid transparent;
}
.kh-season__cell.is-empty { background: transparent; border-color: var(--border-soft); }
.kh-season__cell.is-now { outline: 2px solid var(--text); outline-offset: -2px; }
.kh-season__months {
  display: grid;
  grid-template-columns: 8.5rem repeat(12, 1fr);
  gap: 3px;
  margin-top: 0.2rem;
}
.kh-season__month {
  font-size: var(--fs-label);
  color: var(--text-3);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.kh-season-scroll { overflow-x: auto; max-width: 100%; }
.kh-season { min-width: 600px; }

/* product picker */
.kh-picker {
  margin-bottom: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.kh-picker__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}
.kh-picker__count { font-size: var(--fs-caption); color: var(--text-3); font-variant-numeric: tabular-nums; }
.kh-picker__hint { margin: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-caption); color: var(--text-3); line-height: 1.8; }
.kh-picker__group { margin: 0 0 var(--sp-3); padding: 0; border: 0; }
.kh-picker__legend { padding: 0; margin-bottom: 0.4rem; font-size: var(--fs-caption); font-weight: 600; color: var(--text-2); }
.kh-picker__chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.kh-chip--check { cursor: pointer; user-select: none; }
.kh-chip--check { position: relative; }
.kh-chip--check input { position: absolute; opacity: 0; width: 0; height: 0; }
.kh-chip--check:focus-within { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.kh-chip--check.is-disabled { opacity: 0.45; cursor: not-allowed; }
.kh-picker__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: var(--sp-2); }

.kh-live__others { margin-top: var(--sp-7); }
.kh-live__otherlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kh-live__otherlink {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-2);
}
.kh-live__otherlink strong { color: var(--text); }
.kh-live__otherlink span { font-size: var(--fs-caption); color: var(--text-3); }
.kh-live__otherlink:hover { border-color: var(--text-3); }

/* the phrases people actually type — shown without scores on purpose */
.kh-liveblock__queries {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: var(--sp-4);
}

.kh-liveblock__qrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.kh-liveblock__qlabel {
  min-width: 6.5rem;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-3);
}

.kh-liveblock__qchip {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: var(--fs-caption);
  color: var(--text-2);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .kh-liveblock__qlabel { min-width: 100%; }
}

/* the interpretation — the point of the whole page */
.kh-liveblock__insight {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-inline-start: 2px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

[dir='ltr'] .kh-liveblock__insight {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.kh-liveblock__insight .kh-kicker {
  display: block;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}

.kh-liveblock__insight p {
  font-size: var(--fs-small);
  line-height: 2.1;
  color: var(--text);
}

.kh-liveblock__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-soft);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

@media (min-width: 900px) {
  .kh-lives:not(.kh-lives--single) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .kh-liveblock {
    padding: var(--sp-3);
  }

  .kh-liveblock__head {
    flex-direction: column;
  }

  .kh-liveblock__figure {
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   19d. Private analytics dashboard
   -------------------------------------------------------------------------- */
.kh-dash__filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.kh-dash__periods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.kh-dash__bots {
  margin-inline-start: 0.5rem;
}

.kh-dash__range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.kh-dash__range-label {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-dash__range-input {
  width: 7.5rem;
  min-height: 38px;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-caption);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.kh-dash__range-input::placeholder { color: var(--text-3); }

.kh-dash__range-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.kh-dash__range-go {
  min-height: 38px;
  padding: 0.2rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.kh-dash__range-go:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.kh-dash__window {
  margin-top: var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-dash__window-dates {
  margin-inline-start: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.kh-dash__empty {
  padding: var(--sp-5) 0;
  color: var(--text-3);
  text-align: center;
}

/* Time runs left to right even in RTL: that is how a time axis is read. */
.kh-trend {
  direction: ltr;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 170px;
  padding-bottom: 1.4rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.kh-trend__col {
  position: relative;
  flex: 1 0 9px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
}

.kh-trend__bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  opacity: 0.75;
  transition: opacity var(--dur-fast) var(--ease);
}

.kh-trend__col:hover .kh-trend__bar { opacity: 1; }

.kh-trend__label {
  position: absolute;
  bottom: -1.3rem;
  font-size: var(--fs-label);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Past roughly a fortnight the labels collide, so thin them out. */
.kh-trend--dense .kh-trend__col:nth-child(even) .kh-trend__label { display: none; }
.kh-trend--packed .kh-trend__col:not(:nth-child(7n + 1)) .kh-trend__label { display: none; }

@media (max-width: 700px) {
  .kh-dash__filter { flex-direction: column; align-items: stretch; }
  .kh-dash__range { justify-content: space-between; }
  .kh-dash__range-input { width: 100%; }
}

.kh-dash__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.kh-dash__card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.kh-dash__card-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.3;
}

.kh-dash__card-label {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-dash__block {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.kh-dash__block-title {
  font-size: var(--fs-h3);
  font-weight: 700;
  margin-bottom: var(--sp-3);
}

.kh-dash__grid {
  display: grid;
  gap: var(--sp-4);
}

@media (min-width: 900px) {
  .kh-dash__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kh-dash__grid .kh-dash__block {
    margin-bottom: 0;
  }
}

/* funnel */
.kh-funnel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.kh-funnel__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 0.4rem;
}

.kh-funnel__label {
  font-weight: 600;
  font-size: var(--fs-small);
}

.kh-funnel__count {
  font-size: var(--fs-caption);
  color: var(--text-3);
}

.kh-funnel__bar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  height: 26px;
  overflow: hidden;
}

.kh-funnel__bar {
  height: 100%;
  background: linear-gradient(to left, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
  border-radius: var(--radius-sm);
  transition: width var(--dur-slow) var(--ease);
}

[dir='ltr'] .kh-funnel__bar {
  background: linear-gradient(to right, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
}

.kh-funnel__share {
  position: absolute;
  inset-inline-end: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-2);
}

.kh-funnel__drop {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: var(--fs-label);
  color: var(--neg);
}

/* page-impact: which pages help vs. leak engagement */
.kh-impact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
}

.kh-impact__title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.kh-impact__title.is-good { color: var(--pos); }
.kh-impact__title.is-bad { color: var(--neg); }

@media (max-width: 900px) {
  .kh-impact { grid-template-columns: 1fr; }
}

/* simple labelled bars */
.kh-dash__row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding-block: 0.4rem;
}

.kh-dash__row-label {
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.kh-dash__row-bar {
  height: 7px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
}

.kh-dash__row-bar span {
  display: block;
  height: 100%;
  background: var(--series-b);
  border-radius: 4px;
}

.kh-dash__row-value {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-3);
}

.kh-dash__row--link {
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
}

.kh-dash__row--link:hover {
  background: var(--surface);
}

.kh-dash__row--link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* segment filter bar — repeated above every dashboard section */
.kh-seg-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--border-soft);
}

.kh-seg-filter__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.kh-seg-filter__label {
  font-size: var(--fs-caption);
  color: var(--text-3);
  margin-inline-end: 0.2rem;
}

.kh-seg-filter__count {
  font-size: var(--fs-caption);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.kh-seg-filter__clear {
  font-size: var(--fs-caption);
  color: var(--accent);
  text-decoration: none;
}

.kh-seg-filter__clear:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .kh-seg-filter { flex-direction: column; align-items: flex-start; }
}

/* tables */
.kh-dash__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-caption);
}

.kh-dash__table th {
  text-align: start;
  font-weight: 600;
  color: var(--text-3);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}

.kh-dash__table td {
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
  vertical-align: top;
}

.kh-dash__table tr:last-child td {
  border-bottom: 0;
}

.kh-dash__path {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  unicode-bidi: isolate;
}

.kh-dash__path a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-soft);
}

.kh-dash__path a:hover {
  color: var(--text);
  border-bottom-color: var(--text-2);
}

.kh-dash__table .is-bad { color: var(--neg); }
.kh-dash__table .is-good { color: var(--pos); }

.kh-dash__table--wide {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.kh-dash__when {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  white-space: nowrap;
}

.kh-dash__journey {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.kh-dash__step {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  color: var(--text-2);
  text-decoration: none;
}

.kh-dash__step:hover {
  color: var(--text);
  border-color: var(--text-2);
}

.kh-dash__arrow {
  color: var(--text-3);
}

.kh-dash__note {
  margin-top: var(--sp-3);
  font-size: var(--fs-caption);
  color: var(--text-3);
  line-height: 1.9;
}

.kh-dash__chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-inline-end: 0.3rem;
  color: var(--text-2);
  unicode-bidi: isolate;
}

/* hour x weekday heatmap */
.kh-heat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-x: auto;
}

.kh-heat__hours,
.kh-heat__row {
  display: grid;
  grid-template-columns: 64px repeat(24, minmax(14px, 1fr));
  gap: 3px;
  align-items: center;
}

.kh-heat__hours span {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-3);
  text-align: center;
}

.kh-heat__day {
  font-size: var(--fs-label);
  color: var(--text-3);
  white-space: nowrap;
}

.kh-heat__cell {
  aspect-ratio: 1;
  min-height: 14px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) calc(var(--v) * 100%), var(--surface));
  border: 1px solid var(--border-soft);
}

@media (max-width: 640px) {
  .kh-dash__row {
    grid-template-columns: 1fr auto;
  }
  .kh-dash__row-bar {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------------------------
   20. Pagination
   -------------------------------------------------------------------------- */
.kh-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: var(--sp-6);
}

.kh-pagination a,
.kh-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding-inline: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.kh-pagination a:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.kh-pagination .is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.kh-pagination .kh-ellipsis {
  border: 0;
  min-width: auto;
}

/* --------------------------------------------------------------------------
   21. Empty / status states
   -------------------------------------------------------------------------- */
.kh-empty {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
}

.kh-empty svg {
  width: 120px;
  height: 44px;
  margin: 0 auto var(--sp-3);
  display: block;
  opacity: 0.6;
}

.kh-empty__title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-1);
}

.kh-empty p {
  font-size: var(--fs-small);
}

/* --------------------------------------------------------------------------
   22. Reveal on scroll
   -------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  translate: 0 14px;
  transition: opacity var(--dur-slow) var(--ease), translate var(--dur-slow) var(--ease);
}

[data-reveal].is-visible {
  opacity: 1;
  translate: 0 0;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1;
    translate: 0 0;
  }
}

/* --------------------------------------------------------------------------
   23. Small-screen typography adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* Small screens get tighter tracking, not smaller letters: 10px and 8.5px
     mono capitals were below what can be read on a phone. */
  .kh-kicker {
    letter-spacing: 0.1em;
  }

  .kh-brand__tag {
    letter-spacing: 0.08em;
  }

  .kh-header__inner {
    gap: var(--sp-3);
  }

  .kh-hero__kicker::after {
    display: none;
  }

  .kh-section-head {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  .kh-section-head__title {
    white-space: normal;
  }
}

/* --------------------------------------------------------------------------
   24. Utilities
   -------------------------------------------------------------------------- */
.kh-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;
}

.kh-text-2 { color: var(--text-2); }
.kh-text-3 { color: var(--text-3); }
.kh-mt-2 { margin-top: var(--sp-2); }
.kh-mt-3 { margin-top: var(--sp-3); }
.kh-mt-4 { margin-top: var(--sp-4); }
.kh-mt-5 { margin-top: var(--sp-5); }
.kh-ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }

/* --------------------------------------------------------------------------
   20. Homepage as a market terminal — compact hero, insight bar, panels
   -------------------------------------------------------------------------- */
.kh-hero--compact { padding-block: clamp(1.6rem, 4vh, 2.6rem) clamp(1rem, 2.5vh, 1.6rem); }
.kh-hero--compact .kh-hero__grid { align-items: center; gap: var(--sp-4); }
.kh-hero--compact .kh-hero__title { font-size: clamp(1.45rem, 2.6vw, 2.1rem); margin: 0.35rem 0 0.5rem; }
.kh-hero--compact .kh-hero__lede { font-size: 0.98rem; max-width: 40rem; margin: 0 0 0.8rem; }
.kh-hero--compact .kh-hero__ctas { gap: 0.5rem; }
.kh-hero--compact .kh-hero__ctas .kh-btn { min-height: 38px; padding: 0.3rem 1rem; font-size: var(--fs-caption); }
.kh-hero--compact .kh-viz__canvas { height: clamp(140px, 16vw, 190px); }
.kh-hero--compact .kh-viz__example { margin-bottom: 0.2rem; }

.kh-terminal { padding-block: var(--sp-3) var(--sp-4); }
.kh-terminal__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.5rem 1rem; margin-bottom: var(--sp-3);
}
.kh-terminal__title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.kh-terminal__stamp { font-size: var(--fs-caption); color: var(--text-3); }
.kh-terminal__stamp a { color: inherit; }

.kh-mkt { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.6rem; }
.kh-mkt__card {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.75rem 0.85rem 0.6rem;
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--bg-2); color: var(--text); text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.kh-mkt__card:hover { border-color: var(--text-3); transform: translateY(-1px); }
.kh-mkt__card:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.kh-mkt__label { font-size: 0.78rem; color: var(--text-2); display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.kh-mkt__flag { font-size: var(--fs-label); padding: 0.05rem 0.4rem; border-radius: 999px; background: color-mix(in srgb, var(--pos) 22%, var(--surface)); color: var(--text); }
.kh-mkt__flag--low { background: color-mix(in srgb, var(--neg) 22%, var(--surface)); }
.kh-mkt__value { font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kh-mkt__change { font-size: 0.78rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.kh-mkt__change b { font-weight: 700; }
.kh-mkt__card.is-up .kh-mkt__change b { color: var(--pos); }
.kh-mkt__card.is-down .kh-mkt__change b { color: var(--neg); }
.kh-mkt__change .is-up { color: var(--pos); } .kh-mkt__change .is-down { color: var(--neg); }
.kh-mkt__meta { font-size: var(--fs-label); color: var(--text-3); }
.kh-spark { width: 100%; height: 28px; display: block; margin-top: 0.2rem; }
.kh-spark path { fill: none; stroke: var(--text-3); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.kh-mkt__card.is-up .kh-spark path { stroke: var(--pos); }
.kh-mkt__card.is-down .kh-spark path { stroke: var(--neg); }

.kh-mkt__skeleton { min-height: 120px; border: 1px dashed var(--border); border-radius: var(--radius); }
.is-loading .kh-mkt__skeleton { animation: kh-pulse 1.4s ease-in-out infinite; }
@keyframes kh-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.9; } }
.kh-panel__fail { display: none; font-size: var(--fs-caption); color: var(--text-3); padding: var(--sp-3) 0; }
.is-failed .kh-panel__fail { display: block; }
.is-failed .kh-mkt__skeleton, .is-ready .kh-mkt__skeleton { display: none; }

.kh-pulse { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.7rem; font-size: var(--fs-caption); }
.kh-pulse__chip { padding: 0.15rem 0.65rem; border-radius: 999px; border: 1px solid var(--border-soft); color: var(--text-2); }
.kh-pulse__chip.is-up { border-color: color-mix(in srgb, var(--pos) 50%, transparent); color: var(--pos); }
.kh-pulse__chip.is-down { border-color: color-mix(in srgb, var(--neg) 50%, transparent); color: var(--neg); }
.kh-pulse__text { flex-basis: 100%; color: var(--text-2); line-height: 1.8; }

.kh-panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-top: var(--sp-4); }
.kh-panel {
  border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2);
  padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; min-width: 0;
}
.kh-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.kh-panel__title { margin: 0; font-size: 0.95rem; font-weight: 700; }
.kh-panel__more { font-size: var(--fs-caption); color: var(--text-3); white-space: nowrap; }
.kh-panel__more:hover { color: var(--text); }
.kh-panel__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.kh-panel__list li a, .kh-panel__list li .kh-panel__row {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "badge name value" "badge sub sub";
  align-items: center; column-gap: 0.55rem; padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--text);
}
.kh-panel__list li a:hover { background: var(--surface); }
.kh-panel__list li a > .kh-badge, .kh-panel__list li .kh-panel__row > .kh-badge { grid-area: badge; }
.kh-panel__list li a > span:not(.kh-badge), .kh-panel__list li .kh-panel__row > span:not(.kh-badge) { grid-area: name; font-size: 0.9rem; }
.kh-panel__list li a > b, .kh-panel__list li .kh-panel__row > b { grid-area: value; font-variant-numeric: tabular-nums; }
.kh-panel__list li a > small, .kh-panel__list li .kh-panel__row > small { grid-area: sub; font-size: 0.7rem; color: var(--text-3); }
.kh-panel__list li a > .kh-mp__price, .kh-panel__list li .kh-panel__row > .kh-mp__price { grid-area: value; font-weight: 600; font-variant-numeric: tabular-nums; }
.kh-panel__list b.is-up, .kh-panel__list .is-up { color: var(--pos); }
.kh-panel__list b.is-down, .kh-panel__list .is-down { color: var(--neg); }
.kh-panel__list.kh-panel__list--movers li a { grid-template-columns: 1fr auto; grid-template-areas: "name value" "sub sub"; }
.kh-panel__list.kh-panel__list--mp li .kh-panel__row { grid-template-columns: 1fr auto auto; grid-template-areas: "name price change" "sub sub sub"; }
/* the generic rule above sets grid-area:value, which this layout has no area
   named — an unmatched grid-area falls back to auto-placement and the price
   lands on top of the product name instead of its own column */
.kh-panel__list.kh-panel__list--mp li .kh-panel__row > .kh-mp__price { grid-area: price; }
.kh-panel__list.kh-panel__list--mp li .kh-panel__row > b { grid-area: change; }
.kh-panel__list.kh-panel__list--mp li .kh-panel__row > .kh-mp__nohist { grid-area: change; font-size: var(--fs-label); }
.kh-panel__text { font-size: 0.86rem; line-height: 1.9; color: var(--text-2); margin: 0.4rem 0 0; }
.kh-panel__queries { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-top: 0.5rem; }
.kh-panel__stamp { margin-top: auto; padding-top: 0.6rem; font-size: var(--fs-label); color: var(--text-3); }

.kh-terminal__head--bourse { margin-top: var(--sp-5); }
.kh-bourse { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.kh-bourse__card { min-height: 120px; }
.kh-bourse__activity {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem;
  margin: var(--sp-3) 0 0; padding: 0.7rem 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
}
.kh-bourse__activity-item { display: flex; flex-direction: column; gap: 0.15rem; }
.kh-bourse__activity-item dt { font-size: var(--fs-label); color: var(--text-3); }
.kh-bourse__activity-item dd { margin: 0; font-size: 0.92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kh-bourse__analysis { margin: 0.7rem 0 0; font-size: 0.86rem; line-height: 1.9; color: var(--text-2); }

@media (max-width: 1100px) { .kh-mkt { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kh-panels { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) {
  .kh-mkt { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kh-bourse { grid-template-columns: 1fr; }
  .kh-panels { grid-template-columns: 1fr; }
  .kh-hero--compact .kh-viz { display: none; }
}

/* --------------------------------------------------------------------------
   21. The lab — index tiles, change list, signals, overlay, detail pages
   -------------------------------------------------------------------------- */
.kh-hero--lab .kh-hero__title { font-size: clamp(1.5rem, 2.8vw, 2.2rem); letter-spacing: -0.01em; }
.kh-hero--lab .kh-hero__lede { font-size: 0.95rem; color: var(--text-2); max-width: 44rem; }

.kh-lab { padding-block: var(--sp-3) var(--sp-5); }
.kh-lab__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: var(--sp-3); }
.kh-lab__title { margin: 0.2rem 0 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.kh-lab__stamp { margin: 0; font-size: var(--fs-caption); color: var(--text-3); }
.kh-lab__note { margin: 0.6rem 0 0; font-size: var(--fs-caption); color: var(--text-3); line-height: 1.8; }
.kh-lab__empty { font-size: var(--fs-caption); color: var(--text-3); padding: var(--sp-3) 0; }

.kh-tag { display: inline-block; padding: 0.08rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); font-size: var(--fs-label); font-weight: 600; color: var(--text-2); vertical-align: middle; letter-spacing: 0.02em; }
.kh-tag--exp { border-color: color-mix(in srgb, var(--series-e) 55%, transparent); color: var(--series-e); font-family: var(--font-mono); }
.kh-tag--ok { border-color: color-mix(in srgb, var(--pos) 55%, transparent); color: var(--pos); }
.kh-tag--bad { border-color: color-mix(in srgb, var(--neg) 55%, transparent); color: var(--neg); }
.kh-tag--warn { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }

.kh-idx-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.kh-idx {
  position: relative; display: flex; flex-direction: column; gap: 0.35rem; min-height: 150px;
  padding: 0.8rem 0.9rem 0.7rem; border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--bg-2); color: var(--text); text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.kh-idx:hover { border-color: var(--text-3); transform: translateY(-1px); }
.kh-idx:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.kh-idx--skeleton { border-style: dashed; animation: kh-pulse 1.4s ease-in-out infinite; }
.kh-idx__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.kh-idx__titles { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.kh-idx__label { font-weight: 700; font-size: 0.95rem; }
.kh-idx__en { font-size: var(--fs-label); color: var(--text-3); font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.kh-idx__row { display: flex; align-items: baseline; gap: 0.6rem; }
.kh-idx__value { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kh-idx__value--big { font-size: 3.4rem; }
.kh-idx__delta { font-size: 0.78rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.kh-idx__delta small { font-size: var(--fs-label); }
/* for a stress index, up is bad news; for a demand index, up is good news */
.kh-idx--stress .kh-idx__delta.is-up { color: var(--neg); }
.kh-idx--stress .kh-idx__delta.is-down { color: var(--pos); }
.kh-idx--good .kh-idx__delta.is-up { color: var(--pos); }
.kh-idx--good .kh-idx__delta.is-down { color: var(--neg); }
.kh-idx--good .kh-gauge__fill { background: linear-gradient(90deg, var(--neg), var(--series-a) 55%, var(--pos)); }
[dir='rtl'] .kh-idx--good .kh-gauge__fill { background: linear-gradient(270deg, var(--neg), var(--series-a) 55%, var(--pos)); }
.kh-idx__foot { display: flex; justify-content: space-between; gap: 0.5rem; font-size: var(--fs-label); color: var(--text-3); margin-top: auto; }
.kh-idx__collecting { font-size: var(--fs-caption); color: var(--text-3); margin-top: 0.4rem; }
.kh-idx__caption { font-size: var(--fs-label); line-height: 1.6; color: var(--text-3); margin: 0.5rem 0 0; }
.kh-idx .kh-tag--exp { flex-shrink: 0; white-space: nowrap; }
.kh-spark--idx { height: 24px; }
.kh-spark--idx path { stroke: var(--series-a); }

.kh-gauge { position: relative; height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--text-3) 22%, transparent); overflow: hidden; }
.kh-gauge--big { height: 10px; margin-top: 0.6rem; }
.kh-gauge__fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: calc(var(--v) * 1%); border-radius: 999px; background: linear-gradient(90deg, var(--pos), var(--series-a) 55%, var(--neg)); background-size: calc(100% / (var(--v) / 100)) 100%; }
[dir='rtl'] .kh-gauge__fill { background: linear-gradient(270deg, var(--pos), var(--series-a) 55%, var(--neg)); }
.kh-gauge__mid { position: absolute; top: -2px; bottom: -2px; inset-inline-start: 50%; width: 1px; background: var(--text-3); opacity: 0.6; }

.kh-lab-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: var(--sp-4); }
.kh-lab-col { min-width: 0; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); padding: var(--sp-3) var(--sp-4); }
.kh-lab-col__head { margin-bottom: 0.6rem; }
.kh-lab-col__title { margin: 0.15rem 0 0.2rem; font-size: 1rem; font-weight: 700; }
.kh-lab-col__sub { margin: 0; font-size: 0.72rem; color: var(--text-3); line-height: 1.7; }

.kh-lab-col--wide { margin-top: 1rem; min-width: 0; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); padding: var(--sp-3) var(--sp-4); }

.kh-table-wrap { overflow-x: auto; margin-top: 0.5rem; }
.kh-table-wrap--scroll { max-height: 640px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
.kh-table-wrap--scroll .kh-brand-table thead th { position: sticky; top: 0; background: var(--bg-2); z-index: 1; }

.kh-pager { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.6rem; }
.kh-pager__btn {
  min-width: 2rem; padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); border: 1px solid var(--border-soft);
  background: var(--bg-2); color: var(--text-2); font-size: var(--fs-caption); font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.kh-pager__btn:hover { border-color: var(--text-3); color: var(--text); }
.kh-pager__btn.is-active { background: var(--series-a); border-color: var(--series-a); color: var(--bg); font-weight: 700; }
.kh-brand-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.kh-brand-table th { text-align: start; font-weight: 600; color: var(--text-3); font-size: 0.7rem; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-soft); }
.kh-brand-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.kh-brand-table td:nth-child(5), .kh-brand-table td:nth-child(6) { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kh-brand-row { border-inline-start: 3px solid transparent; }
.kh-brand-row.is-up { border-inline-start-color: var(--pos); }
.kh-brand-row.is-down { border-inline-start-color: var(--neg); }
.kh-brand-row:hover { background: var(--surface); }
.kh-brand-row__link { color: var(--text); text-decoration: none; font-weight: 600; }
.kh-brand-row__link:hover { text-decoration: underline; }
.kh-brand-row__change.is-up { color: var(--pos); }
.kh-brand-row__change.is-down { color: var(--neg); }
.kh-tag--sm { padding: 0.02rem 0.4rem; font-size: var(--fs-label); }

.kh-changed { list-style: none; margin: 0; padding: 0; counter-reset: c; }
.kh-changed__row {
  display: grid; grid-template-columns: auto 1fr 64px auto auto; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0; border-bottom: 1px solid var(--border-soft); font-size: 0.88rem;
}
.kh-changed__row:last-child { border-bottom: 0; }
.kh-changed__kind { font-size: var(--fs-label); padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text-3); white-space: nowrap; }
.kh-changed__kind--search { border-color: color-mix(in srgb, var(--series-b) 50%, transparent); color: var(--series-b); }
.kh-changed__kind--market { border-color: color-mix(in srgb, var(--series-a) 50%, transparent); color: var(--series-a); }
.kh-changed__kind--derived { border-color: color-mix(in srgb, var(--series-c) 50%, transparent); color: var(--series-c); }
.kh-changed__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kh-spark--mini { height: 20px; width: 64px; }
.kh-spark--mini path { stroke: var(--text-3); }
.kh-changed__num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.2rem; text-align: start; }
.kh-changed__num.is-up { color: var(--series-a); } .kh-changed__num.is-down { color: var(--series-b); }
.kh-changed__z { font-size: var(--fs-label); color: var(--text-3); font-family: var(--font-mono); }

.kh-sig { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.kh-sig__card { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.6rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); text-decoration: none; color: var(--text); background: var(--surface); }
.kh-sig__card:hover { border-color: var(--text-3); }
.kh-sig__title { font-size: 0.9rem; font-weight: 600; line-height: 1.6; }
.kh-sig__meta { font-size: 0.7rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.kh-sig--dim .kh-sig__card { background: transparent; }
.kh-sig--dim .kh-sig__title { font-weight: 500; color: var(--text-2); font-size: 0.82rem; }
.kh-sig__more { margin-top: 0.6rem; }
.kh-sig__more summary { cursor: pointer; font-size: var(--fs-caption); color: var(--text-3); }
.kh-sig__more[open] summary { margin-bottom: 0.4rem; }

.kh-overlay { min-width: 0; margin-top: 1rem; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); padding: var(--sp-3) var(--sp-4); }
.kh-overlay__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.5rem; }
.kh-overlay__pick { font-size: var(--fs-caption); color: var(--text-3); display: flex; align-items: center; gap: 0.4rem; }
.kh-overlay__pick select { max-width: min(24rem, 100%); min-width: 0; padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-caption); }
.kh-overlay__chart-wrap { height: 240px; margin-top: 0.4rem; }
.kh-overlay__chart-wrap canvas, .kh-labpage__chart canvas { width: 100%; height: 100%; display: block; }
.kh-overlay__caption { margin: 0.5rem 0 0; font-size: var(--fs-caption); color: var(--text-3); line-height: 1.7; }

/* «این روزها چه چیزی توی داده‌ها دیده می‌شه؟» — rule-based data observations */
.kh-dataobs__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }
.kh-dataobs__card { display: flex; flex-direction: column; gap: 0.4rem; padding: 1rem 1.1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; transition: border-color var(--dur-fast) var(--ease); }
.kh-dataobs__card:hover, .kh-dataobs__card:focus-visible { border-color: var(--accent); }
.kh-dataobs__text { margin: 0; line-height: 1.8; }
.kh-dataobs__limit { margin: 0; font-size: var(--fs-caption); color: var(--text-3); }
.kh-dataobs__note { margin-top: 0.9rem; font-size: var(--fs-caption); color: var(--text-3); }
.kh-mstrip { padding-block: 0 var(--sp-4); }
.kh-mstrip__row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.6rem 0.9rem; border: 1px dashed var(--border); border-radius: var(--radius); font-size: var(--fs-caption); }
.kh-mstrip__label { color: var(--text-3); font-weight: 600; }
.kh-mstrip__item { display: inline-flex; align-items: baseline; gap: 0.4rem; color: var(--text-2); text-decoration: none; }
.kh-mstrip__item b { color: var(--text); font-variant-numeric: tabular-nums; }
.kh-mstrip__item em { font-style: normal; font-size: 0.7rem; }
.kh-mstrip__item em.is-up { color: var(--pos); } .kh-mstrip__item em.is-down { color: var(--neg); }
.kh-mstrip__more { margin-inline-start: auto; color: var(--text-3); text-decoration: none; }
.kh-mstrip__more:hover { color: var(--text); }

/* detail pages */
.kh-labpage__hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--sp-4); align-items: stretch; }
.kh-labpage__value { border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); padding: var(--sp-4); display: flex; flex-direction: column; gap: 0.3rem; }
.kh-labpage__read { margin: 0.6rem 0 0; font-size: var(--fs-caption); color: var(--text-2); line-height: 1.8; }
.kh-labpage__asof { margin: 0.4rem 0 0; font-size: var(--fs-caption); color: var(--text-3); }
.kh-labpage__chart { height: 260px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); padding: 0.6rem; }
.kh-labpage__chart--tall { height: 320px; }

.kh-brand-chart { width: 100%; height: calc(100% - 1.4rem); display: block; }
.kh-brand-chart__line { fill: none; stroke: var(--series-a); stroke-width: 2; vector-effect: non-scaling-stroke; }
.kh-brand-chart__axis { display: flex; justify-content: space-between; margin-top: 0.4rem; font-size: var(--fs-caption); color: var(--text-3); font-family: var(--font-mono); }
.kh-labpage__value .kh-idx__delta.is-up { color: var(--pos); }
.kh-labpage__value .kh-idx__delta.is-down { color: var(--neg); }
.kh-labpage__section { margin-top: var(--sp-6); }
.kh-labpage__two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.kh-labpage__reading { font-size: 1.02rem; line-height: 2; margin: 0 0 0.5rem; }
.kh-labpage__collecting { padding: var(--sp-5); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-2); }
.kh-labpage__comps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.6rem; margin-top: var(--sp-3); }
.kh-comp-mini { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 0.5rem 0.6rem; background: var(--bg-2); }
.kh-comp-mini__label { display: block; font-size: 0.7rem; color: var(--text-3); margin-bottom: 0.2rem; }
.kh-comp-mini__chart { width: 100%; height: 90px; display: block; }
.kh-formulas { margin: 0; padding-inline-start: 1.2rem; line-height: 1.9; font-size: 0.92rem; }
.kh-formulas li + li { margin-top: 0.4rem; }
.kh-comp td:first-child { font-weight: 600; }

@media (max-width: 900px) { .kh-idx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) { .kh-lab-cols, .kh-labpage__two, .kh-labpage__hero { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
  .kh-idx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kh-overlay__head { flex-direction: column; align-items: stretch; }
  .kh-overlay__pick { flex-direction: column; align-items: stretch; }
  .kh-overlay__pick select { width: 100%; }
  .kh-idx__value { font-size: 1.7rem; }
  .kh-changed__row { grid-template-columns: auto 1fr auto; }
  .kh-changed__row .kh-spark--mini, .kh-changed__z { display: none; }
  .kh-mstrip__more { margin-inline-start: 0; flex-basis: 100%; }
}

/* --------------------------------------------------------------------------
   Navigation groups (Data submenu) + taxonomy tags
   Added with the Information-Architecture pass: five primary destinations,
   with the data pages grouped one level down instead of competing for
   top-level attention.
   -------------------------------------------------------------------------- */

.kh-nav__group {
  position: relative;
  display: flex;
  align-items: center;
}

.kh-nav__group-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.kh-nav__caret {
  width: 14px;
  height: 14px;
  opacity: 0.6;
  transition: transform var(--dur-fast) var(--ease);
}

.kh-nav__panel {
  position: absolute;
  top: calc(100% + 0.55rem);
  inset-inline-start: 50%;
  transform: translateX(50%) translateY(-4px);
  min-width: 15rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 44px -20px rgb(0 0 0 / 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
              visibility var(--dur-fast) var(--ease);
  z-index: 95;
}

/* RTL: the panel hangs from the start edge, so the translate flips */
html[dir='ltr'] .kh-nav__panel { transform: translateX(-50%) translateY(-4px); }

.kh-nav__group:hover .kh-nav__panel,
.kh-nav__group:focus-within .kh-nav__panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(50%) translateY(0);
}

html[dir='ltr'] .kh-nav__group:hover .kh-nav__panel,
html[dir='ltr'] .kh-nav__group:focus-within .kh-nav__panel {
  transform: translateX(-50%) translateY(0);
}

.kh-nav__group:hover .kh-nav__caret,
.kh-nav__group:focus-within .kh-nav__caret { transform: rotate(180deg); }

.kh-nav__panel a {
  padding: 0.45rem 0.7rem;
  border-radius: calc(var(--radius) - 4px);
  white-space: nowrap;
  color: var(--text-2);
}

.kh-nav__panel a:hover {
  background: var(--surface-2);
  color: var(--text);
}

@media (max-width: 899px) {
  /* In the mobile sheet there is room to simply show the group inline —
     no hover target to hunt for, no second tap. */
  .kh-nav__group { flex-direction: column; gap: 0.2rem; }
  .kh-nav__caret { display: none; }
  .kh-nav__panel {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    align-items: center;
    gap: 0;
  }
  html[dir='ltr'] .kh-nav__panel { transform: none; }
  .kh-nav__panel a {
    font-size: 0.98rem;
    font-weight: 500;
    color: var(--text-3);
    padding: 0.3rem 1rem;
  }
}

/* Content-type tags: one muted family, only the accent for the daily brief
   so "today's thing" is findable in a grid without shouting. */
.kh-tag--type-analysis { border-color: color-mix(in srgb, var(--series-b) 55%, transparent); color: var(--series-b); }
.kh-tag--type-note     { border-color: color-mix(in srgb, var(--series-a) 55%, transparent); color: var(--series-a); }
.kh-tag--type-brief    { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.kh-tag--type-archive  { border-color: var(--border); color: var(--text-3); }
.kh-tag--type-video    { border-color: color-mix(in srgb, var(--series-e) 55%, transparent); color: var(--series-e); }

.kh-card__excerpt {
  margin-top: 0.4rem;
  font-size: var(--fs-small);
  color: var(--text-3);
  line-height: 1.7;
}

.kh-search--lg input { font-size: 1.05rem; padding-block: 0.7rem; }

/* --------------------------------------------------------------------------
   Article: sources, related content, and the Data / Interpretation / My-view
   distinction. The callout classes are applied inside article bodies from the
   editor, so a reader can always tell which of the three they are reading.
   -------------------------------------------------------------------------- */

.kh-sources__list {
  list-style: none;
  margin: var(--sp-2) 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: var(--fs-small);
  color: var(--text-3);
}

.kh-sources__list li {
  padding-inline-start: 0.9rem;
  position: relative;
  word-break: break-word;
}

.kh-sources__list li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0.62em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  opacity: 0.6;
}

.kh-related {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
  display: grid;
  gap: var(--sp-4);
}

.kh-related__group { display: grid; gap: 0.6rem; }

.kh-related__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* Three callouts for article bodies. Data is stated, interpretation is
   reasoned, a personal view is owned — each gets its own edge colour and
   label so the three are never mistaken for one another. */
.kh-prose .kh-callout {
  margin: var(--sp-4) 0;
  padding: var(--sp-3) var(--sp-4);
  border-inline-start: 3px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
}

.kh-prose .kh-callout::before {
  content: attr(data-label);
  display: block;
  font-size: var(--fs-label);
  letter-spacing: 0;          /* labels are Persian («برداشت تحلیلی»): spacing would break the joins */
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.35rem;
}

.kh-prose .kh-callout--data { border-inline-start-color: var(--series-b); }
.kh-prose .kh-callout--data::before { color: var(--series-b); }
.kh-prose .kh-callout--reading { border-inline-start-color: var(--series-a); }
.kh-prose .kh-callout--reading::before { color: var(--series-a); }
.kh-prose .kh-callout--view { border-inline-start-color: var(--accent); }
.kh-prose .kh-callout--view::before { color: var(--accent); }
.kh-prose .kh-callout--limit { border-inline-start-color: var(--text-3); }
/* «کجای کسب‌وکار شما به کار می‌آید؟» — the business uses the article agent writes after the key facts */
.kh-prose .kh-callout--uses { border-inline-start-color: var(--series-c); }
.kh-prose .kh-callout--uses::before { color: var(--series-c); }
.kh-prose .kh-callout--uses ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.kh-prose .kh-callout--uses li { margin: 0; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border-soft); }
.kh-prose .kh-callout--uses li:last-child { padding-bottom: 0; border-bottom: 0; }
.kh-prose .kh-callout--uses li p { margin: 0 0 0.3rem; }

/* --------------------------------------------------------------------------
   Tickers — scrolling rows of clickable readings (market state, brands).
   Pure CSS marquee: the track holds two copies of the list and translates
   by exactly half its width, so the loop is seamless. RTL flips the
   direction. Pauses on hover/focus; static under reduced motion.
   -------------------------------------------------------------------------- */
.kh-ticker {
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-2);
}

.kh-ticker__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 2.9rem;
}

.kh-ticker__label {
  flex: none;
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  color: var(--text-3);
  white-space: nowrap;
}

.kh-ticker__viewport {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
}

.kh-ticker__track {
  display: flex;
  width: max-content;
  animation: kh-ticker-scroll var(--ticker-speed, 60s) linear infinite;
}

html[dir='rtl'] .kh-ticker__track { animation-name: kh-ticker-scroll-rtl; }

.kh-ticker__viewport:hover .kh-ticker__track,
.kh-ticker__viewport:focus-within .kh-ticker__track { animation-play-state: paused; }

.kh-ticker__list {
  display: flex;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kh-ticker__item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  border-inline-end: 1px solid var(--border-soft);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.kh-ticker__item:hover,
.kh-ticker__item:focus-visible { color: var(--text); background: var(--surface-2); }
.kh-ticker__item b { color: var(--text); font-variant-numeric: tabular-nums; }
.kh-ticker__item small { font-size: var(--fs-label); color: var(--text-3); }
.kh-ticker__item em { font-style: normal; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.kh-ticker__item.is-up em { color: var(--pos); }
.kh-ticker__item.is-down em { color: var(--neg); }
.kh-ticker__item.is-flat em { color: var(--text-3); }

.kh-ticker__scope {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-3);
}

.kh-ticker__more {
  flex: none;
  font-size: var(--fs-small);
  color: var(--text-3);
  text-decoration: none;
  white-space: nowrap;
}
.kh-ticker__more:hover { color: var(--text); }

/* brands run a touch faster and read as one long line */
.kh-ticker--brands { --ticker-speed: 90s; }
.kh-ticker--state { --ticker-speed: 55s; }
.kh-ticker--bourse { --ticker-speed: 80s; }
.kh-ticker--ai { --ticker-speed: 75s; }
.kh-ticker__note { display: block; margin-top: 2px; font-size: 0.68rem; letter-spacing: 0; color: var(--text-3); opacity: 0.85; }

@keyframes kh-ticker-scroll     { from { transform: translateX(0); }  to { transform: translateX(-50%); } }
@keyframes kh-ticker-scroll-rtl { from { transform: translateX(0); }  to { transform: translateX(50%); } }

@media (prefers-reduced-motion: reduce) {
  .kh-ticker__track { animation: none; width: auto; }
  .kh-ticker__viewport { overflow-x: auto; mask-image: none; -webkit-mask-image: none; }
  .kh-ticker__list[aria-hidden='true'] { display: none; }
}

@media (max-width: 899px) {
  .kh-ticker__more { display: none; }
  .kh-ticker__label { display: none; }
}

/* the homepage's recent-analysis grid is a fixed four across, so a fourth
   card fills the row instead of leaving auto-fill's empty slot */
.kh-card-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1099px) { .kh-card-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px)  { .kh-card-grid--four { grid-template-columns: 1fr; } }

/* compact about band, sitting high on the homepage */
.kh-about--compact .kh-portrait img { max-height: 260px; width: auto; }

/* --------------------------------------------------------------------------
   Trending products page: quadrant tags (level AND direction, per
   shopping._quadrant), unavailable rows, and the best-sellers cell.
   -------------------------------------------------------------------------- */
.kh-tag--q-star,
.kh-tag--q-rising  { border-color: color-mix(in srgb, var(--pos) 55%, transparent); color: var(--pos); }
.kh-tag--q-elevated,
.kh-tag--q-seasonal { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.kh-tag--q-peaking,
.kh-tag--q-cooling { border-color: color-mix(in srgb, var(--neg) 55%, transparent); color: var(--neg); }
.kh-tag--q-core,
.kh-tag--q-niche,
.kh-tag--q-thin    { border-color: var(--border); color: var(--text-3); }

.kh-dash__table tr.is-muted td { color: var(--text-3); }
.kh-bestsellers { font-size: 0.78rem; line-height: 1.7; max-width: 22rem; }
.kh-bestsellers a { color: var(--text-2); text-decoration: none; }
.kh-bestsellers a:hover { color: var(--text); text-decoration: underline; }

.kh-ticker--products { --ticker-speed: 75s; }

/* ---- problem paths (homepage: start from the question) ---- */
.kh-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.kh-path { display: flex; flex-direction: column; gap: 0.5rem; padding: var(--sp-4); border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-2); min-width: 0; }
.kh-path__q { font-size: var(--fs-h3); font-weight: 700; margin: 0; color: var(--text); line-height: 1.6; }
.kh-path__lede { color: var(--text-2); font-size: var(--fs-small); margin: 0; }
.kh-path__links { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.kh-path__links a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--fs-small); min-width: 0; }
.kh-path__links a:hover, .kh-path__links a:focus-visible { color: var(--accent-strong); }
.kh-path__kind { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--text-3); letter-spacing: 0.06em; flex: none; direction: ltr; }

/* --------------------------------------------------------------------------
   Even rows. auto-fit / auto-fill choose the column count from the width
   alone, so four cards at a 1024px viewport came out three and one. Where a
   grid holds exactly four, it is two by two until four fit in one row.
   -------------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 1099px) {
  .kh-paths:has(> :nth-child(4):last-child),
  .kh-domain-grid:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Narrow phones (≤ 420px): the brand, the three header actions and the menu
   button were 3px wider than a 390px viewport, which let every page scroll
   sideways. Tighter gaps keep the same controls inside the screen. */
@media (max-width: 420px) {
  .kh-header__inner { gap: var(--sp-2); }
  .kh-header__actions { gap: 0.1rem; }
  .kh-brand { min-width: 0; }
}

/* ---------------------------------------------------------------------
   «از داده تا تصمیم» — scroll-driven story (kh-story.js)
   Static by default (no JS, reduced motion): a list of four steps.
   .is-live: a tall section with a sticky full-height stage.
   --------------------------------------------------------------------- */
.kh-story { position: relative; background: var(--bg-2); border-block: 1px solid var(--border-soft); }
.kh-story__canvas { display: none; }
.kh-story__overlay { position: relative; padding-block: var(--sp-5); }
.kh-story__head { margin-bottom: var(--sp-4); }
.kh-story__title { margin: 0.35rem 0 0; font-size: clamp(1.6rem, 3.4vw, 2.6rem); line-height: 1.25; }
.kh-story__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.kh-story__step { display: grid; grid-template-columns: auto 1fr; column-gap: 0.85rem; row-gap: 0.15rem; align-items: baseline; }
.kh-story__step b { font-size: 1.05rem; }
.kh-story__step span:not(.kh-story__num) { grid-column: 2; color: var(--text-2); font-size: 0.95rem; line-height: 1.7; }
.kh-story__num { grid-row: span 2; font-family: var(--font-mono); font-size: var(--fs-label); color: var(--accent); }
.kh-story__note { margin: var(--sp-4) 0 0; font-size: var(--fs-caption); color: var(--text-3); }

.kh-story.is-live { height: 300vh; }
.kh-story.is-live .kh-story__stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.kh-story.is-live .kh-story__canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.kh-story.is-live .kh-story__overlay { height: 100%; display: flex; flex-direction: column; justify-content: center; pointer-events: none; }
.kh-story.is-live .kh-story__step { opacity: 0.32; transform: translateX(0); transition: opacity 0.45s var(--ease), transform 0.45s var(--ease); }
.kh-story.is-live .kh-story__step.is-done { opacity: 0.55; }
.kh-story.is-live .kh-story__step.is-active { opacity: 1; transform: translateX(-6px); }
.kh-story.is-live .kh-story__step.is-active .kh-story__num { color: var(--accent-strong); }
@media (min-width: 900px) {
  .kh-story.is-live .kh-story__overlay > * { max-width: 40%; }
}
@media (max-width: 899px) {
  .kh-story.is-live { height: 260vh; }
  .kh-story.is-live .kh-story__overlay { justify-content: flex-end; padding-bottom: var(--sp-5); }
  /* below the sticky site header (64px) */
  .kh-story.is-live .kh-story__head { position: absolute; top: calc(64px + var(--sp-3)); inset-inline: var(--gutter, 1rem); }
  .kh-story.is-live .kh-story__steps { gap: 0.5rem; }
  .kh-story.is-live .kh-story__step:not(.is-active) span:not(.kh-story__num) { display: none; }
}
/* Reduced motion: one still picture (the forecast) beside the list, no sticky stage. */
.kh-story.is-live.is-still { height: auto; }
.kh-story.is-live.is-still .kh-story__stage { position: relative; height: auto; min-height: 30rem; }
.kh-story.is-live.is-still .kh-story__step { opacity: 1; transform: none; }
.kh-story.is-live.is-still .kh-story__step span:not(.kh-story__num) { display: block; }

/* ---------------------------------------------------------------------
   Typography repairs (2026-10-02)
   Persian set in a letter-spaced style loses its joins (پ ژ و ه ش); kh.js
   marks such elements .is-fa-text when their text is Persian.
   --------------------------------------------------------------------- */
.is-fa-text { letter-spacing: 0 !important; font-family: var(--font-fa) !important; text-transform: none !important; }
.kh-ticker__label, .kh-timeline__years { letter-spacing: 0; }
.kh-dataobs__card { gap: 0.55rem; }
.kh-dataobs__text { line-height: 1.95; font-size: 1rem; }
.kh-dataobs__limit { line-height: 1.8; }
