:root {
  --desk: #23211e;
  --paper: #f4efe4;
  --dot: rgba(45, 55, 65, 0.22);
  --ink: #1d2126;
  --ink-soft: #4a5159;
  --stamp-red: #b5382a;
  --stamp-blue: #26547c;
  --note-blue: #19324d;
  --note-red: #7d2218;
  --tape: rgba(232, 220, 184, 0.85);
  --blueprint: #1d4e89;
  --c-1: #e6c86e;
  --c-2: #9bc4cb;
  --c-3: #e8998d;
  --c-4: #b5d99c;
  --c-5: #f2b880;
  --c-6: #cbb2fe;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
}
/* Okabe-Ito colorblind-safe palette */
body.cb {
  --c-1: #e69f00;
  --c-2: #56b4e9;
  --c-3: #f0e442;
  --c-4: #2fbf9a;
  --c-5: #cc79a7;
  --c-6: #e07b39;
  --stamp-red: #b35900;
  --stamp-blue: #0072b2;
  --note-red: #8a4500;
  --note-blue: #004f7c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--desk);
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  padding: 84px 16px 48px;
  overflow-x: hidden;
}
a { color: var(--stamp-blue); }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid #e6c86e; outline-offset: 2px; }
img { max-width: 100%; display: block; }
.dots { background-color: var(--paper); background-image: radial-gradient(var(--dot) 1.15px, transparent 1.15px); background-size: 18px 18px; }

/* ---------- hamburger + drawer ---------- */
.fab {
  position: fixed; top: 14px; left: 14px; z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 0 6px 16px rgba(0,0,0,0.45); cursor: pointer;
  display: grid; place-items: center;
}
.fab svg { width: 24px; height: 24px; }
.resume-pill {
  position: fixed; top: 24px; left: 80px; z-index: 50;
  min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center;
  background: #33302b; color: #e8e2d5; border: 1px solid #524d44; border-radius: 18px;
  font: 600 12px var(--mono); letter-spacing: .04em; text-decoration: none;
}
.resume-pill:hover { background: #46413a; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 70; width: min(320px, 86vw);
  background: var(--paper); box-shadow: 8px 0 30px rgba(0,0,0,0.4);
  transform: translateX(-105%); transition: transform .25s ease;
  display: flex; flex-direction: column; padding: 20px 0 16px; overflow-y: auto;
}
body.menu-open .drawer { transform: none; }
body.menu-open .scrim { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 0 20px 14px; }
.drawer-head strong { font-size: 22px; }
.drawer-x { background: none; border: 0; font-size: 26px; width: 44px; height: 44px; cursor: pointer; color: var(--ink); }
.drawer-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 20px;
  background: none; border: 0; text-align: left; font: 500 16px var(--sans); color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.drawer-row:hover, .drawer-row.on { background: rgba(38,84,124,0.09); }
.drawer-row .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); flex: none; }
.drawer-row svg { width: 18px; height: 18px; flex: none; }
.drawer-sec { border-bottom: 1px dashed rgba(29,33,38,.2); }
.drawer-sec[open] { padding-bottom: 8px; }
.drawer-sec-head { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 20px; font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; cursor: pointer; list-style: none; }
.drawer-sec-head::-webkit-details-marker { display: none; }
.drawer-sec-head:hover { background: rgba(0,0,0,.05); }
.drawer-sec-head .count { margin-left: auto; font-weight: 400; color: var(--ink-soft); }
.drawer-sec-head .chev { font-size: 20px; line-height: 1; transition: transform .15s; }
.drawer-sec[open] .chev { transform: rotate(90deg); }
.drawer-sec-head .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sec); border: 1px solid rgba(0,0,0,.35); }
.drawer-sec-head svg { width: 16px; height: 16px; }
.drawer-row.proj { min-height: 40px; padding-left: 44px; font-size: 15px; gap: 10px; border-left: 4px solid transparent; }
.drawer-row.proj .num { display: inline; min-width: 34px; }
.drawer-row.proj.on { border-left-color: var(--sec); background: rgba(0,0,0,.06); font-weight: 700; }
.drawer hr { border: 0; border-top: 1px dashed rgba(29,33,38,.3); margin: 12px 20px; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 20px; font-size: 15px; cursor: pointer; }
.switch input { width: 40px; height: 22px; accent-color: var(--stamp-blue); cursor: pointer; }

