/* Rajesh Kumar Krishnan, personal site.
   Light by default, dark on request. Indigo for structure, amber for photons,
   teal and coral for the experiments. */

:root {
  --paper: #F7F8FC;
  --paper-2: #EEF0FA;
  --card: #FFFFFF;
  --ink: #141A2E;
  --muted: #586079;
  --rule: #DCDFEC;
  --indigo: #4A38E6;
  --indigo-ink: #3B29CF;
  --indigo-soft: #E7E4FF;
  --amber: #F2A33A;
  --amber-ink: #985A00;
  --amber-soft: #FFF0D9;
  --teal: #0C9A95;
  --teal-soft: #DDF5F3;
  --coral: #E14B57;
  --coral-soft: #FDE4E6;
  --hero-dot: 74, 56, 230;
  --hero-fade: 247, 248, 252;
  --shadow: 0 18px 40px rgba(28, 30, 70, .10);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --wrap: 1200px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0D1020;
  --paper-2: #141932;
  --card: #171C36;
  --ink: #E9EBF6;
  --muted: #A3A9C3;
  --rule: #2A3155;
  --indigo: #8E82FF;
  --indigo-ink: #ABA2FF;
  --indigo-soft: #241F55;
  --amber: #F5B04F;
  --amber-ink: #FFC46F;
  --amber-soft: #3A2A12;
  --teal: #3ED3CC;
  --teal-soft: #113A3A;
  --coral: #FF7C85;
  --coral-soft: #44202A;
  --hero-dot: 245, 176, 79;
  --hero-fade: 13, 16, 32;
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-behavior: smooth; scroll-padding-top: calc(76px + env(safe-area-inset-top, 0px)); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.1875rem; line-height: 1.62;
  font-optical-sizing: auto; text-rendering: optimizeLegibility;
  transition: background-color .35s, color .35s;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: var(--indigo); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--indigo-ink); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 3px; border-radius: 3px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(20px, 4vw, 40px); }
.sans { font-family: var(--sans); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition-duration: 0s !important; } }

