/* ============================================================
   Cultivation Archive — design system
   Type: Spectral (display) + IBM Plex Sans (UI) + IBM Plex Mono
   Palette: ink, moonstone, jade, gold leaf, cinnabar
   ============================================================ */

:root {
  /* —————— neutrals (dark theme — default) —————— */
  --ink-0: #0a0b0d;            /* deepest — page bg */
  --ink-1: #101216;            /* base surface */
  --ink-2: #161a1f;            /* elevated surface */
  --ink-3: #1d2228;            /* card, panel */
  --ink-4: #262c34;            /* hover */
  --ink-5: #323a44;            /* active / pressed */
  --line-1: #232830;           /* hairline */
  --line-2: #2e353f;           /* divider */
  --line-3: #404954;           /* stronger */

  --text-1: #e8e6df;           /* primary — warm parchment */
  --text-2: #b6b3a8;           /* secondary */
  --text-3: #7e7c73;           /* muted */
  --text-4: #54534d;           /* faint */

  /* —————— accents —————— */
  --jade:        oklch(0.72 0.08 158);   /* primary accent */
  --jade-soft:   oklch(0.72 0.08 158 / 0.16);
  --jade-line:   oklch(0.72 0.08 158 / 0.35);
  --gold:        oklch(0.78 0.11 82);    /* leaf */
  --gold-soft:   oklch(0.78 0.11 82 / 0.14);
  --gold-line:   oklch(0.78 0.11 82 / 0.4);
  --cinnabar:    oklch(0.66 0.18 28);    /* alert / dropped */
  --cinnabar-soft: oklch(0.66 0.18 28 / 0.14);
  --silver:      oklch(0.85 0.01 240);   /* moon silver */
  --bronze:      oklch(0.62 0.07 50);

  /* —————— rank palette (dark) —————— */
  --rank-sss: oklch(0.82 0.13 82);    /* radiant gold */
  --rank-ss:  oklch(0.78 0.1 60);     /* burnished */
  --rank-s:   oklch(0.72 0.09 38);    /* bronze */
  --rank-a:   oklch(0.72 0.09 158);   /* jade */
  --rank-b:   oklch(0.68 0.06 210);   /* celadon */
  --rank-c:   oklch(0.62 0.04 250);   /* slate */
  --rank-d:   oklch(0.55 0.03 270);   /* dim */
  --rank-f:   oklch(0.46 0.04 18);    /* faded cinnabar */

  /* —————— radii / shadows / motion —————— */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;
  --r-pill: 999px;

  --sh-1: 0 1px 0 0 rgba(0,0,0,0.4), 0 0 0 1px var(--line-1);
  --sh-2: 0 8px 24px -8px rgba(0,0,0,0.6), 0 0 0 1px var(--line-1);
  --sh-3: 0 24px 60px -20px rgba(0,0,0,0.7), 0 0 0 1px var(--line-2);
  --sh-glow-jade: 0 0 0 1px var(--jade-line), 0 0 24px -4px oklch(0.72 0.08 158 / 0.35);

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 340ms;

  /* —————— type scale (compact app) —————— */
  --t-display: 28px;
  --t-h1: 20px;
  --t-h2: 16px;
  --t-h3: 14px;
  --t-body: 13.5px;
  --t-small: 12px;
  --t-tiny: 11px;

  --f-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-serif: 'Spectral', 'Iowan Old Style', Georgia, serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* —————— layout —————— */
  --sidebar-w: 232px;
  --header-h: 56px;
  --filterbar-h: 48px;
  --detail-w: 440px;
}

