/* ───────────── Tokens ───────────── */
:root {
  --bg: #f4efe6;
  --bg-2: #ede6da;
  --surface: #fbf8f2;
  --surface-2: #f6f1e8;
  --ink: #2a2520;
  --ink-2: #4a423a;
  --muted: #857a6d;
  --line: #e2d9cb;
  --line-2: #d4c8b6;
  --accent: #a65f43;      /* terracotta */
  --accent-ink: #fbf6ef;
  --accent-soft: #ead6c8;
  --sage: #7a876a;
  --sage-soft: #dfe3d4;
  --wood: #c4a37a;
  --shadow: 0 1px 2px rgb(60 45 30 / .05), 0 8px 24px -12px rgb(60 45 30 / .18);
  --shadow-lg: 0 2px 4px rgb(60 45 30 / .05), 0 24px 48px -20px rgb(60 45 30 / .28);
  --grain-opacity: .35;

  --serif: "Shippori Mincho", "Iowan Old Style", Georgia, serif;
  --sans: "Zen Kaku Gothic New", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --max: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181614; --bg-2: #1e1b18; --surface: #221f1b; --surface-2: #2a2621;
    --ink: #ece4d7; --ink-2: #cfc5b6; --muted: #9b9081; --line: #34302a; --line-2: #443e36;
    --accent: #d38d6d; --accent-ink: #1b1714; --accent-soft: #3d2b22;
    --sage: #a3b190; --sage-soft: #2b3026; --wood: #b0916b;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 28px 56px -22px rgb(0 0 0 / .75);
    --grain-opacity: .18;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181614; --bg-2: #1e1b18; --surface: #221f1b; --surface-2: #2a2621;
  --ink: #ece4d7; --ink-2: #cfc5b6; --muted: #9b9081; --line: #34302a; --line-2: #443e36;
  --accent: #d38d6d; --accent-ink: #1b1714; --accent-soft: #3d2b22;
  --sage: #a3b190; --sage-soft: #2b3026; --wood: #b0916b;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 28px 56px -22px rgb(0 0 0 / .75);
  --grain-opacity: .18;
  color-scheme: dark;
}

/* ───────────── Base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16.5px/1.75 var(--sans);
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  transition: background-color .6s var(--ease-soft), color .6s var(--ease-soft);
  overflow-x: hidden;
}
/* Washi-paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .3 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, header, footer { position: relative; z-index: 1; }
::selection { background: var(--accent-soft); color: var(--ink); }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
/* Sections focused after an in-page link glide: no outline box around the whole section. */
[tabindex="-1"]:focus { outline: none; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.25; margin: 0; letter-spacing: .01em; }
.wrap { width: min(var(--max), 100% - 32px); margin-inline: auto; }
@media (min-width: 720px) { .wrap { width: min(var(--max), 100% - 64px); } }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ───────────── Header ───────────── */
.site-header {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .4s, background-color .6s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.nav { display: flex; align-items: center; gap: 16px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.12rem; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; color: var(--accent); transition: transform .8s var(--ease); }
.brand:hover svg { transform: rotate(-35deg); }
.nav-links { display: flex; gap: 4px; margin-left: auto; list-style: none; padding: 0; margin-block: 0; }
.nav-links a {
  position: relative; display: block; padding: 6px 12px; font-size: .92rem; color: var(--ink-2);
  border-radius: 999px; transition: color .3s;
}
.nav-links a::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform .45s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); transform-origin: left; }
.nav-tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  transition: transform .35s var(--ease), border-color .3s, background-color .6s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--line-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme toggle: sun ↔ moon */
.theme-toggle .sun-core { transition: r .5s var(--ease), cx .5s var(--ease); }
.theme-toggle .rays { transition: opacity .4s, transform .6s var(--ease); transform-origin: 12px 12px; }
.theme-toggle .moon-mask circle { transition: cx .6s var(--ease), cy .6s var(--ease); }
[data-theme-active="dark"] .theme-toggle .rays { opacity: 0; transform: rotate(-60deg) scale(.6); }
[data-theme-active="dark"] .theme-toggle .moon-mask circle { cx: 17; cy: 7; }
[data-theme-active="dark"] .theme-toggle .sun-core { r: 8; }

.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: grid; }
  .nav-links {
    position: fixed; inset: 68px 0 auto 0; flex-direction: column; gap: 0; padding: 8px 16px 20px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity .35s var(--ease), transform .45s var(--ease);
  }
  .nav-links.open { opacity: 1; transform: none; pointer-events: auto; }
  .nav-links a { padding: 12px 4px; font-size: 1.05rem; border-radius: 0; border-bottom: 1px solid var(--line); }
  .nav-links a::after { display: none; }
  .nav-tools { margin-left: auto; }
}

