/* ==========================================================================
   sohelsagar.com — shared theme
   One stylesheet for every page. No framework, no webfonts.
   Palette derived from the site mark: indigo #101370 on lime #99FF55.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --indigo:        #101370;
  --indigo-700:    #232a86;
  --indigo-400:    #6a71b8;
  --lime:          #99ff55;
  --lime-deep:     #4f8c1c;

  --paper:         #f7f8fc;
  --surface:       #ffffff;
  --surface-2:     #f1f2f9;
  --rule:          #e0e2ee;
  --rule-soft:     #eceef6;

  --text:          #1b1e3d;
  --text-muted:    #5b5f83;
  --text-faint:    #8b90b2;

  --tech:          #3b58d6;
  --science:       #0b8f66;
  --politics:      #c04a10;
  --philosophy:    #7038c8;

  --shadow-sm: 0 1px 2px rgba(16, 19, 112, .06);
  --shadow-md: 0 4px 16px rgba(16, 19, 112, .08);
  --shadow-lg: 0 12px 36px rgba(16, 19, 112, .12);

  --measure: 68ch;
  --page: 1180px;
  --bar: 60px;

  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text",
             "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-read: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text",
               Cambria, Georgia, "Noto Serif Bengali", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .6, .3, 1);
}

html[data-theme="dark"] {
  --paper:      #0a0c26;
  --surface:    #12153a;
  --surface-2:  #191d47;
  --rule:       #262b5e;
  --rule-soft:  #1d2150;

  --text:       #e6e8f5;
  --text-muted: #a2a7c8;
  --text-faint: #7b81a6;

  --indigo:     #aeb4f0;
  --indigo-700: #c6cbff;
  --indigo-400: #7d84c9;

  --tech:       #8fa2ff;
  --science:    #4fd2a5;
  --politics:   #ff9a63;
  --philosophy: #b995ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, .55);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bar) + 16px);
}

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--lime-deep);
  outline-offset: 3px;
  border-radius: 3px;
}
html[data-theme="dark"] :focus-visible { outline-color: var(--lime); }

::selection { background: var(--lime); color: #101370; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--indigo-400); }

/* ---------- layout primitives ---------- */
.wrap { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: 20px; }
.wrap-narrow { max-width: 820px; }

.band { padding-block: 72px; }
.band + .band { padding-top: 0; }
.band-tint { background: var(--surface-2); padding-block: 72px; margin-block: 0; }

@media (max-width: 720px) {
  .band { padding-block: 48px; }
  .band-tint { padding-block: 48px; }
}

/* The recurring primitive: a small lime disc marking the start of a section. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.eyebrow::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 22%, transparent);
  flex: none;
}

.section-head { margin-bottom: 34px; max-width: 56ch; }
.section-head p { color: var(--text-muted); margin-top: 10px; }

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: -.026em;
  line-height: 1.14;
  color: var(--text);
  text-wrap: balance;
}

.t-hero  { font-size: clamp(2.4rem, 6.2vw, 4.1rem); line-height: 1.03; letter-spacing: -.035em; }
.t-1     { font-size: clamp(1.9rem, 3.8vw, 2.7rem); }
.t-2     { font-size: clamp(1.3rem, 2.4vw, 1.6rem); }
.t-3     { font-size: 1.0625rem; letter-spacing: -.012em; }

.lede { font-size: 1.125rem; line-height: 1.62; color: var(--text-muted); max-width: 58ch; }

.rule { height: 1px; background: var(--rule); border: 0; }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 100;
  height: var(--bar);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--rule-soft);
}
.masthead .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand .mark { width: 30px; height: 30px; flex: none; }
.brand b {
  font-size: 1.0625rem; font-weight: 700; letter-spacing: -.03em; color: var(--text);
}

.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav a, .nav > .menu > button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px; border-radius: 7px;
  font-size: .9rem; font-weight: 500; color: var(--text-muted);
  text-decoration: none; background: none; border: 0; cursor: pointer;
  transition: color .13s var(--ease), background .13s var(--ease);
  white-space: nowrap;
}
.nav a:hover, .nav > .menu > button:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--indigo); font-weight: 600; }
html[data-theme="dark"] .nav a[aria-current="page"] { color: var(--lime); }

.menu { position: relative; }
.menu > button::after {
  content: ""; width: 5px; height: 5px; margin-top: -3px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg); opacity: .65;
}
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 50%; translate: -50% 0;
  min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  display: none;
}
.menu[data-open="true"] .menu-panel { display: block; }
.menu-panel a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: .9rem; color: var(--text-muted); text-decoration: none;
}
.menu-panel a:hover { background: var(--surface-2); color: var(--text); }

.bar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: 9px;
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: border-color .13s var(--ease), color .13s var(--ease);
}
.icon-btn:hover { border-color: var(--indigo-400); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .i-sun { display: none; }
html[data-theme="dark"] .icon-btn .i-sun { display: block; }
html[data-theme="dark"] .icon-btn .i-moon { display: none; }

.burger { display: none; }

/* reading progress — one lime hairline, nothing else */
#progress {
  position: fixed; inset: 0 auto auto 0; height: 2px; width: 0;
  background: var(--lime); z-index: 200;
}