/* Light theme — warm rice-paper */
[data-theme="light"] {
  --ink-0: #f3eee3;
  --ink-1: #efe9dc;
  --ink-2: #ebe4d4;
  --ink-3: #f7f2e6;
  --ink-4: #e6dec9;
  --ink-5: #d8ceb5;
  --line-1: #d9d0bb;
  --line-2: #c8bda4;
  --line-3: #ada088;

  --text-1: #1a1a1a;
  --text-2: #4a463d;
  --text-3: #75705f;
  --text-4: #9a937f;

  --jade:        oklch(0.5 0.08 158);
  --jade-soft:   oklch(0.5 0.08 158 / 0.12);
  --jade-line:   oklch(0.5 0.08 158 / 0.4);
  --gold:        oklch(0.55 0.11 65);
  --gold-soft:   oklch(0.55 0.11 65 / 0.12);
  --gold-line:   oklch(0.55 0.11 65 / 0.4);
  --cinnabar:    oklch(0.5 0.18 28);
  --cinnabar-soft: oklch(0.5 0.18 28 / 0.12);

  --rank-sss: oklch(0.6 0.13 65);
  --rank-ss:  oklch(0.55 0.1 50);
  --rank-s:   oklch(0.5 0.09 35);
  --rank-a:   oklch(0.48 0.09 158);
  --rank-b:   oklch(0.5 0.06 210);
  --rank-c:   oklch(0.5 0.03 250);
  --rank-d:   oklch(0.55 0.02 270);
  --rank-f:   oklch(0.5 0.06 18);

  --sh-1: 0 1px 0 0 rgba(0,0,0,0.04), 0 0 0 1px var(--line-1);
  --sh-2: 0 8px 24px -8px rgba(30,20,0,0.15), 0 0 0 1px var(--line-1);
  --sh-3: 0 24px 60px -20px rgba(30,20,0,0.2), 0 0 0 1px var(--line-2);
}

/* ============================================================
   reset / base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--f-sans);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--text-1);
  background: var(--ink-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01' 1, 'cv11' 1;
  overflow: hidden;
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { background: none; border: 0; outline: 0; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-1); border-radius: var(--r-pill); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); background-clip: padding-box; border: 2px solid transparent; }

:focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 2px;
  border-radius: var(--r-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Celestial grid backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, var(--jade-soft), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, var(--gold-soft), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 47px, var(--line-1) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, var(--line-1) 47px 48px);
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 30%, black 30%, transparent 90%);
}
[data-theme="light"] body::before { opacity: 0.6; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* —————— Header —————— */
.header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line-1);
  background: color-mix(in oklab, var(--ink-1) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 100%;
  border-right: 1px solid var(--line-1);
}
.brand__mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--r-2);
  background:
    radial-gradient(circle at 30% 30%, var(--jade-soft), transparent 60%),
    var(--ink-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--jade);
}
.brand__name {
  font-family: var(--f-serif);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-1);
}
.brand__name em {
  font-style: italic;
  color: var(--gold);
  font-weight: 400;
}
.brand__sub {
  display: block;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 1px;
}

.search-wrap {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 100%;
  max-width: 720px;
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--ink-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  color: var(--text-2);
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.search:focus-within {
  border-color: var(--jade-line);
  background: var(--ink-3);
  box-shadow: 0 0 0 3px var(--jade-soft);
}
.search input {
  flex: 1;
  font-size: var(--t-body);
  color: var(--text-1);
}
.search input::placeholder { color: var(--text-3); }
.search__hint {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 2px 6px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-1);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
}
.iconbtn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-2);
  color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  position: relative;
}
.iconbtn:hover { background: var(--ink-3); color: var(--text-1); }
.iconbtn:active { background: var(--ink-4); }
.iconbtn[aria-pressed="true"] { background: var(--ink-3); color: var(--jade); }
.iconbtn svg { width: 16px; height: 16px; }

/* —————— Sidebar —————— */
.sidebar {
  border-right: 1px solid var(--line-1);
  background: color-mix(in oklab, var(--ink-1) 60%, transparent);
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.nav-group__title {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 6px 10px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-group__title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-2);
  color: var(--text-2);
  font-size: var(--t-body);
  width: 100%;
  text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--ink-3); color: var(--text-1); }
.nav-item[aria-current="true"] {
  background: var(--ink-3);
  color: var(--text-1);
  box-shadow: inset 0 0 0 1px var(--line-1);
}
.nav-item[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--jade);
  border-radius: var(--r-pill);
}
.nav-item svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.nav-item[aria-current="true"] svg { color: var(--jade); }
.nav-item__count {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--ink-2);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  min-width: 22px;
  text-align: center;
}

