/* ---------- Tokens: light ---------- */
:root {
  --bg: #ffffff;
  --surface: #f6f8fb;
  --card: #ffffff;
  --border: #e5e9f0;
  --fg: #0f172a;
  --muted: #5b6577;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1ff;
  --teal: #0e7490;
  --teal-soft: #e6f6fa;
  --border-hover: #cfd8e6;
  --fg-soft: #2a3444;
  --nav-bg: rgba(255, 255, 255, .85);
  --nav-bg-solid: rgba(255, 255, 255, .97);
  --dot: rgba(15, 23, 42, .11);
  --bg-rgb: 255, 255, 255;
  --glow-mid: rgba(234, 241, 255, .5);
  --ok: #166534;
  --ok-soft: #dcfce7;
  --ok-dot: #16a34a;
  --code-bg: #0f172a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .12);
  --radius: 14px;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1120px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--fg); background: var(--bg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }
.accent { color: var(--accent); }

/* ---------- Accessibility ---------- */
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; transition: top .2s; }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
:focus:not(:focus-visible) { outline: none; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 56px); background: var(--nav-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .25s, box-shadow .25s, padding .25s;
}
.nav.scrolled { border-color: var(--border); box-shadow: var(--shadow-sm); padding: 12px clamp(20px, 5vw, 56px); }
.logo { font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { font-size: .9rem; font-weight: 500; color: var(--muted); position: relative; transition: color .2s; white-space: nowrap; }
.nav-links a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 2px; background: var(--accent); border-radius: 2px; transform: scaleX(0); transform-origin: left; transition: transform .25s; }
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-links .nav-cta { color: #fff; background: var(--accent); padding: 9px 18px; border-radius: 999px; transition: background .2s, transform .2s, box-shadow .2s; }
.nav-links .nav-cta::after { display: none; }
.nav-links .nav-cta:hover { background: var(--accent-dark); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.nav-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--card); border-radius: 10px; cursor: pointer; flex-direction: column; justify-content: center; gap: 6px; align-items: center; }
.nav-toggle span { width: 18px; height: 2px; background: var(--fg); transition: transform .3s, opacity .3s; }
.nav-toggle.open span:first-child { transform: translateY(4px) rotate(45deg); }
.nav-toggle.open span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative; max-width: var(--max); margin: 0 auto;
  padding: 150px clamp(20px, 5vw, 56px) 72px;
}
.kicker { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: .8rem; color: var(--muted); letter-spacing: .04em; margin-bottom: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-dot); }
.hero h1 { font-size: clamp(2.6rem, 6.5vw, 4.8rem); font-weight: 800; }
.title-line { font-size: clamp(1.05rem, 1.8vw, 1.3rem); font-weight: 600; color: var(--teal); margin: 16px 0 18px; }
.lead { max-width: 620px; font-size: clamp(1.05rem, 1.4vw, 1.15rem); color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: 10px; font-weight: 600; font-size: .95rem; transition: transform .2s, box-shadow .2s, background .2s, border-color .2s, color .2s; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-ghost { border: 1px solid var(--border); color: var(--fg); background: var(--card); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.stats { display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 56px); margin-top: 52px; padding-top: 28px; border-top: 1px solid var(--border); }
.stats li { display: flex; flex-direction: column; gap: 2px; }
.stats strong { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--fg); }
.stats > li > span { font-size: .85rem; color: var(--muted); }

/* ---------- Sections ---------- */
.section { max-width: var(--max); margin: 0 auto; padding: clamp(64px, 9vw, 104px) clamp(20px, 5vw, 56px); }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 36px; }
.num { font-family: var(--mono); color: var(--accent); font-size: .85rem; }
.section-head h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 800; }
.section-head h2::after { content: ""; display: block; width: 44px; height: 3px; background: var(--accent); border-radius: 2px; margin-top: 10px; }
.card-base, .about-side, .tl-card, .skill-card, .project, .case, .contact-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* About */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 44px; align-items: start; }
.about-text p { color: var(--muted); font-size: 1.05rem; margin-bottom: 16px; }
.about-side { padding: 22px; }
.about-side h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font-size: .82rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); transition: border-color .2s, background .2s, color .2s, transform .2s; }
.chips li:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); transform: translateY(-1px); }

/* Timeline */
.timeline { position: relative; padding-left: 36px; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; margin-bottom: 24px; }
.tl-dot { position: absolute; left: -31px; top: 22px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }
.tl-card { padding: 22px 26px; transition: box-shadow .25s, transform .25s, border-color .25s; }
.tl-card:hover { box-shadow: var(--shadow-md); transform: translateX(4px); border-color: var(--border-hover); }
.tl-date { font-family: var(--mono); font-size: .76rem; color: var(--teal); margin-bottom: 6px; }
.tl-card h3 { font-size: 1.12rem; font-weight: 700; }
.tl-org { color: var(--muted); font-size: .92rem; margin: 4px 0 10px; }
.tl-bullets { margin: 0; padding-left: 18px; list-style: disc; color: var(--muted); font-size: .95rem; }
.tl-bullets li { margin-bottom: 6px; }
.tl-bullets li::marker { color: var(--accent); }
.timeline .edu .tl-dot { border-color: var(--teal); }

