/* ---------- Wallpaper / window ---------- */
.ambient { position: fixed; inset: 0; z-index: -20; overflow: hidden; pointer-events: none; background:
  radial-gradient(90% 65% at 10% -5%, rgba(94,92,230,.18), transparent 64%),
  radial-gradient(65% 58% at 96% 3%, rgba(50,173,230,.22), transparent 62%),
  radial-gradient(55% 48% at 72% 95%, rgba(52,199,89,.11), transparent 70%),
  linear-gradient(180deg,var(--bg-2),var(--bg)); }
.orb { position:absolute; border-radius:999px; filter: blur(84px); opacity:.28; transform:translateZ(0); }
.orb-a { width:36rem; height:36rem; right:-14rem; top:2rem; background:#5ac8fa; }
.orb-b { width:30rem; height:30rem; left:-12rem; top:42%; background:#bf5af2; opacity:.18; }
.orb-c { width:34rem; height:25rem; right:8%; bottom:-10rem; background:#34c759; opacity:.13; }
html[data-theme="dark"] .orb { opacity:.15; }
@media (prefers-color-scheme:dark){ html[data-theme="auto"] .orb { opacity:.15; } }

#pageProgress { position:fixed; z-index:300; top:0; left:0; width:var(--progress,0%); height:2px; background:linear-gradient(90deg,var(--blue),var(--purple)); box-shadow:0 0 12px color-mix(in srgb,var(--accent) 50%,transparent); pointer-events:none; }

.app-shell {
  width: min(1540px, calc(100% - 36px));
  min-height: calc(100vh - 36px);
  margin: 18px auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0,1fr);
  overflow: clip;
  border-radius: var(--radius-window);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--separator) 78%, rgba(255,255,255,.30));
  box-shadow: 0 28px 100px rgba(28,31,50,.16), 0 2px 10px rgba(28,31,50,.06);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  backdrop-filter: blur(12px) saturate(120%);
}
.workspace { min-width:0; position:relative; background: color-mix(in srgb, var(--canvas) 76%, transparent); }
.wrap { width:min(calc(100% - 72px),var(--content-w)); margin:0 auto; padding:34px 0 128px; }