/* —————— Main —————— */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ink-0);
  position: relative;
}
.filterbar {
  height: var(--filterbar-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-1);
  gap: 10px;
  background: color-mix(in oklab, var(--ink-1) 50%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.filterbar::-webkit-scrollbar { display: none; }

.view-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-right: 6px;
}
.view-title h1 {
  font-family: var(--f-serif);
  font-size: var(--t-h1);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0;
  white-space: nowrap;
}
.view-title .count {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-3);
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--line-1);
  margin: 0 4px;
  flex-shrink: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--ink-2);
  border: 1px solid var(--line-1);
  color: var(--text-2);
  font-size: var(--t-small);
  white-space: nowrap;
  transition: all var(--dur-1) var(--ease);
  cursor: pointer;
  flex-shrink: 0;
}
.chip:hover { background: var(--ink-3); color: var(--text-1); border-color: var(--line-2); }
.chip[aria-pressed="true"] {
  background: var(--jade-soft);
  border-color: var(--jade-line);
  color: var(--text-1);
}
.chip svg { width: 12px; height: 12px; opacity: 0.7; }
.chip__close {
  width: 14px; height: 14px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  opacity: 0.6;
}
.chip__close:hover { opacity: 1; background: rgba(255,255,255,0.06); }

.select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-2);
  background: var(--ink-2);
  border: 1px solid var(--line-1);
  color: var(--text-2);
  font-size: var(--t-small);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.select:hover { background: var(--ink-3); color: var(--text-1); }
.select svg { width: 12px; height: 12px; opacity: 0.6; }

.density {
  display: inline-flex;
  background: var(--ink-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-2);
  padding: 2px;
  flex-shrink: 0;
}
.density button {
  width: 26px; height: 22px;
  display: grid; place-items: center;
  color: var(--text-3);
  border-radius: var(--r-1);
}
.density button[aria-pressed="true"] {
  background: var(--ink-4);
  color: var(--text-1);
}
.density svg { width: 13px; height: 13px; }

.spacer { flex: 1; }

/* —————— Content scroll —————— */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 60px;
}
.content--padded { padding: 24px 24px 80px; }

/* —————— Grid of cards —————— */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 18px 16px;
}
.grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 14px 12px;
}

.card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  border-radius: var(--r-3);
  transition: transform var(--dur-2) var(--ease);
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}
.card:hover { transform: translateY(-2px); }
.card__cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--ink-2);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--dur-2) var(--ease);
}
.card:hover .card__cover { box-shadow: var(--sh-2); }
.card__cover img,
.card__cover svg {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
}
.card__topbar {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.card__rank {
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--r-1);
  background: rgba(10,11,13,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--rank-color, var(--text-1));
  box-shadow: inset 0 0 0 1px currentColor;
  line-height: 1.2;
}
.card__source {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 2px 6px;
  border-radius: var(--r-1);
  background: rgba(10,11,13,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--text-2);
  text-transform: uppercase;
  line-height: 1.4;
}
.card__fav {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: rgba(10,11,13,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--text-3);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease), color var(--dur-1) var(--ease);
}
.card:hover .card__fav,
.card__fav[data-active="true"] { opacity: 1; }
.card__fav[data-active="true"] { color: var(--gold); }
.card__fav svg { width: 14px; height: 14px; }

.card__status {
  position: absolute;
  bottom: 8px; left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(10,11,13,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--text-1);
  text-transform: uppercase;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: var(--text-3);
}
.status-dot--reading { background: var(--jade); box-shadow: 0 0 6px var(--jade); }
.status-dot--completed { background: var(--gold); }
.status-dot--planned { background: var(--silver); }
.status-dot--hold { background: var(--bronze); }
.status-dot--dropped { background: var(--cinnabar); }
.status-dot--unread { background: var(--text-4); }

.card__title {
  margin-top: 10px;
  font-size: var(--t-body);
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.35;
  letter-spacing: -0.005em;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin-top: 2px;
  font-family: var(--f-mono);
  font-size: var(--t-tiny);
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* —————— Quick actions on card hover —————— */
.card__hoveractions {
  position: absolute;
  inset: auto 8px 8px 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
  pointer-events: none;
}
.card:hover .card__hoveractions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.card__hoveractions button {
  flex: 1;
  height: 26px;
  padding: 0 6px;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-1);
  background: rgba(10,11,13,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-1);
}
.card__hoveractions button:hover { background: var(--jade-soft); border-color: var(--jade-line); }