.admin-pill {
  display: none; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--sage-soft); color: var(--sage); font-size: .8rem; font-weight: 500; white-space: nowrap;
}
.admin-pill svg { width: 14px; height: 14px; }
.is-admin .admin-pill { display: inline-flex; }

/* ───────────── Hero ───────────── */
.hero { position: relative; padding: clamp(64px, 12vw, 140px) 0 clamp(56px, 9vw, 110px); }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; font-size: .78rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: currentColor; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 5rem); margin: 18px 0 18px; line-height: 1.08; }
.hero h1 .accent { color: var(--accent); font-style: normal; }
.hero p.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--ink-2); max-width: 42ch; margin: 0 0 32px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-art { position: relative; justify-self: center; width: 100%; max-width: 340px; aspect-ratio: 1; }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; gap: 28px; } .hero-art { order: -1; max-width: 150px; justify-self: start; } .vertical-word { right: -34px; } }
.enso { width: 100%; height: 100%; color: var(--ink); overflow: visible; }
.enso path, .enso circle:not(.dot) {
  fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: draw 2.4s .35s var(--ease) forwards;
}
.enso .gear-hub { animation-delay: 1.5s; animation-duration: 1.2s; }
.enso .gear-spokes { opacity: .7; animation-delay: 2s; animation-duration: 1s; }
.enso .gear-spin { transform-origin: 100px 100px; animation: gearTurn 90s 2.8s linear infinite; }
.enso .dot { fill: var(--accent); opacity: 0; transform-box: fill-box; transform-origin: center; animation: pop .9s 2.2s var(--ease) forwards; }
@keyframes gearTurn { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
.vertical-word {
  position: absolute; right: -6px; top: 8%; writing-mode: vertical-rl; font-family: var(--serif);
  font-size: .95rem; letter-spacing: .5em; color: var(--muted); opacity: 0; animation: fadeIn 1.4s 1.6s forwards;
}
@keyframes fadeIn { to { opacity: .75; } }

.btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 22px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer;
  font-size: .95rem; overflow: hidden; isolation: isolate;
  transition: transform .35s var(--ease), border-color .3s, color .3s, box-shadow .35s;
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--ink);
  transform: translateY(101%); transition: transform .5s var(--ease);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--ink); color: var(--bg); }
.btn:hover::before { transform: none; }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary::before { background: var(--ink); }
.btn svg { width: 16px; height: 16px; transition: transform .4s var(--ease); }
.btn:hover svg { transform: translateX(3px); }
.btn.small { height: 36px; padding: 0 14px; font-size: .86rem; }
.btn.ghost { background: transparent; }

/* ───────────── Sections ───────────── */
section.block { padding: clamp(56px, 9vw, 110px) 0; scroll-margin-top: 76px; }
/* Section pages (/projects, /about...) show one section; home shows them all. */
.off-view { display: none !important; }