/* mobile nav */
.mobile-nav {
  display: none;
  position: fixed; inset: var(--bar) 0 0 0; z-index: 99;
  background: var(--paper);
  overflow-y: auto;
  padding: 16px 20px 48px;
}
.mobile-nav[data-open="true"] { display: block; }
.mobile-nav a {
  display: block; padding: 12px 4px; text-decoration: none;
  font-size: 1.0625rem; font-weight: 500;
  border-bottom: 1px solid var(--rule-soft);
}
.mobile-nav .group-label {
  padding: 18px 4px 6px; font-size: .78rem; font-weight: 700;
  color: var(--text-faint); letter-spacing: .02em;
}
.mobile-nav .group a { padding-left: 16px; color: var(--text-muted); font-size: 1rem; }

@media (max-width: 940px) {
  .nav { display: none; }
  .burger { display: grid; margin-left: auto; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 9px;
  font-size: .9375rem; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s var(--ease), background .13s var(--ease),
              border-color .13s var(--ease), color .13s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-700); }
html[data-theme="dark"] .btn-primary { background: var(--lime); color: #0a0c26; }
html[data-theme="dark"] .btn-primary:hover { background: #b4ff80; }

.btn-ghost { background: var(--surface); border-color: var(--rule); color: var(--text); }
.btn-ghost:hover { border-color: var(--indigo-400); }

.btn-lime { background: var(--lime); color: #101370; }
.btn-lime:hover { background: #b4ff80; }

/* ---------- hero ---------- */
.hero { padding-block: clamp(48px, 8vw, 92px) 64px; }
.hero-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 56px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; gap: 40px; } }

.hero h1 .loop { color: var(--indigo); }
html[data-theme="dark"] .hero h1 .loop { color: var(--lime); }
.hero .lede { margin-top: 20px; font-size: 1.1875rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.byline { display: flex; align-items: center; gap: 12px; margin-top: 34px; }
.byline img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; }
.byline .n { font-weight: 650; font-size: .9375rem; }
.byline .r { font-size: .84rem; color: var(--text-muted); }

.stats { display: flex; gap: 34px; margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--rule); }
.stats .v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; color: var(--indigo); }
html[data-theme="dark"] .stats .v { color: var(--lime); }
.stats .k { font-size: .82rem; color: var(--text-muted); }