/* ---------- Split view sidebar ---------- */
.sidebar {
  position: sticky; top: 18px; align-self: start; height: calc(100vh - 36px);
  margin: -1px 0 -1px -1px; border-radius: var(--radius-window) 0 0 var(--radius-window);
  padding: 18px 13px 14px; z-index: 95; overflow:auto; scrollbar-width:none;
  box-shadow: none; border-top:0; border-bottom:0; border-left:0;
  border-right:1px solid var(--separator-soft);
}
.sidebar::-webkit-scrollbar { display:none; }
.sidebar-brand { display:flex; align-items:center; gap:12px; padding:7px 9px 17px; }
.app-icon { width:42px; height:42px; flex:0 0 42px; display:grid; place-items:center; border-radius:12px; color:#fff; font-weight:700; font-size:18px; background:linear-gradient(145deg,#64d2ff 0%,#0a84ff 48%,#5e5ce6 100%); box-shadow:0 8px 22px rgba(10,132,255,.24), inset 0 1px rgba(255,255,255,.45); }
.sidebar-brand strong { display:block; font-size:15px; font-weight:650; line-height:1.25; letter-spacing:-.015em; }
.sidebar-brand span { display:block; margin-top:3px; color:var(--text-tertiary); font-size:11px; line-height:1.3; }
.sidebar-search { width:100%; min-height:44px; display:flex; align-items:center; gap:9px; padding:0 11px; border-radius:13px; cursor:pointer; text-align:left; background:var(--surface-inset); color:var(--text-tertiary); box-shadow:inset 0 1px rgba(255,255,255,.07); }
.sidebar-search svg,.search-field svg,.icon-button svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex:0 0 auto; }
.sidebar-search span { flex:1; font-size:13px; }
kbd { padding:2px 6px; border-radius:6px; background:color-mix(in srgb,var(--surface) 76%,transparent); border:1px solid var(--separator); color:var(--text-quaternary); font:600 10px/1.5 var(--font-ui); box-shadow:0 1px 0 rgba(0,0,0,.05); }
.nav { padding:11px 0 8px; }
.nav-group-label { padding:12px 12px 6px; color:var(--text-quaternary); font-size:10px; font-weight:650; letter-spacing:.055em; }
.nav a { min-height:44px; display:grid; grid-template-columns:30px 1fr 10px; gap:10px; align-items:center; margin:2px 0; padding:5px 9px; border-radius:13px; text-decoration:none; color:var(--text-secondary); font-size:13px; font-weight:480; }
.nav a.active { background:var(--accent-soft); color:var(--accent); font-weight:620; }
.nav-chevron { color:var(--text-quaternary); font-size:20px; line-height:1; transform:translateY(-1px); }
.nav-icon { width:29px; height:29px; display:grid; place-items:center; border-radius:8px; color:white; font-size:9px; font-weight:750; box-shadow:inset 0 1px rgba(255,255,255,.28),0 2px 6px rgba(0,0,0,.08); }
.ni-blue{background:var(--blue)}.ni-cyan{background:var(--cyan)}.ni-indigo{background:var(--indigo)}.ni-purple{background:var(--purple)}.ni-pink{background:var(--pink)}.ni-green{background:var(--green)}.ni-orange{background:var(--orange)}.ni-teal{background:var(--teal)}.ni-red{background:var(--red)}.ni-gray{background:var(--gray)}.ni-mint{background:var(--mint);color:#073a39}.ni-brown{background:var(--brown)}
.sidebar-controls { position:sticky; bottom:-1px; margin-top:8px; padding:10px 7px 3px; background:linear-gradient(180deg,transparent,color-mix(in srgb,rgba(var(--glass-rgb),.86) 92%,transparent) 28%); }
.sidebar-controls>span { display:block; padding:0 5px 7px; color:var(--text-tertiary); font-size:11px; }
.sidebar-backdrop { display:none; }

/* ---------- Cupertino controls ---------- */
.segmented { display:flex; align-items:center; padding:3px; border-radius:11px; background:var(--surface-inset); border:1px solid var(--separator-soft); }
.seg-btn,.seg-link { min-height:32px; flex:1; display:grid; place-items:center; border-radius:8px; background:transparent; color:var(--text-tertiary); text-decoration:none; font-size:11px; font-weight:560; cursor:pointer; }
.seg-btn.active,.seg-link.active { background:var(--surface); color:var(--text); box-shadow:0 1px 4px rgba(0,0,0,.11), inset 0 1px rgba(255,255,255,.32); }
.icon-button { width:42px; height:42px; display:grid; place-items:center; border-radius:50%; background:transparent; cursor:pointer; color:var(--text-secondary); }
.mobile-only { display:none; }

/* ---------- Floating navigation bar ---------- */
.topbar { position:sticky; top:10px; z-index:80; width:min(calc(100% - 32px), calc(var(--content-w) + 48px)); min-height:56px; margin:12px auto 0; padding:0 8px 0 14px; display:flex; align-items:center; border-radius:20px; }
.topbar-title { display:flex; min-width:0; flex-direction:column; line-height:1.15; }
.topbar-title strong { font-size:14px; font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar-title span { margin-top:4px; color:var(--text-tertiary); font-size:10px; }
.topbar-spacer { flex:1; }

/* ---------- Hero ---------- */
.hero { padding:48px 4px 38px; }
.eyebrow,.kicker { color:var(--text-tertiary); font-size:11px; font-weight:650; letter-spacing:.055em; }
h1,h2,h3,h4,strong,b { font-family:var(--font-ui); }
h1 { max-width:780px; margin:9px 0 13px; font-size:clamp(2rem,3.6vw,2.9rem); line-height:1.12; font-weight:720; letter-spacing:-.032em; }
.hero>p { max-width:780px; margin:0; color:var(--text-secondary); font-size:15px; line-height:1.8; }
.hero-stats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); margin-top:27px; border-radius:20px; overflow:hidden; background:color-mix(in srgb,var(--surface) 74%,transparent); border:1px solid var(--separator-soft); box-shadow:var(--shadow-1); }
.hero-stat { min-height:78px; display:flex; align-items:center; gap:10px; padding:14px 16px; border-right:1px solid var(--separator-soft); }
.hero-stat:last-child { border-right:0; }
.hero-stat strong { display:block; font-size:15px; font-weight:650; line-height:1.25; }
.hero-stat span:not(.status-dot) { display:block; margin-top:3px; color:var(--text-tertiary); font-size:10px; line-height:1.35; }
.status-dot { width:9px; height:9px; flex:0 0 9px; border-radius:50%; box-shadow:0 0 0 4px color-mix(in srgb,currentColor 12%,transparent); }
.dot-blue{background:var(--blue);color:var(--blue)}.dot-green{background:var(--green);color:var(--green)}.dot-purple{background:var(--purple);color:var(--purple)}.dot-orange{background:var(--orange);color:var(--orange)}
.hero-segmented { width:min(420px,100%); margin-top:17px; }