/* Case studies */
.case-list { display: flex; flex-direction: column; gap: 24px; }
.case { display: grid; grid-template-columns: 1fr 1.25fr; gap: 30px; align-items: center; padding: 26px; transition: box-shadow .25s, transform .25s; }
.case:nth-child(even) .case-fig { order: 2; }
.case:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.case-fig { margin: 0; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.case-fig svg { width: 100%; height: auto; display: block; font-family: var(--font); }
.cs-box { fill: var(--card); stroke: var(--border); stroke-width: 1.2; }
.cs-box-accent { fill: var(--accent-soft); stroke: var(--accent); }
.cs-t { fill: var(--fg); font-size: 12px; font-weight: 600; text-anchor: middle; }
.cs-s { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.cs-arrow { stroke: var(--teal); stroke-width: 1.6; fill: none; }
.cs-ah { fill: var(--teal); }
.case-num { font-family: var(--mono); font-size: .74rem; color: var(--teal); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.case-body h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 14px; }
.case-body dl { margin: 0 0 14px; display: grid; grid-template-columns: 88px 1fr; gap: 8px 14px; }
.case-body dt { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding-top: 3px; }
.case-body dd { margin: 0; color: var(--muted); font-size: .95rem; }
.case-body dd.case-result { color: var(--fg); font-weight: 500; }

/* Skills */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.skill-card { padding: 22px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.skill-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.skill-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.certs { grid-column: 1 / -1; }
.cert-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.cert-list li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: .95rem; font-weight: 500; transition: border-color .2s, background .2s; }
.cert-list li:hover { border-color: var(--accent); background: var(--accent-soft); }
.cert-badge { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700; }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.project { padding: 24px; display: flex; flex-direction: column; gap: 12px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.project:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--border-hover); }
.p-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: .78rem; background: var(--accent-soft); color: var(--accent-dark); }
.project h3 { font-size: 1.08rem; font-weight: 700; }
.project p { color: var(--muted); font-size: .93rem; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-family: var(--mono); font-size: .7rem; padding: 4px 9px; border-radius: 6px; background: var(--teal-soft); color: var(--teal); }

/* Contact */
.contact-card { position: relative; text-align: center; padding: clamp(40px, 7vw, 72px) clamp(20px, 5vw, 60px); border-radius: 20px; background: linear-gradient(160deg, var(--accent-soft), var(--card) 70%); }
.contact-card .num { display: block; margin-bottom: 10px; }
.contact-card h2 { font-size: clamp(1.7rem, 3.8vw, 2.6rem); font-weight: 800; }
.contact-card p { color: var(--muted); margin: 14px auto 0; max-width: 520px; }
.contact-card .hero-actions { justify-content: center; }

