/* ════════════════════════════════════════════════════════════════════
   ZIION DESIGN SYSTEM — Components
   Reset, primitives, surfaces, controls, patterns.
   ════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-1);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--bg-0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Type primitives ─────────────────────────────────────────── */
.t-display { font-family: var(--font-serif); font-size: var(--t-display); font-weight: 400; letter-spacing: -.02em; line-height: 1.05; }
.t-h1      { font-size: var(--t-h1); font-weight: 700; letter-spacing: -.015em; line-height: 1.15; }
.t-h2      { font-size: var(--t-h2); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.t-h3      { font-size: var(--t-h3); font-weight: 600; letter-spacing: -.005em; line-height: 1.3; }
.t-lead    { font-size: var(--t-lead); line-height: 1.55; color: var(--ink-2); }
.t-body    { font-size: var(--t-body); line-height: 1.55; }
.t-meta    { font-size: var(--t-meta); line-height: 1.4; color: var(--ink-2); }
.t-mono    { font-family: var(--font-mono); font-size: var(--t-mono); letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
.ink-2     { color: var(--ink-2); }
.ink-3     { color: var(--ink-3); }

/* ── App shell ───────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "nav header"
    "nav main";
  height: 100dvh;
  overflow: hidden;
}
.header  { grid-area: header; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--s-5); padding: 0 var(--s-6); background: var(--bg-1); }
.nav     { grid-area: nav; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: var(--s-4) var(--s-3); gap: var(--s-1); overflow-y: auto; background: var(--bg-1); }
.main    { grid-area: main; overflow-y: auto; }

/* ── Header ──────────────────────────────────────────────────── */
.brand { font-weight: 800; letter-spacing: 6px; font-size: 16px; padding-left: 4px; }
.brand .dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; display: inline-block; margin-left: 8px; }
.search-wrap {
  flex: 0 1 420px; height: 36px; display: flex; align-items: center; gap: var(--s-2);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-2);
  padding: 0 var(--s-3); transition: border-color var(--t-base) var(--ease);
}
.search-wrap:focus-within { border-color: var(--line-2); }
.search-wrap input { flex: 1; background: none; border: 0; outline: 0; font-size: var(--t-body); color: var(--ink); }
.search-wrap input::placeholder { color: var(--ink-3); }
.search-wrap kbd {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--bg-3); color: var(--ink-3); border: 1px solid var(--line);
}
.search-scope { font-size: var(--t-meta); color: var(--ink-3); padding-right: var(--s-2); border-right: 1px solid var(--line); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-2);
  color: var(--ink-2); position: relative; transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn[aria-label]::after { /* tooltip on hover via title attr; kept simple */ }
