@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/montserrat-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url(fonts/montserrat-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f5f1ea;
  --paper: #fbf9f5;
  --ink: #2a2927;
  --ink-2: #5d5953;
  --line: #d9d3c9;
  --line-2: #e8e3da;
  --focus: #2a2927;
  --bar-h: 4.5rem;
  --pad: clamp(1rem, 2.6vw, 2.25rem);
  --ease: cubic-bezier(.2, .7, .1, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.spiral-mode { overflow: hidden; overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.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;
}
.skip {
  position: fixed; left: var(--pad); top: -4rem; z-index: 50;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ---------- Header ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  min-height: var(--bar-h);
  padding: max(.9rem, env(safe-area-inset-top)) var(--pad) .9rem;
  background: linear-gradient(var(--bg) 55%, rgba(245, 241, 234, 0));
}
.index-mode .bar { background: var(--bg); border-bottom: 1px solid var(--line-2); }
.brand { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.wordmark { font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.tagline { font-size: .8125rem; color: var(--ink-2); letter-spacing: .02em; }

.tools { display: flex; align-items: center; gap: .6rem; }
.search {
  display: flex; align-items: center; gap: .5rem;
  height: 2.5rem; padding: 0 .85rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  color: var(--ink-2);
  transition: border-color .2s;
}
.search:focus-within { border-color: var(--ink); color: var(--ink); }
.search input {
  border: 0; outline: none; background: transparent; width: 11rem;
  font-size: .9375rem; color: var(--ink);
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 2.5rem; padding: 0 1.05rem; border-radius: 999px;
  font-size: .9375rem; font-weight: 500; letter-spacing: .01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .2s, color .2s, border-color .2s;
}
.btn.ghost { background: var(--paper); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.solid { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn.solid:hover { background: #000; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.badge[hidden] { display: none; }
.badge {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem;
  border-radius: 999px; background: var(--ink); color: var(--paper); font-size: .75rem; font-weight: 600;
}
.link {
  background: none; border: 0; padding: .5rem .25rem; cursor: pointer;
  font-size: .875rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .3em;
  transition: text-decoration-color .2s;
}
.link:hover { text-decoration-color: currentColor; }
.link:disabled { opacity: .35; cursor: default; text-decoration: none; }

.sort select {
  appearance: none; height: 2.5rem; padding: 0 2.1rem 0 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%232a2927' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right .9rem center;
  font-size: .9375rem; font-weight: 500; cursor: pointer;
}
.sort select:hover { border-color: var(--ink); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 3px; }
.seg-btn {
  border: 0; background: none; height: calc(2.5rem - 8px); padding: 0 .9rem; border-radius: 999px;
  font-size: .875rem; font-weight: 500; cursor: pointer; color: var(--ink-2);
}
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Filter panel ---------- */
.filter-panel {
  position: fixed; z-index: 30; top: calc(var(--bar-h) + .25rem); right: var(--pad);
  width: min(23rem, calc(100vw - 2 * var(--pad)));
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 24px 60px -24px rgba(42, 41, 39, .28);
}
.filter-panel[hidden] { display: none; }
.fp-head, .fp-foot { display: flex; align-items: center; justify-content: space-between; }
.fp-head h2 { font-size: 1rem; font-weight: 600; }
.fp-foot { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line-2); }
fieldset { border: 0; padding: 0; margin: 1rem 0 0; min-width: 0; }
legend { font-size: .8125rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .55rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  height: 2.25rem; padding: 0 .85rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); font-size: .875rem; cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .n { opacity: .65; margin-left: .3rem; font-size: .8125rem; }
.range { display: flex; align-items: end; gap: .6rem; }
.range label { display: flex; flex-direction: column; gap: .25rem; flex: 1; font-size: .8125rem; color: var(--ink-2); }
.range input {
  height: 2.5rem; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  font-size: 1rem; color: var(--ink); width: 100%;
}
.range input:focus { border-color: var(--ink); outline: none; }
.range .dash { padding-bottom: .55rem; color: var(--ink-2); }
.hint { margin-top: .45rem; font-size: .8125rem; color: var(--ink-2); }
.panel-only { display: none; }

/* ---------- Spiral stage ---------- */
.stage { position: fixed; inset: 0; outline: none; touch-action: none; }
.stage[hidden] { display: none; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#gl.dragging { cursor: grabbing; }
#gl.pointing { cursor: pointer; }
.stage:focus-visible::after {
  content: ''; position: absolute; inset: calc(var(--bar-h) + .5rem) var(--pad) var(--pad);
  border: 1px dashed var(--ink-2); border-radius: 14px; pointer-events: none;
}

.caption {
  position: absolute; left: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  max-width: min(30rem, 42vw); pointer-events: none;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.caption.swap { opacity: 0; transform: translateY(6px); }
.cap-num { font-size: .8125rem; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); min-height: 1.2em; }
.cap-title { font-size: clamp(1.6rem, 2.6vw, 2.4rem); line-height: 1.12; font-weight: 400; letter-spacing: -.01em; margin: .3rem 0 .45rem; text-wrap: balance; }
.cap-meta { font-size: .9375rem; color: var(--ink-2); }
.cap-meta strong { color: var(--ink); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: .8125rem; }
.cap-open { margin-top: 1rem; pointer-events: auto; }

.pager {
  position: absolute; right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 1rem;
}
.count { font-size: .875rem; font-weight: 500; letter-spacing: .08em; min-width: 4.5rem; text-align: center; }

.drag-hint {
  position: absolute; left: 50%; bottom: calc(var(--pad) + 1.5rem); transform: translateX(-50%);
  font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
  pointer-events: none; transition: opacity .6s;
}
.drag-hint.gone { opacity: 0; }

.loader { position: absolute; left: 50%; top: 50%; width: 7rem; height: 1px; background: var(--line); transform: translate(-50%, -50%); overflow: hidden; transition: opacity .5s; }
.loader-line { position: absolute; inset: 0; background: var(--ink); transform-origin: left; transform: scaleX(var(--p, .05)); transition: transform .3s; }
.loader.done { opacity: 0; pointer-events: none; }

/* ---------- Index view ---------- */
.index-view { padding: calc(var(--bar-h) + 1.75rem) var(--pad) 4rem; max-width: 96rem; margin: 0 auto; }
.index-view[hidden] { display: none; }
.results { font-size: .875rem; color: var(--ink-2); margin-bottom: 1.25rem; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 42vw), 1fr)); gap: clamp(1.25rem, 3vw, 2.75rem) clamp(1rem, 2.5vw, 2.25rem); }
.tile { all: unset; display: flex; flex-direction: column; gap: .7rem; cursor: pointer; width: 100%; }
.tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; border-radius: 4px; }
.tile-img { position: relative; display: block; aspect-ratio: 4 / 5; background: var(--paper); border-radius: 6px; transition: background-color .3s; }
.tile:hover .tile-img { background: #fff; }
.tile-img img { position: absolute; left: 10%; top: 9%; width: 80%; height: 82%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 10px 14px rgba(42, 41, 39, .14)); transition: transform .5s var(--ease); }
.tile:hover .tile-img img { transform: translateY(-4px) scale(1.02); }
.tile-num { font-size: .75rem; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); min-height: 1.1em; }
.tile-title { font-size: 1rem; font-weight: 500; line-height: 1.3; }
.tile-meta { font-size: .875rem; color: var(--ink-2); }
.tile-meta strong { color: var(--ink); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: .75rem; }

.empty { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1rem; text-align: center; pointer-events: none; z-index: 5; }
.empty[hidden] { display: none; }
.empty p { font-size: 1.125rem; }
.empty button { pointer-events: auto; }
.index-mode .empty { position: static; padding: 4rem 1rem; }

/* ---------- Detail ---------- */
.detail {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--ink);
}
.detail::backdrop { background: rgba(245, 241, 234, .6); }
.detail[open] { animation: d-in .5s var(--ease); }
@keyframes d-in { from { opacity: 0; transform: translateY(14px); } }
.d-inner {
  height: 100%; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(19rem, 1fr);
  grid-template-rows: auto 1fr; column-gap: clamp(1.5rem, 4vw, 5rem);
  padding: max(1rem, env(safe-area-inset-top)) var(--pad) var(--pad);
}
.d-top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; min-height: 3rem; }
.d-nav { display: flex; gap: 1.25rem; }
.d-figure { margin: 0; min-height: 0; display: grid; place-items: center; padding: clamp(.5rem, 3vw, 3rem); }
.d-figure img { max-width: 100%; max-height: calc(100dvh - 9rem); object-fit: contain; filter: drop-shadow(0 22px 30px rgba(42, 41, 39, .16)); }
.d-info { align-self: center; padding-bottom: 2rem; max-width: 30rem; }
.d-num { font-size: .875rem; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); min-height: 1.3em; }
.d-title { font-size: clamp(2rem, 3.6vw, 3.1rem); line-height: 1.08; font-weight: 400; letter-spacing: -.015em; margin: .4rem 0 .9rem; text-wrap: balance; }
.d-credit { font-size: 1rem; color: var(--ink-2); font-style: italic; margin: -.35rem 0 1rem; max-width: 28rem; }
.d-status { display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; border: 1px solid var(--ink); border-radius: 999px; padding: .3rem .75rem; }
.d-status:empty { display: none; }
.d-facts { margin: 1.5rem 0 1.75rem; display: grid; grid-template-columns: max-content 1fr; gap: .7rem 1.5rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.d-facts dt { font-size: .8125rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding-top: .15rem; }
.d-facts dd { margin: 0; font-size: 1rem; }
.d-inquire { height: 3rem; padding: 0 1.6rem; font-size: 1rem; }
.d-note { margin-top: .75rem; font-size: .8125rem; color: var(--ink-2); }
.d-note a { color: var(--ink); text-underline-offset: .2em; }

.noscript { padding: 6rem var(--pad); }

/* ---------- Reduced motion ---------- */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  :root { --bar-h: 7.4rem; }
  .bar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .7rem .5rem; align-items: center;
    grid-template-areas: "brand seg seg" "search filter sort";
    padding-bottom: .8rem;
  }
  .brand { grid-area: brand; }
  .tools { display: contents; }
  .seg { grid-area: seg; justify-self: end; }
  .search { grid-area: search; min-width: 0; }
  .search input { width: 100%; min-width: 0; }
  #filter-btn { grid-area: filter; padding: 0 .95rem; justify-self: stretch; }
  .sort { justify-self: end; }
  .sort { grid-area: sort; }
  .sort select {
    width: 2.5rem; padding: 0; color: transparent;
    background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M2 4h12M4 8h8M6 12h4' fill='none' stroke='%232a2927' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center;
  }
  .sort select option { color: var(--ink); }
  .bar .motion { display: none; }
  .panel-only { display: block; }

  .filter-panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; border-radius: 18px 18px 0 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom)); max-height: 85dvh; overflow: auto;
    animation: sheet .35s var(--ease);
  }
  @keyframes sheet { from { transform: translateY(30%); opacity: 0; } }

  .caption { left: 0; right: 0; bottom: 0; max-width: none; padding: 3rem var(--pad) calc(var(--pad) + 3rem + env(safe-area-inset-bottom)); background: linear-gradient(rgba(245,241,234,0), rgba(245,241,234,.94) 34%); }
  .pager { z-index: 2; }
  .cap-title { font-size: 1.6rem; }
  .cap-open { margin-top: .75rem; height: 2.5rem; }
  .pager { left: var(--pad); justify-content: space-between; }
  .drag-hint { bottom: auto; top: calc(var(--bar-h) + .75rem); }

  .d-inner { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 52dvh) auto; overflow: auto; padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom)); }
  .d-figure { padding: .5rem 0 1.25rem; height: 100%; overflow: hidden; }
  .d-figure img { max-height: 100%; }
  .d-info { align-self: start; max-width: none; }
  .d-inquire { width: 100%; position: sticky; bottom: .5rem; }
}
@media (max-width: 380px) {
  .seg-btn { padding: 0 .7rem; }
}