footer { text-align: center; padding: 26px 16px 34px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- Reveal (minimal) ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s ease, transform .55s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .case { grid-template-columns: 1fr; gap: 18px; }
  .case:nth-child(even) .case-fig { order: 0; }
  .case-body dl { grid-template-columns: 1fr; gap: 4px; }
  .case-body dt { margin-top: 8px; }
  .cs-t { font-size: 14px; } .cs-s { font-size: 11.5px; }
  .about-grid { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 480px) {
  .hero { padding-top: 110px; }
  .stats { gap: 22px; }
  .stats strong { font-size: 1.5rem; }
  .timeline { padding-left: 28px; }
  .tl-dot { left: -23px; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; opacity: 1; transform: none; }
  * { transition-duration: 0s !important; }
}

/* ---------- Compact cards + popup ---------- */
.details { display: none; }
.clickable { cursor: pointer; position: relative; transform-style: preserve-3d; will-change: transform; }
.clickable:hover { border-color: var(--accent); }
.card-hint { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: .8rem; font-weight: 600; color: var(--accent); opacity: .75; transition: opacity .2s, gap .2s; }
.card-hint svg { width: 14px; height: 14px; transition: transform .2s; }
.clickable:hover .card-hint { opacity: 1; }
.clickable:hover .card-hint svg { transform: translateX(3px); }
.card-sub { color: var(--muted); font-size: .9rem; margin: -4px 0 0; }
.tl-card.clickable:hover { transform: none; }
.tl-card .card-hint { margin-top: 4px; }
.tl-org { margin-bottom: 4px; }
.skill-card h3 { margin-bottom: 6px; }

.case-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.case { display: block; padding: 24px; }
.case:hover { transform: none; }
.case .case-body h3 { margin-bottom: 8px; font-size: 1.15rem; }
.teaser { color: var(--muted); font-size: .93rem; margin-bottom: 12px; }
.case .card-hint { display: inline-flex; margin-top: 12px; }
.case .tags { margin-bottom: 0; }

.section-head h2::after { transform: scaleX(0); transform-origin: left; transition: transform .6s cubic-bezier(.2,.7,.2,1) .2s; }
.section-head.visible h2::after { transform: scaleX(1); }
.reveal { transform: translateY(22px); }

.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .25s ease; }
.modal-card { position: relative; width: min(820px, 100%); max-height: min(86vh, 900px); overflow: auto; background: var(--card); border-radius: 18px; padding: 32px 36px 36px; box-shadow: 0 30px 80px rgba(15,23,42,.35); animation: pop .32s cubic-bezier(.2,.8,.2,1); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.modal-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); cursor: pointer; display: grid; place-items: center; color: var(--muted); transition: background .2s, color .2s, transform .2s; }
.modal-close svg { width: 18px; height: 18px; }
.modal-close:hover { background: var(--surface); color: var(--fg); transform: rotate(90deg); }
.modal-kind { font-family: var(--mono); font-size: .74rem; color: var(--teal); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.modal-card h3 { font-size: 1.5rem; font-weight: 800; padding-right: 40px; }
.modal-sub { color: var(--muted); font-size: .95rem; margin: 4px 0 0; }
.modal-sub:empty { display: none; }
.modal-body { margin-top: 20px; }
.modal-body .details { display: block; }
.modal-body .tl-bullets li { margin-bottom: 10px; font-size: 1rem; }
.modal-body .chips li { font-size: .9rem; padding: 8px 14px; }
.modal-body .cert-list { grid-template-columns: 1fr; }
.modal-body .case-fig { margin-bottom: 22px; }
.modal-body dl { display: grid; grid-template-columns: 96px 1fr; gap: 10px 16px; margin: 0; }
.modal-body dt { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding-top: 4px; }
.modal-body dd { margin: 0; color: var(--muted); font-size: 1rem; }
.modal-body dd.case-result { color: var(--fg); font-weight: 500; }
.modal-body > .details > p { color: var(--muted); font-size: 1.02rem; }
body.modal-open { overflow: hidden; }

@media (max-width: 640px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 92vh; padding: 26px 20px 30px; animation-name: slideup; }
  @keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
  .modal-body dl { grid-template-columns: 1fr; gap: 4px; }
  .modal-body dt { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-card, .modal-backdrop { animation: none; }
  .section-head h2::after { transform: none; transition: none; }
}

/* ---------- Motion pass 2: hero, nav, stagger, timeline, background ---------- */
html, body { overflow-x: clip; }
body { position: relative; }
.bg-glow { position: absolute; top: 0; right: 0; width: min(720px, 100%); height: 560px; z-index: -1; pointer-events: none;
  background: radial-gradient(520px 420px at 92% 18%, var(--accent-soft), var(--glow-mid) 45%, transparent 72%);
  animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-90px, 70px) scale(1.1); } }
body { background: var(--bg); }

/* Hero: lines fade in one after another */
.hero > .reveal:nth-child(1) { transition-delay: .05s; }
.hero > .reveal:nth-child(2) { transition-delay: .15s; }
.hero > .reveal:nth-child(3) { transition-delay: .25s; }
.hero > .reveal:nth-child(4) { transition-delay: .35s; }
.hero > .reveal:nth-child(5) { transition-delay: .45s; }
.hero > .reveal:nth-child(6) { transition-delay: .55s; }
.caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 3px; vertical-align: -0.15em; background: var(--teal); opacity: 0; }
.typing .caret { opacity: 1; animation: blink .9s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0; } }

/* Nav: scroll progress + sliding underline */
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; pointer-events: none; }
@media (min-width: 1141px) { .nav-links { position: relative; } }
.nav-ink { position: absolute; bottom: -6px; height: 2px; background: var(--accent); border-radius: 2px; left: 0; width: 0; opacity: 0; transition: left .35s cubic-bezier(.2,.7,.2,1), width .35s cubic-bezier(.2,.7,.2,1), opacity .25s; pointer-events: none; }
.nav-ink.on { opacity: 1; }
.nav-links.has-ink a.active::after { transform: scaleX(0); }

/* Staggered card entrance */
.reveal { transition-delay: var(--d, 0ms); }

