/* ============================================================
   Tokens
   ============================================================ */
:root {
  --paper: #ffffff;
  --ink: #0b0b0a;
  --muted: rgba(11, 11, 10, 0.42);
  --faint: rgba(11, 11, 10, 0.14);
  --line: rgba(11, 11, 10, 0.10);
  --pill: rgba(11, 11, 10, 0.05);

  /* one typeface everywhere; --serif is kept as an alias so the roles
     (interface vs. voice) stay legible in the stylesheet */
  --grotesk: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --serif: var(--grotesk);

  --ui: 11.5px;
  --track: 0.01em;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);

  --edge: 14px;
  color-scheme: light;
}

[data-theme='dark'] {
  --paper: #0b0b0a;
  --ink: #f3f2ee;
  --muted: rgba(243, 242, 238, 0.42);
  --faint: rgba(243, 242, 238, 0.16);
  --line: rgba(243, 242, 238, 0.12);
  --pill: rgba(243, 242, 238, 0.07);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--grotesk);
  font-size: var(--ui);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  transition: background-color 0.6s var(--ease), color 0.6s var(--ease);
}

body.is-loading { cursor: progress; }

.page-title, .page-sub, .lead, .cv-name, .case-title, .idx-title { letter-spacing: -0.025em; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ============================================================
   Grain + cursor
   ============================================================ */
.grain {
  position: fixed; inset: -50%;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.32;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.55'/></svg>");
  mix-blend-mode: multiply;
  animation: grain 900ms steps(3) infinite;
}
[data-theme='dark'] .grain { mix-blend-mode: screen; opacity: 0.14; }
@keyframes grain {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-2%, 1.5%); }
  66%  { transform: translate(1.5%, -1%); }
  100% { transform: translate(0, 0); }
}

.cursor {
  position: fixed; top: 0; left: 0;
  z-index: 9500;
  pointer-events: none;
  transform: translate3d(-100px, -100px, 0);
  will-change: transform;
}
.cursor::before {
  content: '';
  position: absolute; left: -3px; top: -3px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.4s var(--ease), opacity 0.3s;
}
.cursor.is-grab::before { transform: scale(2.4); opacity: 0.25; }
.cursor-label {
  position: absolute; left: 12px; top: -6px;
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
  opacity: 0; transform: translateY(3px);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.cursor.has-label .cursor-label { opacity: 1; transform: none; }
@media (hover: none) { .cursor { display: none; } }

/* ============================================================
   Chrome — mark / nav / toggle
   ============================================================ */
.mark {
  position: fixed; top: var(--edge); left: var(--edge);
  z-index: 8000;
  font-size: 13px; letter-spacing: 0.02em;
  color: #fff;
  mix-blend-mode: exclusion;
  white-space: pre;
}

.nav {
  position: fixed; top: 10px; left: 0;
  z-index: 8000;
  width: 100%;
  display: flex; justify-content: center; align-items: center; gap: 4px;
  pointer-events: none;
}
.nav-link {
  pointer-events: auto;
  position: relative;
  display: flex; align-items: flex-end; gap: 2px;
  padding: 5px 9px 5px 10px;
  border-radius: 3px;
  background: transparent;
  transition: background-color 0.45s var(--ease);
}
.nav-link:hover, .nav-link.is-current { background: var(--pill); }
.nav-swap {
  position: relative;
  overflow: hidden;
  height: 15px;
  display: block;
}
.nav-swap span {
  display: block;
  white-space: nowrap;
  transition: transform 0.55s var(--ease), opacity 0.4s var(--ease);
}
.nav-a { font-size: 12px; letter-spacing: var(--track); }
.nav-b {
  position: absolute; inset: 0;
  font-size: 12px; line-height: 15px; letter-spacing: var(--track);
  color: var(--muted);
  transform: translateY(105%);
}
.nav-link:hover .nav-a { transform: translateY(-115%); opacity: 0; }
.nav-link:hover .nav-b { transform: translateY(1px); }
.nav-link sup {
  font-size: 9px; line-height: 1;
  color: var(--muted);
  transform: translateY(-4px);
}

.toggle {
  position: fixed; top: var(--edge); right: var(--edge);
  z-index: 8000;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 3px;
  transition: background-color 0.4s var(--ease);
}
.toggle:hover { background: var(--pill); }
.toggle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--ink);
  transition: background-color 0.5s var(--ease), transform 0.5s var(--ease);
}
[data-theme='dark'] .toggle-dot { background: transparent; transform: rotate(180deg); }

