/* Niket Jain portfolio. Editorial, type-led, one accent.
   Tokens first, then base, then components. Dark theme defined alongside light. */

:root {
  --paper: #F4F0E8;
  --paper-2: #ECE6DA;
  --paper-3: #E2DBCC;
  --ink: #161719;
  --ink-2: #55544F;
  --ink-3: #8A8780;
  --line: rgba(22, 23, 25, .16);
  --line-2: rgba(22, 23, 25, .08);
  --accent: #B4411D;
  --accent-2: #8F3317;
  --accent-soft: rgba(180, 65, 29, .10);
  --ok: #2F6B4F;
  --nav-bg: rgba(244, 240, 232, .78);
  --sheet-bg: rgba(244, 240, 232, .92);
  --grain-opacity: .055;
  --shadow: 0 1px 0 rgba(22,23,25,.04), 0 12px 40px -18px rgba(22,23,25,.35);
  --shadow-lg: 0 2px 0 rgba(22,23,25,.04), 0 30px 80px -30px rgba(22,23,25,.45);
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --radius-s: 8px;
  --nav-h: 64px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --ease-spring: cubic-bezier(.3, 1.25, .4, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #111214;
  --paper-2: #18191C;
  --paper-3: #222327;
  --ink: #EDE8DD;
  --ink-2: #B3AEA3;
  --ink-3: #7E7A72;
  --line: rgba(237, 232, 221, .16);
  --line-2: rgba(237, 232, 221, .08);
  --accent: #E8703F;
  --accent-2: #F3916A;
  --accent-soft: rgba(232, 112, 63, .14);
  --ok: #6FBF95;
  --nav-bg: rgba(17, 18, 20, .74);
  --sheet-bg: rgba(17, 18, 20, .92);
  --grain-opacity: .07;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 12px 40px -18px rgba(0,0,0,.8);
  --shadow-lg: 0 2px 0 rgba(0,0,0,.3), 0 30px 80px -30px rgba(0,0,0,.9);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111214;
    --paper-2: #18191C;
    --paper-3: #222327;
    --ink: #EDE8DD;
    --ink-2: #B3AEA3;
    --ink-3: #7E7A72;
    --line: rgba(237, 232, 221, .16);
    --line-2: rgba(237, 232, 221, .08);
    --accent: #E8703F;
    --accent-2: #F3916A;
    --accent-soft: rgba(232, 112, 63, .14);
    --ok: #6FBF95;
    --nav-bg: rgba(17, 18, 20, .74);
    --sheet-bg: rgba(17, 18, 20, .92);
    --grain-opacity: .07;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 12px 40px -18px rgba(0,0,0,.8);
    --shadow-lg: 0 2px 0 rgba(0,0,0,.3), 0 30px 80px -30px rgba(0,0,0,.9);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  font-feature-settings: "ss01", "kern";
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
  overflow-x: clip;
}
/* paper grain, over everything, never interactive */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::after { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::after { mix-blend-mode: screen; } }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; text-decoration-color: var(--ink-3); }
a:hover { text-decoration-color: var(--accent); }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; margin: 0; font-variation-settings: "SOFT" 30, "WONK" 0; }
h1 { font-size: clamp(2.75rem, 7.2vw, 6.4rem); line-height: .98; letter-spacing: -.025em; }
h2 { font-size: clamp(1.9rem, 3.8vw, 3.1rem); line-height: 1.04; letter-spacing: -.018em; }
h3 { font-size: clamp(1.3rem, 2vw, 1.6rem); line-height: 1.18; letter-spacing: -.01em; }
h4 { font-size: 1.1rem; line-height: 1.3; letter-spacing: 0; font-family: var(--font-body); font-weight: 600; }
p { margin: 0 0 1em; }
.lede { font-size: clamp(1.15rem, 1.6vw, 1.35rem); line-height: 1.45; color: var(--ink-2); max-width: 36em; letter-spacing: -.005em; }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }
em.serif { font-family: var(--font-display); font-style: italic; font-weight: 400; font-variation-settings: "SOFT" 60, "WONK" 1; }

.wrap { width: min(100% - 2rem, 76rem); margin-inline: auto; }
@media (min-width: 48em) { .wrap { width: min(100% - 5rem, 76rem); } }