.icon-btn .badge-dot { position: absolute; top: 7px; right: 8px; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

/* ── Type-card (Create view) ─────────────────────────────────── */
.type-card { transition: border-color var(--t-base) var(--ease), background var(--t-base) var(--ease); position: relative; }
.type-card.is-active { border-color: var(--accent); background: var(--accent-tint-1); }
.type-card.is-active strong { color: var(--ink); }

/* ── Accent swatch picker ───────────────────────────────────── */
.accent-picker { display: flex; align-items: center; gap: 6px; padding: 0 var(--s-2); border-right: 1px solid var(--line); margin-right: var(--s-2); height: 36px; }
.accent-swatch {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line-2); cursor: pointer;
  position: relative; transition: transform var(--t-base) var(--ease);
}
.accent-swatch:hover { transform: scale(1.15); }
.accent-swatch.is-active::after {
  content: ''; position: absolute; inset: -3px;
  border: 1px solid var(--ink); border-radius: 50%;
}
.accent-swatch[data-accent="green"]  { background: #34C759; }
.accent-swatch[data-accent="yellow"] { background: #D5FF5A; }
.accent-swatch[data-accent="blue"]   { background: #007AFF; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #2A2832, #15141A);
  border: 1px solid var(--line-2); display: grid; place-items: center; font-size: var(--t-meta); font-weight: 600; color: var(--ink-2);
}

/* ── Nav ─────────────────────────────────────────────────────── */
.nav-section-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--ink-3);
  padding: var(--s-4) var(--s-3) var(--s-2); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  height: 36px; padding: 0 var(--s-3); border-radius: var(--r-2);
  font-size: var(--t-body); color: var(--ink-2);
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.is-active { background: var(--bg-2); color: var(--ink); }
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-item .nav-icon { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; transition: color var(--t-base) var(--ease); }
.nav-item .nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }
.nav-item .live-pulse { width: 6px; height: 6px; background: var(--live); border-radius: 50%; margin-left: auto; box-shadow: 0 0 8px var(--live); animation: pulse 2s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.nav-divider { height: 1px; background: var(--line); margin: var(--s-3) var(--s-2); }
.nav-spacer  { flex: 1; }
.nav-foot    { padding: var(--s-3); display: flex; align-items: center; gap: var(--s-3); }
.nav-foot .avatar { width: 28px; height: 28px; }
.nav-foot .me { font-size: var(--t-meta); color: var(--ink-2); }
.nav-foot .me strong { display: block; color: var(--ink); font-size: var(--t-body); font-weight: 600; }

/* ── Page ────────────────────────────────────────────────────── */
.page { padding: var(--s-7) var(--s-7) var(--s-9); max-width: var(--container); margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-5); margin-bottom: var(--s-7); }
.page-title-block .crumb { font-family: var(--font-mono); font-size: var(--t-mono); color: var(--ink-3); margin-bottom: var(--s-2); }
.page-title-block h1 { font-size: var(--t-h1); font-weight: 700; letter-spacing: -.015em; }
.page-title-block .sub { font-size: var(--t-body); color: var(--ink-2); margin-top: var(--s-2); max-width: var(--reading); }
.page-actions { display: flex; gap: var(--s-2); align-items: center; }