/* ---------- cards ---------- */
/* Hierarchy is carried by radius + weight, not by one repeated card shape. */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.card:hover { border-color: var(--indigo-400); box-shadow: var(--shadow-md); }
.card > a { text-decoration: none; display: flex; flex-direction: column; height: 100%; }
.card .body { padding: 20px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card .thumb { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: var(--surface-2); }
.card h3 { font-size: 1.0625rem; letter-spacing: -.015em; }
.card p { font-size: .9rem; color: var(--text-muted); }
.card .meta {
  margin-top: auto; padding-top: 10px;
  font-size: .8rem; color: var(--text-faint);
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* domain tint: a 3px cap rule, the only decoration on an essay card */
.card[data-domain]::before { content: ""; display: block; height: 3px; background: var(--rule); }
.card[data-domain="technology"]::before  { background: var(--tech); }
.card[data-domain="science"]::before     { background: var(--science); }
.card[data-domain="politics"]::before    { background: var(--politics); }
.card[data-domain="philosophy"]::before  { background: var(--philosophy); }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .005em;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--rule-soft);
}
.chip[data-domain="technology"]  { color: var(--tech);       border-color: color-mix(in srgb, var(--tech) 30%, transparent);       background: color-mix(in srgb, var(--tech) 8%, transparent); }
.chip[data-domain="science"]     { color: var(--science);    border-color: color-mix(in srgb, var(--science) 30%, transparent);    background: color-mix(in srgb, var(--science) 8%, transparent); }
.chip[data-domain="politics"]    { color: var(--politics);   border-color: color-mix(in srgb, var(--politics) 30%, transparent);   background: color-mix(in srgb, var(--politics) 8%, transparent); }
.chip[data-domain="philosophy"]  { color: var(--philosophy); border-color: color-mix(in srgb, var(--philosophy) 30%, transparent); background: color-mix(in srgb, var(--philosophy) 8%, transparent); }
.chip-new { background: var(--lime); color: #101370; border-color: transparent; }

.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 940px) { .g-3, .g-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } }

/* featured essay panel — larger radius, heavier surface: the one loud card */
.feature {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.feature img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.feature .body { padding: 24px; }
.feature .metaline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.feature h2 { font-size: clamp(1.25rem, 2.2vw, 1.55rem); margin-bottom: 10px; }
.feature p { color: var(--text-muted); font-size: .95rem; }
.feature .foot {
  margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--rule-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.feature a.more { font-weight: 650; font-size: .9rem; color: var(--indigo); text-decoration: none; }
html[data-theme="dark"] .feature a.more { color: var(--lime); }
.feature a.more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* category tiles */
.tile {
  display: block; padding: 22px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 12px;
  border-left: 3px solid var(--rule);
  transition: border-color .14s var(--ease), transform .14s var(--ease);
}
.tile:hover { transform: translateY(-2px); }
.tile[data-domain="technology"]  { border-left-color: var(--tech); }
.tile[data-domain="science"]     { border-left-color: var(--science); }
.tile[data-domain="politics"]    { border-left-color: var(--politics); }
.tile[data-domain="philosophy"]  { border-left-color: var(--philosophy); }
.tile:hover { border-color: var(--indigo-400); }
.tile[data-domain="technology"]:hover  { border-left-color: var(--tech); }
.tile[data-domain="science"]:hover     { border-left-color: var(--science); }
.tile[data-domain="politics"]:hover    { border-left-color: var(--politics); }
.tile[data-domain="philosophy"]:hover  { border-left-color: var(--philosophy); }
.tile h3 { font-size: 1.125rem; margin-bottom: 7px; }
.tile p { font-size: .89rem; color: var(--text-muted); }
.tile .count { display: block; margin-top: 14px; font-size: .8rem; color: var(--text-faint); font-weight: 600; }

/* project cards — lime is the active surface here */
.project {
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--rule);
  text-decoration: none;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.project:hover { border-color: var(--indigo); box-shadow: var(--shadow-md); }
.project .ico {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--lime); color: #101370; flex: none;
}
.project .ico svg { width: 21px; height: 21px; }
.project h3 { font-size: 1.125rem; }
.project p { font-size: .9rem; color: var(--text-muted); flex: 1; }
.project .tags { display: flex; gap: 7px; flex-wrap: wrap; }

/* note / observation cards */
.note {
  padding: 20px; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--rule);
  border-top: 3px solid var(--rule);
}
.note[data-domain="technology"] { border-top-color: var(--tech); }
.note[data-domain="science"]    { border-top-color: var(--science); }
.note[data-domain="politics"]   { border-top-color: var(--politics); }
.note h3 { font-size: 1rem; margin: 10px 0 8px; }
.note p { font-size: .9rem; color: var(--text-muted); }
.note time { display: block; margin-top: 14px; font-size: .79rem; color: var(--text-faint); }