.label {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
  color: var(--ink-3); display: inline-flex; gap: .6em; align-items: center;
}
.label::before { content: ""; width: 1.5em; height: 1px; background: var(--accent); }
.label.plain::before { display: none; }

.section { padding-block: clamp(4rem, 9vw, 8rem); border-top: 1px solid var(--line-2); }
.section-head { display: grid; gap: 1rem; margin-bottom: clamp(2rem, 4vw, 3.5rem); max-width: 50rem; }
.section-head .lede { margin-top: .25rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55em;
  padding: .8em 1.25em; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper); font-weight: 600; font-size: .95rem; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 150ms var(--ease-out), background-color 150ms, color 150ms, border-color 150ms;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { transform: scale(.97); transition-duration: 90ms; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn .arrow { transition: transform 200ms var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }
.btn.sm { padding: .6em 1em; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--nav-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%);
}
.nav::after { /* scroll edge: soft gradient instead of a hard rule */
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--ink) 9%, transparent), transparent);
  opacity: 0; transition: opacity .3s ease;
}
.nav.scrolled::after { opacity: 1; }
.nav .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; text-decoration: none; display: inline-flex; align-items: baseline; gap: .15em; }
.brand .dot { color: var(--accent); }
.nav-links { display: none; gap: 1.6rem; list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; font-size: .92rem; color: var(--ink-2); font-weight: 500; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
@media (min-width: 52em) { .nav-links { display: flex; } }
.nav-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink);
  transition: transform 150ms var(--ease-out), border-color 150ms, background-color 150ms;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-btn .sun, .theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="light"] .theme-btn .moon { display: block; }
:root:not([data-theme]) .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-btn .moon { display: none; } :root:not([data-theme]) .theme-btn .sun { display: block; } }
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ---------- Hero ---------- */
.hero { padding-top: calc(var(--nav-h) + clamp(3rem, 9vw, 7.5rem)); padding-bottom: clamp(3rem, 6vw, 5rem); position: relative; }
.hero-grid { display: grid; gap: 2.5rem; align-items: end; }
@media (min-width: 60em) { .hero-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 4rem; } }
.hero h1 { margin: 1rem 0 1.25rem; max-width: 11em; text-wrap: balance; }
.hero h1 .accent { color: var(--accent); font-style: italic; font-weight: 400; font-variation-settings: "SOFT" 80, "WONK" 1; }
.hero .lede { margin-bottom: 1.75rem; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.hero-note { margin-top: 1.25rem; font-size: .9rem; color: var(--ink-3); }

/* staggered load */
.rise { opacity: 0; transform: translateY(14px); animation: rise .8s var(--ease-out) forwards; }
.rise.d1 { animation-delay: .08s } .rise.d2 { animation-delay: .18s } .rise.d3 { animation-delay: .28s } .rise.d4 { animation-delay: .38s } .rise.d5 { animation-delay: .5s } .rise.d6 { animation-delay: .62s }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ledger of numbers */
.ledger { border-top: 1px solid var(--ink); }
.ledger-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line-2); }
.ledger-row .k { font-size: .95rem; color: var(--ink-2); }
.ledger-row .v { font-family: var(--font-display); font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1; letter-spacing: -.02em; font-weight: 500; font-variant-numeric: tabular-nums; }
.ledger-row .v small { font-size: .55em; color: var(--ink-3); font-family: var(--font-body); font-weight: 500; letter-spacing: 0; margin-left: .25em; }
.ledger-foot { font-size: .8rem; color: var(--ink-3); padding-top: .75rem; }

/* ask bar */
.askbar { margin-top: clamp(2.5rem, 5vw, 4rem); }
.askbar form {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .4rem .4rem 1.1rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper-2);
  box-shadow: var(--shadow); transition: border-color 150ms, box-shadow 200ms;
}
.askbar form:focus-within { border-color: var(--ink); box-shadow: var(--shadow-lg); }
.askbar input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink); padding: .6rem 0; }
.askbar input::placeholder { color: var(--ink-3); }
.askbar input:focus { outline: none; }
.askbar .chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .45em .9em;
  font-size: .85rem; color: var(--ink-2); cursor: pointer; transition: transform 150ms var(--ease-out), border-color 150ms, color 150ms, background-color 150ms;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- System map ---------- */