/* Games */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.game-card { display: block; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface); color: inherit; text-decoration: none; transition: transform .5s var(--ease), box-shadow .5s var(--ease), border-color .5s var(--ease); }
.game-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: 0 18px 40px -24px rgba(42, 37, 32, .35); }
.game-art { aspect-ratio: 16 / 9; display: grid; place-items: stretch; }
.game-art svg { width: 100%; height: 100%; display: block; }
.game-art.courier { background: linear-gradient(#121726, #241f36); }
.game-art.sumo { background: var(--bg-2); }
.game-art.zen { background: #ece2cf; }
.game-art.pup { background: linear-gradient(#f3e6d1, #f7efe2); }
.game-card .card-body { padding: 20px 22px 22px; }
.game-card h3 { margin: 0 0 6px; }
.game-card p { margin: 0 0 14px; color: var(--ink-2); }
.game-play { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: .95rem; }
.game-play span { width: 16px; display: inline-flex; }
.game-stage { display: grid; gap: 16px; }
.game-stage[hidden] { display: none; }
.games-grid[hidden] { display: none; }
.game-back { justify-self: start; }
.game-back span { width: 16px; display: inline-flex; }
.game-title { margin: 4px 0 0; font-size: 1.6rem; }
.game-host { width: min(100%, calc((100vh - 280px) * 1.6)); min-width: min(100%, 560px); margin: 0 auto; position: relative; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); }
.game-canvas { display: block; width: 100%; height: auto; outline: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.game-canvas:focus, .game-canvas:focus-visible { outline: none; }
#games.playing .section-head { display: none; }
body:not([data-view="home"]) main > section#games.playing { padding-top: 24px; }
.game-loading { aspect-ratio: 16 / 10; display: grid; place-items: center; color: var(--muted); }
.game-about { max-width: 68ch; margin: 0; }
body:not([data-view="home"]) main > section.block:not(.off-view) { min-height: 70vh; padding-top: clamp(40px, 7vw, 80px); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 40px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.section-head .num { font-family: var(--serif); color: var(--accent); font-size: .95rem; letter-spacing: .1em; display: block; margin-bottom: 6px; }
.section-head p { margin: 6px 0 0; color: var(--muted); max-width: 46ch; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--line-2), transparent); border: 0; margin: 0; }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
body:not([data-view="home"]) .view-more { display: none; }
.add-btn { display: none; }
.is-admin .add-btn { display: inline-flex; }

/* About */
.about-grid { display: grid; grid-template-columns: 280px 1fr; gap: clamp(32px, 6vw, 80px); align-items: start; }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }
.portrait {
  aspect-ratio: 4/5; border-radius: 160px 160px var(--radius) var(--radius); overflow: hidden;
  background: linear-gradient(160deg, var(--accent-soft), var(--sage-soft)); box-shadow: var(--shadow);
  display: grid; place-items: center; font-family: var(--serif); font-size: 4rem; color: var(--accent);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.about-meta { margin-top: 20px; display: grid; gap: 10px; font-size: .92rem; }
.about-meta a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); transition: color .3s, transform .3s var(--ease); }
.about-meta a:hover { color: var(--accent); transform: translateX(3px); }
.prose { font-size: 1.06rem; color: var(--ink-2); max-width: 64ch; }
.prose p { margin: 0 0 1.1em; }
.prose h2, .prose h3 { color: var(--ink); margin: 1.6em 0 .6em; font-size: 1.35rem; }
.prose h3 { font-size: 1.15rem; }
.prose a { color: var(--accent); background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; transition: background-size .4s var(--ease); }
.prose a:hover { background-size: 0 1px; background-position: 100% 100%; }
.prose code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose blockquote { margin: 1.2em 0; padding-left: 18px; border-left: 2px solid var(--wood); color: var(--muted); font-family: var(--serif); }
.prose img { border-radius: var(--radius-sm); margin: 1.2em 0; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li::marker { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding: 0; list-style: none; }
.chip {
  font-size: .8rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2);
  background: var(--surface); transition: background-color .3s, border-color .3s, transform .3s var(--ease);
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip.small { font-size: .72rem; padding: 2px 10px; }

/* Cards */
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.grid.featured { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); margin-bottom: 22px; }
.card {
  position: relative; display: flex; flex-direction: column; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  transition: transform .55s var(--ease), box-shadow .55s var(--ease), border-color .4s, background-color .6s;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.card:active { transform: translateY(-2px) scale(.995); }
.card-media { position: relative; aspect-ratio: 16/10; overflow: hidden; background: var(--bg-2); }
.featured .card-media { aspect-ratio: 16/9; }
.card-media img, .card-media .ph { width: 100%; height: 100%; object-fit: cover; transition: transform 1.1s var(--ease), filter .6s; }
.card:hover .card-media img, .card:hover .card-media .ph { transform: scale(1.045); }
.ph {
  display: grid; place-items: center; font-family: var(--serif); font-size: 2.6rem; color: color-mix(in oklab, var(--ink) 45%, transparent);
  background:
    radial-gradient(120% 90% at 85% 10%, color-mix(in oklab, var(--ph, var(--accent-soft)) 70%, transparent), transparent 60%),
    radial-gradient(90% 90% at 10% 100%, var(--sage-soft), transparent 70%),
    var(--surface-2);
}
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; color: var(--muted); letter-spacing: .06em; }
.card h3 { font-size: 1.28rem; }
.featured .card h3 { font-size: 1.5rem; }
.card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.card .chips { margin-top: auto; padding-top: 10px; }
.card .arrow { width: 18px; height: 18px; color: var(--accent); transition: transform .5s var(--ease); }
.card:hover .arrow { transform: translate(3px, -3px); }

.badge-private {
  display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); letter-spacing: .04em;
}
.badge-private svg { width: 11px; height: 11px; }
.card.private { border-style: dashed; }
.edit-fab {
  display: none; position: absolute; top: 12px; right: 12px; z-index: 2; height: 30px; padding: 0 12px; border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 88%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line);
  font-size: .76rem; align-items: center; gap: 5px; opacity: 0; transform: translateY(-4px);
  transition: opacity .3s, transform .4s var(--ease);
}
.is-admin .edit-fab { display: inline-flex; }
.card:hover .edit-fab, .photo:hover .edit-fab, .edit-fab:focus-visible { opacity: 1; transform: none; }