/* download rows */
.dl-list { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--surface); }
.dl-row { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--rule-soft); }
.dl-row:last-child { border-bottom: 0; }
.dl-row .ft {
  width: 44px; height: 44px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: .68rem; font-weight: 700;
  background: var(--surface-2); color: var(--text-muted); letter-spacing: .02em;
}
.dl-row .ft[data-kind="pdf"] { background: color-mix(in srgb, var(--politics) 12%, transparent); color: var(--politics); }
.dl-row .ft[data-kind="apk"] { background: color-mix(in srgb, var(--science) 12%, transparent); color: var(--science); }
.dl-row .n { font-weight: 600; font-size: .96rem; }
.dl-row .s { font-size: .82rem; color: var(--text-faint); margin-top: 2px; }
.dl-row .btn { margin-left: auto; flex: none; }
@media (max-width: 560px) {
  .dl-row { flex-wrap: wrap; }
  .dl-row .btn { margin-left: 58px; width: calc(100% - 58px); }
}

/* photo of the week */
.photo-frame { border-radius: 16px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); box-shadow: var(--shadow-lg); }
.photo-frame img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.photo-frame .cap { padding: 20px 24px; }
.photo-frame .cap h3 { font-size: 1.2rem; margin-bottom: 8px; }
.photo-frame .cap p { color: var(--text-muted); font-size: .95rem; }
.photo-frame .cap dl { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule-soft); }
.photo-frame .cap dt { font-size: .76rem; color: var(--text-faint); }
.photo-frame .cap dd { font-size: .88rem; font-weight: 600; margin: 2px 0 0; }

/* newsletter */
.subscribe {
  border-radius: 16px; padding: clamp(28px, 5vw, 48px);
  background: var(--indigo); color: #fff; text-align: center;
  position: relative; overflow: hidden;
}
html[data-theme="dark"] .subscribe { background: var(--surface); border: 1px solid var(--rule); color: var(--text); }
.subscribe::after {
  content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%;
  background: var(--lime); opacity: .16; right: -90px; top: -110px; pointer-events: none;
}
.subscribe h2 { color: inherit; font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
.subscribe p { color: color-mix(in srgb, currentColor 72%, transparent); margin-top: 10px; }
.subscribe form { display: flex; gap: 10px; max-width: 460px; margin: 26px auto 0; flex-wrap: wrap; }
.subscribe input {
  flex: 1 1 220px; min-width: 0; padding: 12px 16px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.1); color: inherit;
}
html[data-theme="dark"] .subscribe input { background: var(--surface-2); border-color: var(--rule); }
.subscribe input::placeholder { color: rgba(255,255,255,.6); }
html[data-theme="dark"] .subscribe input::placeholder { color: var(--text-faint); }
.subscribe .fine { font-size: .82rem; margin-top: 14px; }

/* ---------- essay pages ---------- */
.essay-hero { padding-block: 56px 34px; border-bottom: 1px solid var(--rule); }
.essay-hero .t-hero { max-width: 20ch; }
.essay-hero .lede { margin-top: 18px; }

.essay {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: clamp(22px, 4vw, 52px);
  margin-bottom: 40px;
}
.essay > .metaline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; font-size: .84rem; color: var(--text-faint); }
.essay > h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin-bottom: 22px; }
.essay > figure { margin: 0 0 26px; }