/* —————— List view —————— */
.list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--ink-1);
}
.list__row {
  display: grid;
  grid-template-columns: 56px 1fr 110px 110px 80px 32px;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.list__row:last-child { border-bottom: 0; }
.list__row:hover { background: var(--ink-2); }
.list__cover {
  width: 48px; height: 64px;
  border-radius: var(--r-1);
  overflow: hidden;
  background: var(--ink-2);
  box-shadow: var(--sh-1);
}
.list__cover svg, .list__cover img { width: 100%; height: 100%; object-fit: cover; }
.list__title { font-weight: 500; color: var(--text-1); }
.list__alt { font-size: var(--t-small); color: var(--text-3); margin-top: 2px; }
.list__meta { font-family: var(--f-mono); font-size: var(--t-small); color: var(--text-3); }
.list__hdr {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
  background: var(--ink-2);
  display: grid;
  grid-template-columns: 56px 1fr 110px 110px 80px 32px;
  gap: 14px;
  position: sticky;
  top: 0;
}

/* —————— Rank pill —————— */
.rankpill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-1);
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--rank-color, var(--text-1));
  background: color-mix(in oklab, var(--rank-color, var(--text-3)) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--rank-color, var(--text-3)) 40%, transparent);
}
.rankpill--unranked {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--text-3);
  background: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
  text-transform: uppercase;
}

/* —————— Detail panel —————— */
.detail {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: var(--detail-w);
  background: var(--ink-1);
  border-left: 1px solid var(--line-1);
  box-shadow: var(--sh-3);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-3) var(--ease-out);
}
.detail--open { transform: translateX(0); }
.detail__close {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--ink-2);
  color: var(--text-2);
  z-index: 2;
}
.detail__close:hover { background: var(--ink-3); color: var(--text-1); }
.detail__scroll { flex: 1; overflow-y: auto; }
.detail__hero {
  position: relative;
  padding: 24px 24px 0;
}
.detail__hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 80% at 30% 0%, var(--jade-soft), transparent 60%),
    radial-gradient(ellipse 80% 60% at 100% 30%, var(--gold-soft), transparent 70%);
  pointer-events: none;
  opacity: 0.6;
}
.detail__cover {
  position: relative;
  width: 168px;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-3);
  overflow: hidden;
  box-shadow: var(--sh-2);
}
.detail__cover svg, .detail__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail__head {
  position: relative;
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
}
.detail__titles { flex: 1; min-width: 0; padding-top: 6px; }
.detail__title {
  font-family: var(--f-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin: 6px 0 6px;
  text-wrap: balance;
}
.detail__alt {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.detail__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.detail__chips .chip { cursor: default; height: 22px; font-size: 10.5px; padding: 0 7px; }

.detail__body { padding: 18px 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.section-label {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--text-3);
  text-transform: uppercase;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-1), transparent);
}
.synopsis {
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--text-2);
  text-wrap: pretty;
}
.synopsis::first-letter {
  font-family: var(--f-serif);
  font-size: 28px;
  font-weight: 500;
  float: left;
  line-height: 1;
  padding: 2px 6px 0 0;
  color: var(--gold);
}

.metarows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 24px;
}
.metarow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line-1);
  font-size: var(--t-small);
}
.metarow__k {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.metarow__v { color: var(--text-1); font-weight: 500; }

/* —————— Rank picker —————— */
.rank-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.rank-picker button {
  height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--rank-color, var(--text-2));
  background: color-mix(in oklab, var(--rank-color, var(--text-3)) 8%, var(--ink-2));
  border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
  transition: all var(--dur-1) var(--ease);
  position: relative;
}
.rank-picker button:hover {
  background: color-mix(in oklab, var(--rank-color, var(--text-3)) 16%, var(--ink-2));
  transform: translateY(-1px);
}
.rank-picker button[aria-pressed="true"] {
  background: color-mix(in oklab, var(--rank-color, var(--text-3)) 22%, var(--ink-2));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--rank-color, var(--text-3)) 60%, transparent),
              0 0 12px -2px color-mix(in oklab, var(--rank-color, var(--text-3)) 60%, transparent);
}

/* —————— Status segmented —————— */
.statusgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.statuspill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-2);
  background: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
  color: var(--text-2);
  font-size: var(--t-small);
  transition: all var(--dur-1) var(--ease);
}
.statuspill:hover { color: var(--text-1); background: var(--ink-3); }
.statuspill[aria-pressed="true"] {
  background: var(--ink-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--text-1);
}