/* ---------- book ---------- */
.book-wrapper { position: relative; max-width: 1240px; margin: 0 auto; display: flex; align-items: stretch; }
.sketchbook {
  position: relative; width: 100%; min-height: 680px;
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  border-radius: 6px 10px 10px 6px; cursor: pointer;
  box-shadow: 0 25px 60px rgba(0,0,0,0.65), 0 0 0 6px #181614, inset 0 0 40px rgba(130,110,80,0.14);
  overflow: hidden;
}
.sketchbook::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 44px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent 0%, rgba(30,25,18,.08) 32%, rgba(20,16,10,.24) 50%, rgba(30,25,18,.08) 68%, transparent 100%);
  pointer-events: none; z-index: 5;
}
.page { position: relative; padding: 36px 48px 60px 42px; display: flex; flex-direction: column; gap: 16px; }
.page-right { padding: 36px 42px 60px 48px; }
.flipping .page { animation: pulse .28s ease; }
@keyframes pulse { from { opacity: .35; transform: scale(.992); } to { opacity: 1; transform: none; } }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 1.5px dashed rgba(29,33,38,.25); padding-bottom: 12px; }
.folio-num { font: 11px var(--mono); letter-spacing: .04em; color: var(--ink-soft); }
h1 { font-size: 30px; line-height: 1.12; letter-spacing: -0.02em; margin-top: 6px; }
.hook { font-size: 17px; line-height: 1.55; }
.cliff { font-family: var(--hand); font-size: 22px; color: var(--note-blue); }
.page-footer {
  position: absolute; left: 42px; right: 48px; bottom: 18px;
  display: flex; justify-content: space-between; gap: 12px;
  font: 11px var(--mono); color: var(--ink-soft); border-top: 1px solid rgba(0,0,0,.1); padding-top: 8px;
}
.page-right .page-footer { left: 48px; right: 42px; }
.turn { background: none; border: 0; font: 600 11px var(--mono); color: var(--ink-soft); cursor: pointer; min-height: 28px; padding: 0 4px; }
.turn:hover { color: var(--ink); text-decoration: underline; }

.stamp {
  display: inline-block; flex: none; font: 700 11px var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 9px; border: 2px solid var(--stamp-red); color: var(--stamp-red); border-radius: 3px;
  transform: rotate(-2deg); opacity: .9; user-select: none;
}
.stamp.blue { border-color: var(--stamp-blue); color: var(--stamp-blue); transform: rotate(1.5deg); }