/* the reading column */
.prose {
  font-family: var(--font-read);
  font-size: 1.115rem;
  line-height: 1.72;
  color: var(--text);
  max-width: var(--measure);
}
.prose > * + * { margin-top: 1.15em; }
.prose p { hyphens: auto; }
.prose .standfirst { font-size: 1.28rem; line-height: 1.55; color: var(--text-muted); }
.prose h2 {
  font-family: var(--font-ui); font-size: 1.55rem; margin-top: 2em; margin-bottom: .1em;
  padding-top: .85em; border-top: 1px solid var(--rule-soft);
}
.prose h3 { font-family: var(--font-ui); font-size: 1.2rem; margin-top: 1.8em; margin-bottom: .1em; }
.prose h4 { font-family: var(--font-ui); font-size: 1.02rem; margin-top: 1.5em; }
.prose a { color: var(--indigo); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2.5px; }
html[data-theme="dark"] .prose a { color: var(--lime); }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .45em; }
.prose ul { list-style: none; padding-left: 1.25em; }
.prose ul > li { position: relative; }
.prose ul > li::before {
  content: ""; position: absolute; left: -1.05em; top: .68em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--lime);
}
.prose blockquote {
  font-family: var(--font-read); font-size: 1.2rem; line-height: 1.55; font-style: italic;
  border-left: 3px solid var(--lime); padding: 4px 0 4px 22px; color: var(--text-muted);
  margin-block: 1.7em;
}
.prose blockquote cite, .prose blockquote em:last-child { display: block; font-size: .88rem; font-style: normal; color: var(--text-faint); margin-top: 10px; }
.prose figure { margin-block: 1.9em; }
.prose figure img { width: 100%; border-radius: 10px; border: 1px solid var(--rule); }
.prose figcaption { font-family: var(--font-ui); font-size: .82rem; color: var(--text-faint); margin-top: 9px; line-height: 1.5; }
.prose code { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr, .prose .section-divider {
  border: 0; height: 1px; background: var(--rule); margin-block: 2.2em;
  max-width: 120px;
}

/* tables inside essays */
.prose table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .92rem; }
.prose thead th { text-align: left; font-weight: 650; padding: 10px 12px; border-bottom: 2px solid var(--rule); }
.prose td { padding: 10px 12px; border-bottom: 1px solid var(--rule-soft); }
.prose tbody tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* callouts carried over from the old pages */
.prose .callout, .prose .highlight-box, .prose .info-box, .prose .key-point, .prose .stat-box {
  font-family: var(--font-ui); font-size: .98rem; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--lime);
  border-radius: 10px; padding: 18px 20px; margin-block: 1.8em; color: var(--text);
}
.prose .callout > * + *, .prose .highlight-box > * + * { margin-top: .7em; }

/* ---------- legal / plain pages ---------- */
.legal-head { padding-block: 48px 26px; }
.crumb { font-size: .85rem; color: var(--text-faint); margin-bottom: 16px; }
.crumb a { text-decoration: none; color: var(--text-muted); }
.crumb a:hover { color: var(--text); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--rule); margin-top: 72px; padding-block: 48px 28px; background: var(--surface); }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
@media (max-width: 780px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > :first-child { grid-column: 1 / -1; } }
.foot p { color: var(--text-muted); font-size: .92rem; max-width: 42ch; margin-top: 12px; }
.foot h4 { font-size: .82rem; color: var(--text-faint); margin-bottom: 12px; font-weight: 700; }
.foot ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.foot ul a { font-size: .92rem; color: var(--text-muted); text-decoration: none; }
.foot ul a:hover { color: var(--text); }
.social { display: flex; gap: 10px; margin-top: 18px; }
.social a {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  border: 1px solid var(--rule); color: var(--text-muted);
  transition: border-color .13s var(--ease), color .13s var(--ease);
}
.social a:hover { border-color: var(--indigo-400); color: var(--text); }
.social svg { width: 16px; height: 16px; }
.foot-base {
  margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--rule-soft);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: .85rem; color: var(--text-faint);
}
.foot-base a { text-decoration: none; color: inherit; }
.foot-base a:hover { color: var(--text); }
.foot-base .links { display: flex; gap: 20px; }