/* ============================================================
   Views
   ============================================================ */
.view {
  position: fixed; inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s var(--ease), filter 0.7s var(--ease);
  filter: blur(6px);
}
.view.is-active { opacity: 1; visibility: visible; filter: none; }

/* ── 1 · the plane ─────────────────────────────────────────── */
/* the paper has to be painted *inside* this stacking context, otherwise
   the difference-blended split text has nothing to blend against and
   disappears everywhere except on top of a plate */
.view--space { overflow: hidden; touch-action: none; background: var(--paper); }

.plane {
  position: absolute; inset: 0;
  cursor: grab;
}
.plane.is-dragging { cursor: grabbing; }

.tile {
  position: absolute; top: 0; left: 0;
  will-change: transform, opacity;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  opacity: var(--o, 1);          /* depth fade, written per frame */
}
.tile-inner {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  transition: transform 0.6s var(--ease);
}
.tile img, .tile video {
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  background: var(--faint);
}
.plane.is-hovering .tile { opacity: calc(var(--o, 1) * 0.45); }
.plane.is-hovering .tile.is-hot { opacity: 1; }
.tile.is-hot .tile-inner { transform: scale(1.06); }

.split {
  position: absolute; top: 50%; left: 0;
  transform: translateY(-50%);
  width: 100%;
  padding: 0 9%;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
  z-index: 30;
  mix-blend-mode: difference;
  color: #fff;
}
[data-theme='dark'] .split { mix-blend-mode: exclusion; }
.split-l { font-size: 13px; letter-spacing: 0.02em; }
.split-r { font-size: 13px; letter-spacing: 0.02em; display: flex; gap: 0.3em; opacity: 0.6; }
.mask { display: inline-block; overflow: hidden; vertical-align: bottom; flex: none; }
.mask > span { display: inline-block; }

.counter {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
}
.counter span {
  display: block;
  font-size: 13px; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.7s var(--ease), opacity 0.5s;
}
.counter.is-out span { transform: translateY(130%); opacity: 0; }

.hint {
  position: absolute; bottom: 18px; right: var(--edge);
  z-index: 30;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.8s var(--ease);
  pointer-events: none;
}
.hint.is-in { opacity: 1; }
.hint.is-gone { opacity: 0; }

.plate-label {
  position: absolute; bottom: 16px; left: var(--edge);
  z-index: 30;
  display: flex; align-items: flex-start; gap: 3px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.35s, transform 0.45s var(--ease);
}
.plate-label.is-in { opacity: 1; transform: none; }
.plate-label-title { font-size: 13px; line-height: 1; }
.plate-label-idx { font-size: 9px; color: var(--muted); }

/* ── 2/3 · document views ──────────────────────────────────── */
.view--collection, .view--cv { overflow-y: auto; overscroll-behavior: contain; }
.page {
  max-width: 940px;
  margin: 0 auto;
  padding: 16vh 6vw 18vh;
}
.page-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.page-title { font-family: var(--serif); font-size: clamp(28px, 5vw, 52px); font-weight: 400; line-height: 1; }
.page-count { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.page-sub {
  margin: 14vh 0 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif); font-size: clamp(20px, 3vw, 30px); font-weight: 400; line-height: 1;
}

/* ── projects grid: 3 columns, hairlines, no gutters ─────────── */
.grid-head {
  padding: 18vh 6vw 7vh;
  text-align: center;
  font-weight: 400;
  font-size: 13px; letter-spacing: 0.01em;
  line-height: 1.3;
}
.grid-head em { font-style: normal; color: var(--muted); }

/* sub-navigation inside a section (AI → Cinematic / Interactive) */
.tabs {
  display: flex; justify-content: center; gap: 4px;
  padding: 0 6vw 5vh;
  margin-top: -4vh;
}
.tab {
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--muted);
  transition: color 0.4s var(--ease), background-color 0.4s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-current { color: var(--ink); background: var(--pill); }
.tabs--sub { margin-top: -4vh; padding-bottom: 5vh; }
.tabs--sub[hidden] { display: none; }     /* the flex rule must not beat the hidden attribute */
.tabs--sub .tab { font-size: 11px; padding: 4px 8px; }
.card.is-off { display: none; }