/* Timeline draws itself in */
.timeline::after { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--accent); transform: scaleY(0); transform-origin: top; transition: transform 1.4s cubic-bezier(.2,.7,.2,1) .1s; }
.timeline.visible::after { transform: scaleY(1); }
.tl-dot { transition: background .3s, box-shadow .3s; }
.timeline.visible .tl-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline.visible .edu .tl-dot { background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.timeline.visible li:nth-child(1) .tl-dot { transition-delay: .25s; }
.timeline.visible li:nth-child(2) .tl-dot { transition-delay: .5s; }
.timeline.visible li:nth-child(3) .tl-dot { transition-delay: .75s; }
.timeline.visible li:nth-child(4) .tl-dot { transition-delay: 1s; }
.timeline.visible li:nth-child(5) .tl-dot { transition-delay: 1.25s; }

/* Popup contents: chips and bullets fade in with a stagger */
.modal-body .chips li, .modal-body .tl-bullets li, .modal-body .cert-list li { animation: chipin .4s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes chipin { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1140px) {
  .nav-toggle { display: flex; position: relative; z-index: 41; }
  /* The header's backdrop-filter makes it the containing block, so the menu is a panel under the header */
  .nav-links { position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100vh - 72px); overflow-y: auto; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 16px 16px; background: var(--nav-bg-solid); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: translateY(-8px); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .25s, opacity .25s, visibility .25s; z-index: 40; }
  .nav-links.open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; }
  .nav-links a { font-size: 1.02rem; padding: 11px 12px; border-radius: 10px; }
  .nav-links a::after { display: none; }
  .nav-links a:hover, .nav-links a.active { background: var(--surface); color: var(--fg); }
  .nav-links a.active { color: var(--accent); }
  .nav-links .nav-cta { margin-top: 8px; text-align: center; justify-content: center; }
  .nav-links .nav-cta:hover, .nav-links .nav-cta.active { background: var(--accent-dark); color: #fff; }
  .nav { padding: 14px 20px; }
  .nav-ink { display: none; }
  .theme-btn { position: relative; z-index: 41; }
}
@media (max-width: 860px) {
  .bg-glow { height: 420px; background-size: 100% 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-glow { animation: none; }
  .hero > .reveal, .reveal { transition-delay: 0s; }
  .caret { display: none; }
  .nav-ink { transition: none; }
  .timeline::after { transition: none; transform: scaleY(1); }
  .tl-dot { transition: none; }
  .modal-body .chips li, .modal-body .tl-bullets li, .modal-body .cert-list li { animation: none; }
}

/* ---------- Background: faint dot grid across the page ---------- */
body::before { content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 70% 80% at 30% 55%, rgba(var(--bg-rgb), .95), rgba(var(--bg-rgb), 0) 70%); }
.contact, footer { position: relative; }

/* ---------- Services, Notes, article, sub-pages ---------- */
.section-intro { color: var(--muted); max-width: 640px; margin: -18px 0 30px; font-size: 1.02rem; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.service { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; display: flex; flex-direction: column; gap: 10px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.service:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-hover); }
.service h3 { font-size: 1.05rem; font-weight: 700; }
.service p { color: var(--muted); font-size: .93rem; }
.service .p-icon { margin-bottom: 2px; }
.nav-links { gap: 20px; }
.nav-links a { font-size: .88rem; }
.nav-right { display: flex; align-items: center; gap: 10px; }

.page { padding-top: 60px; }
.notes-list { display: grid; gap: 18px; }
.note-card { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 26px 28px; max-width: 760px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.note-card h3 { font-size: 1.25rem; font-weight: 800; margin: 6px 0 8px; }
.note-card p { color: var(--muted); font-size: .97rem; }
.note-card .tags { margin-top: 14px; }
.note-meta { font-family: var(--mono); font-size: .76rem; color: var(--teal); letter-spacing: .03em; }

.article { max-width: 760px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--accent); font-weight: 600; }
.crumbs span { margin: 0 8px; }
.article h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); font-weight: 800; margin: 8px 0 16px; }
.standfirst { font-size: 1.15rem; color: var(--muted); line-height: 1.6; margin-bottom: 28px; padding-left: 18px; border-left: 3px solid var(--accent); }
.article h2 { font-size: 1.35rem; font-weight: 800; margin: 34px 0 12px; }
.article p { margin-bottom: 14px; font-size: 1.03rem; color: var(--fg-soft); }
.article ul { padding-left: 20px; list-style: disc; margin-bottom: 14px; }
.article li { margin-bottom: 8px; color: var(--fg-soft); font-size: 1.03rem; }
.article li::marker { color: var(--accent); }
.article .case-fig { margin: 8px 0 20px; }
.article-foot { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
@media (max-width: 1140px) { .nav-links { gap: 2px; } } @media (max-width: 860px) { .page { padding-top: 48px; } }

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2b; --card: #121c2e; --border: #233047; --border-hover: #34466a;
  --fg: #e6ecf5; --fg-soft: #c7d0dd; --muted: #9aa7ba;
  --accent: #6b9aff; --accent-dark: #8db0ff; --accent-soft: #172850;
  --teal: #4cc3dd; --teal-soft: #0f2a35;
  --nav-bg: rgba(11, 18, 32, .82); --nav-bg-solid: rgba(11, 18, 32, .97);
  --dot: rgba(230, 236, 245, .08); --bg-rgb: 11, 18, 32; --glow-mid: rgba(23, 40, 80, .45);
  --ok: #86efac; --ok-soft: #0f2e1e; --ok-dot: #22c55e; --code-bg: #0a101c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 8px 24px rgba(0,0,0,.45); --shadow-lg: 0 18px 40px rgba(0,0,0,.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #0b1220; --surface: #111a2b; --card: #121c2e; --border: #233047; --border-hover: #34466a;
  --fg: #e6ecf5; --fg-soft: #c7d0dd; --muted: #9aa7ba;
  --accent: #6b9aff; --accent-dark: #8db0ff; --accent-soft: #172850;
  --teal: #4cc3dd; --teal-soft: #0f2a35;
  --nav-bg: rgba(11, 18, 32, .82); --nav-bg-solid: rgba(11, 18, 32, .97);
  --dot: rgba(230, 236, 245, .08); --bg-rgb: 11, 18, 32; --glow-mid: rgba(23, 40, 80, .45);
  --ok: #86efac; --ok-soft: #0f2e1e; --ok-dot: #22c55e; --code-bg: #0a101c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 8px 24px rgba(0,0,0,.45); --shadow-lg: 0 18px 40px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"] .nav-links .nav-cta, :root[data-theme="dark"] .btn-primary { color: #0b1220; }
:root[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .chips li:hover { color: var(--accent); }
:root[data-theme="dark"] .p-icon { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .cert-badge { color: #0b1220; }
html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

.theme-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: color .2s, border-color .2s, transform .3s; }
.theme-btn:hover { color: var(--fg); border-color: var(--accent); transform: rotate(20deg); }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }

/* ---------- Availability pill ---------- */
.kicker { flex-wrap: wrap; }
.avail { display: inline-flex; align-items: center; gap: 7px; margin-left: 12px; padding: 4px 11px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-family: var(--font); font-weight: 600; font-size: .74rem; letter-spacing: 0; }
.avail::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok-dot); box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, .08); } }