/* ---------- utility ---------- */
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-24 { margin-bottom: 24px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.wrap-flex { flex-wrap: wrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 300;
  background: var(--lime); color: #101370; padding: 10px 16px; border-radius: 8px;
  font-weight: 600; text-decoration: none; transition: top .15s var(--ease);
}
.skip:focus { top: 12px; }

/* one orchestrated page-load reveal, hero only */
@media (prefers-reduced-motion: no-preference) {
  .reveal > * { animation: rise .5s var(--ease) both; }
  .reveal > :nth-child(2) { animation-delay: .06s; }
  .reveal > :nth-child(3) { animation-delay: .12s; }
  .reveal > :nth-child(4) { animation-delay: .18s; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

@media print {
  .masthead, .foot, #progress, .mobile-nav, .bar-actions, .subscribe { display: none !important; }
  body { background: #fff; color: #000; }
  .essay { border: 0; padding: 0; }
}

/* ==========================================================================
   Components carried over from the original essays.
   These class names already existed in the content, so they keep working.
   ========================================================================== */

.prose .highlight-box { border-left-color: var(--indigo); }
.prose .key-point     { border-left-color: var(--science); }
.prose .info-card     { border-left-color: var(--tech); }

.prose .info-card > p:first-child,
.prose .action-list > p:first-child {
  font-weight: 700; font-size: .95rem; color: var(--text); margin-bottom: .5em;
}

.prose .pull-quote {
  font-family: var(--font-read);
  font-size: 1.25rem; line-height: 1.5; font-style: italic;
  color: var(--text); text-align: left;
  border: 0; border-top: 2px solid var(--lime); border-bottom: 1px solid var(--rule);
  padding: 22px 0; margin-block: 2em; background: none;
}
.prose .pull-quote br + * , .prose .pull-quote br { }

.prose .stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-block: 2em;
}
.prose .stat-card {
  font-family: var(--font-ui); text-align: left;
  padding: 18px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-top: 3px solid var(--lime);
}
.prose .stat-number {
  font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; color: var(--indigo); line-height: 1.1;
}
html[data-theme="dark"] .prose .stat-number { color: var(--lime); }
.prose .stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

.prose .timeline-item {
  font-family: var(--font-ui);
  position: relative; padding: 0 0 22px 26px; margin: 0;
  border-left: 2px solid var(--rule);
}
.prose .timeline-item::before {
  content: ""; position: absolute; left: -6px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--lime); border: 2px solid var(--surface);
}
.prose .timeline-item h3 { margin: 0 0 6px; font-size: 1.02rem; }
.prose .timeline-item p { font-size: .94rem; color: var(--text-muted); margin: 0; }
.prose .timeline-item + .timeline-item { margin-top: 0; }

.prose .flow-box {
  font-family: var(--font-ui); font-weight: 650; font-size: .92rem;
  padding: 14px 16px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--rule);
  display: inline-block; margin: 0 8px 8px 0; min-width: 190px; vertical-align: top;
}
.prose .flow-box span { display: block; font-weight: 400; font-size: .84rem; color: var(--text-muted); margin-top: 4px; }

.prose .tech-diagram {
  font-family: var(--font-ui); font-size: .95rem;
  padding: 22px; border-radius: 12px; margin-block: 2em;
  background: var(--surface-2); border: 1px solid var(--rule);
}
.prose .tech-diagram h3 { margin-top: 0; font-size: 1.1rem; }
.prose .tech-diagram h4 { font-size: .95rem; margin-top: 1.2em; color: var(--indigo); }
html[data-theme="dark"] .prose .tech-diagram h4 { color: var(--lime); }

.prose .action-list {
  font-family: var(--font-ui); font-size: .96rem;
  padding: 20px 22px; border-radius: 12px; margin-block: 2em;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--philosophy);
}
.prose .action-list ol { padding-left: 1.2em; }

.prose .info-card {
  display: block;
  font-family: var(--font-ui); font-size: .96rem;
  padding: 20px 22px; border-radius: 12px; margin-block: 2em;
  background: var(--surface-2); border: 1px solid var(--rule); border-left: 3px solid var(--tech);
}