.grid {
  --gap: clamp(14px, 1.8vw, 28px);
  display: grid;
  align-items: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--gap) * 1.6) var(--gap);   /* row gap a little larger than column gap */
  padding: 0 var(--gap);
}
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--paper);
  min-width: 0;
}
/* every cell is the same shape — change --cell once to change them all
   (the original uses a portrait cell, roughly 4 / 5) */
.grid { --cell: 16 / 9; }
.card-media {
  position: relative;
  aspect-ratio: var(--cell);
  overflow: hidden;
  background: var(--faint);
}
/* a piece whose ratio doesn't match the cell is shown whole, centred,
   over a blurred copy of its own poster */
.card-media.is-contain::before {
  content: '';
  position: absolute; inset: -10%;
  background: var(--poster) center / cover no-repeat, #111;
  filter: blur(28px) saturate(0.6) brightness(0.55);
}
.card-media.is-contain img, .card-media.is-contain video { object-fit: contain; }
.card--tall .card-media { aspect-ratio: 9 / 16; }   /* vertical video: a vertical card, edge to edge */
.card-media img, .card-media video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(var(--zoom, 1));      /* --zoom trims a thin baked-in border */
  transition: transform 1.1s var(--ease), opacity 0.6s var(--ease);
}
.card:hover .card-media img, .card:hover .card-media video { transform: scale(calc(var(--zoom, 1) * 1.03)); }
.card-media video { opacity: 0; }
.card-media video.is-playing { opacity: 1; }


.card-cap {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 0 0;
}
.card-title { font-size: 11px; letter-spacing: 0.01em; }
.card-sub { font-size: 11px; color: var(--muted); }
.card-tag {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: 10px; letter-spacing: 0.02em;
  color: #fff; mix-blend-mode: exclusion;
}

.page--tight { padding-top: 0; padding-bottom: 10vh; }
.page--tight .page-sub { margin-top: 12vh; }

.foot {
  padding: 6vh 6vw 8vh;
  text-align: center;
  font-size: 11px; color: var(--muted);
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
}

.expl { list-style: none; }
.expl li {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  transition: color 0.4s, padding 0.5s var(--ease);
}
.expl li:hover { color: var(--ink); padding-left: 12px; }