.taped-box {
  position: relative; background: #fffdf8; border: 1px solid rgba(0,0,0,.16);
  padding: 16px 16px 12px; box-shadow: 2px 4px 10px rgba(0,0,0,.08); transform: rotate(-1deg);
}
.taped-box::before, .taped-box::after {
  content: ""; position: absolute; width: 58px; height: 18px; top: -9px;
  background: var(--tape); box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.taped-box::before { left: 14px; transform: rotate(-14deg); }
.taped-box::after { right: 14px; transform: rotate(12deg); }
.teasers { list-style: none; display: grid; gap: 10px; font-size: 15px; line-height: 1.45; }

.margin-note {
  font-family: var(--hand); font-size: 20px; line-height: 1.3; color: var(--note-blue);
  background: rgba(255,252,235,.7); border-left: 3px solid var(--stamp-blue); border-radius: 0;
  padding: 8px 12px; transform: rotate(-.8deg);
}
.margin-note.red { color: var(--note-red); border-left-color: var(--stamp-red); transform: rotate(.9deg); }
.scribble-strike { text-decoration: line-through; text-decoration-color: var(--stamp-red); text-decoration-thickness: 2px; opacity: .7; }

/* polaroid + blueprint treatment */
.polaroid { position: relative; background: #fff; padding: 12px 12px 38px; box-shadow: 3px 6px 14px rgba(0,0,0,.18); transform: rotate(1.2deg); margin-top: 10px; }
.polaroid::before { content: ""; position: absolute; top: -10px; left: 50%; width: 90px; height: 20px; transform: translateX(-50%) rotate(-3deg); background: var(--tape); z-index: 2; }
.polaroid figcaption { position: absolute; left: 12px; right: 12px; bottom: 9px; font-family: var(--hand); font-size: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blueprint { position: relative; background: var(--blueprint); aspect-ratio: 4 / 3; overflow: hidden; }
.blueprint img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.15) brightness(1.05); mix-blend-mode: screen; opacity: .9; }
.blueprint::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px);
  background-size: 24px 24px;
}
.blueprint.empty { display: grid; place-items: center; padding: 24px 24px 64px; text-align: center; }
.bp-title { position: relative; z-index: 1; color: #fff; font: 700 clamp(18px, 2.2vw, 30px)/1.15 var(--mono); text-transform: uppercase; letter-spacing: .04em; border: 2px solid rgba(255,255,255,.85); padding: 12px 16px; }
.titleblock {
  position: absolute; right: 8px; bottom: 8px; z-index: 2; max-width: 70%;
  border: 1px solid rgba(255,255,255,.85); color: #fff; background: rgba(13,40,74,.8);
  font: 10px/1.35 var(--mono); text-transform: uppercase; letter-spacing: .04em;
  display: grid; grid-template-columns: 1fr auto;
}
.titleblock span { padding: 3px 6px; }
.titleblock span:first-child { grid-column: 1 / -1; border-bottom: 1px solid rgba(255,255,255,.6); font-weight: 600; }
.titleblock span + span + span { border-left: 1px solid rgba(255,255,255,.6); }
.page-links { display: flex; flex-wrap: wrap; gap: 8px; }
.page-links:empty { display: none; }
.video-btn { align-self: flex-start; font: 600 12px var(--mono); min-height: 40px; padding: 0 14px; border: 2px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }

.tab-btn.active { outline: 2px solid var(--ink); outline-offset: -2px; }

/* top section tabs */
.sec-tabs { max-width: 1240px; margin: 0 auto; padding-left: 20px; display: flex; gap: 6px; flex-wrap: wrap; position: relative; z-index: 6; }
.sec-tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  background: var(--sec); color: var(--ink); border: 1px solid rgba(0,0,0,.3); border-bottom: 0;
  border-radius: 8px 8px 0 0; font: 700 13px var(--mono); cursor: pointer;
  transform: translateY(8px); filter: saturate(.7) brightness(.85); transition: transform .15s, filter .15s;
}
.sec-tab svg { width: 16px; height: 16px; }
.sec-tab:hover { transform: translateY(4px); filter: none; }
.sec-tab.active { transform: translateY(2px); filter: none; box-shadow: 0 -2px 0 var(--ink) inset; }

/* side tabs: projects in the current section */
.proj-tabs { display: flex; flex-direction: column; gap: 6px; width: 190px; flex: none; margin-left: -4px; padding-top: 24px; z-index: 6; }
.tab-btn {
  display: block; text-align: left; min-height: 44px; padding: 8px 12px;
  background: var(--paper); color: var(--ink); border: 1px solid rgba(0,0,0,.25); border-left: 6px solid var(--sec);
  border-radius: 0 6px 6px 0; font: 500 13px/1.25 var(--sans); cursor: pointer;
  box-shadow: 3px 3px 6px rgba(0,0,0,.3); transition: transform .15s;
}
.tab-btn .num, .drawer .num { display: block; font: 600 11px var(--mono); color: var(--ink-soft); }
.tab-btn:hover { transform: translateX(4px); }
.tab-btn.active { background: var(--sec); transform: translateX(8px); font-weight: 700; }