/* ── Surfaces ────────────────────────────────────────────────── */
.surface {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-3);
  padding: var(--s-5);
}
.surface-quiet { background: transparent; border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); }
.surface-tint  { background: var(--accent-glow); border: 1px solid var(--accent-tint-4); border-radius: var(--r-3); padding: var(--s-5); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4); border-radius: var(--r-2);
  font-size: var(--t-body); font-weight: 500;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  border: 1px solid transparent; white-space: nowrap;
}
.btn-primary    { background: var(--accent); color: var(--accent-on); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary  { background: var(--bg-2); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost      { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-danger     { color: var(--critical); border-color: rgba(255,92,92,0.3); }
.btn-danger:hover { background: rgba(255,92,92,0.08); }
.btn-sm         { height: 30px; padding: 0 var(--s-3); font-size: var(--t-meta); border-radius: var(--r-1); }
.btn-lg         { height: 44px; padding: 0 var(--s-5); font-size: var(--t-lead); border-radius: var(--r-2); }
.btn:disabled   { opacity: .4; cursor: not-allowed; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin-bottom: var(--s-6); }
.tab {
  padding: var(--s-3) var(--s-4); font-size: var(--t-body); color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { color: var(--ink-3); margin-left: var(--s-2); font-family: var(--font-mono); font-size: 11px; }

/* ── Pills (filters) ──────────────────────────────────────────── */
.pills { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pill {
  padding: 6px var(--s-3); border: 1px solid var(--line); border-radius: var(--r-pill);
  font-size: var(--t-meta); color: var(--ink-2); transition: all var(--t-base) var(--ease);
}
.pill:hover { border-color: var(--line-2); color: var(--ink); }
.pill.is-active { background: var(--ink); color: var(--bg-0); border-color: var(--ink); }

/* ── Inputs ──────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label { font-size: var(--t-meta); color: var(--ink-2); }
.field .help { font-size: var(--t-meta); color: var(--ink-3); }
.input, .textarea, .select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-2);
  padding: 10px 12px; font-size: var(--t-body); color: var(--ink); width: 100%;
  transition: border-color var(--t-base) var(--ease);
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ink-3); }
.textarea { min-height: 100px; resize: vertical; line-height: 1.55; }

/* ── Toggle ──────────────────────────────────────────────────── */
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { position: absolute; inset: 0; background: var(--bg-3); border-radius: 999px; transition: background var(--t-base) var(--ease); }
.toggle .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--ink-2); border-radius: 50%; transition: transform var(--t-base) var(--ease), background var(--t-base) var(--ease); }
.toggle input:checked ~ .track { background: var(--accent); }
.toggle input:checked ~ .thumb { transform: translateX(16px); background: var(--bg-0); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.badge-accent  { background: var(--accent-glow); color: var(--accent); }
.badge-quiet   { background: var(--bg-3); color: var(--ink-2); }
.badge-gold    { background: rgba(229,184,92,0.10); color: var(--gold); }
.badge-live    { background: rgba(74,222,128,0.10); color: var(--live); }
.badge-live::before { content: ''; width: 5px; height: 5px; background: var(--live); border-radius: 50%; box-shadow: 0 0 6px var(--live); }

/* ── Card patterns ───────────────────────────────────────────── */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-5); transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease); }
.card-hover:hover { border-color: var(--line-2); }
.card-link:hover { border-color: var(--line-2); transform: translateY(-1px); }

/* ── Ziion Creator Pass ──────────────────────────────────────── */
.zi-pass-wrap {
  display: grid;
  gap: var(--s-4);
  max-width: 560px;
}
.zi-pass-frame {
  background: #111510;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 28px 70px rgba(17,21,16,0.24);
}
.zi-pass-card {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.58 / 1;
  min-height: 260px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.72);
  background:
    radial-gradient(110% 70% at 50% 46%, rgba(255,224,92,0.80), rgba(255,224,92,0.18) 42%, transparent 62%),
    linear-gradient(180deg, #A8D7D2 0%, #E4C868 46%, #E98550 76%, #C84A48 100%);
  color: #FFFDF4;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.66),
    inset 0 -24px 48px rgba(55,18,16,0.18);
}
.zi-pass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.62'/%3E%3C/svg%3E");
}
.zi-pass-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.55), transparent 22%, transparent 78%, rgba(255,255,255,0.22)),
    radial-gradient(140% 90% at 0% 0%, rgba(255,255,255,0.34), transparent 52%);
  pointer-events: none;
}
.zi-pass-top,
.zi-pass-bottom {
  position: absolute;
  left: clamp(18px, 5%, 30px);
  right: clamp(18px, 5%, 30px);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-shadow: 0 1px 14px rgba(48,24,10,0.24);
}
.zi-pass-top { top: 22px; }
.zi-pass-bottom { bottom: 20px; color: rgba(255,253,244,0.82); }
.zi-pass-title {
  position: absolute;
  z-index: 1;
  left: clamp(24px, 7%, 44px);
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-serif);
  font-size: clamp(42px, 7vw, 76px);
  line-height: .95;
  letter-spacing: -.035em;
  font-weight: 500;
  text-shadow: 0 2px 18px rgba(60,20,12,0.18);
}
.zi-pass-brand {
  position: absolute;
  z-index: 1;
  right: clamp(22px, 7%, 42px);
  top: 50%;
  transform: translateY(-44%);
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  font-family: var(--font-label);
  font-weight: 800;
  letter-spacing: .18em;
  line-height: 1;
  text-transform: uppercase;
}
.zi-pass-brand strong {
  display: block;
  font-size: clamp(16px, 2.1vw, 24px);
}
.zi-pass-brand span {
  display: block;
  max-width: 120px;
  font-size: 9px;
  color: rgba(255,253,244,0.76);
  letter-spacing: .16em;
}
.zi-pass-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,0.48);
  border-radius: var(--r-pill);
  background: rgba(17,21,16,0.16);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  backdrop-filter: blur(12px) saturate(120%);
}
.zi-pass-ledger {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--line);
}
.zi-pass-row {
  display: grid;
  grid-template-columns: minmax(112px, .8fr) 1fr auto;
  align-items: center;
  gap: var(--s-3);
  padding: 12px 14px;
  background: var(--glass-bg);
}
.zi-pass-row-k {
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.zi-pass-row-v {
  color: var(--ink);
  font-weight: 600;
}
.zi-pass-row-s {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── Stat (Kanso — one number, one delta) ───────────────────── */
.stat { display: flex; flex-direction: column; gap: var(--s-1); }
.stat .stat-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--ink-3); text-transform: uppercase; }
.stat .stat-num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .stat-delta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); }
.stat .stat-delta.up { color: var(--live); }
.stat .stat-delta.down { color: var(--critical); }