.system { display: grid; gap: 0; border-top: 1px solid var(--ink); counter-reset: stage; }
@media (min-width: 60em) { .system { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.stage { position: relative; padding: 1.25rem 1rem 1.5rem 0; border-bottom: 1px solid var(--line-2); transition: background-color .25s ease; }
@media (min-width: 60em) {
  .stage { border-bottom: 0; border-right: 1px solid var(--line-2); padding: 1.5rem 1rem 1.75rem 1rem; min-height: 15rem; }
  .stage:last-child { border-right: 0; }
}
.stage:hover, .stage:focus-within { background: var(--accent-soft); }
.stage .n { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: 1rem; }
.stage h3 { margin: .4rem 0 .5rem; font-size: 1.5rem; }
.stage p { font-size: .92rem; color: var(--ink-2); margin-bottom: .75rem; }
.stage .tools { font-size: .78rem; color: var(--ink-3); line-height: 1.5; }
.stage .tools b { color: var(--ink-2); font-weight: 600; }
.stage::after { /* arrow to next on desktop */
  content: "→"; position: absolute; right: -.55em; top: 1.3rem; color: var(--ink-3); font-size: .9rem; display: none; background: var(--paper); padding: 0 .1em;
}
@media (min-width: 60em) { .stage:not(:last-child)::after { display: block; } }

/* ---------- Work list ---------- */
.work-list { display: grid; gap: 0; border-top: 1px solid var(--ink); }
.work { display: grid; gap: 1.25rem; padding: clamp(1.5rem, 3vw, 2.5rem) 0; border-bottom: 1px solid var(--line-2); position: relative; text-decoration: none; color: inherit; }
@media (min-width: 60em) { .work { grid-template-columns: 6rem minmax(0, 1fr) 16rem; gap: 2.5rem; align-items: start; } }
.work .idx { font-family: var(--font-display); font-style: italic; font-weight: 300; font-size: clamp(2.4rem, 4vw, 3.6rem); line-height: 1; color: var(--ink-3); letter-spacing: -.03em; transition: color .25s; }
.work:hover .idx { color: var(--accent); }
.work .tag { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: .5rem; display: block; }
.work h3 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin-bottom: .6rem; text-wrap: balance; }
.work p { color: var(--ink-2); max-width: 42em; margin-bottom: .75rem; }
.work .more { font-weight: 600; font-size: .92rem; display: inline-flex; gap: .4em; align-items: center; text-decoration: none; }
.work .more .arrow { transition: transform .2s var(--ease-out); }
.work:hover .more .arrow { transform: translateX(4px); }
.work .results { display: grid; gap: .6rem; align-content: start; }
.work .results div { border-top: 1px solid var(--line-2); padding-top: .5rem; }
.work .results b { display: block; font-family: var(--font-display); font-size: 1.5rem; line-height: 1.05; letter-spacing: -.02em; font-weight: 500; }
.work .results span { font-size: .82rem; color: var(--ink-3); }

/* ---------- Decisions table ---------- */
.table { width: 100%; border-collapse: collapse; border-top: 1px solid var(--ink); font-size: .95rem; }
.table th { text-align: left; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: .9rem .75rem .9rem 0; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.table td { padding: 1rem .75rem 1rem 0; border-bottom: 1px solid var(--line-2); vertical-align: top; color: var(--ink-2); }
.table td:first-child { color: var(--ink); }
.table td b { color: var(--ink); font-weight: 600; }
.table.tight td, .table.tight th { padding-block: .6rem; }
@media (max-width: 47.99em) {
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; gap: .35rem; padding: 1rem 0; border-bottom: 1px solid var(--line-2); }
  .table.stack td { display: block; padding: 0; border: 0; }
  .table.stack td::before { content: attr(data-l); display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: .15rem; }
}
.table-wrap { overflow-x: auto; }

/* ---------- Principles ---------- */
.principles { display: grid; gap: 0; border-top: 1px solid var(--ink); counter-reset: p; }
@media (min-width: 48em) { .principles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.principle { padding: 1.4rem 1.25rem 1.4rem 0; border-bottom: 1px solid var(--line-2); display: grid; gap: .35rem; }
@media (min-width: 48em) { .principle { border-right: 1px solid var(--line-2); padding-left: 1.25rem; } .principle:nth-child(3n) { border-right: 0; } .principle:nth-child(3n+1) { padding-left: 0; } }
.principle .n { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: .95rem; }
.principle b { font-family: var(--font-display); font-weight: 500; font-size: 1.25rem; letter-spacing: -.01em; line-height: 1.2; }
.principle span { color: var(--ink-2); font-size: .92rem; }

/* ---------- Experience ---------- */
.exp-grid { display: grid; gap: 3rem; }
@media (min-width: 60em) { .exp-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 5rem; } }
.roles { border-top: 1px solid var(--ink); }
.role { display: grid; gap: .35rem 1.5rem; padding: 1.25rem 0; border-bottom: 1px solid var(--line-2); }
@media (min-width: 40em) { .role { grid-template-columns: 9.5rem minmax(0, 1fr); } }
.role .when { font-size: .85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: .3rem; }
.role h3 { font-size: 1.3rem; }
.role .org { color: var(--accent); font-weight: 600; font-size: .95rem; display: block; margin: .15rem 0 .4rem; }
.role p { font-size: .95rem; color: var(--ink-2); margin: 0; }
.role ul { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--ink-2); font-size: .93rem; }
.role li { margin: .2rem 0; }
.spec { border-top: 1px solid var(--ink); }
.spec-row { display: grid; gap: .25rem 1.25rem; padding: .85rem 0; border-bottom: 1px solid var(--line-2); font-size: .93rem; }
@media (min-width: 40em) { .spec-row { grid-template-columns: 9.5rem minmax(0, 1fr); } }
.spec-row .k { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding-top: .3rem; }
.spec-row .v { color: var(--ink-2); }
.spec-row .v b { color: var(--ink); font-weight: 600; }