.status {
  display: inline-block;
  margin-bottom: 6vh;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 11px; color: var(--muted);
}
.lead {
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 44px);
  line-height: 1.15;
  max-width: 18ch;
  text-wrap: balance;
}
.about-body { margin-top: 14vh; display: grid; gap: 10vh; }
.about-sec { display: grid; grid-template-columns: 1fr 2fr; gap: 5vw; align-items: start; }
.about-sec h3 { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
.about-sec p { font-size: 15px; line-height: 1.55; max-width: 58ch; }
.about-sec p + p { margin-top: 1.1em; }

/* ── cv ─────────────────────────────────────────────────────── */
.cv-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding-bottom: 14px; margin-bottom: 5vh;
  border-bottom: 1px solid var(--line);
}
.cv-name { font-family: var(--serif); font-size: clamp(30px, 5vw, 54px); font-weight: 400; line-height: 1; }
.cv-role { margin-top: 8px; font-size: 12px; color: var(--muted); }
.cv-pdf {
  flex: none;
  padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 3px;
  font-size: 11px;
  transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.cv-pdf:hover { background: var(--pill); border-color: transparent; }
.cv-blocks { margin-top: 12vh; display: grid; gap: 9vh; }
.cv-rows { list-style: none; }
.cv-rows li {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.cv-rows li:first-child { padding-top: 4px; }
.cv-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.cv-what em { display: block; margin-top: 2px; font-style: normal; font-size: 12px; color: var(--muted); }
.cv-note { color: var(--muted); font-size: 11px; text-align: right; }
.cv-tags { font-size: 15px; line-height: 1.6; letter-spacing: -0.01em; }
.cv-tags span { color: var(--faint); }
@media (max-width: 720px) {
  .cv-head { flex-direction: column; align-items: flex-start; }
  .cv-rows li { grid-template-columns: 72px 1fr; }
  .cv-note { grid-column: 2; text-align: left; }
}

.contact { list-style: none; }
.contact li { border-bottom: 1px solid var(--line); }
.contact a {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 0;
  transition: padding 0.5s var(--ease);
}
.contact a:hover { padding-left: 12px; }
.contact-label { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.contact-value { font-size: 15px; letter-spacing: -0.01em; }

@media (max-width: 720px) {
  .about-sec { grid-template-columns: 1fr; gap: 14px; }
  .idx a { grid-template-columns: 24px 1fr; row-gap: 4px; }
  .idx-tags, .idx-year { grid-column: 2; text-align: left; }
  .split { padding: 0 6%; flex-direction: column; gap: 6px; align-items: flex-start; }
  .nav-link { padding: 5px 7px; }
}

/* ============================================================
   Case overlay — small centred title, full-bleed gallery, info panel
   ============================================================ */
.case {
  position: fixed; inset: 0;
  z-index: 7500;                 /* under the nav, which stays usable */
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
.case.is-open { opacity: 1; }
body.is-case .mark { opacity: 0; pointer-events: none; }

.case-info-btn {
  position: fixed; top: var(--edge); left: var(--edge);
  z-index: 8600;
  padding: 4px 8px;
  border-radius: 3px;
  background: var(--pill);
  font-size: 11px;
  backdrop-filter: blur(10px);
  transition: background-color 0.4s var(--ease), opacity 0.3s;
}
.case-info-btn:hover { background: var(--faint); }

.case-flip {
  position: fixed;
  z-index: 8550;
  overflow: hidden;
  pointer-events: none;
  will-change: transform, width, height;
}
.case-flip img { width: 100%; height: 100%; object-fit: cover; }

.case-scroll {
  position: absolute; inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transition: opacity 0.5s var(--ease) 0.15s;
}
.case.is-ready .case-scroll { opacity: 1; }

.case-head { padding: 19vh 6vw 7vh; text-align: center; }
.case-title { font-size: 13px; font-weight: 500; letter-spacing: 0; line-height: 1.3; }
.case-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }

/* gallery: modules separated by a 6px seam, full-bleed with a 6px page edge */
.case-gallery { --g: 6px; padding: 0 var(--g); display: grid; gap: var(--g); }
.case-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--g); align-items: start; }
.case-row--single { grid-template-columns: 1fr; max-width: 50%; margin: 0 auto; }   /* a lone portrait, never full-bleed */
.fig--sized img { object-fit: contain; }   /* the slot already has the image's ratio; keep every pixel */
.fig {
  position: relative; margin: 0;
  overflow: hidden;
  background: var(--faint);
  aspect-ratio: 16 / 9;
}
.fig--half { aspect-ratio: 1; }
.fig img, .fig video, .fig iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border: 0; display: block;
}
/* small quiet captions above a module ("Film", "B-roll", "Stills") */
.fig-cap {
  position: absolute; top: 10px; left: 12px; z-index: 2;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff; mix-blend-mode: exclusion;
  pointer-events: none;
}
.fig--embed { background: var(--paper); border: 1px solid var(--line); }
.fig--embed iframe { background: var(--paper); }
.fig-open {
  position: absolute; right: 12px; top: 10px; z-index: 2;
  padding: 4px 8px; border-radius: 3px;
  background: var(--pill); backdrop-filter: blur(10px);
  font-size: 10px; letter-spacing: 0.04em;
}
.fig--film video { object-fit: contain; background: #000; }
.fig--film { aspect-ratio: 16 / 9; }

/* B-roll strip */
.case-strip { position: relative; display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--g); padding-top: 0; }
.case-strip .fig-cap { position: static; grid-column: 1 / -1; color: var(--muted); mix-blend-mode: normal; padding: 18px 0 8px; }
.fig--clip { aspect-ratio: 16 / 9; }
.strip-item { min-width: 0; }
.fig-sub { margin-top: 8px; font-size: 11px; color: var(--muted); }
.fig--tallclip { aspect-ratio: 9 / 16; }
@media (max-width: 640px) { .case-strip { grid-template-columns: 1fr 1fr; } }

/* a portrait in a wide slot: shown whole on the paper, in a slightly taller slot */
.fig--contain { aspect-ratio: 3 / 2; background: var(--paper); }
.fig--contain img { object-fit: contain; }
.fig--tall { aspect-ratio: 3 / 4; }

.case-next {
  display: block;
  padding: 16vh 6vw 4vh;
  text-align: center;
}
.case-next span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.case-next strong { display: block; font-weight: 400; font-size: clamp(22px, 3vw, 34px); letter-spacing: -0.02em; transition: opacity 0.3s; }
.case-next:hover strong { opacity: 0.5; }