/* ── Empty state (Shizen — anticipation, not labor) ──────────── */
.empty { text-align: center; padding: var(--s-9) var(--s-5); max-width: 480px; margin: 0 auto; }
.empty .icon { width: 48px; height: 48px; margin: 0 auto var(--s-4); color: var(--ink-3); }
.empty h3 { font-size: var(--t-h3); margin-bottom: var(--s-2); }
.empty p { color: var(--ink-2); margin-bottom: var(--s-5); }

/* ── Loading skeleton (Yūgen — soft suggestion) ──────────────── */
.skel { background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; border-radius: var(--r-2); animation: skel 1.4s var(--ease) infinite; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-line { height: 12px; }
.skel-block { height: 80px; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: var(--s-5); right: var(--s-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.toast { background: var(--bg-3); border: 1px solid var(--line-2); padding: var(--s-3) var(--s-4); border-radius: var(--r-2); font-size: var(--t-body); pointer-events: auto; box-shadow: var(--shadow-2); animation: toast-in var(--t-reveal) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: var(--z-modal); display: grid; place-items: center; backdrop-filter: blur(8px); }
.modal { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-3); padding: var(--s-7); min-width: 380px; max-width: 560px; box-shadow: var(--shadow-2); }
.modal h3 { font-size: var(--t-h3); margin-bottom: var(--s-3); }
.modal .modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-6); }

/* ── Section header ──────────────────────────────────────────── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s-4); }
.section-head h2 { font-size: var(--t-h3); font-weight: 600; }
.section-head .section-sub { font-size: var(--t-meta); color: var(--ink-3); }

/* ── Grid utilities ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-5 > * + * { margin-top: var(--s-5); }
.stack-7 > * + * { margin-top: var(--s-7); }

/* ── Reading column ──────────────────────────────────────────── */
.reading { max-width: var(--reading); }

/* ── Mobile collapse ─────────────────────────────────────────── */
@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr 56px;
    grid-template-areas: "header" "main" "mobnav";
  }
  .nav { display: none; }
  .mobnav { grid-area: mobnav; display: flex; border-top: 1px solid var(--line); background: var(--bg-1); }
  .mobnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-3); font-size: 10px; }
  .mobnav a.is-active { color: var(--accent); }
  .mobnav svg { width: 18px; height: 18px; }
  .search-wrap { display: none; }
  .page { padding: var(--s-5) var(--s-4) var(--s-9); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 881px) { .mobnav { display: none; } }

/* ── Mobile-specific layout adjustments ──────────────────────── */
@media (max-width: 880px) {
  .surface-tint, .surface { padding: var(--s-4); }
  /* Stack horizontal flex containers in surfaces */
  .surface-tint[style*="display:flex"], .surface[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { justify-content: flex-start; flex-wrap: wrap; }
  .t-h1 { font-size: 26px; }
  .t-h2 { font-size: 20px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .stat .stat-num { font-size: 24px; }
  .zi-pass-row { grid-template-columns: 1fr; align-items:start; gap: 4px; }
}

/* ── Visually hidden ─────────────────────────────────────────── */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ════════════════════════════════════════════════════════════════════
   LIBRARY — YouTube/Netflix row-scroll style on Shibui foundation
   ════════════════════════════════════════════════════════════════════ */
.lib-hero {
  position: relative;
  border-radius: var(--r-3);
  overflow: hidden;
  margin-bottom: var(--s-7);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-tint-2), rgba(0,0,0,0.4)), linear-gradient(135deg, var(--bg-3), var(--bg-2));
  min-height: 280px;
  display: flex; align-items: flex-end;
  padding: var(--s-7);
}
.lib-hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 20%, var(--accent-tint-2), transparent 60%);
  pointer-events: none;
}
.lib-hero .hero-body { position: relative; z-index: 1; max-width: 540px; }
.lib-hero .hero-mono { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; margin-bottom: var(--s-3); }
.lib-hero h2 { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-bottom: var(--s-2); }
.lib-hero .hero-meta { color: var(--ink-2); margin-bottom: var(--s-4); }
.lib-hero .hero-progress { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; margin-bottom: var(--s-5); max-width: 400px; }
.lib-hero .hero-progress > span { display: block; height: 100%; background: var(--accent); }
.lib-hero .hero-actions { display: flex; gap: var(--s-2); position: relative; z-index: 1; }