/* ---------- Back to top ---------- */
.to-top { position: fixed; right: 22px; bottom: 22px; z-index: 45; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--fg); box-shadow: var(--shadow-md); cursor: pointer; display: grid; place-items: center; opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s, transform .25s, color .2s, border-color .2s; }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }
.to-top svg { width: 20px; height: 20px; }

/* ---------- GitHub strip ---------- */
.gh-strip { margin-top: 36px; }
.gh-strip h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.gh-strip h3 svg { width: 16px; height: 16px; }
.gh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.gh-card { display: block; padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; transition: transform .2s, box-shadow .2s, border-color .2s; }
.gh-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.gh-card strong { display: block; font-family: var(--mono); font-size: .88rem; color: var(--accent); margin-bottom: 4px; }
.gh-card p { color: var(--muted); font-size: .88rem; min-height: 2.6em; }
.gh-card .gh-meta { display: flex; gap: 14px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.gh-card .gh-meta span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-right: 6px; }

/* ---------- FAQ ---------- */
.faq { max-width: 820px; display: grid; gap: 10px; }
.faq details { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 22px; transition: border-color .2s, box-shadow .2s; }
.faq details[open] { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; font-weight: 600; font-size: 1.02rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent); font-weight: 600; transition: transform .25s, background .2s; }
.faq details[open] summary::after { transform: rotate(45deg); background: var(--accent-soft); }
.faq details p { color: var(--muted); padding: 0 0 18px; margin: 0; max-width: 700px; }