/* info panel — slides in from the left over a dimmed page */
.case-veil {
  position: absolute; inset: 0;
  z-index: 5;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s var(--ease);
}
.case.is-panel .case-veil { opacity: 1; pointer-events: auto; }
.case-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  z-index: 6;
  width: min(440px, 100%);
  padding: 44px var(--edge) 32px;
  background: var(--paper);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.65s var(--ease);
}
.case.is-panel .case-panel { transform: none; }
.case-panel-close { display: none; }   /* the top-left pill closes the panel */
.case-panel .case-title, .case-panel .case-sub { text-align: left; }
.case-panel-body { margin-top: 5vh; }
.case-panel-body p { font-size: 13px; line-height: 1.55; max-width: 44ch; }
.case-panel-body p + p { margin-top: 1em; }
.case-panel-body dl { margin-top: 5vh; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.case-panel-body .span2 { grid-column: 1 / -1; }
.case-panel-body dt { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.case-panel-body dd { margin-top: 3px; font-size: 12px; }
.case-links { list-style: none; margin-top: 4vh; display: flex; flex-wrap: wrap; gap: 6px; }
.case-links a { display: inline-block; padding: 5px 9px; border: 1px solid var(--line); border-radius: 3px; font-size: 11px; transition: background-color 0.3s; }
.case-links a:hover { background: var(--pill); }
.case-all { display: inline-block; margin-top: 6vh; font-size: 11px; color: var(--muted); }
.case-all:hover { color: var(--ink); }

@media (max-width: 640px) {
  .case-row { grid-template-columns: 1fr; }
  .fig--half { aspect-ratio: 4 / 5; }
}

/* ============================================================
   Search
   ============================================================ */
.search-tags { padding: 8px 20px 6px; }
.search-taggroup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; }
.search-taggroup + .search-taggroup { border-top: 1px solid var(--line); }
.search-taglabel { width: 100%; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 2px 0 2px; }
.search-tag {
  padding: 5px 9px;
  border: 1px solid var(--line); border-radius: 3px;
  font-size: 11px; color: var(--ink);
  transition: background-color 0.3s, border-color 0.3s;
}
.search-tag span { margin-left: 5px; color: var(--muted); font-size: 10px; }
.search-tag:hover { background: var(--pill); border-color: transparent; }

.search { position: fixed; inset: 0; z-index: 8800; }
.search-veil { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.4s var(--ease); }
.search.is-open .search-veil { opacity: 1; }
.search-box {
  position: absolute; left: 50%; top: 12vh;
  width: min(640px, calc(100% - 2 * var(--edge)));
  transform: translate(-50%, 12px);
  background: var(--paper);
  border-radius: 4px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.35s var(--ease), transform 0.5s var(--ease);
}
.search.is-open .search-box { opacity: 1; transform: translate(-50%, 0); }
.search-input {
  width: 100%;
  padding: 18px 20px;
  border: 0; outline: 0;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 16px;
  border-bottom: 1px solid var(--line);
}
.search-input::placeholder { color: var(--muted); }
.search-results { list-style: none; max-height: 56vh; overflow-y: auto; }
.search-results li a {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 20px;
  transition: background-color 0.2s;
}
.search-results li a:hover, .search-results li.is-active a { background: var(--pill); }
.search-thumb { width: 64px; height: 40px; object-fit: cover; background: var(--faint); border-radius: 2px; }
.search-results li a > span:nth-child(2) { min-width: 0; }
.search-title { display: block; font-size: 13px; }
.search-meta { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-sec { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.search-results mark { background: none; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.search-empty { padding: 18px 20px; font-size: 12px; color: var(--muted); }
.search-hint { display: flex; gap: 16px; padding: 10px 20px 12px; border-top: 1px solid var(--line); font-size: 10px; letter-spacing: 0.06em; color: var(--muted); }
.case-panel-body .tag { cursor: pointer; }
.case-panel-body .tag:hover { text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 720px) { .search-box { top: 6vh; } .search-sec { display: none; } }

/* ============================================================
   Preloader veil
   ============================================================ */
.pre {
  position: fixed; inset: 0;
  z-index: 7000;
  background: var(--paper);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s var(--ease);
}
.pre.is-gone { opacity: 0; }

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.08s !important; }
  .grain { animation: none; }
  .view { filter: none; }
}