.lib-row { margin-bottom: var(--s-7); }
.lib-row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s-3); padding: 0 var(--s-1); }
.lib-row-head h3 { font-size: 18px; font-weight: 600; }
.lib-row-head h3 .row-count { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); letter-spacing: .1em; margin-left: var(--s-2); }

.lib-scroll {
  display: flex; gap: var(--s-3);
  overflow-x: auto; padding-bottom: var(--s-2);
  scrollbar-width: thin; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.lib-scroll::-webkit-scrollbar { height: 6px; }
.lib-scroll::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
.lib-scroll::-webkit-scrollbar-track { background: transparent; }

.lib-card {
  flex: 0 0 240px; scroll-snap-align: start;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-2);
  overflow: hidden; transition: transform var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  text-decoration: none; color: inherit; display: block;
  position: relative;
}
.lib-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.lib-card.is-mine { border-left: 2px solid var(--accent); }
.lib-card .thumb {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-4));
  position: relative; display: grid; place-items: center;
  color: rgba(255,255,255,0.18); font-size: 28px;
}
.lib-card .thumb .play {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  display: grid; place-items: center; color: #fff;
  opacity: 0; transition: opacity var(--t-base) var(--ease);
}
.lib-card:hover .thumb .play { opacity: 1; }
.lib-card .thumb .runtime {
  position: absolute; bottom: 8px; right: 8px;
  font-family: var(--font-mono); font-size: 10px;
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 2px 6px; border-radius: 4px; letter-spacing: .04em;
}
.lib-card .thumb .progress-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,0.12);
}
.lib-card .thumb .progress-bar > span { display: block; height: 100%; background: var(--accent); }
.lib-card .body { padding: 12px 14px; }
.lib-card .body .ti { font-size: 14px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.lib-card .body .meta { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); letter-spacing: .04em; }

/* Top-10 ranked list — Netflix-style numerals */
.lib-top10 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-2); margin-top: var(--s-4); }
.lib-top10 li { display: flex; align-items: center; gap: var(--s-3); padding: 10px 12px; border-radius: 10px; transition: background var(--t-base) var(--ease); }
.lib-top10 li:hover { background: var(--bg-2); }
.lib-top10 .rank {
  font-family: var(--font-serif); font-size: 38px; font-weight: 500;
  color: rgba(255,255,255,0.10); width: 36px; text-align: center; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.lib-top10 .body { flex: 1; min-width: 0 }
.lib-top10 .ti { font-size: 14px; font-weight: 600; }
.lib-top10 .meta { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); margin-top: 2px; }

