/* style.css */
:root {
  color-scheme: dark;
  --bg:#09111f; --bg-deep:#050a13; --surface:#111d30; --surface-raised:#17253b; --surface-soft:#0e192a;
  --text:#f3f7fc; --muted:#aebdd0; --faint:#7387a1; --line:rgba(189,214,241,.16); --line-strong:rgba(189,214,241,.28);
  --accent:#75d7ff; --accent-strong:#1ba6df; --accent-ink:#04131d; --gold:#f6c65b; --violet:#bb9cff; --mint:#7ce3be; --coral:#ff9b91;
  --shadow:0 20px 60px rgba(0,0,0,.24); --radius:18px;
  --body-font:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
@media (prefers-color-scheme:light) {
  :root {
    color-scheme:light; --bg:#eff5fb; --bg-deep:#e6eef8; --surface:#fff; --surface-raised:#f8fbff; --surface-soft:#f4f8fc;
    --text:#102238; --muted:#53677e; --faint:#76879a; --line:rgba(26,63,101,.14); --line-strong:rgba(26,63,101,.25);
    --accent:#087db8; --accent-strong:#006da7; --accent-ink:#fff; --gold:#a96a00; --violet:#6d4bc5; --mint:#047650; --coral:#c4544a;
    --shadow:0 20px 50px rgba(35,64,94,.13);
  }
}
:root[data-theme="dark"] {
  color-scheme:dark; --bg:#09111f; --bg-deep:#050a13; --surface:#111d30; --surface-raised:#17253b; --surface-soft:#0e192a;
  --text:#f3f7fc; --muted:#aebdd0; --faint:#7387a1; --line:rgba(189,214,241,.16); --line-strong:rgba(189,214,241,.28);
  --accent:#75d7ff; --accent-strong:#1ba6df; --accent-ink:#04131d; --gold:#f6c65b; --violet:#bb9cff; --mint:#7ce3be; --coral:#ff9b91;
  --shadow:0 20px 60px rgba(0,0,0,.24);
}
:root[data-theme="light"] {
  color-scheme:light; --bg:#eff5fb; --bg-deep:#e6eef8; --surface:#fff; --surface-raised:#f8fbff; --surface-soft:#f4f8fc;
  --text:#102238; --muted:#53677e; --faint:#76879a; --line:rgba(26,63,101,.14); --line-strong:rgba(26,63,101,.25);
  --accent:#087db8; --accent-strong:#006da7; --accent-ink:#fff; --gold:#a96a00; --violet:#6d4bc5; --mint:#047650; --coral:#c4544a;
  --shadow:0 20px 50px rgba(35,64,94,.13);
}

* { box-sizing:border-box; }
html { background:var(--bg-deep); scroll-behavior:smooth; }
body {
  min-width:320px; min-height:100dvh; margin:0; overflow-x:hidden; color:var(--text); font-family:var(--body-font); line-height:1.55;
  background:radial-gradient(circle at 8% -10%,color-mix(in srgb,var(--accent) 13%,transparent),transparent 28rem),radial-gradient(circle at 94% 18%,color-mix(in srgb,var(--violet) 10%,transparent),transparent 30rem),var(--bg);
}
button,input { font:inherit; }
button,a,input { -webkit-tap-highlight-color:transparent; }
button { cursor:pointer; }
button:focus-visible,a:focus-visible,input:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
a { color:inherit; text-underline-offset:.18em; }

.site-shell { width:min(1440px,100%); margin:0 auto; padding:0 max(18px,env(safe-area-inset-left)) calc(76px + env(safe-area-inset-bottom)); }
.topbar { min-height:76px; display:flex; align-items:center; justify-content:space-between; gap:16px; border-bottom:1px solid var(--line); }
.brand { min-width:0; display:inline-flex; align-items:center; gap:11px; text-decoration:none; }
.brand-mark { width:43px; height:43px; flex:0 0 auto; display:grid; place-items:center; border:1px solid color-mix(in srgb,var(--accent) 48%,transparent); border-radius:14px; color:var(--accent); background:color-mix(in srgb,var(--accent) 8%,transparent); }
.brand-mark svg { width:29px; height:29px; }
.brand strong,.brand small { display:block; white-space:nowrap; }
.brand strong { font-size:.95rem; line-height:1.15; letter-spacing:.01em; }
.brand small { margin-top:3px; color:var(--muted); font-size:.72rem; line-height:1.2; }
.top-actions { display:flex; gap:8px; }
.icon-button { width:44px; height:44px; display:grid; place-items:center; border:1px solid var(--line); border-radius:13px; color:var(--muted); background:color-mix(in srgb,var(--surface) 80%,transparent); transition:160ms ease; }
.icon-button:hover { border-color:var(--line-strong); color:var(--accent); background:var(--surface-raised); }
.icon-button svg { width:21px; height:21px; }

.hero { display:grid; gap:28px; padding:clamp(42px,7vw,90px) 0 clamp(30px,5vw,58px); }
.eyebrow,.card-label { margin:0; color:var(--accent); font-size:.72rem; font-weight:800; letter-spacing:.13em; line-height:1.25; text-transform:uppercase; }
.hero h1,.detail-panel h2,.guide-section h2,.sources-section h2 { margin:0; letter-spacing:-.045em; line-height:1.03; }
.hero h1 { max-width:850px; margin-top:10px; font-size:clamp(2.45rem,7vw,5.6rem); }
.hero-text { max-width:760px; margin:20px 0 0; color:var(--muted); font-size:clamp(1.02rem,2.1vw,1.22rem); }
.hero-side { display:grid; gap:11px; align-content:end; }
.hero-stats { display:grid; grid-template-columns:repeat(3,1fr); overflow:hidden; border:1px solid var(--line); border-radius:var(--radius); background:color-mix(in srgb,var(--surface) 74%,transparent); box-shadow:var(--shadow); }
.hero-stats div { min-width:0; padding:17px 13px; text-align:center; }
.hero-stats div + div { border-left:1px solid var(--line); }
.hero-stats strong,.hero-stats span { display:block; }
.hero-stats strong { font-size:clamp(1.35rem,5vw,2.1rem); line-height:1.1; }
.hero-stats span { margin-top:4px; color:var(--muted); font-size:.74rem; }

.resume-button { width:100%; min-height:58px; display:flex; align-items:center; gap:11px; padding:8px 11px; border:1px solid color-mix(in srgb,var(--accent) 34%,var(--line)); border-radius:14px; color:var(--text); text-align:left; background:color-mix(in srgb,var(--accent) 8%,var(--surface)); transition:160ms ease; }
.resume-button:hover:not(:disabled) { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 14%,var(--surface)); transform:translateY(-1px); }
.resume-button:disabled { cursor:default; opacity:.58; }
.resume-button small,.resume-button strong { display:block; }
.resume-button small { color:var(--muted); font-size:.67rem; font-weight:700; line-height:1.2; letter-spacing:.08em; text-transform:uppercase; }
.resume-button strong { overflow:hidden; max-width:100%; margin-top:2px; color:var(--accent); font-size:.79rem; line-height:1.25; text-overflow:ellipsis; white-space:nowrap; }
.resume-icon { width:37px; height:37px; flex:0 0 auto; display:grid; place-items:center; border-radius:11px; color:var(--accent-ink); background:var(--accent); }
.resume-icon svg { width:20px; height:20px; }