/* about */
.about { display: grid; gap: 1.75rem; align-items: start; }
@media (min-width: 48em) { .about { grid-template-columns: 11rem minmax(0, 1fr); gap: 2.5rem; } }
.portrait { width: 11rem; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--paper-3); box-shadow: var(--shadow); }
.portrait img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Assistant section ---------- */
.modes { display: grid; gap: 0; border-top: 1px solid var(--ink); }
@media (min-width: 48em) { .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mode-card { text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line-2); padding: 1.5rem 1.25rem 1.6rem 0; cursor: pointer; display: grid; gap: .5rem; transition: background-color .25s; align-content: start; }
@media (min-width: 48em) { .mode-card { border-right: 1px solid var(--line-2); padding-left: 1.25rem; } .mode-card:last-child { border-right: 0; } .mode-card:first-child { padding-left: 0; } }
.mode-card:hover { background: var(--accent-soft); }
.mode-card .n { font-family: var(--font-display); font-style: italic; color: var(--accent); }
.mode-card h3 { font-size: 1.45rem; }
.mode-card p { color: var(--ink-2); font-size: .93rem; margin: 0; }
.mode-card .go { font-weight: 600; font-size: .9rem; margin-top: .4rem; display: inline-flex; gap: .4em; }
.mode-card .go .arrow { transition: transform .2s var(--ease-out); }
.mode-card:hover .go .arrow { transform: translateX(4px); }

/* ---------- Contact ---------- */
.contact h2 { font-size: clamp(2.2rem, 5vw, 4.2rem); max-width: 14em; text-wrap: balance; }
.contact-links { display: flex; flex-wrap: wrap; gap: .75rem 2rem; margin-top: 2rem; font-size: 1.05rem; }
.contact-links a { text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: .15em; transition: border-color .15s; }
.contact-links a:hover { border-color: var(--accent); }