/* the three candidate cards in the ranked-voting essay */
.prose .candidate-card {
  font-family: var(--font-ui); text-align: center;
  padding: 18px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--rule);
}
.prose .candidate-card .badge {
  display: grid; place-items: center; width: 52px; height: 52px;
  margin: 0 auto 10px; border-radius: 50%;
  background: var(--indigo); color: #fff; font-size: 1.25rem; font-weight: 700;
}
html[data-theme="dark"] .prose .candidate-card .badge { background: var(--lime); color: #0a0c26; }
.prose .candidate-card:nth-child(2) .badge { background: var(--politics); color: #fff; }
.prose .candidate-card:nth-child(3) .badge { background: var(--science); color: #fff; }
.prose .candidate-card h4 { margin: 0 0 3px; font-size: 1rem; }
.prose .candidate-card p { margin: 0; font-size: .85rem; color: var(--text-muted); }

.prose .info-card:has(.candidate-card) {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; background: none; border: 0; border-left: 0; padding: 0;
}

/* charts */
.chart-figure {
  font-family: var(--font-ui);
  margin-block: 2.2em; padding: 20px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 12px;
}
.chart-figure .chart-title {
  font-size: 1rem; font-weight: 650; color: var(--text); margin: 0 0 14px;
}
.ss-chart { width: 100%; height: auto; }
.chart-legend {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .84rem; color: var(--text-muted);
}
.chart-legend li { display: flex; align-items: center; gap: 7px; }
.chart-legend span { width: 11px; height: 11px; border-radius: 3px; flex: none; }

/* hero image on an essay */
.essay-hero-img { margin: 0 0 26px; }
.essay-hero-img img {
  width: 100%; max-height: 380px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--rule);
}
.essay-hero-img figcaption {
  font-size: .82rem; color: var(--text-faint); margin-top: 9px; line-height: 1.5;
}

/* legal pages use the prose column at UI scale */
.legal .prose { font-family: var(--font-ui); font-size: 1rem; }


/* refinements */
.prose .section-divider + h2 { border-top: 0; padding-top: 0; margin-top: 1.3em; }
.feature img { object-position: center 22%; }
.hero h1 .loop { color: inherit; }

/* ==========================================================================
   App shells: /chat/ and /csvanalyzer/
   ========================================================================== */
.app-page { display: flex; flex-direction: column; min-height: calc(100vh - var(--bar)); }
.app-head { padding: 28px 0 18px; }
.app-head .row { justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.app-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.app-head p { color: var(--text-muted); font-size: .95rem; margin-top: 6px; }

.field {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 12px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--surface); font-size: .875rem;
}
.field label { color: var(--text-faint); }
.field select { border: 0; background: none; font-weight: 600; cursor: pointer; }

.chat-shell {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  overflow: hidden; height: min(70vh, 640px); margin-bottom: 32px;
}
#chat-box { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

.message {
  max-width: 78%; padding: 12px 16px; border-radius: 14px;
  font-size: .95rem; line-height: 1.6; overflow-wrap: anywhere;
}
.message > * + * { margin-top: .7em; }
.message pre { background: rgba(0,0,0,.25); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .85em; }
.message code { font-family: var(--font-mono); font-size: .88em; }
.user-message { align-self: flex-end; background: var(--indigo); color: #fff; border-bottom-right-radius: 4px; }
html[data-theme="dark"] .user-message { background: var(--lime); color: #0a0c26; }
.bot-message {
  align-self: flex-start; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--rule); border-bottom-left-radius: 4px;
}
.bot-message pre { background: var(--surface); border: 1px solid var(--rule); }

.composer { border-top: 1px solid var(--rule); padding: 14px; background: var(--surface); }
.composer .row { gap: 10px; align-items: flex-end; }
#message-input {
  flex: 1; resize: none; min-height: 46px; max-height: 160px;
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--rule); background: var(--paper); color: var(--text);
}
#message-input:disabled { opacity: .6; }
#send-button { flex: none; min-width: 88px; }
.composer .hint { font-size: .78rem; color: var(--text-faint); margin-top: 9px; }

/* StatCal: styles injected into the Python-generated pages */
.statcal-wrap { padding-block: 28px 56px; }
.statcal-wrap form { display: block; }
.statcal-wrap fieldset { border: 1px solid var(--rule); border-radius: 12px; padding: 18px 20px; margin-block: 18px; }
.statcal-wrap legend { font-weight: 700; font-size: .9rem; padding-inline: 6px; }
.statcal-wrap label { display: inline-block; font-size: .9rem; font-weight: 600; margin-bottom: 5px; }
.statcal-wrap input[type=text], .statcal-wrap input[type=number], .statcal-wrap input[type=file],
.statcal-wrap select, .statcal-wrap textarea {
  padding: 9px 12px; border: 1px solid var(--rule); border-radius: 9px;
  background: var(--surface); color: var(--text); max-width: 100%;
}
.statcal-wrap input[type=submit], .statcal-wrap button {
  padding: 11px 20px; border-radius: 9px; border: 0; cursor: pointer;
  background: var(--indigo); color: #fff; font-weight: 600;
}
html[data-theme="dark"] .statcal-wrap input[type=submit], html[data-theme="dark"] .statcal-wrap button { background: var(--lime); color: #0a0c26; }
.statcal-wrap table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-block: 14px; }
.statcal-wrap th { text-align: left; background: var(--surface-2); padding: 10px 12px; border-bottom: 2px solid var(--rule); }
.statcal-wrap td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); }
.statcal-wrap img { border: 1px solid var(--rule); border-radius: 10px; }