.explore-bar { display:grid; gap:17px; padding:18px; border:1px solid var(--line); border-radius:var(--radius); background:color-mix(in srgb,var(--surface) 88%,transparent); box-shadow:var(--shadow); }
.search-wrap label,.filter-label { display:block; margin-bottom:7px; color:var(--muted); font-size:.76rem; font-weight:700; }
.search-field { min-height:47px; display:flex; align-items:center; gap:9px; padding:0 13px; border:1px solid var(--line); border-radius:12px; color:var(--faint); background:var(--bg-deep); }
.search-field:focus-within { border-color:var(--accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 15%,transparent); }
.search-field svg { width:20px; height:20px; flex:0 0 auto; }
.search-field input { width:100%; min-width:0; border:0; outline:0; color:var(--text); background:transparent; }
.search-field input::placeholder { color:var(--faint); }
.filters { display:flex; gap:8px; overflow-x:auto; padding-bottom:2px; scrollbar-width:thin; }
.filter-button { min-height:44px; flex:0 0 auto; padding:0 13px; border:1px solid var(--line); border-radius:999px; color:var(--muted); background:var(--surface-soft); font-size:.83rem; font-weight:700; transition:150ms ease; }
.filter-button:hover { border-color:var(--line-strong); color:var(--text); }
.filter-button.is-active { border-color:var(--accent); color:var(--accent-ink); background:var(--accent); }