footer { border-top: 1px solid var(--line-2); padding: 2rem 0 3rem; font-size: .85rem; color: var(--ink-3); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
html:not(.js) .reveal, html:not(.js) .rise { opacity: 1; transform: none; animation: none; }

/* ---------- Chat dock and panel ---------- */
.dock {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  display: inline-flex; align-items: center; gap: .6em; padding: .85em 1.15em .85em .95em;
  border-radius: 999px; background: var(--ink); color: var(--paper); border: 0; cursor: pointer;
  font-weight: 600; font-size: .95rem; box-shadow: var(--shadow-lg);
  transition: transform 150ms var(--ease-out), background-color 150ms;
}
.dock:hover { background: var(--accent); color: #fff; }
.dock:active { transform: scale(.96); }
.dock .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s ease-out infinite; }
.dock:hover .pulse { background: #fff; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (min-width: 48em) { .dock { right: 1.5rem; bottom: 1.5rem; } }
body.chat-open .dock { opacity: 0; pointer-events: none; }

.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
body.chat-open .scrim { opacity: 1; pointer-events: auto; }

.chat {
  position: fixed; z-index: 80; display: flex; flex-direction: column;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  box-shadow: var(--shadow-lg);
  /* mobile: bottom sheet */
  left: 0; right: 0; bottom: 0; height: min(88dvh, 100dvh - 2rem);
  border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: 0;
  transform: translateY(105%); transition: transform .36s var(--ease-out);
  will-change: transform;
}
.chat.dragging { transition: none; }
body.chat-open .chat { transform: none; }
@media (min-width: 48em) {
  .chat {
    left: auto; right: 1.5rem; bottom: 1.5rem; top: auto; width: min(440px, calc(100vw - 3rem)); height: min(720px, calc(100dvh - 3rem));
    border-radius: 20px; border-bottom: 1px solid var(--line);
    transform-origin: calc(100% - 3rem) calc(100% - 1.5rem);
    transform: translateY(14px) scale(.96); opacity: 0; transition: transform .32s var(--ease-spring), opacity .22s ease;
    pointer-events: none;
  }
  body.chat-open .chat { transform: none; opacity: 1; pointer-events: auto; }
  .scrim { background: transparent; }
  body.chat-open .scrim { pointer-events: none; }
}
@media (prefers-reduced-transparency: reduce) { .chat { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }

.chat-handle { height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.chat-handle::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
@media (min-width: 48em) { .chat-handle { display: none; } }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 1rem .75rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.chat-head .t { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; display: flex; align-items: center; gap: .5em; }
.chat-head .t .live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.chat-head .acts { display: flex; gap: .25rem; }
.chat-head .icon-btn { width: 34px; height: 34px; border-color: transparent; }
.chat-head .icon-btn:hover { border-color: var(--line); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: .6rem 1rem 0; }
.seg button { border: 1px solid var(--line-2); background: var(--paper-2); border-radius: 10px; padding: .55em .4em; font-size: .8rem; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: transform 150ms var(--ease-out), background-color 150ms, color 150ms, border-color 150ms; }
.seg button:hover { border-color: var(--line); color: var(--ink); }
.seg button:active { transform: scale(.97); }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem 1rem .5rem; display: flex; flex-direction: column; gap: .8rem; overscroll-behavior: contain; scroll-behavior: smooth; }
.msg { max-width: 92%; font-size: .95rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--paper); padding: .65em .9em; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--paper-2); border: 1px solid var(--line-2); padding: .75em 1em; border-radius: 16px 16px 16px 4px; }
.msg.bot p { margin: 0 0 .6em; } .msg.bot p:last-child { margin: 0; }
.msg.bot ul, .msg.bot ol { margin: .2em 0 .6em; padding-left: 1.2em; } .msg.bot li { margin: .15em 0; }
.msg.bot strong { font-weight: 650; }
.msg.bot.err { border-color: var(--accent); color: var(--accent-2); }
.msg.bot .caret { display: inline-block; width: .5em; height: 1em; background: var(--accent); vertical-align: -.15em; margin-left: .1em; animation: blink 1s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.msg.intro { align-self: stretch; max-width: none; background: transparent; border: 0; padding: 0 .25rem; color: var(--ink-2); font-size: .9rem; }
.sugg { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .6rem; }
.sugg .chip { font-size: .8rem; padding: .4em .8em; }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; padding: .6rem 1rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); }
.chat-form textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: .7em .9em; font: inherit; font-size: .95rem; line-height: 1.4; background: var(--paper); color: var(--ink); max-height: 9em; min-height: 2.6em; }
.chat-form textarea:focus { outline: none; border-color: var(--ink); }
.chat-form .send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; transition: transform 150ms var(--ease-out), background-color 150ms; }
.chat-form .send:hover { background: var(--accent-2); }
.chat-form .send:active { transform: scale(.94); }
.chat-form .send[disabled] { opacity: .5; cursor: progress; }
.chat-form .send svg { width: 18px; height: 18px; }
.chat-foot { font-size: .72rem; color: var(--ink-3); padding: 0 1.1rem .7rem; }