/* ---------- Base content surfaces ---------- */
section { margin-bottom:92px; scroll-margin-top:86px; }
.section-head { display:grid; grid-template-columns:minmax(0,1fr) minmax(260px,390px); gap:28px; align-items:end; margin-bottom:18px; padding:0 4px; }
.section-head h2 { margin:4px 0 0; font-size:clamp(1.7rem,2.6vw,2.15rem); line-height:1.18; font-weight:700; letter-spacing:-.028em; }
.section-head p { margin:0; color:var(--text-tertiary); font-size:12px; line-height:1.65; }
.glass { background:var(--surface-raised); border:1px solid var(--separator-soft); border-radius:var(--radius-lg); box-shadow:var(--shadow-1); }
.card,.chart,.person { padding:22px 24px; }
.card h3,.chart h3 { margin:0 0 12px; font-size:16px; line-height:1.35; font-weight:650; letter-spacing:-.015em; }
p { color:var(--text-secondary); }
.callout { padding:24px 26px; border-left:4px solid var(--accent); font-size:19px; line-height:1.55; }
.callout em { font-style:normal; font-weight:690; color:var(--text); }
.grid2 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.grid3 { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.metric-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.metric { min-height:104px; padding:18px 19px; display:flex; flex-direction:column; justify-content:center; }
.metric b { font-size:25px; font-weight:700; line-height:1.05; letter-spacing:-.025em; }
.metric span { margin-top:8px; color:var(--text-tertiary); font-size:11px; }
.clean { margin:0; padding-left:20px; }
.clean li { margin:0 0 8px; color:var(--text-secondary); }
blockquote { margin:16px 0 0; padding:12px 14px; border-left:3px solid var(--purple); background:var(--surface-inset); border-radius:0 10px 10px 0; color:var(--text-secondary); }
.micro { color:var(--text-tertiary)!important; font-size:10.5px!important; }
.tag { display:inline-flex; align-items:center; min-height:25px; padding:0 9px; border-radius:999px; background:var(--surface-inset); color:var(--text-secondary); font-size:10px; font-weight:580; }

/* Charts / tables */
.chart svg { width:100%; height:auto; overflow:visible; }
.grid-line { stroke:var(--separator-soft); stroke-width:1; }
.axis-label { fill:var(--text-tertiary); font-size:9.5px; font-family:var(--font-ui); }
.bar-a { fill:color-mix(in srgb,var(--purple) 56%,transparent); }
.bar-b { fill:color-mix(in srgb,var(--blue) 76%,transparent); }
.legend { display:flex; gap:16px; margin-top:8px; color:var(--text-tertiary); font-size:11px; }
.dot { display:inline-block; width:8px; height:8px; margin-right:6px; border-radius:50%; background:color-mix(in srgb,var(--purple) 58%,transparent); }
.dot.b { background:var(--blue); }
.table-wrap { overflow:auto; border-radius:13px; border:1px solid var(--separator-soft); }
table { width:100%; border-collapse:collapse; min-width:520px; }
th,td { padding:11px 13px; text-align:left; border-bottom:1px solid var(--separator-soft); font-size:11.5px; }
th { background:var(--surface-inset); color:var(--text-tertiary); font-weight:620; }
td { color:var(--text-secondary); }
tr:last-child td { border-bottom:0; }

/* Search sheet */
.sheet-backdrop { position:fixed; inset:0; z-index:190; background:rgba(0,0,0,.28); opacity:0; pointer-events:none; transition:opacity 180ms ease-out; -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px); }
.sheet-backdrop.open { opacity:1; pointer-events:auto; }
.search-sheet { position:fixed; z-index:200; left:50%; top:12vh; width:min(650px,calc(100% - 32px)); max-height:74vh; overflow:hidden; border-radius:28px; padding:10px 16px 16px; transform:translate(-50%,28px) scale(.988); opacity:0; pointer-events:none; will-change:transform,opacity; }
.search-sheet.open { pointer-events:auto; }
.sheet-handle { width:34px; height:5px; margin:1px auto 10px; border-radius:999px; background:var(--separator); }
.sheet-header { display:flex; align-items:center; gap:12px; padding:3px 2px 12px; }
.sheet-header>div:first-child { min-width:0; flex:1; }
.sheet-header h2 { margin:0; font-size:20px; font-weight:690; letter-spacing:-.022em; }
.sheet-header p { margin:3px 0 0; color:var(--text-tertiary); font-size:11px; }
.search-field { min-height:46px; display:flex; align-items:center; gap:9px; padding:0 13px; border-radius:13px; background:var(--surface-inset); color:var(--text-tertiary); }
.search-field input { width:100%; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font-size:14px; }
.search-field input::placeholder { color:var(--text-quaternary); }
.search-results { max-height:48vh; overflow:auto; margin-top:11px; }
.search-result { display:block; padding:12px 13px; border-radius:13px; text-decoration:none; border-bottom:1px solid var(--separator-soft); }
.search-result:last-child { border-bottom:0; }
.search-result strong { display:block; font-size:13px; }
.search-result span { display:block; margin-top:4px; color:var(--text-tertiary); font-size:11px; line-height:1.5; }
.search-empty { padding:32px 10px; text-align:center; color:var(--text-tertiary); font-size:12px; }