/* Navigation */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  font-family: var(--sans); font-size: .95rem;
  border-bottom: 1px solid transparent; transition: background .3s, border-color .3s;
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 66px; }
.nav .brand { font-family: var(--serif); font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
.nav .right { display: flex; align-items: center; gap: clamp(10px, 2vw, 22px); }
.nav ul { display: flex; gap: clamp(12px, 2.2vw, 26px); list-style: none; margin: 0; padding: 0; }
.nav ul a { text-decoration: none; color: var(--muted); }
.nav ul a:hover, .nav ul a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--amber); }
.nav.solid { background: color-mix(in srgb, var(--paper) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-color: var(--rule); }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rule); background: var(--card);
  color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none;
}
.theme-toggle:hover { border-color: var(--indigo); color: var(--indigo); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (max-width: 720px) { .nav ul li.optional { display: none; } .nav .brand { font-size: 1.02rem; } }
@media (max-width: 380px) { .nav .brand { font-size: .94rem; } }

/* Hero: a two-slit detector plate */
.hero { position: relative; min-height: 100svh; display: flex; align-items: flex-end; overflow: hidden; isolation: isolate; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -3;
  background:
    radial-gradient(60% 70% at 72% 45%, color-mix(in srgb, var(--indigo) 9%, transparent), transparent 70%),
    radial-gradient(40% 50% at 15% 85%, color-mix(in srgb, var(--amber) 10%, transparent), transparent 70%),
    var(--paper);
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--hero-fade), .94) 0%, rgba(var(--hero-fade), .6) 40%, rgba(var(--hero-fade), 0) 68%);
}
.hero-inner { padding-top: 130px; padding-bottom: clamp(56px, 10vh, 110px); width: 100%; }
.hero h1 {
  font-weight: 300; font-size: clamp(3.4rem, 10.5vw, 9.25rem); line-height: .88;
  letter-spacing: -.028em; margin: 0 0 .3em; font-variation-settings: "opsz" 72;
}
.hero h1 span { display: block; }
.hero h1 span:nth-child(2) { padding-left: .55em; }
.hero h1 span:nth-child(3) { padding-left: 1.1em; }
.hero .lede { font-size: clamp(1.25rem, 2.1vw, 1.6rem); line-height: 1.4; max-width: 30em; margin: 0 0 1.1em; }
.hero .role { font-family: var(--sans); font-size: .98rem; line-height: 1.65; color: var(--muted); margin: 0 0 2em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  font-family: var(--sans); font-size: .98rem; font-weight: 500; text-decoration: none; line-height: 1.2;
  padding: .8em 1.35em; border-radius: 999px; border: 1px solid var(--indigo);
  background: var(--indigo); color: #fff; display: inline-flex; align-items: center; gap: .5em; cursor: pointer;
}
.btn:hover { background: var(--indigo-ink); border-color: var(--indigo-ink); color: #fff; }
:root[data-theme="dark"] .btn { color: #0D1020; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { border-color: var(--indigo); color: var(--indigo); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: #241500; }
.btn.amber:hover { filter: brightness(1.05); color: #241500; }
.btn.small { font-size: .86rem; padding: .5em 1em; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.readout {
  position: absolute; right: clamp(20px, 4vw, 40px); bottom: clamp(20px, 4vh, 36px);
  font-family: var(--sans); font-size: .85rem; color: var(--muted); text-align: right; max-width: 21em; line-height: 1.45; margin: 0;
}
.readout strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 2rem; color: var(--amber-ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
@media (max-width: 760px) {
  .hero { flex-direction: column; justify-content: flex-end; align-items: stretch; }
  .hero::after { background: linear-gradient(180deg, rgba(var(--hero-fade), .15) 0%, rgba(var(--hero-fade), .82) 48%, rgba(var(--hero-fade), .95) 100%); }
  .hero-inner { padding-top: 22vh; padding-bottom: 28px; }
  .hero .role { margin-bottom: 1.6em; }
  .readout { position: static; text-align: left; margin: 0 clamp(20px, 4vw, 40px) 32px; max-width: none; }
}

/* Sections */
section.block { padding: clamp(76px, 11vw, 140px) 0; }
section.tint { background: var(--paper-2); }
h2 {
  font-weight: 400; font-size: clamp(2.2rem, 4.6vw, 3.6rem); line-height: 1.04;
  letter-spacing: -.018em; margin: 0 0 .55em; font-variation-settings: "opsz" 60;
}
h3 { font-weight: 500; font-size: 1.35rem; line-height: 1.25; margin: 0 0 .3em; }
.intro { color: var(--muted); max-width: 38em; margin: -.5em 0 2.6em; }
.prose p { max-width: 34em; margin: 0 0 1.05em; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 88px); align-items: start; }
.portrait { position: relative; aspect-ratio: 4 / 5; overflow: hidden; border-radius: 20px 20px 120px 20px; box-shadow: var(--shadow); }
.portrait img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.portrait .monogram {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(4rem, 9vw, 7rem); font-weight: 300; color: #fff; letter-spacing: .04em;
  background:
    radial-gradient(circle at 72% 28%, rgba(242,163,58,.75), transparent 34%),
    radial-gradient(circle at 20% 90%, rgba(12,154,149,.55), transparent 45%),
    linear-gradient(155deg, #4A38E6, #1E1660);
}
.quote {
  margin: 2.2em 0 0; padding: 1.1em 0 0 1.4em; border-left: 3px solid var(--amber);
  font-size: clamp(1.4rem, 2.4vw, 1.85rem); line-height: 1.3; font-style: italic; max-width: 22em;
}
.quote cite { display: block; font-family: var(--sans); font-style: normal; font-size: .85rem; color: var(--muted); margin-top: .7em; }
@media (max-width: 820px) { .about { grid-template-columns: 1fr; } .portrait { max-width: 340px; } }

/* Journey: a real sequence, so it is numbered by position on a line */
.journey { list-style: none; margin: 3.2em 0 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; position: relative; }
.journey::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 2px; background: linear-gradient(90deg, var(--teal), var(--indigo), var(--amber)); border-radius: 2px; }
.journey li { position: relative; padding: 34px 18px 0 0; }
.journey li::before { content: ""; position: absolute; top: 2px; left: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 3px solid var(--indigo); }
.journey li:last-child::before { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 6px color-mix(in srgb, var(--amber) 25%, transparent); }
.journey .when { font-family: var(--sans); font-size: .85rem; color: var(--indigo-ink); font-weight: 500; }
.journey .what { font-size: 1.08rem; line-height: 1.35; margin: .25em 0 .2em; }
.journey .where { font-family: var(--sans); font-size: .88rem; color: var(--muted); }
@media (max-width: 900px) {
  .journey { grid-auto-flow: row; grid-template-columns: 1fr; }
  .journey::before { left: 7px; right: auto; top: 0; bottom: 0; width: 2px; height: auto; background: linear-gradient(180deg, var(--teal), var(--indigo), var(--amber)); }
  .journey li { padding: 0 0 1.6em 40px; }
}
.edu { margin-top: 2.6em; font-family: var(--sans); font-size: .93rem; color: var(--muted); line-height: 1.75; }
.edu strong { color: var(--ink); font-weight: 500; }

/* Fields of work */
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.field-item { background: var(--card); border: 1px solid var(--rule); border-radius: 18px; padding: 1.4em 1.4em 1.5em; }
.field-item .glyph { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 1em; }
.field-item .glyph svg { width: 26px; height: 26px; }
.field-item dt { font-size: 1.28rem; font-weight: 500; margin-bottom: .35em; line-height: 1.25; }
.field-item dd { margin: 0; color: var(--muted); font-size: 1.04rem; }
.g-indigo { background: var(--indigo-soft); color: var(--indigo-ink); }
.g-amber { background: var(--amber-soft); color: var(--amber-ink); }
.g-teal { background: var(--teal-soft); color: var(--teal); }
.g-coral { background: var(--coral-soft); color: var(--coral); }
.field-item.wide { grid-column: span 1; }
@media (max-width: 980px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .fields { grid-template-columns: 1fr; } }
.reach { margin-top: 2.4em; display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--sans); font-size: .9rem; }
.reach span { border: 1px solid var(--rule); border-radius: 999px; padding: .35em .9em; background: var(--card); }

/* Playground */
.playground { background: var(--paper-2); }
.lab-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; font-family: var(--sans); }
.lab-tabs button {
  font: inherit; font-size: .95rem; padding: .6em 1.1em; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
}
.lab-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.lab { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--rule); border-radius: 24px; padding: clamp(20px, 3.4vw, 40px); box-shadow: var(--shadow); }
.lab-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
@media (max-width: 900px) { .lab-grid { grid-template-columns: minmax(0, 1fr); } }
.lab h3 { font-size: 1.7rem; font-weight: 400; margin-bottom: .4em; }
.lab .how { color: var(--muted); font-size: 1.05rem; }
.lab .how p { margin: 0 0 .9em; }
.lab canvas { width: 100%; height: 220px; display: block; border-radius: 16px; background: var(--paper); border: 1px solid var(--rule); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 0; font-family: var(--sans); font-size: .92rem; }
.switch { display: inline-flex; align-items: center; gap: .55em; cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--rule); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--coral); }
.switch input:checked::after { transform: translateX(18px); }
.range { display: flex; align-items: center; gap: 12px; width: 100%; font-family: var(--sans); font-size: .92rem; margin-top: 14px; }
.range input { flex: 1; accent-color: var(--indigo); }
.range output { min-width: 3.2em; font-variant-numeric: tabular-nums; font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; padding: .7em .9em; }
.stat .k { font-family: var(--sans); font-size: .8rem; color: var(--muted); display: block; }
.stat .v { font-size: 1.6rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--rule); overflow: hidden; margin: 8px 0 4px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--teal); border-radius: 999px; transition: width .35s, background .35s; }
.meter .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .6; }
.meter-label { display: flex; justify-content: space-between; font-family: var(--sans); font-size: .8rem; color: var(--muted); }
.verdict { font-family: var(--sans); font-size: .95rem; border-radius: 12px; padding: .7em .9em; margin-top: 12px; }
.verdict.safe { background: var(--teal-soft); color: var(--teal); }
.verdict.alarm { background: var(--coral-soft); color: var(--coral); }
.verdict.idle { background: var(--paper); color: var(--muted); border: 1px solid var(--rule); }