/* ---------- Case study pages ---------- */
.case-hero { padding-top: calc(var(--nav-h) + clamp(2.5rem, 7vw, 6rem)); padding-bottom: clamp(2rem, 4vw, 3.5rem); }
.case-hero .crumbs { font-size: .85rem; color: var(--ink-3); margin-bottom: 1.25rem; }
.case-hero .crumbs a { text-decoration: none; }
.case-hero h1 { font-size: clamp(2.3rem, 5.6vw, 4.6rem); max-width: 13em; margin: .75rem 0 1rem; }
.case-meta { display: grid; gap: .75rem 2rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); border-top: 1px solid var(--ink); margin-top: 2rem; padding-top: 1rem; max-width: 48rem; }
.case-meta div { font-size: .9rem; color: var(--ink-2); }
.case-meta b { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: .2rem; }
.prose { max-width: 44rem; }
.prose h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); margin: 2.75rem 0 1rem; }
.prose h3 { margin: 1.75rem 0 .5rem; }
.prose p, .prose li { color: var(--ink-2); }
.prose p b, .prose li b { color: var(--ink); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin: .3rem 0; }
.prose .table { margin: 1rem 0 1.5rem; }
.prose .table td, .prose .table th { font-size: .93rem; }
.case-section { padding-block: clamp(2rem, 4vw, 3.5rem); border-top: 1px solid var(--line-2); }
.stats { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); border-top: 1px solid var(--ink); margin: 1.5rem 0 2rem; }
.stats div { padding: 1rem 1rem 1.1rem 0; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding-left: 1rem; }
.stats div:first-child { padding-left: 0; }
.stats b { display: block; font-family: var(--font-display); font-weight: 500; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1; letter-spacing: -.02em; }
.stats span { font-size: .85rem; color: var(--ink-3); }
.steps { display: grid; gap: 0; border-top: 1px solid var(--ink); counter-reset: step; }
@media (min-width: 48em) { .steps { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); } }
.step { padding: 1.1rem 1rem 1.2rem 0; border-bottom: 1px solid var(--line-2); }
@media (min-width: 48em) { .step { border-right: 1px solid var(--line-2); padding-left: 1rem; } .step:first-child { padding-left: 0; } .step:last-child { border-right: 0; } }
.step .n { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: .95rem; }
.step b { display: block; font-family: var(--font-display); font-weight: 500; font-size: 1.3rem; margin: .2rem 0 .35rem; letter-spacing: -.01em; }
.step span { font-size: .9rem; color: var(--ink-2); }
.callout { border-left: 2px solid var(--accent); padding: .25rem 0 .25rem 1.25rem; margin: 1.5rem 0; color: var(--ink-2); font-family: var(--font-display); font-size: 1.25rem; line-height: 1.35; font-style: italic; font-weight: 400; font-variation-settings: "SOFT" 60, "WONK" 1; }
.next-case { border-top: 1px solid var(--ink); margin-top: 3rem; padding-top: 1.5rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: baseline; }
.next-case a { font-family: var(--font-display); font-size: 1.4rem; text-decoration: none; }
.next-case a .arrow { color: var(--accent); }

/* signal scorer */
.scorer { display: grid; gap: 1.5rem; margin: 1.5rem 0 2rem; }
@media (min-width: 60em) { .scorer { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 3rem; } }
.layer { border-top: 1px solid var(--line-2); padding: .9rem 0; }
.layer .lh { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .5rem; }
.layer .lh b { font-weight: 600; }
.layer .lh span { font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.layer .opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.layer .opts .chip { font-size: .82rem; }
.score-out { position: sticky; top: calc(var(--nav-h) + 1rem); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem 1.4rem; background: var(--paper-2); box-shadow: var(--shadow); align-self: start; }
.score-out .big { font-family: var(--font-display); font-size: clamp(3.5rem, 7vw, 5.5rem); line-height: 1; letter-spacing: -.03em; font-weight: 500; font-variant-numeric: tabular-nums; transition: color .3s; }
.score-out .big small { font-size: .3em; color: var(--ink-3); font-family: var(--font-body); letter-spacing: 0; font-weight: 500; }
.score-out .tier { display: inline-block; margin: .5rem 0 .75rem; padding: .3em .8em; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--paper-3); color: var(--ink-2); transition: background-color .3s, color .3s; }
.score-out .tier.act { background: var(--accent); color: #fff; }
.score-out .tier.engage { background: var(--ink); color: var(--paper); }
.score-out p { font-size: .92rem; color: var(--ink-2); margin: 0 0 .5rem; }
.score-out .bar { height: 6px; background: var(--paper-3); border-radius: 6px; overflow: hidden; margin: .25rem 0 1rem; }
.score-out .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .5s var(--ease-out); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise { animation: none; opacity: 1; transform: none; }
  .reveal { transform: none; transition: opacity .2s ease; }
  .chat, .dock, .btn, .chip, .icon-btn, .seg button, .score-out .bar i { transition: none !important; }
  .dock .pulse { animation: none; }
  .msg.bot .caret { animation: none; }
  .chat-log { scroll-behavior: auto; }
}