@media (max-width: 880px) {
  .lib-hero { min-height: 220px; padding: var(--s-5); }
  .lib-hero h2 { font-size: 24px; }
  .lib-card { flex: 0 0 180px; }
  .lib-top10 { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════════════════════
   POST COMPONENT — applies the /threads forensic audit (April 2026)
   • No serif headline. The body IS the post (Threads/X/Bluesky pattern).
   • Hairline separator + 24px outside-card air. The gap IS the rhythm (Ma).
   • Upvote-only Charge (research: Cheng et al. Stanford 2014).
   • Mono caps action labels. Reply lead, Save right-aligned.
   • Link-card unfurl for URL-only posts.
   • Lead variant for thoughtful posts: Fraunces 18.5/1.5.
   • ICU plural via Intl.PluralRules in views/threads.js.
   ════════════════════════════════════════════════════════════════════ */
.post {
  padding: var(--s-5) var(--s-4);          /* 24 × 16 */
  border-bottom: 1px solid var(--line);    /* hairline, NOT a card box */
  background: transparent;
  transition: background var(--t-base) var(--ease);
}
.post:hover { background: rgba(255,255,255,0.015); }

.post__head {
  display: flex; flex-wrap: nowrap; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.post__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #2A2832, #15141A);
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  color: var(--ink-2);
}
.post__byline { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; flex-wrap: wrap; }
.post__author { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.post__dot { color: var(--ink-4); }
.post__ago {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-3); letter-spacing: .12em; text-transform: uppercase;
  white-space: nowrap;
}
.post__scope {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 9.5px;
  color: var(--gold); letter-spacing: .2em; text-transform: uppercase;
  border: 1px solid rgba(229,184,92,0.25);
  border-radius: 3px;
  padding: 2px 7px; white-space: nowrap;
}

/* Body — the post IS the headline. No <h2>, no display serif. */
.post__body {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  letter-spacing: -.003em;
  max-width: 64ch;
}
.post__body--lead {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 18.5px;
  line-height: 1.5;
}
.post__body + .post__body--secondary {
  margin-top: var(--s-3);
  font-size: 14px;
  color: var(--ink-2);
}

/* Link unfurl — replaces raw URLs */
.post__linkcard {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  text-decoration: none;
  color: var(--ink);
  transition: border-color var(--t-base) var(--ease);
}
.post__linkcard:hover { border-color: var(--line-2); }
.post__linkcard .thumb {
  width: 40px; height: 40px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-tint-4), rgba(0,0,0,0.4));
}
.post__linkcard .ti  { font-size: 13px; font-weight: 500; color: var(--ink); }
.post__linkcard .url { font-family: var(--font-mono); font-size: 10px; color: var(--accent); margin-top: 2px; letter-spacing: .02em; }

/* Action row — mono caps, counts in heavy ink, upvote-only Charge */
.post__footer {
  display: flex; align-items: center; gap: var(--s-5);
  margin-top: var(--s-4);
  color: var(--ink-3);
}
.post__action {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase;
  min-height: 32px;             /* visible target — keep 44 on mobile via padding */
  padding: 6px 0;
  background: none; border: 0; cursor: pointer; color: inherit;
  transition: color var(--t-base) var(--ease);
}
.post__action:hover { color: var(--ink); }
.post__action b { color: var(--ink); font-weight: 500; }
.post__action--charge[aria-pressed="true"] { color: var(--accent); }
.post__action--charge[aria-pressed="true"] b { color: var(--accent); }
.post__action--save { margin-left: auto; color: var(--ink-4); padding: 6px; }
.post__action--save[aria-pressed="true"] { color: var(--accent); }
.post__action svg { width: 14px; height: 14px; }

/* Composer — single-line, body-first */
.composer {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.composer .composer-input {
  flex: 1; background: none; border: 0; outline: 0;
  font-family: var(--font-serif); font-style: italic;
  font-size: 15px; color: var(--ink-3);
}
.composer .composer-send {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .22em; color: var(--accent); text-transform: uppercase;
  background: none; border: 0; cursor: pointer; padding: 8px 4px;
}

/* Filter row — minimal, scope right-aligned */
.feed-filter {
  display: flex; align-items: baseline; gap: var(--s-6);
  padding: 6px var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.feed-filter .ff-tab {
  font-size: 13px; color: var(--ink-3); position: relative;
  padding-bottom: 2px;
}
.feed-filter .ff-tab.is-active { color: var(--ink); }
.feed-filter .ff-tab.is-active::after {
  content: ''; position: absolute; left: 0; right: 60%; bottom: -8px;
  height: 1px; background: var(--accent);
}
.feed-filter .ff-scope {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  letter-spacing: .2em; text-transform: uppercase;
}