/* BB84 photon table */
.qtable { width: 100%; overflow-x: auto; }
.qtable table { border-collapse: separate; border-spacing: 4px; font-family: var(--sans); font-size: .82rem; min-width: 560px; }
.qtable th { text-align: left; font-weight: 500; color: var(--muted); padding-right: 6px; white-space: nowrap; }
.qtable td { width: 34px; height: 30px; text-align: center; border-radius: 8px; background: var(--paper); font-variant-numeric: tabular-nums; }
.qtable td.kept { background: var(--teal-soft); color: var(--teal); font-weight: 600; }
.qtable td.err { background: var(--coral-soft); color: var(--coral); font-weight: 600; }
.qtable td.drop { opacity: .4; }
.qtable tr.eve-row td { background: var(--coral-soft); }
.pol { display: inline-block; width: 16px; height: 16px; position: relative; }
.pol::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--indigo); border-radius: 2px; transform: rotate(var(--a, 0deg)); }
.newest { animation: pop .45s ease-out; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bits { font-family: var(--sans); font-size: .95rem; letter-spacing: .12em; word-break: break-all; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; padding: .7em .9em; min-height: 3.2em; font-variant-numeric: tabular-nums; }
.bits b { color: var(--amber-ink); font-weight: 600; }

/* Books */
.shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: clamp(48px, 6vw, 72px) clamp(28px, 4vw, 48px); }
.book { display: flex; flex-direction: column; }
.volume-wrap { --w: min(196px, 52vw); --h: calc(var(--w) * 1.5); --t: 34px; perspective: 1400px; height: var(--h); width: var(--w); margin: 0 0 30px 6px; }
.volume { position: relative; width: var(--w); height: var(--h); transform-style: preserve-3d; transform: rotateY(-28deg); transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.book:hover .volume, .book:focus-within .volume { transform: rotateY(-8deg) translateY(-6px); }
.volume .front { position: absolute; inset: 0; transform: translateZ(calc(var(--t) / 2)); border-radius: 1px 4px 4px 1px; overflow: hidden; box-shadow: 12px 18px 34px rgba(20, 22, 60, .30); }
.volume .front svg, .volume .front img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.volume .front img { z-index: 1; }
.volume .front::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 10px; z-index: 2; background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.12) 45%, rgba(0,0,0,0)); }
.volume::before { content: ""; position: absolute; top: 3px; left: 0; width: calc(var(--t) - 2px); height: calc(var(--h) - 6px); transform: translateX(calc(var(--w) - var(--t) / 2 - 3px)) rotateY(90deg); background: repeating-linear-gradient(90deg, #FBFAF6 0 2px, #E6E3DA 2px 3px); }
.volume::after { content: ""; position: absolute; inset: 0; transform: translateZ(calc(var(--t) / -2)); background: #10142A; border-radius: 1px 4px 4px 1px; box-shadow: -12px 0 40px 6px rgba(20,22,60,.18); }
.book h3 a { text-decoration: none; }
.book .sub { font-style: italic; color: var(--muted); margin: 0 0 .7em; line-height: 1.4; }
.book .blurb { font-size: 1.02rem; margin: 0 0 1em; }
.book .status { font-family: var(--sans); font-size: .88rem; margin: auto 0 0; }
.book .status span { display: inline-block; border-radius: 999px; padding: .3em .85em; background: var(--amber-soft); color: var(--amber-ink); }
.book .status a { display: inline-flex; border-radius: 999px; padding: .45em 1em; background: var(--indigo); color: #fff; text-decoration: none; }
:root[data-theme="dark"] .book .status a { color: #0D1020; }

/* Research lists */
.research { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 64px); }
@media (max-width: 900px) { .research { grid-template-columns: 1fr; } }
.research h3 { font-size: 1.6rem; font-weight: 400; margin-bottom: .8em; display: flex; align-items: baseline; gap: .5em; }
.research h3 small { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cards li { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 1em 1.15em; border-left: 4px solid var(--indigo); }
.cards.patents li { border-left-color: var(--amber); }
.cards .t { font-size: 1.12rem; line-height: 1.35; margin: 0 0 .35em; }
.cards .t a { text-decoration: none; }
.cards .t a:hover { text-decoration: underline; }
.cards .m { font-family: var(--sans); font-size: .84rem; color: var(--muted); margin: 0; line-height: 1.55; }
.chip { display: inline-block; font-family: var(--sans); font-size: .74rem; font-weight: 500; border-radius: 999px; padding: .15em .65em; margin-right: .45em; vertical-align: .1em; }
.chip.granted { background: var(--teal-soft); color: var(--teal); }
.chip.published { background: var(--indigo-soft); color: var(--indigo-ink); }
.chip.year { background: var(--paper-2); color: var(--muted); }

/* Lists: talks, writing */
.entries { list-style: none; margin: 0; padding: 0; max-width: 56em; }
.entries li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 0 1.5em; padding: 1.15em 0; border-top: 1px solid var(--rule); }
.entries li:last-child { border-bottom: 1px solid var(--rule); }
.entries .when { font-family: var(--sans); font-size: .9rem; color: var(--muted); padding-top: .3em; font-variant-numeric: tabular-nums; }
.entries .title { font-size: 1.3rem; line-height: 1.3; margin: 0; }
.entries .title a { text-decoration: none; }
.entries .title a:hover { text-decoration: underline; }
.entries .detail { color: var(--muted); margin: .3em 0 0; }
.entries .kind { font-family: var(--sans); font-size: .76rem; border-radius: 999px; padding: .12em .65em; margin-left: .5em; vertical-align: .25em; background: var(--coral-soft); color: var(--coral); }
@media (max-width: 560px) { .entries li { grid-template-columns: 1fr; } }
.empty { color: var(--muted); font-style: italic; border-top: 1px solid var(--rule); padding-top: 1.1em; max-width: 34em; }
.more { font-family: var(--sans); font-size: .98rem; margin-top: 1.8em; }

/* Contact */
.contact-band { background: linear-gradient(135deg, #4A38E6 0%, #2B1F8F 60%, #1A1452 100%); color: #fff; border-radius: 28px; padding: clamp(36px, 6vw, 72px); position: relative; overflow: hidden; }
.contact-band::after { content: ""; position: absolute; width: 340px; height: 340px; right: -80px; top: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(242,163,58,.55), transparent 65%); }
.contact-band h2 { max-width: 13em; color: #fff; position: relative; z-index: 1; }
.contact-band .lines { position: relative; z-index: 1; font-size: clamp(1.3rem, 2.4vw, 1.7rem); line-height: 1.5; margin: 0 0 1em; }
.contact-band a { color: #fff; text-decoration-color: var(--amber); }
.contact-band .links { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--sans); font-size: .92rem; }
.contact-band .links a { border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: .45em 1em; text-decoration: none; }
.contact-band .links a:hover { background: rgba(255,255,255,.12); }

/* Footer */
footer { border-top: 1px solid var(--rule); padding: 36px 0 48px; font-family: var(--sans); font-size: .88rem; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

/* Inner pages (blog, post, admin) */
.page-head { padding: calc(124px + env(safe-area-inset-top, 0px)) 0 clamp(36px, 6vw, 64px); border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.page-head h1 { font-weight: 300; font-size: clamp(2.8rem, 7vw, 5.5rem); line-height: .95; letter-spacing: -.02em; margin: 0 0 .3em; }
.page-head p { color: var(--muted); margin: 0; max-width: 34em; }
.page-body { padding: clamp(40px, 6vw, 72px) 0 clamp(72px, 10vw, 120px); }
.back { font-family: var(--sans); font-size: .95rem; display: inline-block; margin-bottom: 1.4em; }
.viewer { width: 100%; height: 82vh; min-height: 520px; border: 1px solid var(--rule); background: #fff; border-radius: 14px; }

/* Forms (admin) */
.panel { max-width: 40em; }
.field { display: block; margin: 0 0 1.25em; }
.field span { display: block; font-family: var(--sans); font-size: .92rem; margin-bottom: .4em; }
.field input, .field textarea { width: 100%; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: .65em .8em; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--indigo); outline-offset: 0; border-color: transparent; }
.field small { display: block; font-family: var(--sans); font-size: .82rem; color: var(--muted); margin-top: .35em; }
.notice { font-family: var(--sans); font-size: .95rem; padding: .8em 1em; border-radius: 10px; margin: 0 0 1.2em; border: 1px solid var(--rule); }
.notice.error { border-color: var(--coral); color: var(--coral); background: var(--coral-soft); }
.notice.ok { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn.danger { background: transparent; border-color: var(--coral); color: var(--coral); }
.btn.danger:hover { background: var(--coral); color: #fff; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 72px); align-items: start; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: 1fr; } }
.legend { font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 12px 0 0; }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }
.legend .sw.kept { background: var(--teal-soft); border: 1px solid var(--teal); }
.legend .sw.err { background: var(--coral-soft); border: 1px solid var(--coral); }
.legend .sw.drop { background: var(--paper); border: 1px solid var(--rule); }
.legend > span { white-space: nowrap; }

/* ---------- v3 additions ---------- */
.hero h1 { font-size: min(10.5vw, 14vh, 9.25rem); }
@media (max-width: 760px) { .hero h1 { font-size: clamp(3rem, 15vw, 5rem); } }
@media (max-height: 760px) and (min-width: 761px) { .hero-inner { padding-top: 96px; padding-bottom: 40px; } .hero .lede { margin-bottom: .7em; } .hero .role { margin-bottom: 1.2em; } }

/* Mobile menu */
.menu-toggle { display: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); place-items: center; cursor: pointer; }
.menu-toggle svg { width: 20px; height: 20px; }
.mobile-menu { display: grid; gap: 2px; padding: 8px clamp(20px, 4vw, 40px) 16px; background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: var(--shadow); }
.mobile-menu a { font-family: var(--sans); font-size: 1.1rem; padding: .7em 0; text-decoration: none; border-bottom: 1px solid var(--rule); }
.mobile-menu a:last-child { border-bottom: 0; }
@media (max-width: 860px) {
  .nav nav { display: none; }
  .menu-toggle { display: grid; }
  .nav { background: color-mix(in srgb, var(--paper) 90%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .btn { min-height: 44px; }
}
@media (min-width: 861px) { .mobile-menu { display: none !important; } }

/* Research highlight */
.research-band { background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%); }
.highlights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 clamp(36px, 5vw, 56px); }
.hl { display: flex; flex-direction: column; gap: .45em; text-decoration: none; color: #fff; border-radius: 22px; padding: 1.5em 1.5em 1.7em; min-height: 220px; position: relative; overflow: hidden; transition: transform .25s; }
.hl:hover { transform: translateY(-4px); color: #fff; }
.hl::after { content: ""; position: absolute; right: -40px; bottom: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hl-indigo { background: linear-gradient(140deg, #4A38E6, #2A1F92); }
.hl-amber { background: linear-gradient(140deg, #E08A12, #A3480B); }
.hl-teal { background: linear-gradient(140deg, #0C9A95, #0B5E6B); }
.hl-k { font-family: var(--sans); font-size: .82rem; opacity: .85; }
.hl-t { font-size: 1.45rem; line-height: 1.2; }
.hl-d { font-family: var(--sans); font-size: .9rem; opacity: .88; margin-top: auto; position: relative; z-index: 1; }
@media (max-width: 900px) { .highlights { grid-template-columns: 1fr; } .hl { min-height: 0; } }

/* Playground extras */
.stat.wide { grid-column: 1 / -1; }
.challenge { font-family: var(--sans); font-size: .9rem; background: var(--amber-soft); color: var(--ink); border-radius: 14px; padding: .8em 1em; margin: 16px 0 0; }
.challenge strong { color: var(--amber-ink); }
@media (max-width: 600px) { .lab canvas { height: 200px; } .lab-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; } .lab-tabs button { white-space: nowrap; } }

/* Books */
.book .status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.book .status a.buy { display: inline-flex; align-items: center; min-height: 40px; border-radius: 999px; padding: .45em 1.1em; background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 500; }
.book .status a.buy:hover { background: var(--indigo); color: #fff; }
@media (max-width: 560px) { .shelf { grid-template-columns: 1fr; } .book { align-items: flex-start; } }

/* Writing */
.tags { margin: .55em 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--sans); font-size: .75rem; border-radius: 999px; padding: .15em .7em; background: var(--indigo-soft); color: var(--indigo-ink); }

/* Articles */
.wrap.narrow { max-width: 860px; }
.post-head h1 { font-size: clamp(2.2rem, 5.4vw, 3.9rem); line-height: 1.05; font-weight: 400; }
.post-meta { font-family: var(--sans); font-size: .92rem; color: var(--muted); margin: .4em 0 .6em !important; }
.article { font-size: 1.15rem; line-height: 1.72; }
.article .standfirst { font-size: 1.35rem; line-height: 1.5; color: var(--muted); margin-bottom: 1.6em; }
.article h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 1.8em 0 .5em; }
.article p, .article ul { margin: 0 0 1.1em; }
.article ul { padding-left: 1.2em; }
.article li { margin-bottom: .5em; }
.article a { color: var(--indigo-ink); }
.article table { border-collapse: collapse; width: 100%; margin: 1.2em 0 1.6em; font-family: var(--sans); font-size: .92rem; display: block; overflow-x: auto; }
.article th, .article td { text-align: left; padding: .6em .9em; border-bottom: 1px solid var(--rule); }
.article th { background: var(--paper-2); font-weight: 600; }
.article .katex-display, .article .math-block { overflow-x: auto; overflow-y: hidden; padding: .4em 0; margin: 1em 0; }
.article .katex { font-size: 1.06em; }
.note { border-radius: 14px; padding: 1em 1.2em; margin: 1.6em 0; font-size: 1.05rem; border-left: 4px solid; }
.note strong { font-family: var(--sans); font-size: .9rem; display: block; margin-bottom: .2em; }
.note.intuition { background: var(--indigo-soft); border-color: var(--indigo); }
.note.takeaway { background: var(--teal-soft); border-color: var(--teal); }
.note.practical { background: var(--amber-soft); border-color: var(--amber); }
.author { display: flex; gap: 16px; align-items: flex-start; margin: 3em 0 2em; padding: 1.3em; border: 1px solid var(--rule); border-radius: 18px; background: var(--card); font-size: 1rem; }
.author p { margin: 0; }
.author-mark { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1rem; background: linear-gradient(150deg, #4A38E6, #1E1660); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.post-nav a { display: block; border: 1px solid var(--rule); border-radius: 14px; padding: .9em 1.1em; text-decoration: none; font-size: 1.02rem; line-height: 1.35; background: var(--card); }
.post-nav a:hover { border-color: var(--indigo); }
.post-nav a span { display: block; font-family: var(--sans); font-size: .8rem; color: var(--muted); margin-bottom: .2em; }
.post-nav a.next { text-align: right; }
@media (max-width: 600px) { .post-nav { grid-template-columns: 1fr; } .post-nav a.next { text-align: left; } .article { font-size: 1.08rem; } }

/* ---------- Quantum Lab: follows the light / dark theme ---------- */
.lab-band {
  padding: clamp(76px, 10vw, 130px) 0;
  background:
    radial-gradient(50% 60% at 85% 0%, color-mix(in srgb, var(--indigo) 14%, transparent), transparent 70%),
    radial-gradient(40% 50% at 0% 100%, color-mix(in srgb, var(--teal) 12%, transparent), transparent 70%),
    var(--paper-2);
}
.lab-kicker { font-family: var(--sans); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--amber-ink); margin: 0 0 .6em; }
.lab-picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.lab-picker button {
  text-align: left; font: inherit; cursor: pointer; color: var(--ink); border-radius: 18px; padding: 1em 1.05em;
  background: var(--card); border: 1px solid var(--rule); display: grid; gap: .25em; align-content: start; transition: border-color .2s, transform .2s, box-shadow .2s;
}
.lab-picker button:hover { transform: translateY(-2px); border-color: var(--indigo); }
.lab-picker button[aria-selected="true"] { border-color: var(--indigo); box-shadow: 0 0 0 1px var(--indigo) inset, 0 14px 30px color-mix(in srgb, var(--indigo) 22%, transparent); }
.pk-i { font-family: var(--sans); font-size: .8rem; font-weight: 600; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: .3em; }
.pk-indigo { background: var(--indigo-soft); color: var(--indigo-ink); } .pk-coral { background: var(--coral-soft); color: var(--coral); }
.pk-amber { background: var(--amber-soft); color: var(--amber-ink); } .pk-teal { background: var(--teal-soft); color: var(--teal); }
.pk-t { font-size: 1.08rem; line-height: 1.25; }
.pk-d { font-family: var(--sans); font-size: .8rem; color: var(--muted); }
@media (max-width: 1100px) { .lab-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .lab-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pk-d { display: none; } .pk-t { font-size: .98rem; } }
.lab-band .lab { background: var(--card); border: 1px solid var(--rule); box-shadow: var(--shadow); }
.lab-band .how { color: var(--muted); font-size: 1.04rem; }
.lab-band canvas { border: 1px solid var(--rule); border-radius: 16px; background: var(--paper); width: 100%; display: block; }
.lab-band canvas.stage { height: 220px; }
.lab-band canvas.stage.short { height: 130px; margin-bottom: 12px; }
.lab-band canvas.stage.tall { height: 300px; }
.lab-band canvas.chart { height: 150px; margin-top: 12px; }
.lab-band .range output { color: var(--amber-ink); min-width: 5.5em; text-align: right; }
.stat.hot { background: linear-gradient(135deg, var(--teal-soft), var(--indigo-soft)); border-color: color-mix(in srgb, var(--teal) 45%, transparent); }
.stat.hot .v { font-size: 2rem; }
.fine { font-family: var(--sans); font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.verdict.warn { background: var(--amber-soft); color: var(--amber-ink); }

/* One-time pad grid */
.otp-grid { margin: 16px 0; display: grid; gap: 6px; overflow-x: auto; }
.otp-row { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; gap: 8px; font-family: var(--sans); font-size: .8rem; }
.otp-l { color: var(--muted); }
.otp-cells { display: flex; gap: 2px; }
.otp-cells span { min-width: 21px; height: 26px; font-size: .74rem; display: grid; place-items: center; border-radius: 6px; background: var(--paper-2); font-variant-numeric: tabular-nums; }
.otp-row.k .otp-cells span { background: var(--amber-soft); color: var(--amber-ink); }
.otp-row.c .otp-cells span { background: var(--indigo-soft); color: var(--indigo-ink); }
.otp-row.x .otp-cells span { background: var(--coral-soft); color: var(--coral); }
.otp-reuse { margin: 4px 0 14px; }
.crib-strip { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--sans); font-size: .85rem; margin-top: 8px; }
.crib-strip span { background: var(--paper-2); border-radius: 8px; padding: .3em .55em; color: var(--muted); letter-spacing: .05em; }
.crib-strip span b { font-weight: 500; opacity: .6; margin-right: .4em; font-size: .75rem; }
.crib-strip span.hit { background: var(--teal-soft); color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; }

/* Key strength lab */
.pw-wrap { display: flex; gap: 8px; }
.pw-wrap input { flex: 1; font-family: var(--sans); font-size: 1.1rem; letter-spacing: .04em; padding: .7em .9em; border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); min-width: 0; }
.pw-wrap input:focus { outline: 2px solid var(--indigo); border-color: transparent; }
.pw-wrap button { font-family: var(--sans); font-size: .85rem; border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); padding: 0 .9em; cursor: pointer; }
.pw-lock { display: flex; gap: 6px; margin: 16px 0 6px; }
.pw-lock i { flex: 1; height: 12px; border-radius: 999px; background: var(--paper-2); transition: background .3s, transform .3s; }
.pw-lock i.on { transform: scaleY(1.15); }
.pw-bits { font-family: var(--sans); font-size: .9rem; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.pw-bits strong { color: var(--ink); font-weight: 600; }
.race { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.race li { display: grid; gap: 5px; font-family: var(--sans); font-size: .86rem; }
.race .rl { display: flex; justify-content: space-between; gap: 10px; }
.race .rl span:last-child { font-weight: 600; text-align: right; }
.race .track { height: 10px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.race .track i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.pw-tips { font-family: var(--sans); font-size: .88rem; color: var(--muted); margin: 14px 0 0; padding-left: 1.1em; }
.pw-tips li { margin-bottom: .3em; }
.lab-band .controls { margin-top: 14px; }

/* ---------- Site editor ---------- */
.ed-bar { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.ed-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-tabs button { font-family: var(--sans); font-size: .9rem; padding: .5em .95em; border-radius: 999px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); cursor: pointer; min-height: 38px; }
.ed-tabs button[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ed-tabs .count { font-size: .75rem; opacity: .6; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ed-head h2 { font-size: 1.9rem; margin: 0; }
.ed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ed-list li { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: .7em .9em; }
.ed-item { flex: 1; min-width: 0; display: grid; }
.ed-item strong { font-weight: 500; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item span { font-family: var(--sans); font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-thumb { width: 40px; height: 60px; border-radius: 4px; background: var(--paper-2); overflow: hidden; flex: none; }
.ed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ed-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ed-actions button, .ed-actions .link-btn { font-family: var(--sans); font-size: .82rem; padding: .4em .8em; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 34px; display: inline-flex; align-items: center; }
.ed-actions button:disabled { opacity: .35; cursor: default; }
.ed-actions button.danger { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 45%, transparent); }
.ed-form { max-width: 720px; }
.ed-form.wide { max-width: none; }
.ed-form select, .field select { width: 100%; font: inherit; font-size: 1rem; padding: .6em .7em; border-radius: 10px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ed-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.ed-split textarea { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.55; }
.article.preview { border: 1px solid var(--rule); border-radius: 12px; padding: 1em 1.2em; background: var(--card); max-height: 640px; overflow: auto; font-size: 1rem; }
@media (max-width: 900px) { .ed-split, .two { grid-template-columns: 1fr; } .ed-bar { flex-direction: column; } .ed-list li { flex-wrap: wrap; } }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { font-family: var(--sans); font-size: .92rem; border: 1px solid var(--rule); border-radius: 999px; padding: .45em .9em; cursor: pointer; background: var(--card); }
.img-field { display: flex; gap: 16px; align-items: flex-start; }
.img-field small { display: block; margin-top: .5em; font-family: var(--sans); color: var(--muted); font-size: .8rem; }
.img-prev { width: 110px; height: 160px; border-radius: 8px; border: 1px dashed var(--rule); display: grid; place-items: center; font-family: var(--sans); font-size: .8rem; color: var(--muted); overflow: hidden; flex: none; background: var(--paper-2); }
.img-prev img { width: 100%; height: 100%; object-fit: cover; }
.btn.upl { cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; font-family: var(--sans); font-size: .95rem; padding: .8em 1.2em; border-radius: 12px; box-shadow: var(--shadow); max-width: min(92vw, 560px); }
.toast.ok { background: var(--teal); color: #fff; } .toast.error { background: var(--coral); color: #fff; } .toast.info { background: var(--ink); color: var(--paper); }
.ed-bar .btn { white-space: nowrap; flex: none; }
:root[data-theme="dark"] .btn.ghost { color: var(--ink); }

/* Education list under the career line */
.edu { display: grid; gap: .55em; }
.edu .edu-h { font-family: var(--sans); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--amber-ink); }

/* ---------- Moments ---------- */
@media (max-width: 1180px) and (min-width: 861px) { .nav ul li:first-child { display: none; } }
.mo-hero { padding: calc(130px + env(safe-area-inset-top, 0px)) 0 40px; background: radial-gradient(50% 70% at 90% 10%, color-mix(in srgb, var(--coral) 14%, transparent), transparent 70%), var(--paper); }
.mo-hero h1 { font-weight: 300; font-size: clamp(3rem, 8vw, 6.6rem); line-height: .95; letter-spacing: -.025em; margin: 0 0 .35em; }
.mo-hero h1 em { font-style: italic; color: var(--coral); }
.mo-lede { font-size: clamp(1.15rem, 1.9vw, 1.4rem); color: var(--muted); max-width: 38em; margin: 0 0 1.6em; }
.mo-stats { display: flex; flex-wrap: wrap; gap: 12px; }
.mo-stats div { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: .8em 1.2em; min-width: 9em; }
.mo-stats strong { display: block; font-weight: 400; font-size: 2.2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mo-stats span { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.mo-tools { position: relative; z-index: 15; background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.mo-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; }
.seg-toggle { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 4px; }
.seg-toggle button { font-family: var(--sans); font-size: .92rem; border: 0; background: transparent; color: var(--muted); padding: .5em 1.1em; border-radius: 999px; cursor: pointer; min-height: 38px; }
.seg-toggle button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(20,26,46,.12); }
.mo-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.mo-legend button { font-family: var(--sans); font-size: .82rem; display: inline-flex; align-items: center; gap: .45em; border: 1px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 999px; padding: .35em .8em; cursor: pointer; min-height: 32px; }
.mo-legend button i { width: 10px; height: 10px; border-radius: 50%; }
.mo-legend button span { color: var(--muted); }
.mo-legend button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }

.mo-timeline { padding: 40px 0 80px; }
.mo-year { padding: 40px 0; border-bottom: 1px solid var(--rule); }
.mo-yh { display: grid; grid-template-columns: auto 1fr; gap: clamp(16px, 4vw, 44px); align-items: start; margin-bottom: 26px; position: sticky; top: calc(130px + env(safe-area-inset-top, 0px)); }
.mo-yh { position: static; }
.mo-yn { font-size: clamp(3rem, 8vw, 5.5rem); line-height: .9; font-weight: 300; color: var(--coral); letter-spacing: -.03em; }
.mo-yc { font-family: var(--sans); font-size: .82rem; color: var(--muted); margin: .4em 0 .2em; }
.mo-yh h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); margin: 0 0 .2em; }
.mo-yh p:last-child { color: var(--muted); margin: 0; max-width: 40em; }
.mo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.mo-card { background: var(--card); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; }
.mo-card:hover, .mo-card:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow); }
.mo-card.big { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.mo-ph { position: relative; aspect-ratio: 4 / 3; background: var(--paper-2); overflow: hidden; }
.mo-card.big .mo-ph { aspect-ratio: auto; min-height: 320px; }
.mo-ph img { width: 100%; height: 100%; object-fit: cover; }
.mo-count { position: absolute; right: 10px; bottom: 10px; font-family: var(--sans); font-size: .75rem; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; padding: .2em .7em; }
.mo-tx { padding: 1em 1.15em 1.2em; }
.mo-card.big .mo-tx { padding: clamp(1.2em, 3vw, 2.2em); align-self: center; }
.mo-meta { font-family: var(--sans); font-size: .8rem; color: var(--muted); margin: 0 0 .4em; display: flex; align-items: center; gap: .5em; }
.mo-meta i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mo-tx h3 { font-size: 1.22rem; line-height: 1.25; margin: 0 0 .35em; }
.mo-card.big h3 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 400; }
.mo-tx p:last-child { margin: 0; color: var(--muted); font-size: 1rem; }
.mo-card.big .mo-tx p:last-child { font-size: 1.12rem; color: var(--ink); font-style: italic; }
@media (max-width: 760px) { .mo-card.big { display: flex; } .mo-card.big .mo-ph { min-height: 0; aspect-ratio: 4 / 3; } .mo-yh { grid-template-columns: 1fr; gap: 4px; } }
.mo-end { padding: clamp(70px, 10vw, 120px) 0; text-align: center; }
.mo-end h2 { font-size: clamp(2rem, 5vw, 3.4rem); }
.mo-end .mo-lede { margin: 0 auto; }

/* Moment panel */
.mo-panel { position: fixed; inset: 0; z-index: 60; background: rgba(8,10,24,.55); display: flex; justify-content: flex-end; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.mo-panel-in { position: relative; width: min(560px, 100%); height: 100%; background: var(--card); overflow-y: auto; box-shadow: -20px 0 50px rgba(0,0,0,.25); animation: slidein .3s ease-out; padding-bottom: env(safe-area-inset-bottom, 0px); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.mp-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 1.6rem; cursor: pointer; line-height: 1; }
.mp-photos { position: relative; background: #0D1020; }
.mp-photos img { width: 100%; max-height: 62vh; object-fit: contain; display: block; }
.mp-pp, .mp-pn { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); color: #141A2E; font-size: 1.6rem; cursor: pointer; }
.mp-pp { left: 10px; } .mp-pn { right: 10px; }
.mp-pc { position: absolute; left: 12px; bottom: 10px; font-family: var(--sans); font-size: .78rem; color: #fff; background: rgba(0,0,0,.55); border-radius: 999px; padding: .2em .7em; }
.mp-body { padding: 1.4em 1.5em 2em; }
.mp-meta { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin: 0 0 .5em; }
.mp-theme { color: #fff; border-radius: 999px; padding: .15em .7em; font-size: .75rem; margin-right: .4em; }
.mp-body h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); line-height: 1.12; margin: 0 0 .5em; }
.mp-memory { font-size: 1.18rem; line-height: 1.6; font-style: italic; border-left: 3px solid var(--coral); padding-left: 1em; }
.mp-lh { font-family: var(--sans); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 1.6em 0 .5em; }
.mp-links { display: grid; gap: 6px; }
.mp-links button { display: flex; align-items: center; gap: .55em; text-align: left; font: inherit; font-size: .98rem; background: var(--paper-2); color: var(--ink); border: 0; border-radius: 12px; padding: .55em .8em; cursor: pointer; }
.mp-links button i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mp-links button span { margin-left: auto; font-family: var(--sans); font-size: .78rem; color: var(--muted); }
.mp-links button:hover { background: var(--indigo-soft); }
.mp-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 1.6em; }
body.panel-open { overflow: hidden; }
@media (max-width: 640px) { .mo-panel { align-items: flex-end; } .mo-panel-in { height: 92vh; border-radius: 20px 20px 0 0; animation-name: slideup; } }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.ph-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ph-grid img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--rule); }
.field textarea#f-photos { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: .8rem; margin-bottom: 8px; }
.mo-teaser-band h2 em { font-style: italic; color: var(--coral); }
.mo-teaser { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 10px 0 8px; }
.mo-teaser .mt { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; text-decoration: none; color: #fff; background: var(--paper-2); }
.mo-teaser .mt img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.mo-teaser .mt:hover img { transform: scale(1.06); }
.mo-teaser .mt span { position: absolute; inset: auto 0 0 0; padding: 2.4em .8em .8em; font-family: var(--sans); font-size: .82rem; line-height: 1.3; background: linear-gradient(transparent, rgba(0,0,0,.78)); }
.mo-teaser .mt b { display: block; font-size: 1.1rem; font-weight: 600; color: #FFC46F; }
@media (max-width: 900px) { .mo-teaser { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Moments v2: Storybook, Threads, plain list ---------- */
.mo-tools { border-bottom: 0; background: var(--paper); }
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* Storybook */
.sb-year { border-top: 1px solid var(--rule); }
.sb-chapter { min-height: 72vh; display: flex; align-items: center; padding: 80px 0; background: radial-gradient(60% 80% at 80% 30%, color-mix(in srgb, var(--coral) 9%, transparent), transparent 70%), var(--paper-2); }
.sb-cn { font-family: var(--sans); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.sb-yn { font-size: clamp(6rem, 22vw, 15rem); line-height: .82; font-weight: 300; letter-spacing: -.05em; margin: .05em 0 .1em; color: var(--coral); }
.sb-chapter h2 { font-size: clamp(2.2rem, 5vw, 3.8rem); margin: 0 0 .25em; }
.sb-ct { font-size: clamp(1.2rem, 2vw, 1.5rem); color: var(--muted); max-width: 32em; margin: 0 0 1em; font-style: italic; }
.sb-count { font-family: var(--sans); font-size: .9rem; color: var(--amber-ink); margin: 0; }
.sb-tag { display: inline-block; font-family: var(--sans); font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); border-radius: 999px; padding: .2em .7em; margin-bottom: .7em; }
.sb-meta { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin: 0 0 .4em; display: flex; flex-wrap: wrap; align-items: center; gap: .5em; }
.sb-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .6; }
.sb-spread { position: relative; padding: 0 0 70px; }
.sb-spread-ph { position: relative; height: min(78vh, 760px); overflow: hidden; cursor: zoom-in; background: #0D1020; }
.sb-spread-ph img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; transform: scale(1.04); transition: transform 1.6s ease; }
.sb-spread.in .sb-spread-ph img { transform: scale(1); }
.sb-spread-tx { position: relative; margin-top: -140px; max-width: 760px; background: var(--card); border-radius: 24px; padding: clamp(1.4em, 3.4vw, 2.6em); box-shadow: var(--shadow); }
.sb-spread-tx h3 { font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 400; line-height: 1.08; margin: 0 0 .45em; }
.sb-spread-tx blockquote { margin: 0 0 1.2em; font-size: clamp(1.15rem, 1.9vw, 1.4rem); line-height: 1.55; font-style: italic; border-left: 3px solid var(--coral); padding-left: 1em; }
.sb-page { padding: 34px 0; }
.sb-page-in { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(20px, 5vw, 64px); align-items: center; }
.sb-page.flip .sb-ph { order: 2; }
.sb-page.nophoto .sb-page-in { grid-template-columns: 1fr; max-width: 820px; }
.sb-ph { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; border: 0; padding: 0; border-radius: 20px; overflow: hidden; cursor: zoom-in; background: var(--paper-2); box-shadow: var(--shadow); }
.sb-ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.sb-ph:hover img { transform: scale(1.04); }
.sb-tx h3 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 400; line-height: 1.15; margin: 0 0 .4em; }
.sb-tx h3 button { all: unset; cursor: pointer; }
.sb-tx h3 button:hover { text-decoration: underline; text-decoration-color: var(--coral); }
.sb-tx h3 button:focus-visible { outline: 2px solid var(--indigo); outline-offset: 3px; border-radius: 3px; }
.sb-tx p:last-child { font-size: 1.12rem; color: var(--muted); max-width: 34em; margin: 0; }
@media (max-width: 760px) { .sb-page-in { grid-template-columns: 1fr; } .sb-page.flip .sb-ph { order: 0; } .sb-chapter { min-height: 56vh; } .sb-spread-ph { height: 56vh; } .sb-spread-tx { margin-top: -70px; } }

/* Year rail (desktop) and progress bar (phones) */
.sb-rail { position: fixed; right: clamp(10px, 2vw, 26px); top: 50%; transform: translateY(-50%); z-index: 20; display: grid; gap: 2px; opacity: 0; pointer-events: none; transition: opacity .3s; }
body.in-story .sb-rail { opacity: 1; pointer-events: auto; }
.sb-rail a { font-family: var(--sans); font-size: .78rem; text-decoration: none; color: var(--muted); padding: .2em .55em; border-radius: 999px; text-align: right; font-variant-numeric: tabular-nums; }
.sb-rail a:hover { color: var(--ink); }
.sb-rail a.on { background: var(--coral); color: #fff; }
.sb-progress { position: fixed; left: 0; right: 0; top: calc(66px + env(safe-area-inset-top, 0px)); z-index: 19; height: 3px; background: transparent; opacity: 0; transition: opacity .3s; pointer-events: none; }
.sb-progress i { display: block; height: 100%; width: 0; background: var(--coral); transition: width .4s; }
.sb-progress span { position: absolute; right: 12px; top: 8px; font-family: var(--sans); font-size: .8rem; font-weight: 600; color: #fff; background: var(--coral); border-radius: 999px; padding: .15em .7em; }
body.in-story .sb-progress { opacity: 1; }
@media (min-width: 1100px) { .sb-progress span { display: none; } }
@media (max-width: 1099px) { .sb-rail { display: none; } }

/* Threads */
.th { padding: 30px 0 60px; }
.th-intro { margin-bottom: 10px !important; }
.th-line { padding: 34px 0 26px; border-top: 1px solid var(--rule); }
.th-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.th-k { font-family: var(--sans); font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c); margin: 0 0 .3em; display: flex; align-items: center; gap: .5em; }
.th-k i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.th-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.5rem); margin: 0 0 .15em; }
.th-span { font-family: var(--sans); font-size: .88rem; color: var(--muted); margin: 0; }
.th-arrows { display: flex; gap: 6px; flex: none; }
.th-arrows button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--rule); background: var(--card); color: var(--ink); font-size: 1.1rem; cursor: pointer; }
.th-arrows button:hover { border-color: var(--c); color: var(--c); }
.th-track { --pad: max(20px, calc((100vw - var(--wrap)) / 2 + 40px)); overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding: 0 var(--pad); scroll-padding-inline: var(--pad); scrollbar-width: thin; }
.th-cards { list-style: none; margin: 0; padding: 62px 0 10px; display: flex; gap: 18px; position: relative; width: max-content; }
.th-cards::before { content: ""; position: absolute; left: 0; right: 0; top: 41px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 30%, transparent), var(--c)); }
.th-card { position: relative; width: 230px; flex: none; scroll-snap-align: start; }
.th-card.big { width: 300px; }
.th-node { position: absolute; top: -27px; left: 14px; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 3px solid var(--c); }
.th-card.big .th-node { background: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent); }
.th-year { position: absolute; top: -52px; left: 6px; font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--c); background: var(--paper); padding: 0 .4em; }
.th-card button { all: unset; display: block; width: 100%; cursor: pointer; background: var(--card); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; box-sizing: border-box; transition: transform .2s, box-shadow .2s; }
.th-card button:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.th-card button:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.th-ph { display: block; aspect-ratio: 4 / 3; background: var(--paper-2); }
.th-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.th-ph.empty { aspect-ratio: 8 / 1; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 25%, transparent), transparent); }
.th-tx { display: block; padding: .8em .95em 1em; }
.th-d { display: block; font-family: var(--sans); font-size: .76rem; color: var(--muted); margin-bottom: .25em; }
.th-tx strong { font-weight: 500; font-size: 1.05rem; line-height: 1.3; }
@media (max-width: 640px) { .th-arrows { display: none; } .th-card { width: 72vw; } .th-card.big { width: 80vw; } }

/* Timeline: plain list */
.mo-list { padding: 30px 0 70px; }
.ml-year { padding: 22px 0 10px; }
.ml-year h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 0 0 .5em; display: flex; gap: .6em; align-items: baseline; }
.ml-year h2 span { font-family: var(--sans); font-weight: 600; color: var(--coral); font-size: .8em; }
.ml-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.ml-rows li { border-bottom: 1px solid var(--rule); }
.ml-rows button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 5.2em 10px minmax(0, 1fr) minmax(0, 14em); gap: 12px; align-items: center; padding: .7em .4em; }
.ml-rows button:hover { background: var(--paper-2); }
.ml-rows button:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }
.ml-d { font-family: var(--sans); font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ml-rows i { width: 10px; height: 10px; border-radius: 50%; }
.ml-t { font-size: 1.08rem; }
.ml-t b { color: var(--amber); font-weight: 400; }
.ml-p { font-family: var(--sans); font-size: .82rem; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .ml-rows button { grid-template-columns: 4.4em 10px minmax(0, 1fr); } .ml-p { display: none; } }

/* Panel additions */
.mp-more { margin: 0 0 .5em; font-family: var(--sans); font-size: .95rem; }
.mp-more a { color: var(--indigo-ink); }
.mp-links button em { font-style: normal; font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: .2em; }
@media (max-width: 640px) { .mo-stats { display: grid; grid-template-columns: 1fr 1fr; } .mo-stats div { min-width: 0; } .mo-stats strong { font-size: 1.7rem; } }

/* Article figures and diagrams */
.article figure { margin: 1.8em 0; }
.article figure img { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--rule); border-radius: 14px; padding: 6px; }
.article figcaption { font-family: var(--sans); font-size: .86rem; color: var(--muted); margin-top: .6em; line-height: 1.5; }
.article > svg { width: 100%; height: auto; display: block; margin: 1.6em 0; background: #fff; border: 1px solid var(--rule); border-radius: 14px; padding: 10px; box-sizing: border-box; }
.article ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.article ol li { margin-bottom: .5em; }
.entries .kind.ext { background: var(--indigo-soft); color: var(--indigo-ink); }
.maint { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 1.2em 1.4em; margin-bottom: 14px; max-width: 760px; }
.maint h3 { margin: 0 0 .3em; }
.maint p { color: var(--muted); margin: 0 0 1em; font-size: 1rem; }
.profile-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.2em; font-family: var(--sans); font-size: .9rem; }
.profile-links a { text-decoration: none; border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: .4em .95em; color: var(--ink); }
.profile-links a:hover { border-color: var(--indigo); color: var(--indigo-ink); }

/* Hero portrait */
.hero-photo { margin: 0; }
.hero-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 1100px) {
  .hero-photo { position: absolute; right: max(40px, calc((100vw - var(--wrap)) / 2 + 20px)); top: 50%; transform: translateY(-55%); width: min(30vw, 420px); aspect-ratio: 1 / 1; border-radius: 36px; overflow: hidden; z-index: 1;
    box-shadow: 0 30px 80px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.08), 0 0 70px color-mix(in srgb, var(--amber) 22%, transparent); }
  .hero-photo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); pointer-events: none; }
  .hero-inner h1, .hero .lede, .hero .role { max-width: min(46vw, 640px); }
}
@media (min-width: 1100px) and (max-height: 760px) { .hero-photo { width: min(26vw, 340px); } }
@media (max-width: 1099px) {
  .hero-photo { width: 112px; height: 112px; border-radius: 50%; overflow: hidden; margin: 0 0 22px; box-shadow: 0 0 0 3px var(--amber), 0 12px 30px rgba(0,0,0,.3); }
}
.portrait picture { position: absolute; inset: 0; z-index: 1; }
.portrait picture img { width: 100%; height: 100%; object-fit: cover; }