/* ---------- write-up below the book ---------- */
.writeup {
  max-width: 1240px; margin: 40px auto 0; padding: 48px clamp(20px, 5vw, 72px) 40px;
  background-color: var(--paper); background-image: radial-gradient(var(--dot) 1.15px, transparent 1.15px); background-size: 18px 18px;
  border-radius: 6px; box-shadow: 0 18px 40px rgba(0,0,0,.5); font-size: 17px; line-height: 1.65;
}
.writeup > * { max-width: 880px; }
.w-meta { font: 13px var(--mono); color: var(--ink-soft); margin-top: 8px; }
.writeup h2 { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.12; letter-spacing: -.02em; }
.memo { margin-top: 36px; display: flow-root; }
.memo h3 { font: 700 13px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--stamp-red); border-bottom: 1.5px dashed rgba(29,33,38,.25); padding-bottom: 6px; margin-bottom: 14px; }
.memo p + p { margin-top: 12px; }
.memo.cont { margin-top: 12px; }
.memo ul { margin: 12px 0 0 22px; }
.memo li { margin-bottom: 6px; }
.parts { font: 13px/1.5 var(--mono); color: var(--ink-soft); margin-top: 12px; }
.memo .margin-note, .memo .strike, .equation { display: flow-root; } /* sit beside a floated photo, not under it */
.memo .margin-note, .memo .strike { margin: 18px 0; max-width: 560px; }
.inline-fig { float: right; width: min(42%, 380px); margin: 4px 0 16px 28px; background: #fff; padding: 8px; border: 1px solid rgba(0,0,0,.14); }
.inline-fig figcaption, .gallery figcaption { font: 12px/1.4 var(--mono); color: var(--ink-soft); padding-top: 6px; }
.equation { font-family: var(--hand); font-size: 26px; line-height: 1.6; color: var(--note-blue); margin: 18px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--stamp-blue); }
.equation .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 22px; line-height: 1.2; border-top: 2px solid currentColor; }
.equation .frac > span:first-child { order: -1; border-bottom: 2px solid currentColor; margin-top: -2px; padding: 0 6px 2px; }
.equation .rad { font-size: 34px; vertical-align: middle; }
.video { aspect-ratio: 16 / 9; margin-top: 36px; background: #000; }
.video iframe { width: 100%; height: 100%; border: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; max-width: none; }
.gallery figure { background: #fff; padding: 8px; border: 1px solid rgba(0,0,0,.14); }
.gallery img { width: 100%; height: 200px; object-fit: contain; }
.related { margin-top: 32px; }
.prevnext { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 40px; max-width: none; border-top: 1px solid rgba(0,0,0,.12); padding-top: 20px; }
.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); background: transparent; color: var(--ink); font: 600 13px var(--mono); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--ink); color: var(--paper); }
.back { margin-bottom: 18px; }

/* ---------- contact ---------- */
.sheet { margin-top: 0; }
.sheet h1 { font-size: clamp(34px, 5vw, 52px); }
.bio p { margin-top: 14px; }
.toolbox { margin: 40px 0 28px; max-width: 760px; }
.tool-group { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dotted rgba(0,0,0,.2); font-size: 15px; }
.tool-group:last-child { border-bottom: 0; }
.tool-group b { display: flex; gap: 8px; align-items: center; font: 700 12px var(--mono); text-transform: uppercase; }
.tool-group .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--sec); border: 1px solid rgba(0,0,0,.35); flex: none; }
.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 28px; }
.link-card { background: #fffdf8; border: 1px solid rgba(0,0,0,.16); padding: 14px 16px; }
.link-card small { display: block; font: 12px var(--mono); color: var(--ink-soft); }

/* ---------- phone ---------- */
.cards { display: none; }
@media (max-width: 900px) {
  body { padding-top: 84px; }
  body[data-view="item"] .sec-tabs { display: none; }
  .sec-tabs { padding-left: 0; margin-bottom: 16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sec-tab { flex: none; }
  .sec-tab { transform: none; border-radius: 6px; border-bottom: 1px solid rgba(0,0,0,.3); filter: none; font-size: 12px; padding: 0 12px; }
  .book-wrapper { display: none; }
  body[data-view="list"] .writeup { display: none; }
  body[data-view="list"] .cards { display: block; }
  .cards h2 { display: flex; align-items: center; gap: 10px; color: #e8e2d5; font: 700 13px var(--mono); letter-spacing: .08em; text-transform: uppercase; margin: 28px 0 12px; }
  .cards h2:first-child { margin-top: 0; }
  .cards h2 .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sec); }
  .card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; padding: 12px; margin-bottom: 12px; text-decoration: none; color: var(--ink); border-left: 6px solid var(--sec); }
  .card .blueprint { aspect-ratio: 1; }
  .card .titleblock { display: none; }
  .card .blueprint.empty { font-size: 0; }
  .card .bp-title { display: none; }
  .card strong { display: block; font-size: 17px; line-height: 1.2; }
  .card span { display: block; font-size: 14px; line-height: 1.4; margin-top: 4px; color: var(--ink-soft); }
  .writeup { margin-top: 0; padding: 28px 18px; font-size: 16px; }
  .inline-fig { float: none; width: 100%; margin: 12px 0; }
  .tool-group { grid-template-columns: 1fr; gap: 4px; }
  .w-glance { margin-top: 20px; }
}
@media (min-width: 901px) { .w-glance, .back { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .flipping .page { animation: none; }
  .drawer, .scrim, .tab-btn, .sec-tab { transition: none; }
}