.timeline-layout { display:grid; gap:18px; margin-top:18px; }
.timeline-rail,.detail-panel { min-width:0; border:1px solid var(--line); border-radius:var(--radius); background:color-mix(in srgb,var(--surface) 91%,transparent); box-shadow:var(--shadow); }
.timeline-rail { overflow:hidden; }
.rail-heading { padding:19px 18px 14px; border-bottom:1px solid var(--line); }
.rail-heading p:last-child { margin:5px 0 0; color:var(--muted); font-size:.84rem; }
.timeline-list { position:relative; max-height:min(53dvh,660px); overflow-y:auto; padding:12px 10px 18px; scrollbar-width:thin; }
.timeline-list::before { content:""; position:absolute; top:0; bottom:0; left:29px; width:1px; background:var(--line); }
.period-marker { position:relative; z-index:1; margin:15px 0 7px 43px; color:var(--faint); font-size:.68rem; font-weight:800; letter-spacing:.14em; }
.timeline-item { position:relative; width:100%; min-height:62px; display:grid; grid-template-columns:21px 42px minmax(0,1fr); gap:7px; align-items:start; padding:9px 8px 9px 0; border:1px solid transparent; border-radius:12px; color:var(--text); text-align:left; background:transparent; transition:background 150ms ease,border-color 150ms ease; }
.timeline-item:hover { background:color-mix(in srgb,var(--accent) 7%,transparent); }
.timeline-item.is-active { border-color:color-mix(in srgb,var(--accent) 45%,transparent); background:color-mix(in srgb,var(--accent) 13%,transparent); }
.timeline-item.is-active .timeline-title { color:var(--accent); }
.timeline-node { z-index:1; width:13px; height:13px; justify-self:center; margin-top:4px; border:3px solid var(--surface); border-radius:50%; background:var(--faint); box-shadow:0 0 0 1px var(--line-strong); }
.timeline-item.is-active .timeline-node { box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 18%,transparent); }
.category-foundations { --category-color:var(--gold); } .category-protocols { --category-color:var(--accent); } .category-web { --category-color:var(--violet); } .category-business { --category-color:var(--coral); } .category-access { --category-color:var(--mint); } .category-mobile { --category-color:#e595ff; } .category-cloud { --category-color:#74a8ff; }
.timeline-node[class*="category-"] { background:var(--category-color); }
.timeline-year { padding-top:1px; color:var(--faint); font-size:.76rem; font-weight:800; font-variant-numeric:tabular-nums; }
.timeline-item-copy { min-width:0; }
.timeline-title,.timeline-category { display:block; }
.timeline-title { overflow:hidden; font-size:.87rem; font-weight:720; line-height:1.25; text-overflow:ellipsis; }
.timeline-category { margin-top:3px; color:var(--faint); font-size:.68rem; }
.empty-state { position:relative; z-index:1; margin:24px 8px; padding:20px; border:1px dashed var(--line-strong); border-radius:14px; background:var(--surface-soft); }
.empty-state strong { display:block; }
.empty-state p { margin:5px 0 12px; color:var(--muted); font-size:.88rem; }
.text-button { min-height:44px; display:inline-flex; align-items:center; gap:7px; border:0; color:var(--accent); background:transparent; font-weight:750; }
.text-button svg { width:18px; height:18px; }

.detail-panel { padding:clamp(21px,4vw,48px); overflow:hidden; }
.detail-topline,.detail-meta,.detail-actions,.nearby-nav { display:flex; align-items:center; }
.detail-topline { justify-content:space-between; gap:12px; }
.detail-meta { gap:11px; }
.detail-meta time { color:var(--muted); font-size:.94rem; font-variant-numeric:tabular-nums; }
.category-pill { display:inline-flex; align-items:center; min-height:27px; padding:0 9px; border:1px solid color-mix(in srgb,var(--category-color) 46%,transparent); border-radius:999px; color:var(--category-color); background:color-mix(in srgb,var(--category-color) 9%,transparent); font-size:.7rem; font-weight:800; }
.save-button,.read-button { min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:7px; padding:0 12px; border:1px solid var(--line-strong); border-radius:11px; color:var(--text); background:var(--surface-soft); font-size:.8rem; font-weight:750; transition:160ms ease; }
.save-button:hover,.read-button:hover { border-color:var(--accent); }
.save-button.is-saved,.read-button.is-read { border-color:color-mix(in srgb,var(--accent) 50%,transparent); color:var(--accent); background:color-mix(in srgb,var(--accent) 10%,transparent); }
.save-button svg,.read-button svg,.source-link svg { width:18px; height:18px; }
.signal-line { width:min(230px,60%); display:flex; align-items:center; justify-content:space-between; margin:30px 0 21px; }
.signal-line::before,.signal-line::after { content:""; height:1px; flex:1; background:linear-gradient(90deg,transparent,var(--accent),transparent); }
.signal-line span { width:5px; height:5px; margin:0 5px; border-radius:50%; background:var(--accent); box-shadow:0 0 12px color-mix(in srgb,var(--accent) 80%,transparent); }
.detail-panel h2 { max-width:900px; font-size:clamp(2rem,5vw,4.3rem); }
.detail-summary { max-width:850px; margin:21px 0 0; color:var(--muted); font-size:clamp(1.04rem,2vw,1.23rem); line-height:1.63; }
.detail-grid { display:grid; gap:12px; margin-top:30px; }
.why-card,.connection-card { padding:19px; border-radius:14px; }
.why-card { border:1px solid color-mix(in srgb,var(--accent) 25%,var(--line)); background:color-mix(in srgb,var(--accent) 8%,var(--surface-soft)); }
.connection-card { border:1px solid var(--line); background:var(--surface-soft); }
.why-card p:last-child,.connection-card p:last-child { margin:8px 0 0; color:var(--muted); font-size:.92rem; }
.evidence-card { display:grid; gap:17px; margin-top:13px; padding:19px; border:1px solid var(--line); border-radius:14px; background:var(--surface-soft); }
.evidence-card h3 { margin:7px 0 3px; font-size:.96rem; line-height:1.34; }
.evidence-card p:last-child { margin:0; color:var(--faint); font-size:.77rem; }
.source-link { min-height:44px; width:max-content; display:inline-flex; align-items:center; gap:8px; padding:0 13px; border-radius:10px; color:var(--accent-ink); background:var(--accent); font-size:.82rem; font-weight:800; text-decoration:none; }
.source-link:hover { filter:brightness(1.08); }
.detail-actions { flex-wrap:wrap; gap:13px; margin-top:23px; }
.keyboard-hint { color:var(--faint); font-size:.75rem; }
.nearby-nav { justify-content:space-between; gap:10px; margin-top:36px; padding-top:18px; border-top:1px solid var(--line); }
.nearby { width:min(47%,270px); min-height:56px; display:grid; gap:2px; padding:0; border:0; color:var(--text); text-align:left; background:transparent; }
.nearby:hover strong { color:var(--accent); }
.nearby span { color:var(--faint); font-size:.67rem; font-weight:800; letter-spacing:.11em; text-transform:uppercase; }
.nearby strong { overflow:hidden; font-size:.79rem; line-height:1.3; text-overflow:ellipsis; white-space:nowrap; transition:color 150ms ease; }
.nearby.next { position:relative; padding-right:30px; text-align:right; }
.nearby-arrow { position:absolute; top:50%; right:0; width:22px; height:22px; color:var(--accent); transform:translateY(-50%); }
.nearby-arrow svg { width:22px; height:22px; }

.guide-section,.sources-section { display:grid; gap:25px; margin-top:66px; padding-top:35px; border-top:1px solid var(--line); }
.guide-section h2,.sources-section h2 { margin-top:8px; font-size:clamp(1.75rem,4vw,3rem); }
.guide-grid { display:grid; gap:11px; }
.guide-grid article { min-height:150px; padding:18px; border:1px solid var(--line); border-radius:14px; background:color-mix(in srgb,var(--surface) 78%,transparent); }
.guide-number { color:var(--accent); font-size:.72rem; font-weight:850; letter-spacing:.13em; }
.guide-grid h3 { margin:11px 0 6px; font-size:1rem; }
.guide-grid p { margin:0; color:var(--muted); font-size:.87rem; }
.sources-intro { max-width:720px; }
.sources-intro > p:last-child { margin:14px 0 0; color:var(--muted); }
.sources-list { display:grid; gap:0; margin:0; padding:0; list-style:none; border-top:1px solid var(--line); }
.sources-list li { display:grid; grid-template-columns:40px minmax(0,1fr); gap:10px; padding:15px 0; border-bottom:1px solid var(--line); }
.source-number { padding-top:2px; color:var(--accent); font-size:.73rem; font-weight:850; font-variant-numeric:tabular-nums; }
.sources-list a { color:var(--text); font-size:.91rem; font-weight:720; }
.sources-list a:hover { color:var(--accent); }
.sources-list p { margin:3px 0 0; color:var(--faint); font-size:.76rem; }
footer { display:flex; flex-wrap:wrap; justify-content:space-between; gap:13px 26px; margin-top:48px; padding-top:20px; border-top:1px solid var(--line); color:var(--faint); font-size:.77rem; }
footer p { max-width:700px; margin:0; }
footer a { color:var(--accent); font-weight:750; }
.toast { position:fixed; z-index:20; right:max(16px,env(safe-area-inset-right)); bottom:calc(17px + env(safe-area-inset-bottom)); max-width:min(360px,calc(100vw - 32px)); padding:12px 15px; border:1px solid color-mix(in srgb,var(--accent) 38%,var(--line)); border-radius:11px; color:var(--text); background:color-mix(in srgb,var(--surface-raised) 94%,var(--bg-deep)); box-shadow:var(--shadow); font-size:.86rem; font-weight:650; opacity:0; pointer-events:none; transform:translateY(14px); transition:opacity 180ms ease,transform 180ms ease; }
.toast.is-visible { opacity:1; transform:translateY(0); }

@media (min-width:620px) {
  .site-shell { padding-right:max(28px,env(safe-area-inset-right)); padding-left:max(28px,env(safe-area-inset-left)); }
  .hero { grid-template-columns:minmax(0,1fr) minmax(300px,.55fr); align-items:end; }
  .hero-side { justify-self:end; width:100%; }
  .explore-bar { grid-template-columns:minmax(250px,.8fr) minmax(280px,1.2fr); align-items:end; }
  .detail-grid { grid-template-columns:1fr 1fr; }
  .evidence-card { grid-template-columns:minmax(0,1fr) auto; align-items:center; }
  .guide-grid { grid-template-columns:repeat(2,1fr); }
  .sources-list { grid-template-columns:1fr 1fr; column-gap:35px; }
}
@media (min-width:980px) {
  .site-shell { padding-right:max(42px,env(safe-area-inset-right)); padding-left:max(42px,env(safe-area-inset-left)); }
  .timeline-layout { grid-template-columns:minmax(308px,.57fr) minmax(0,1.43fr); align-items:start; }
  .timeline-rail { position:sticky; top:18px; }
  .timeline-list { max-height:calc(100dvh - 176px); }
  .guide-section,.sources-section { grid-template-columns:minmax(240px,.55fr) minmax(0,1.45fr); }
  .sources-list { grid-template-columns:1fr; }
}
@media (min-width:1240px) {
  .guide-grid { grid-template-columns:repeat(4,1fr); }
  .guide-grid article { min-height:182px; }
}
@media (max-height:610px) and (orientation:landscape) {
  .topbar { min-height:59px; }
  .brand small { display:none; }
  .hero { padding:25px 0; }
  .hero h1 { font-size:2.5rem; }
  .hero-text { margin-top:10px; font-size:.94rem; }
  .timeline-list { max-height:55dvh; }
}