/* —————— Textarea —————— */
.notes {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  background: var(--ink-2);
  border-radius: var(--r-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
  color: var(--text-1);
  font-size: var(--t-body);
  resize: vertical;
  font-family: var(--f-sans);
  line-height: 1.6;
}
.notes:focus { box-shadow: inset 0 0 0 1px var(--jade-line), 0 0 0 3px var(--jade-soft); }
.notes::placeholder { color: var(--text-3); font-style: italic; }

/* —————— Tier list view —————— */
.tier-view { padding: 18px 24px 80px; }
.tier-view__intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-1);
  margin-bottom: 18px;
}
.tier-view__intro h1 {
  font-family: var(--f-serif);
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.005em;
}
.tier-view__intro p {
  margin: 6px 0 0;
  font-size: var(--t-small);
  color: var(--text-3);
  max-width: 380px;
}
.tier-toolbar { display: flex; gap: 8px; align-items: center; }

.tierband {
  display: grid;
  grid-template-columns: 96px 1fr;
  border: 1px solid var(--line-1);
  border-radius: var(--r-3);
  margin-bottom: 10px;
  background: var(--ink-1);
  overflow: hidden;
  min-height: 96px;
}
.tierband__label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: color-mix(in oklab, var(--rank-color, var(--text-3)) 14%, var(--ink-2));
  border-right: 1px solid var(--line-1);
  position: relative;
}
.tierband__rank {
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 32px;
  letter-spacing: 0.04em;
  color: var(--rank-color, var(--text-1));
  line-height: 1;
}
.tierband__count {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-3);
  text-transform: uppercase;
}
.tierband__tagline {
  position: absolute;
  bottom: 8px;
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: color-mix(in oklab, var(--rank-color, var(--text-3)) 70%, transparent);
  text-transform: uppercase;
}
.tierband__items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  align-content: flex-start;
  min-height: 96px;
  transition: background var(--dur-2) var(--ease);
}
.tierband__items.is-drop {
  background: color-mix(in oklab, var(--rank-color, var(--jade)) 8%, transparent);
}
.tierband__empty {
  align-self: center;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 16px 0;
}

.tier-card {
  width: 72px;
  border-radius: var(--r-2);
  overflow: hidden;
  cursor: grab;
  position: relative;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  background: var(--ink-2);
  box-shadow: var(--sh-1);
}
.tier-card:active { cursor: grabbing; }
.tier-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.tier-card.dragging { opacity: 0.4; }
.tier-card__cover {
  aspect-ratio: 2 / 3;
  background: var(--ink-2);
}
.tier-card__cover svg, .tier-card__cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.tier-card__title {
  font-size: 10px;
  padding: 4px 6px 6px;
  color: var(--text-2);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

/* —————— Search palette —————— */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 80;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  animation: fade var(--dur-2) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.palette {
  width: min(640px, calc(100vw - 32px));
  background: var(--ink-1);
  border-radius: var(--r-3);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: pop var(--dur-3) var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(-12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.palette__input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-1);
}
.palette__input input { flex: 1; font-size: 16px; color: var(--text-1); }
.palette__input input::placeholder { color: var(--text-3); }
.palette__input svg { width: 16px; height: 16px; color: var(--text-3); }
.palette__hint { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--text-3); padding: 2px 6px; border: 1px solid var(--line-1); border-radius: var(--r-1); }
.palette__results {
  max-height: 56vh;
  overflow-y: auto;
  padding: 6px;
}
.palette__group-title {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 10px 12px 6px;
}
.palette__row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-2);
  cursor: pointer;
  min-width: 0;
}
.palette__row > div { min-width: 0; }
.palette__title, .palette__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__row[data-active="true"] {
  background: var(--ink-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.palette__cover { width: 30px; height: 40px; border-radius: var(--r-1); overflow: hidden; background: var(--ink-2); }
.palette__cover svg, .palette__cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.palette__title { font-size: var(--t-body); color: var(--text-1); }
.palette__sub { font-size: var(--t-small); color: var(--text-3); margin-top: 1px; }
.palette__quick { display: flex; gap: 4px; opacity: 0; transition: opacity var(--dur-1) var(--ease); }
.palette__row[data-active="true"] .palette__quick,
.palette__row:hover .palette__quick { opacity: 1; }
.palette__quick button {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: var(--r-1);
  background: var(--ink-2);
  color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
}
.palette__quick button:hover { background: var(--jade-soft); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--jade-line); }
.palette__empty {
  text-align: center;
  padding: 36px 18px;
  color: var(--text-3);
  font-style: italic;
}

/* —————— Empty / loading / fallback —————— */
.empty {
  display: grid;
  place-items: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty__seal {
  width: 72px; height: 72px;
  border-radius: var(--r-pill);
  background:
    radial-gradient(circle at 50% 50%, var(--jade-soft), transparent 70%);
  display: grid; place-items: center;
  margin: 0 auto 18px;
  position: relative;
}
.empty__seal::before {
  content: "";
  position: absolute; inset: 8px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-pill);
}
.empty__seal svg { width: 28px; height: 28px; color: var(--jade); }
.empty h2 {
  font-family: var(--f-serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text-1);
}
.empty p { margin: 0; max-width: 320px; font-size: var(--t-small); }
.empty__hint {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-top: 12px;
}

.skeleton {
  background: linear-gradient(90deg, var(--ink-2) 0%, var(--ink-3) 50%, var(--ink-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-2);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* —————— Dropdown menu —————— */
.menu {
  position: absolute;
  background: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  box-shadow: var(--sh-3);
  min-width: 220px;
  padding: 6px;
  z-index: 60;
}
.menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-2);
  text-align: left;
  color: var(--text-2);
  font-size: var(--t-body);
}
.menu__item:hover { background: var(--ink-3); color: var(--text-1); }
.menu__item svg { width: 14px; height: 14px; color: var(--text-3); }
.menu__item--danger { color: var(--cinnabar); }
.menu__item--danger svg { color: var(--cinnabar); }
.menu__divider { height: 1px; background: var(--line-1); margin: 4px 6px; }
.menu__hint { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-3); margin-left: auto; }