/* ---------- Print ---------- */
@media print {
  .nav, .dock, .chat, .scrim, .askbar, body::after { display: none !important; }
  .hero { padding-top: 0; }
  body { background: #fff; color: #000; }
}

/* ---------- Site menu (expertise dropdown on desktop, full menu on phones) ---------- */
.nav-dd { background: none; border: 0; padding: 0; cursor: pointer; font-size: .92rem; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: .35em; line-height: 1; }
.nav-dd:hover, .nav-dd[aria-expanded="true"] { color: var(--ink); }
.nav-dd svg { width: 12px; height: 12px; transition: transform .2s var(--ease-out); }
.nav-dd[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu-btn { display: inline-grid; }
@media (min-width: 52em) { .menu-btn { display: none; } }
.menu-btn .x { display: none; }
body.menu-open .menu-btn .x { display: block; }
body.menu-open .menu-btn .bars { display: none; }
.menu {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 1;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - var(--nav-h)); overflow-y: auto;
  visibility: hidden; opacity: 0; transform: translateY(-8px);
  transition: opacity .2s ease, transform .25s var(--ease-out), visibility 0s linear .25s;
}
body.menu-open .menu { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
.nav .menu .wrap { height: auto; display: grid; gap: 1.5rem 3rem; padding: 1.25rem 0 1.75rem; align-items: start; justify-content: stretch; }
@media (min-width: 52em) { .nav .menu .wrap { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); padding: 1.75rem 0 2rem; } }
.menu ul { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .1rem .75rem; }
@media (min-width: 40em) { .menu-col.wide ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64em) { .menu-col.wide ul { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.menu a { text-decoration: none; display: flex; gap: .6em; align-items: baseline; padding: .45rem .55rem; margin-left: -.55rem; border-radius: var(--radius-s); color: var(--ink-2); font-size: .95rem; line-height: 1.3; transition: background-color .15s, color .15s; }
.menu a:hover, .menu a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }
.menu a .n { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: .85rem; min-width: 1.4em; }
@media (max-width: 51.99em) { .menu { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-reduced-transparency: reduce) { .menu { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ---------- Expertise grid (home) ---------- */
.areas { display: grid; gap: 0; border-top: 1px solid var(--ink); }
@media (min-width: 40em) { .areas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 60em) { .areas { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.area { display: grid; gap: .45rem; align-content: start; padding: 1.4rem 1.25rem 1.6rem 0; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit; transition: background-color .25s; }
@media (min-width: 40em) {
  .area { padding-left: 1.25rem; border-right: 1px solid var(--line-2); }
  .area:nth-child(2n) { border-right: 0; }
  .area:nth-child(2n+1) { padding-left: 0; }
}
@media (min-width: 60em) {
  .area:nth-child(2n) { border-right: 1px solid var(--line-2); }
  .area:nth-child(2n+1) { padding-left: 1.25rem; }
  .area:nth-child(3n) { border-right: 0; }
  .area:nth-child(3n+1) { padding-left: 0; }
}
.area:hover { background: var(--accent-soft); }
.area .n { font-family: var(--font-display); font-style: italic; color: var(--accent); font-size: .95rem; }
.area h3 { font-size: 1.4rem; text-wrap: balance; }
.area p { color: var(--ink-2); font-size: .93rem; margin: 0; }
.area .key { font-size: .8rem; color: var(--ink-3); line-height: 1.55; margin-top: .3rem; }
.area .key b { color: var(--ink); font-weight: 600; }
.area .go { font-weight: 600; font-size: .9rem; margin-top: .4rem; display: inline-flex; gap: .4em; }
.area .go .arrow { transition: transform .2s var(--ease-out); }
.area:hover .go .arrow { transform: translateX(4px); }

/* ---------- Ask strip (expertise pages) ---------- */
.ask-strip { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line-2); }
.ask-strip .label { margin-right: .25rem; }