/* Writing list */
.list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.list-item {
  display: grid; grid-template-columns: 90px 1fr auto; gap: 20px; align-items: baseline; padding: 22px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; position: relative;
  transition: padding .5s var(--ease), background-color .4s;
}
.list-item:hover { padding-left: 16px; background: color-mix(in oklab, var(--surface) 60%, transparent); }
.list-item .year { color: var(--muted); font-size: .85rem; }
.list-item h3 { font-size: 1.2rem; }
.list-item p { margin: 4px 0 0; color: var(--muted); font-size: .93rem; }
.list-item .arrow { width: 18px; color: var(--accent); opacity: 0; transform: translateX(-6px); transition: .45s var(--ease); }
.list-item:hover .arrow { opacity: 1; transform: none; }
@media (max-width: 600px) { .list-item { grid-template-columns: 1fr auto; } .list-item .year { grid-column: 1 / -1; } }

/* Photos */
.photos { columns: 3 260px; column-gap: 16px; }
.photo {
  position: relative; break-inside: avoid; margin: 0 0 16px; border-radius: var(--radius-sm); overflow: hidden; cursor: zoom-in;
  background: var(--bg-2); display: block; width: 100%; padding: 0; border: 0;
}
.photo img { width: 100%; height: auto; transition: transform 1.2s var(--ease), filter .6s; }
.photo:hover img { transform: scale(1.04); }
.photo figcaption {
  position: absolute; inset: auto 0 0 0; padding: 28px 14px 12px; font-size: .85rem; color: #fbf6ee; text-align: left;
  background: linear-gradient(transparent, rgb(20 16 12 / .6)); opacity: 0; transform: translateY(6px); transition: .45s var(--ease);
}
.photo:hover figcaption { opacity: 1; transform: none; }

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 40px 24px; text-align: center; color: var(--muted);
  font-size: .95rem; background: color-mix(in oklab, var(--surface) 50%, transparent);
}

/* ───────────── Overlay / detail ───────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 0;
  background: rgb(24 20 16 / .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .45s var(--ease);
}
@media (min-width: 720px) { .overlay { place-items: center; padding: 32px; } }
.overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: relative; width: min(820px, 100%); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border: 1px solid var(--line); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(40px) scale(.98); transition: transform .6s var(--ease);
}
@media (min-width: 720px) { .sheet { border-radius: 22px; } }
.overlay.open .sheet { transform: none; }
.sheet-media { aspect-ratio: 16/8; overflow: hidden; background: var(--bg-2); }
.sheet-media img, .sheet-media .ph { width: 100%; height: 100%; object-fit: cover; }
.sheet-body { padding: clamp(24px, 5vw, 48px); }
.sheet-body h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 10px 0 12px; }
.sheet-body .lede { font-size: 1.1rem; color: var(--ink-2); margin: 0 0 24px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 28px; }
.sheet-close { position: sticky; top: 14px; float: right; margin: 14px 14px -54px 0; z-index: 2; }

.lightbox { place-items: center; padding: 16px; background: rgb(14 12 10 / .85); }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; transform: scale(.96); transition: transform .6s var(--ease); }
.lightbox.open figure { transform: none; }
.lightbox img { max-height: 84vh; max-width: 100%; border-radius: 10px; margin: auto; }
.lightbox figcaption { color: #e9e1d4; text-align: center; margin-top: 12px; font-size: .92rem; }
.lightbox .icon-btn { position: absolute; top: 16px; right: 16px; background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .15); color: #fff; }

/* ───────────── Footer ───────────── */
.site-footer { padding: 56px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-row a:hover { color: var(--accent); }
.key-link { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; opacity: .55; transition: opacity .3s, transform .5s var(--ease); }
.key-link:hover { opacity: 1; transform: rotate(-20deg); }
.key-link svg { width: 15px; height: 15px; }

/* ───────────── Motion ───────────── */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 1s var(--ease), transform 1.1s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
.load-in { opacity: 0; transform: translateY(16px); animation: rise 1.1s var(--ease) forwards; animation-delay: var(--d, 0s); }
@keyframes rise { to { opacity: 1; transform: none; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow-lg);
  transition: opacity .35s, transform .5s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .reveal, .load-in { opacity: 1; transform: none; }
  .enso path, .enso circle { stroke-dashoffset: 0; }
  .enso .gear-spin { animation: none; }
  .enso .dot { opacity: 1; }
  html { scroll-behavior: auto; }
}

/* Spaceship mode entry points (the cockpit itself lives in css/ship.css) */
html.ship-open, html.ship-open body { overflow: hidden; }
.ship-root[hidden] { display: none; }
.ship-btn span, .ship-return span { width: 16px; display: inline-flex; }
.ship-return {
  position: fixed; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: #1c1a17; color: #ece4d7; border: 1px solid #c8a96a; font-size: .9rem; text-decoration: none;
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, .5); transition: transform .3s var(--ease);
}
.ship-return:hover { transform: translateY(-2px); }
.ship-return[hidden] { display: none; }