/* —————— Toast —————— */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-3);
  font-size: var(--t-small);
  color: var(--text-1);
  animation: slideup var(--dur-3) var(--ease-out);
}
.toast svg { width: 14px; height: 14px; color: var(--jade); }
@keyframes slideup { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* —————— Buttons —————— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-2);
  font-size: var(--t-small);
  color: var(--text-2);
  background: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-1);
  transition: all var(--dur-1) var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--ink-3); color: var(--text-1); }
.btn svg { width: 13px; height: 13px; }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--ink-2); }
.btn--jade {
  color: var(--text-1);
  background: var(--jade-soft);
  box-shadow: inset 0 0 0 1px var(--jade-line);
}
.btn--jade:hover { background: color-mix(in oklab, var(--jade-soft) 50%, var(--ink-3)); }
.btn--danger { color: var(--cinnabar); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--cinnabar) 30%, transparent); }

/* —————— Tweaks panel —————— */
.tweaks {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 90;
  width: 280px;
  background: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  box-shadow: var(--sh-3);
  padding: 12px;
  font-size: var(--t-small);
}
.tweaks__title { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3); margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.tweak { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px dashed var(--line-1); }
.tweak:first-of-type { border-top: 0; }
.tweak__label { color: var(--text-2); }
.swatches { display: flex; gap: 4px; }
.swatch { width: 20px; height: 20px; border-radius: var(--r-pill); cursor: pointer; box-shadow: inset 0 0 0 1px var(--line-2); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--text-1); }

/* —————— Responsive —————— */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; --detail-w: 100%; }
  .app { grid-template-columns: 1fr; }
  .header { grid-template-columns: auto 1fr auto; }
  .brand { padding: 0 14px; }
  .brand__name { display: none; }
  .sidebar {
    position: fixed;
    top: var(--header-h); bottom: 0; left: 0;
    width: 260px;
    background: var(--ink-1);
    transform: translateX(-100%);
    transition: transform var(--dur-3) var(--ease-out);
    z-index: 50;
  }
  .sidebar--open { transform: translateX(0); }
  .detail { width: 100%; top: 0; }
  .list__row { grid-template-columns: 56px 1fr 60px; }
  .list__col-hide { display: none; }
  .list__hdr { grid-template-columns: 56px 1fr 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px 12px; }
  .metarows { grid-template-columns: 1fr; }
  .search-wrap { padding: 0 12px; }
  .search__hint { display: none; }
}

/* —————— Helpers —————— */
.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; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