/* Interaction */
.cu-press { --press-scale:1; scale:var(--press-scale); transform-origin:center; touch-action:manipulation; }
:focus-visible { outline:none!important; box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 20%,transparent),0 0 0 1.5px var(--accent)!important; }
.reveal { opacity:0; transform:translateY(9px); }
.reveal.on { opacity:1; transform:none; transition:opacity .40s var(--ease-out), transform .46s var(--ease-out); }
@media (hover:hover) and (pointer:fine) {
  .nav a:hover { background:color-mix(in srgb,var(--text) 5%,transparent); }
  .nav a.active:hover { background:var(--accent-soft); }
  .card,.metric,.evidence,.revision,.text-chapter,.person { transition:transform .20s var(--ease-out), box-shadow .20s var(--ease-out), border-color .20s var(--ease-out); }
  .card:hover,.metric:hover,.evidence:hover,.revision:hover,.text-chapter:hover,.person:hover { transform:translateY(-2px); border-color:color-mix(in srgb,var(--accent) 16%,var(--separator-soft)); box-shadow:var(--shadow-2); }
  .search-result:hover { background:var(--accent-soft); }
}

/* ===== Cupertino layout rewrite v2 ===== */
/* The wallpaper is content; glass floats above it instead of turning every card into glass. */
.ambient {
  background:
    radial-gradient(52rem 42rem at 8% -8%, color-mix(in srgb, var(--indigo) 22%, transparent), transparent 67%),
    radial-gradient(46rem 38rem at 96% 6%, color-mix(in srgb, var(--cyan) 25%, transparent), transparent 70%),
    radial-gradient(42rem 34rem at 78% 92%, color-mix(in srgb, var(--green) 14%, transparent), transparent 72%),
    radial-gradient(36rem 30rem at 22% 78%, color-mix(in srgb, var(--pink) 10%, transparent), transparent 76%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

.app-shell {
  grid-template-columns: 272px minmax(0, 1fr);
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  border-color: color-mix(in srgb, var(--separator) 64%, rgba(255,255,255,.36));
}

/* Compact large title: a readable document title, not a landing-page hero. */
.hero { padding: 34px 4px 30px; }
h1 {
  max-width: 760px;
  margin: 8px 0 10px;
  font-size: clamp(1.9rem, 2.9vw, 2.34rem);
  line-height: 1.16;
  font-weight: 690;
  letter-spacing: -.032em;
}
.hero > p { max-width: 800px; font-size: 14px; line-height: 1.75; }
.eyebrow, .kicker { letter-spacing: .04em; }

/* Standard material for content. Liquid Glass is reserved for controls/navigation. */
.glass {
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  border-color: var(--separator-soft);
  box-shadow: 0 1px 2px rgba(20,24,38,.035), 0 10px 30px rgba(20,24,38,.055);
  -webkit-backdrop-filter: blur(8px) saturate(108%);
  backdrop-filter: blur(8px) saturate(108%);
}
html[data-theme="dark"] .glass {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

/* iOS/macOS 26-style floating toolbars: clearer, brighter rim, less bulky. */
.topbar {
  min-height: 52px;
  width: min(calc(100% - 34px), calc(var(--content-w) + 42px));
  border-radius: 18px;
}
.topbar-title strong { font-size: 13.5px; font-weight: 620; }
.topbar-title span { margin-top: 3px; }
.sidebar { padding-top: 14px; }
.sidebar-brand { padding-bottom: 13px; }
.sidebar-search { min-height: 40px; border-radius: 12px; }
.nav a { min-height: 41px; border-radius: 12px; }
.nav-icon { width: 27px; height: 27px; border-radius: 8px; }
.segmented { border-radius: 10px; }
.seg-btn, .seg-link { min-height: 31px; border-radius: 7.5px; }

/* Concentric corner hierarchy: outer window > glass bar > group > cell. */
.hero-stats { border-radius: 18px; }
.card, .chart, .person, details, .evidence, .revision { border-radius: 17px; }
.trait, .signal { border-radius: 12px; }

/* Pressables: no native blue rectangle, but preserve keyboard accessibility. */
button, a, summary, [role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus, a:focus, summary:focus, input:focus { outline: none; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent),
              0 0 0 1px color-mix(in srgb, var(--accent) 82%, transparent) inset;
}

/* Make frequent navigation feel fast: no decorative hover lift. */
@media (hover:hover) and (pointer:fine) {
  .nav a:hover, .sidebar-search:hover, .icon-button:hover, .seg-btn:hover, .seg-link:hover {
    background-color: color-mix(in srgb, var(--surface-inset) 78%, transparent);
  }
}