/* ---------- Snippets ---------- */
.snippet { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 26px; overflow: hidden; }
.snippet-head { padding: 20px 24px 14px; }
.snippet-head h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; }
.snippet-head p { color: var(--muted); font-size: .95rem; }
.snippet-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 8px 24px; background: var(--code-bg); border-bottom: 1px solid rgba(255,255,255,.08); }
.snippet-bar span { font-family: var(--mono); font-size: .74rem; color: #94a3b8; }
.copy-btn { font: 600 .78rem var(--font); color: #e2e8f0; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: background .2s; }
.copy-btn:hover { background: rgba(255,255,255,.16); }
.copy-btn.done { color: #86efac; }
.snippet pre { margin: 0; padding: 20px 24px; background: var(--code-bg); color: #e2e8f0; font-family: var(--mono); font-size: .84rem; line-height: 1.6; overflow-x: auto; tab-size: 2; }
.snippet code { font-family: inherit; }
.tok-c { color: #7c8aa5; font-style: italic; }
.tok-s { color: #a5d6a7; }
.tok-k { color: #93c5fd; }
.tok-n { color: #fbbf24; }
.tok-f { color: #e9d5ff; }

/* ---------- Print ---------- */
@media print {
  .nav, .progress, .to-top, .bg-glow, .card-hint, .modal, .hero-actions, .theme-btn, .skip-link, .gh-strip, .avail, body::before, .hero::before { display: none !important; }
  body { background: #fff; color: #000; }
  .details { display: block !important; }
  .reveal, .section-head { opacity: 1 !important; transform: none !important; }
  .section { padding: 24px 0; break-inside: avoid; }
  .hero { padding: 24px 0 12px; }
  .card-base, .about-side, .tl-card, .skill-card, .project, .case, .contact-card, .service { box-shadow: none; border-color: #ccc; }
  .project, .case, .skill-card, .service { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .contact .btn::after { content: " " attr(href); font-size: .8rem; color: #555; }
  footer { background: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Case study cards as links ---------- */
.case-link { display: block; color: inherit; }
.case-link:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.case-link:hover .card-hint { opacity: 1; }
.case-link:hover .card-hint svg { transform: translateX(3px); }

/* ---------- Case study pages: scroll story ---------- */
.casepage { max-width: 1040px; }
.casepage h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); font-weight: 800; margin: 6px 0 16px; }
.casepage .tags { margin-bottom: 40px; }
.story { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; margin-bottom: 56px; }
.story-fig { position: sticky; top: 96px; margin: 0; padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.story-fig svg { width: 100%; height: auto; display: block; }
.story-fig figcaption { margin-top: 10px; font-family: var(--mono); font-size: .76rem; color: var(--teal); text-align: center; min-height: 1.2em; }
.story-fig .st { opacity: .18; transition: opacity .5s ease; }
.story-fig .st.lit { opacity: 1; }
.story-fig .cs-arrow.st.lit { stroke-dasharray: 300; stroke-dashoffset: 0; animation: draw .7s ease; }
@keyframes draw { from { stroke-dashoffset: 300; } }
.steps { display: grid; gap: 0; }
.step { min-height: 52vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; opacity: .35; transform: translateY(6px); transition: opacity .4s, transform .4s; border-top: 1px solid var(--border); }
.step:first-child { border-top: 0; }
.step.active { opacity: 1; transform: none; }
.step-num { font-family: var(--mono); font-size: .74rem; color: var(--teal); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.step h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 10px; }
.step p:last-child { color: var(--fg-soft); font-size: 1.03rem; }
@media (max-width: 860px) {
  .story { grid-template-columns: 1fr; gap: 20px; }
  .story-fig { top: 72px; z-index: 5; padding: 12px; }
  .step { min-height: 0; padding: 22px 0; }
}
@media (prefers-reduced-motion: reduce) { .story-fig .cs-arrow.st.lit { animation: none; } .step { transition: none; } }


/* ---------- Comments ---------- */
.comments { margin-top: 48px; padding-top: 36px; border-top: 1px solid var(--border); }
.comments-head h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.comments-head p { color: var(--muted); max-width: 680px; margin-bottom: 22px; }
.giscus, .giscus-frame { width: 100%; }

/* ---------- Footer links ---------- */
.foot-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 12px; font-size: .85rem; }
.foot-nav a { color: var(--muted); font-weight: 500; transition: color .2s; }
.foot-nav a:hover { color: var(--accent); }
.inline-link { color: var(--accent); font-weight: 600; }
.inline-link:hover { text-decoration: underline; }
.section-foot { color: var(--muted); margin-top: 26px; font-size: .98rem; }

/* ---------- Search palette (Cmd+K) ---------- */
.search-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: color .2s, border-color .2s; }
.search-btn:hover { color: var(--fg); border-color: var(--accent); }
.search-btn svg { width: 18px; height: 18px; }
.palette { position: fixed; inset: 0; z-index: 300; display: none; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.palette.open { display: flex; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .2s ease; }
.palette-box { position: relative; width: min(640px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .25s cubic-bezier(.2,.8,.2,1); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 500 1.05rem var(--font); color: var(--fg); }
.palette-input kbd { font: 500 .7rem var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.palette-list { max-height: min(56vh, 480px); overflow: auto; padding: 8px; }
.palette-group { font: 600 .68rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--fg); cursor: pointer; }
.palette-item .pi { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font: 700 .66rem var(--mono); background: var(--accent-soft); color: var(--accent-dark); }
.palette-item strong { display: block; font-size: .95rem; font-weight: 600; }
.palette-item span { display: block; font-size: .82rem; color: var(--muted); }
.palette-item:hover { background: var(--surface); }
.palette-item.sel { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.palette-item mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted); }
.palette-foot kbd { font: 500 .7rem var(--mono); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; margin-right: 4px; }
body.palette-open { overflow: hidden; }
:root[data-theme="dark"] .palette-item .pi { color: var(--accent); }
@media (max-width: 640px) { .palette { padding: 12px; } .palette-input kbd, .palette-foot { display: none; } }

/* ---------- Case study filter ---------- */
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -12px 0 24px; }
.filter button { font: 600 .82rem var(--font); padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; transition: border-color .2s, background .2s, color .2s, transform .2s; }
.filter button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.filter button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .filter button[aria-pressed="true"] { color: #0b1220; }
.filter-count { margin-left: auto; font: .78rem var(--mono); color: var(--muted); }
.case-list .case { transition: opacity .3s, transform .3s, box-shadow .25s, border-color .25s; }
.case.is-out { opacity: 0; transform: scale(.96); }
.case.is-hidden { display: none; }

/* ---------- GitHub activity heatmap ---------- */
.gh-heat { margin-top: 32px; }
.gh-heat h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.gh-heat h3 svg { width: 16px; height: 16px; }
.heat-wrap { overflow-x: auto; padding-bottom: 6px; }
.heat-wrap svg { display: block; min-width: 720px; width: 100%; height: auto; font-family: var(--mono); }
.heat-wrap .hm { fill: var(--muted); font-size: 9px; }
.heat-wrap rect { fill: var(--surface); stroke: var(--border); stroke-width: .6; rx: 2; }
.heat-wrap rect[data-l="1"] { fill: #bfdbfe; } .heat-wrap rect[data-l="2"] { fill: #60a5fa; } .heat-wrap rect[data-l="3"] { fill: #2563eb; } .heat-wrap rect[data-l="4"] { fill: #1e3a8a; }
:root[data-theme="dark"] .heat-wrap rect[data-l="1"] { fill: #1e3a8a; } :root[data-theme="dark"] .heat-wrap rect[data-l="2"] { fill: #1d4ed8; } :root[data-theme="dark"] .heat-wrap rect[data-l="3"] { fill: #3b82f6; } :root[data-theme="dark"] .heat-wrap rect[data-l="4"] { fill: #93c5fd; }
.heat-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.heat-legend { display: inline-flex; align-items: center; gap: 4px; }
.heat-legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; background: var(--surface); border: 1px solid var(--border); }
.heat-legend i[data-l="1"] { background: #bfdbfe; } .heat-legend i[data-l="2"] { background: #60a5fa; } .heat-legend i[data-l="3"] { background: #2563eb; } .heat-legend i[data-l="4"] { background: #1e3a8a; }
:root[data-theme="dark"] .heat-legend i[data-l="1"] { background: #1e3a8a; } :root[data-theme="dark"] .heat-legend i[data-l="2"] { background: #1d4ed8; } :root[data-theme="dark"] .heat-legend i[data-l="3"] { background: #3b82f6; } :root[data-theme="dark"] .heat-legend i[data-l="4"] { background: #93c5fd; }

/* ---------- Tools page ---------- */
.tool { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 28px; margin-bottom: 28px; scroll-margin-top: 90px; }
.tool-head { margin-bottom: 22px; }
.tool-head h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.tool-head p { color: var(--muted); max-width: 700px; }
.tool-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: -14px 0 30px; }
.tool-nav a { font: 600 .84rem var(--font); padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--muted); transition: border-color .2s, color .2s; }
.tool-nav a:hover { border-color: var(--accent); color: var(--accent); }
.tool-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 28px; align-items: start; }
.tool-grid > * { min-width: 0; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field > .lbl { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field select, .field input[type="number"] { font: 500 .95rem var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; max-width: 360px; }
.field select:focus, .field input:focus, .ops input:focus, .ops select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: .9rem; font-weight: 500; transition: border-color .2s, background .2s; }
.check:hover { border-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.check small { margin-left: auto; font: .7rem var(--mono); color: var(--muted); white-space: nowrap; }
.seg { display: flex; flex-wrap: wrap; max-width: max-content; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); position: relative; }
.seg label { flex: 1 1 auto; text-align: center; padding: 8px 14px; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s, color .2s; }
.seg label:hover { color: var(--fg); }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .seg label:has(input:checked) { color: #0b1220; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.result { position: sticky; top: 96px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.result h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 8px; }
.result .big { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.result .big small { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.result .lines { display: grid; gap: 6px; margin: 16px 0 4px; font-size: .9rem; }
.result .lines li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.result .lines li span:last-child { font: .8rem var(--mono); color: var(--teal); white-space: nowrap; }
.result .lines li.total { border-bottom: 0; font-weight: 700; flex-direction: column; gap: 2px; }
.result .lines li.total span:last-child { white-space: normal; font-weight: 600; }
.result .note { font-size: .8rem; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.result .hero-actions { margin-top: 16px; gap: 8px; }
.result .btn { padding: 10px 16px; font-size: .88rem; }
.result .verdict { font-weight: 700; margin-top: 10px; }
.result .verdict.ok { color: var(--ok); } .result .verdict.warn { color: #b45309; } .result .verdict.over { color: #dc2626; }
:root[data-theme="dark"] .result .verdict.warn { color: #fbbf24; } :root[data-theme="dark"] .result .verdict.over { color: #f87171; }
.meter { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 10px 0 6px; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok-dot); transition: width .4s cubic-bezier(.2,.7,.2,1), background .3s; }
.meter.warn i { background: #f59e0b; } .meter.over i { background: #ef4444; }
.advice { margin-top: 12px; font-size: .88rem; color: var(--fg-soft); padding: 12px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); }
#governance .tool-grid { grid-template-columns: 1.6fr 1fr; }
.ops { width: 100%; border-collapse: collapse; font-size: .86rem; }
.ops th { text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 8px 8px 0; font-weight: 700; }
.ops td { padding: 7px 6px 7px 0; border-top: 1px solid var(--border); vertical-align: middle; }
.ops td.u { font: .78rem var(--mono); color: var(--teal); white-space: nowrap; }
.ops td.name { font-weight: 500; }
.ops td.name small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.ops input[type="number"] { width: 64px; font: 500 .9rem var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.ops select { font: 500 .8rem var(--font); color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px; max-width: 150px; }
.ops-wrap { overflow-x: auto; }
.imap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; }
.imap-fig { margin: 0; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.imap svg { width: 100%; height: auto; display: block; font-family: var(--font); }
.imap .node { cursor: pointer; }
.imap .node rect { fill: var(--card); stroke: var(--border); stroke-width: 1.5; transition: stroke .2s, fill .2s; }
.imap .node text { fill: var(--fg); font-size: 12px; font-weight: 600; text-anchor: middle; pointer-events: none; }
.imap .node .sub { fill: var(--muted); font-size: 9.5px; font-weight: 500; }
.imap .node:hover rect, .imap .node.on rect { stroke: var(--accent); fill: var(--accent-soft); }
.imap .node:focus { outline: none; } .imap .node:focus-visible rect { stroke: var(--accent); stroke-width: 2.5; }
.imap .hub rect { fill: var(--accent); stroke: var(--accent); }
.imap .hub text { fill: #fff; font-size: 14px; font-weight: 800; }
.imap .hub .sub { fill: rgba(255,255,255,.8); font-weight: 500; }
:root[data-theme="dark"] .imap .hub text { fill: #0b1220; } :root[data-theme="dark"] .imap .hub .sub { fill: rgba(11,18,32,.75); }
.imap .link { stroke: var(--border); stroke-width: 1.5; fill: none; transition: stroke .2s, stroke-width .2s; }
.imap .link.on { stroke: var(--teal); stroke-width: 2.5; stroke-dasharray: 6 4; animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -20; } }
.imap-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; min-height: 300px; }
.imap-panel h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 2px; }
.imap-panel .kind { font: .72rem var(--mono); color: var(--teal); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
.imap-panel dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0 0 14px; font-size: .9rem; }
.imap-panel dt { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding-top: 3px; }
.imap-panel dd { margin: 0; color: var(--fg-soft); }
.imap-panel p { color: var(--muted); font-size: .92rem; }
.imap-panel .tags { margin-top: 12px; }
@media (max-width: 860px) { .tool-grid, #governance .tool-grid, .imap { grid-template-columns: 1fr; } .result { position: static; } .tool { padding: 20px; } .imap svg { min-width: 560px; } .imap-fig { overflow-x: auto; } }
@media (prefers-reduced-motion: reduce) { .imap .link.on { animation: none; } .meter i { transition: none; } }

/* ---------- Article: reading time + table of contents ---------- */
.article-wrap { display: grid; grid-template-columns: minmax(0, 760px) 220px; justify-content: center; gap: 56px; align-items: start; }
.article-wrap .article { max-width: none; min-width: 0; }
.toc { position: sticky; top: 100px; font-size: .86rem; }
.toc h4 { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc ol { display: grid; gap: 2px; border-left: 2px solid var(--border); }
.toc a { display: block; padding: 5px 12px; color: var(--muted); margin-left: -2px; border-left: 2px solid transparent; transition: color .2s, border-color .2s; line-height: 1.4; }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-prog { margin-top: 16px; font: .74rem var(--mono); color: var(--teal); }
.toc-bar { height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 6px; }
.toc-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
@media (max-width: 1024px) { .article-wrap { grid-template-columns: minmax(0, 760px); } .toc { display: none; } }

/* ---------- Now page ---------- */
.now-grid { display: grid; gap: 18px; max-width: 760px; }
.now-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px 26px; }
.now-card h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.now-card h2 .p-icon { width: 34px; height: 34px; border-radius: 9px; font-size: .68rem; }
.now-card ul { padding-left: 20px; list-style: disc; }
.now-card li { margin-bottom: 8px; color: var(--fg-soft); }
.now-card li::marker { color: var(--accent); }
.now-updated { font: .78rem var(--mono); color: var(--teal); margin: -12px 0 22px; }

/* ---------- Print additions ---------- */
@media print { .search-btn, .palette, .filter, .gh-heat, .toc, .tool-nav { display: none !important; } }
