/* SpaceKitty — single stylesheet. Mobile first; desktop tweaks at 900px. */

:root {
  color-scheme: dark;
  --bg: #0b0b10;
  --surface: #14141c;
  --surface-2: #1c1c27;
  --surface-3: #262634;
  --border: #2a2a3a;
  --text: #ececf3;
  --muted: #9797ad;
  --accent: #ff4f8b;
  --accent-2: #9b6bff;
  --accent-soft: rgba(255, 79, 139, 0.14);
  --star: #ffc94d;
  --danger: #ff5c5c;
  --success: #3ddc97;
  --warning: #ffb547;
  --radius: 14px;
  --radius-lg: 20px;
  --gutter: 16px;
  --topbar-h: 60px;
  --tabbar-h: calc(62px + env(safe-area-inset-bottom));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Pixelify Sans", var(--font);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--tabbar-h);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:hover { color: #fff; }
img, video { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.brand-mark { font-family: var(--font-brand); color: var(--accent); white-space: nowrap; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-3); color: #fff; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff3a7d; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 999px; background: transparent; color: var(--text);
  font-size: 1.15rem; cursor: pointer; transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.icon-btn:active { transform: scale(.92); }
.glass { background: rgba(10, 10, 16, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.glass:hover { background: rgba(10, 10, 16, .7); }

.field {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 16px; /* prevents iOS zoom on focus */
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-sm { width: auto; min-height: 36px; padding: 6px 10px; font-size: 0.9rem; border-radius: 999px; }
textarea.field { resize: vertical; }
.label { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.field-error { color: var(--danger); font-size: 0.85rem; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.stack { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.form-card { max-width: 560px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--gutter);
  background: rgba(11, 11, 16, .82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-brand); font-size: 1.25rem; }
.brand-name { display: none; }
.topbar-search, .mobile-search {
  position: relative; display: flex; align-items: center; flex: 1; max-width: 420px;
}
.topbar-search i, .mobile-search i { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.topbar-search input, .mobile-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 16px;
}
.topbar-search input:focus, .mobile-search input:focus { outline: none; border-color: var(--accent); }
.topbar-search { display: none; }
.mobile-search { max-width: none; margin-bottom: 14px; }
.topnav { display: none; }
.menu { position: relative; margin-left: auto; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700;
}
.avatar-sm { width: 32px; height: 32px; font-size: .85rem; flex: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-panel a, .menu-panel button, .link-list a, .link-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; font-size: .95rem;
}
.menu-panel a:hover, .menu-panel button:hover, .link-list a:hover, .link-list button:hover { background: var(--surface-3); }
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; background: var(--surface-3); color: var(--muted);
}
.role-moderator { background: rgba(155, 107, 255, .18); color: #c3a6ff; }
.role-admin { background: var(--accent-soft); color: var(--accent); }

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(11, 11, 16, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.tabbar a { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; }
.tabbar i { font-size: 1.25rem; }
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"] i { color: var(--accent); }

/* ---------- Page layout ---------- */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 18px var(--gutter) 40px; }
.page-wide { max-width: 1480px; padding-top: 0; }
.page-auth { display: grid; place-items: center; min-height: calc(100svh - var(--topbar-h) - var(--tabbar-h)); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.page-head-sub { margin-top: 32px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.toolbar .field-sm[type="search"] { flex: 1; min-width: 160px; }
.empty { display: grid; place-items: center; gap: 4px; padding: 60px 20px; text-align: center; color: var(--muted); }
.empty .brand-mark { font-size: 1.8rem; }
.loader { display: grid; place-items: center; padding: 28px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Chips ---------- */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.filter-row > .chips { flex-basis: 100%; }
.match-titles { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips-wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--surface-3); }
.chip.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-sm { padding: 3px 10px; font-size: .78rem; }

/* ---------- Thread & list cards ---------- */
.thread-grid, .list-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.thread-card, .list-card { display: block; min-width: 0; }
.thread-cover, .list-cover {
  position: relative; aspect-ratio: 4 / 5; overflow: hidden; border-radius: var(--radius);
  background: var(--surface-2);
}
.list-cover { display: grid; place-items: center; font-size: 2rem; color: var(--muted); }
.list-card-fav .list-cover { background: linear-gradient(135deg, rgba(255, 201, 77, .25), rgba(255, 79, 139, .25)); color: var(--star); }
.thread-card:hover .thumb, .list-card:hover .thumb { transform: scale(1.04); }
.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); background: var(--surface-2); }
.thumb.broken { opacity: 0; }
.thumb-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 1.6rem; }
.count-pill, .kind-badge {
  position: absolute; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff;
}
.count-pill { left: 8px; bottom: 8px; }
.kind-badge { right: 8px; top: 8px; }
.thread-meta { padding: 8px 2px 0; }
.thread-meta h3 { font-size: .95rem; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-meta p { margin: 2px 0 0; font-size: .8rem; }
.card-meta {
  display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden;
  color: var(--muted); white-space: nowrap;
}
.card-meta .stars { margin: 0; font-size: .72rem; flex: none; }
.card-meta .stars + time::before { content: "·"; margin-right: 6px; }
.card-meta time { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Stage: the header player ---------- */
.stage-wrap { margin: 0 calc(-1 * var(--gutter)); }
.stage {
  position: relative; overflow: hidden; outline: none;
  height: calc(100svh - var(--topbar-h) - var(--tabbar-h) - 64px);
  min-height: 320px;
  background: #000;
  isolation: isolate;
}
.stage-layer { position: absolute; inset: 0; opacity: 0; transition: opacity .45s var(--ease); z-index: 0; }
.stage-layer.is-active { opacity: 1; z-index: 1; }
.media-fit { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.media-backdrop {
  position: absolute; inset: -8%; background-size: cover; background-position: center;
  filter: blur(36px) brightness(.45) saturate(1.2); transform: scale(1.1);
}
.stage-center { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none; }
.stage-center > * { grid-area: 1 / 1; }
.stage-bigplay {
  pointer-events: auto; display: grid; place-items: center; width: 76px; height: 76px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #fff; font-size: 2.4rem; cursor: pointer; transition: opacity .2s, transform .2s;
}
.stage.is-playing .stage-bigplay { opacity: 0; transform: scale(.8); pointer-events: none; }
.stage-error { padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, .7); font-size: .85rem; }

.stage-top, .stage-bottom, .stage-rail { position: absolute; z-index: 4; transition: opacity .3s; }
.stage-top {
  top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.stage-title { display: flex; flex-direction: column; min-width: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.stage-counter { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-thread { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-exit { display: none; }
.stage-rail { right: 10px; bottom: 96px; display: grid; gap: 12px; }
.rail-btn {
  display: grid; justify-items: center; gap: 2px; border: 0; background: none; color: #fff; cursor: pointer;
  font-size: .72rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.rail-btn i {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-size: 1.35rem;
  background: rgba(10, 10, 16, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .15s var(--ease), color .15s;
}
.rail-btn:active i { transform: scale(.88); }
.rail-btn[data-act="like"][aria-pressed="true"] i { color: var(--accent); }
.rail-btn[data-act="favorite"][aria-pressed="true"] i { color: var(--star); }
.rail-btn[data-act="list"].is-saved i { color: var(--accent-2); }
.stage-bottom { left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.progress { position: relative; height: 4px; margin: 0 4px 8px; border-radius: 4px; background: rgba(255, 255, 255, .2); overflow: hidden; cursor: pointer; }
.progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 4px; }
.stage-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ctrl-group { display: flex; align-items: center; gap: 6px; }
.ctrl-select {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px; border-radius: 999px;
  background: rgba(10, 10, 16, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: .85rem;
}
.ctrl-select select { border: 0; background: transparent; cursor: pointer; }
.ctrl-select select option { background: var(--surface-2); }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(10, 10, 16, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.segmented button { width: 36px; height: 34px; border: 0; border-radius: 999px; background: none; color: rgba(255, 255, 255, .7); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: rgba(255, 255, 255, .18); color: #fff; }

/* Auto-hide the chrome while something plays and the pointer is still */
.stage.is-idle.is-playing .stage-top,
.stage.is-idle.is-playing .stage-bottom,
.stage.is-idle.is-playing .stage-rail { opacity: 0; pointer-events: none; }
.stage.is-idle.is-playing { cursor: none; }

/* Mode: fill the page (site chrome stays, the player takes the rest of the viewport) */
body.stage-fill { overflow: hidden; }
.stage[data-mode="page"] {
  position: fixed; z-index: 45; left: 0; right: 0; top: var(--topbar-h); bottom: var(--tabbar-h);
  height: auto; min-height: 0;
}
/* Mode: cinema. The stage element itself goes full screen, so switching between
   videos, images and GIFs happens inside it without leaving full screen. */
.stage[data-mode="cinema"] { height: 100%; }
.stage:fullscreen { width: 100vw; height: 100vh; }
.stage.is-pseudo-fullscreen { position: fixed; inset: 0; z-index: 200; height: auto; min-height: 0; }
.stage[data-mode="page"] .stage-exit, .stage[data-mode="cinema"] .stage-exit, .stage[data-mode="popout"] .stage-exit { display: grid; }
/* Mode: pop-out. Floats over the page; the page underneath keeps its scroll position. */
.stage[data-mode="popout"] {
  position: fixed; z-index: 95; inset: 0; height: auto; min-height: 0; border-radius: 0;
  animation: pop-in .22s var(--ease);
}
.stage-backdrop { position: fixed; inset: 0; z-index: 94; background: rgba(0, 0, 0, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }

/* ---------- Thread info ---------- */
.thread-info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 16px; padding: 18px 0 8px; }
.thread-head { flex: 1 1 420px; min-width: 0; display: grid; gap: 6px; }
.thread-head h1 { overflow-wrap: anywhere; }
/* Facts separated by dots; the dot that would start a wrapped line is clipped off. */
.facts-clip { overflow: hidden; }
.thread-facts { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; margin: 0 0 0 -16px; color: var(--muted); font-size: .85rem; }
.thread-facts > * { position: relative; display: inline-flex; align-items: center; padding-left: 16px; }
.thread-facts > *::before { content: "·"; position: absolute; left: 5px; color: var(--muted); opacity: .6; }
.thread-facts > .rarity-badge { margin-left: 16px; padding-left: 8px; }
.thread-facts > .rarity-badge::before, .thread-facts > .rarity-badge + *::before { content: none; }
.thread-facts .stars { margin: 0; font-size: .85rem; }
.thread-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; flex: 0 1 auto; max-width: 100%; }
.thread-actions .btn { flex: none; }
.wide-only { display: none; }
.section-actions { flex-wrap: wrap; gap: 8px 12px; }
.thread-desc-wrap { flex-basis: 100%; }
.thread-desc-wrap .thread-desc { margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.thread-desc-wrap.is-open .thread-desc { -webkit-line-clamp: unset; display: block; }
.link-btn { padding: 2px 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: .85rem; cursor: pointer; }
.thread-tags { flex-basis: 100%; margin: 0; }
.thread-info-main { flex: 1 1 420px; min-width: 0; }
.thread-info h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
.thread-desc { margin: 8px 0 10px; color: #c9c9d8; overflow-wrap: anywhere; max-width: 75ch; }
.thread-info .chips { margin: 8px 0; }
.thread-info-actions { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; }

/* ---------- Media grid ---------- */
.media-section { padding-top: 10px; }
.section-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0 12px; }
.section-actions { display: flex; align-items: center; gap: 12px; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; margin: 0 calc(-1 * var(--gutter)); }
.tile {
  position: relative; aspect-ratio: 3 / 4; overflow: hidden; padding: 0; border: 0; cursor: pointer;
  background: var(--surface-2); color: #fff;
}
.tile .thumb { transition: transform .4s var(--ease), opacity .2s; }
.tile:hover .thumb { transform: scale(1.04); }
.tile.is-current { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.is-current::after {
  content: "\F4F4"; font-family: "bootstrap-icons"; position: absolute; left: 8px; bottom: 6px; font-size: 1rem;
  color: var(--accent); text-shadow: 0 1px 3px #000;
}
.tile.is-hidden .thumb { opacity: .35; }
.tile-video, .cover-video { pointer-events: none; }
.repeat-btn.is-on { color: var(--accent); }

/* Volume: speaker button plus a slider (the slider is hidden on phones, which ignore page volume). */
.volume-ctrl { display: inline-flex; align-items: center; border-radius: 999px; }
.volume-ctrl .icon-btn:hover { background: transparent; }
.volume-slider { display: none; width: 84px; height: 4px; margin: 0 12px 0 0; --fill: 100%;
  -webkit-appearance: none; appearance: none; border-radius: 4px; cursor: pointer;
  background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, .25) var(--fill)); }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(0, 0, 0, .25); }
.volume-slider::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
.volume-slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) { .volume-slider { display: block; } }
.tile-flag { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .7); font-size: .7rem; font-weight: 700; }
.tile-check {
  position: absolute; right: 8px; bottom: 8px; display: none; place-items: center; width: 26px; height: 26px;
  border: 2px solid #fff; border-radius: 50%; background: rgba(0, 0, 0, .35); font-size: .9rem;
}
.is-selecting .tile-check { display: grid; }
.is-selecting .tile.is-selected .tile-check { background: var(--accent); border-color: var(--accent); }
.is-selecting .tile.is-selected .thumb { transform: scale(.92); border-radius: 10px; }
.tile-fav { position: absolute; left: 8px; bottom: 6px; color: var(--star); font-size: .9rem; text-shadow: 0 1px 3px #000; }
.tile.is-current .tile-fav { left: 28px; }

.select-bar {
  position: fixed; z-index: 60; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + 8px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: rgba(28, 28, 39, .96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
}
.select-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ---------- Sheets (dialogs): bottom sheet on phones, modal on desktop ---------- */
.sheet {
  width: 100%; max-width: 100%; max-height: 85svh; margin: auto 0 0; padding: 0 0 env(safe-area-inset-bottom);
  border: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface-2); color: var(--text);
}
.sheet[open] { animation: sheet-up .25s var(--ease); }
.sheet::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-grip { width: 40px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: var(--surface-3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 6px 18px; }
.sheet-body { display: grid; gap: 12px; padding: 6px 18px 18px; }
.sheet-body > * { min-width: 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; min-width: 0; }
.sheet-actions .btn { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list-options, .thread-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 46svh; overflow-y: auto; }
.list-options label, .thread-options button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid transparent;
  border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer;
}
.list-options input { width: 20px; height: 20px; accent-color: var(--accent); }
.list-options .muted, .thread-options .muted { padding: 10px 4px; }
.thread-options button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.thread-options .tid { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 16px; }

/* ---------- Feed (TikTok-style) ---------- */
body.is-feed { padding: 0; overflow: hidden; background: #000; }
.feed-main { margin: 0; }
.feed {
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain; outline: none;
  scroll-snap-type: y mandatory; scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.slide {
  position: relative; height: 100vh; height: 100dvh; overflow: hidden;
  scroll-snap-align: start; scroll-snap-stop: always; background: #000;
}
.slide-media { position: absolute; inset: 0; }
.slide-info {
  position: absolute; z-index: 3; left: 0; right: 76px; bottom: 0;
  padding: 40px 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.slide-info a { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; max-width: 100%; }
.slide-info a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slide-info p { margin: 2px 0 0; font-size: .82rem; color: rgba(255, 255, 255, .75); }
.slide-rail { position: absolute; z-index: 3; right: 10px; bottom: calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.slide-progress { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .15); }
.slide-progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.slide-paused {
  position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 4rem; color: rgba(255, 255, 255, .8); opacity: 0; transition: opacity .2s;
}
.slide.is-paused .slide-paused { opacity: 1; }
.heart-burst {
  position: absolute; z-index: 5; font-size: 6rem; color: var(--accent); pointer-events: none;
  transform: translate(-50%, -50%); animation: burst .8s var(--ease) forwards;
}
@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
.feed-top {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
  pointer-events: none;
}
.feed-top > * { pointer-events: auto; }
.feed-title { flex: 1; min-width: 0; display: flex; flex-direction: column; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.feed-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-title span { font-size: .78rem; font-variant-numeric: tabular-nums; }
[data-feed-auto][aria-pressed="true"] { background: var(--accent); }
.feed-sort { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px; border-radius: 999px; font-size: .85rem; flex: none; }
.feed-sort select { max-width: 7.5em; border: 0; background: transparent; color: #fff; font-weight: 600; cursor: pointer; }
.feed-sort select option { background: var(--surface-2); }
.feed-empty { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; }
.feed-empty .brand-mark { font-size: 2rem; }

/* ---------- Lists, logs, users, account ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { display: grid; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat strong { font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.section-title { margin: 22px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.link-list { display: grid; gap: 2px; padding: 6px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.log-list, .user-list { display: grid; gap: 6px; }
.log-item { border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.log-item summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.log-item summary::-webkit-details-marker { display: none; }
.log-item p { margin: 0; padding: 0 14px 12px; color: #c9c9d8; overflow-wrap: anywhere; }
.log-name { overflow-wrap: anywhere; }
.log-meta { grid-column: 2; }
.log-type { padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; text-transform: uppercase; background: var(--surface-3); }
.log-info { color: #7cc4ff; }
.log-warning { color: var(--warning); }
.log-error, .log-critical { color: var(--danger); }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.user-main { flex: 1; min-width: 0; display: grid; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 20px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 16px; }
.auth-brand { display: grid; justify-items: center; gap: 4px; text-align: center; }
.auth-brand .brand-mark { font-size: 1.8rem; }
.auth-foot { margin: 0; text-align: center; }
.auth-foot a { color: var(--accent); }

/* ---------- Flash & toast ---------- */
.flash-stack { position: fixed; z-index: 300; top: calc(var(--topbar-h) + 8px); left: var(--gutter); right: var(--gutter); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.flash { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.flash-stack .flash { pointer-events: auto; max-width: 520px; }
.form-card .flash { margin-bottom: 14px; }
.flash-success { border-color: rgba(61, 220, 151, .4); }
.flash-warning { border-color: rgba(255, 181, 71, .4); }
.flash-error { border-color: rgba(255, 92, 92, .5); }
.toast {
  position: fixed; z-index: 400; left: 50%; bottom: calc(var(--tabbar-h) + 18px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px;
  background: #fff; color: #111; font-weight: 600; font-size: .9rem;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
body.is-feed .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  :root { --gutter: 28px; --tabbar-h: 0px; }
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .brand-name { display: inline; }
  .topbar-search { display: flex; }
  .mobile-search { display: none; }
  .topnav { display: flex; gap: 4px; margin-left: auto; }
  .topnav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .9rem; }
  .topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
  .menu { margin-left: 4px; }
  .topbar .sound-toggle { margin-left: 4px; }
  h1 { font-size: 2rem; }

  .thread-grid { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 22px 16px; }
  .list-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px 16px; }

  .stage-wrap { margin: 18px 0 0; }
  .stage { height: clamp(380px, 68vh, 820px); border-radius: var(--radius-lg); }
  .stage[data-mode="page"], .stage[data-mode="cinema"], .stage.is-pseudo-fullscreen { border-radius: 0; }
  .thread-info h1 { font-size: 1.7rem; }

  .media-grid { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px; margin: 0; }
  .filter-row { flex-wrap: nowrap; }
  .filter-row > .chips { flex-basis: auto; }
  .tile { border-radius: 12px; }

  .select-bar { left: 50%; right: auto; bottom: 22px; transform: translateX(-50%); width: min(820px, calc(100% - 40px)); }
  .sheet { max-width: 460px; margin: auto; border-radius: var(--radius-lg); }
  .sheet-grip { display: none; }
  .toast { bottom: 28px; }

  .slide-info { left: 50%; right: auto; width: min(640px, 100%); transform: translateX(-50%); padding-bottom: 26px; }
  .slide-rail { right: max(24px, calc(50% - 440px)); bottom: 40px; }
  .feed-top { padding: 16px 24px; }
}

/* ---------- Columns control, sort direction, site settings ---------- */
.columns-control { display: none; }  /* phones use fixed 2/3-column grids */
.segmented-solid { background: var(--surface); border: 1px solid var(--border); backdrop-filter: none; }
.segmented-solid button { color: var(--muted); font-weight: 700; font-size: .85rem; }
.segmented-solid button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.segmented-label { display: inline-grid; place-items: center; padding: 0 6px 0 8px; color: var(--muted); }
.sort-form { display: flex; flex-wrap: wrap; gap: 6px; }
.sort-dir { min-height: 36px; }
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; }
.setting-row > span { display: inline-flex; align-items: center; gap: 10px; }
.topbar-login { margin-left: auto; }
.tabbar-3 { grid-template-columns: repeat(3, 1fr); }
.ip-hint { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .85rem; }
.ip-hint code { font-size: .9rem; color: var(--text); }

/* ---------- Avatars, badges ---------- */
.avatar { overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 20px; height: 20px; font-size: .6rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2.2rem; }
.menu summary { position: relative; }
.dot-badge, .count-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 800; line-height: 1;
}
.dot-badge { position: absolute; top: -4px; right: -6px; border: 2px solid var(--bg); }
.count-badge { margin-left: auto; }
.muted-badge { background: var(--surface-3); color: var(--muted); }
.sound-toggle[aria-pressed="true"] { color: var(--accent); }
.topbar .sound-toggle { margin-left: auto; }
.topbar .sound-toggle + .menu { margin-left: 0; }

/* Thread classes */
.rarity-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  background: rgba(0, 0, 0, .65); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.thread-cover .rarity-badge { position: absolute; left: 8px; top: 8px; }
.rarity-normal { --rarity: #a3a7b7; }
.rarity-epic { --rarity: #b98cff; }
.rarity-rare { --rarity: #4fc3ff; }
.rarity-legendary { --rarity: #ffb54d; }
.rarity-badge { color: var(--rarity); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rarity) 45%, transparent); }
.thread-card.rarity-legendary .thread-cover { box-shadow: 0 0 0 2px var(--rarity), 0 0 24px -6px var(--rarity); }
.thread-card.rarity-rare .thread-cover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--rarity) 70%, transparent); }
.locked-cover {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--rarity) 35%, transparent), transparent 70%), var(--surface-2);
  color: var(--rarity); font-size: 1.8rem;
}
.locked-cover span { font-size: .8rem; font-weight: 700; color: var(--text); }
.stars { color: var(--star); font-size: .78rem; letter-spacing: 1px; margin-right: 6px; white-space: nowrap; }
.thread-badges { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.thread-badges .stars { font-size: .95rem; }
.locked-card { width: 100%; max-width: 460px; display: grid; gap: 14px; justify-items: start; border-color: color-mix(in srgb, var(--rarity) 40%, var(--border)); }
.locked-card h1 { font-size: 1.4rem; overflow-wrap: anywhere; }
.locked-card p { margin: 0; }
.locked-card .stack, .locked-card .btn-block { width: 100%; }
.locked-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: color-mix(in srgb, var(--rarity) 18%, transparent); color: var(--rarity); font-size: 1.5rem; }

/* ---------- Home: tag filter panel (left) and content (right) ---------- */
.home-page { padding-top: 18px; }
.home-main { min-width: 0; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.toolbar-row .sort-form { margin-left: auto; }
.result-count { color: var(--muted); font-size: .9rem; font-weight: 600; margin-right: 4px; }
.btn.is-disabled { opacity: .35; pointer-events: none; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -4px 0 14px; }
.chip.is-in { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip.is-ex { background: rgba(255, 92, 92, .12); border-color: rgba(255, 92, 92, .6); color: var(--text); text-decoration: line-through; text-decoration-color: rgba(255, 92, 92, .8); }
.chip.is-ex i { text-decoration: none; }

.filter-panel {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
  padding: 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
}
.filter-panel-head { display: flex; align-items: center; gap: 8px; }
.filter-panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-right: auto; }
.filter-search { position: relative; display: flex; align-items: center; }
.filter-search i { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.filter-search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 16px; }
.filter-search input:focus { outline: none; border-color: var(--accent); }
.filter-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filter-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.seg-link { display: inline-grid; place-items: center; min-width: 44px; height: 30px; padding: 0 10px; border-radius: 999px; color: var(--muted); font-weight: 700; font-size: .82rem; }
.seg-link[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.tag-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px; display: grid; align-content: start; gap: 2px; scrollbar-width: thin; }
.tag-group { margin: 8px 0 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tag-group:first-child { margin-top: 0; }
.tag-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 4px; padding: 2px 2px 2px 8px; border-radius: 10px; }
.tag-row:hover { background: var(--surface-2); }
.tag-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; padding: 4px 0; }
.tag-count { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; padding-right: 4px; }
.tag-btn { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--muted); font-size: .85rem; }
.tag-btn:hover { background: var(--surface-3); color: var(--text); }
.tag-row.is-in { background: var(--accent-soft); }
.tag-row.is-in .tag-name { color: #fff; font-weight: 700; }
.tag-row.is-in .tag-in { background: var(--accent); color: #fff; }
.tag-row.is-ex { background: rgba(255, 92, 92, .1); }
.tag-row.is-ex .tag-name { text-decoration: line-through; color: #ffb3b3; }
.tag-row.is-ex .tag-ex { background: var(--danger); color: #fff; }

/* Phones: the panel is a bottom sheet behind the Filters button. */
.filter-panel { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; max-height: 82svh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; transform: translateY(105%); transition: transform .25s var(--ease); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
body.filters-open .filter-panel { transform: none; }
.filter-scrim { position: fixed; inset: 0; z-index: 69; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
body.filters-open .filter-scrim { opacity: 1; pointer-events: auto; }
body.filters-open { overflow: hidden; }

/* ---------- Home: banner rows & featured lists ---------- */
.banner-strip { margin-bottom: 14px; }
.banner-strip h2, .featured-lists h2 { display: flex; align-items: center; gap: 8px; }
.thread-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 42%); gap: 12px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; padding-bottom: 4px;
}
.thread-row::-webkit-scrollbar { display: none; }
.thread-row .thread-card { scroll-snap-align: start; }
.thread-row .thread-cover { aspect-ratio: 1 / 1; }
.featured-lists { margin-bottom: 18px; }
.list-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 42%); gap: 12px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.list-row::-webkit-scrollbar { display: none; }
.list-row .list-card { scroll-snap-align: start; }
.owner-inline { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.owner-inline:hover { color: var(--text); }
.owner-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); }
.owner-link:hover { color: var(--text); }

/* ---------- Profile & settings ---------- */
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin: 8px 0 22px; }
.profile-main { flex: 1; min-width: 200px; }
.profile-main p { margin: 4px 0 0; }
.profile-bio { color: #d0d0dc; max-width: 60ch; }
.settings-card { display: grid; gap: 16px; padding: 16px; }
.settings-card p { margin: 0; }
.avatar-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.avatar-edit .stack { gap: 8px; }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.request-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.request-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.request-list a { font-weight: 600; }
.status-pill { padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--surface-3); }
.status-pending { color: var(--warning); }
.status-approved { color: var(--success); }
.status-denied { color: var(--danger); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice-group { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 6px; }
.page-overrides { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.page-overrides summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.page-overrides[open] summary { margin-bottom: 10px; }

/* ---------- Admin panel ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)) 20px; padding: 0 var(--gutter) 2px; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count-badge { margin-left: 2px; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.task-card { display: grid; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: border-color .15s, transform .15s; }
.task-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.task-card i { font-size: 1.4rem; color: var(--accent); }
.task-card strong { font-size: 1.6rem; }
.task-card span { color: var(--muted); font-size: .88rem; }
.curate-list, .request-cards { display: grid; gap: 8px; margin-bottom: 16px; }
.banner-card { display: grid; gap: 12px; padding: 14px; margin-bottom: 12px; }
.banner-card.is-off { opacity: .6; }
.banner-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.banner-card-head .inline-form { flex: 1; min-width: 180px; }
.banner-card-head .inline-form input { font-weight: 700; }
.banner-threads { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.banner-threads li.muted { display: block; }
.banner-threads li { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.banner-threads .banner-thumb { position: relative; width: 54px; height: 54px; }
.thread-picker { position: relative; }
.thread-picker .field-sm { width: 100%; }
.picker-options { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); padding: 6px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.new-row-form { margin-top: 4px; }
.bulk-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.bulk-filters .field-sm { width: 100%; }
.bulk-selection { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.bulk-selection > span { margin-right: 4px; }
.bulk-layout { display: grid; gap: 16px; }
.bulk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bulk-row { display: grid; grid-template-columns: auto 56px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.bulk-row.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.bulk-check input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.bulk-thumb { position: relative; display: grid; place-items: center; width: 56px; height: 56px; overflow: hidden; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.bulk-thumb img, .bulk-thumb video { width: 100%; height: 100%; object-fit: cover; }
.bulk-main { display: grid; gap: 4px; min-width: 0; }
.bulk-main .rarity-badge { padding: 0 6px; font-size: .65rem; }
.bulk-main .stars { margin: 0; }
.bulk-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.bulk-actions h2 { font-size: 1rem; }
.tag-class-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.tag-class-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.tag-class-row:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.tag-class-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.tag-class-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tag-class-row .rarity-badge { font-size: .62rem; }
.bulk-actions { position: sticky; bottom: calc(var(--tabbar-h) + 8px); z-index: 5; }
.merge-warning { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 92, 92, .1); border: 1px solid rgba(255, 92, 92, .35); font-size: .88rem; }
.word-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.word-list li[data-word] { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.word-list li.is-dragging { opacity: .5; border-color: var(--accent); }
.drag-handle { color: var(--muted); cursor: grab; }
.word-suggestions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.word-add { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.word-add:hover { border-color: var(--accent); }
.word-add i { color: var(--accent); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.curate-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px 14px; align-items: center;
  padding: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.curate-row.is-dirty { border-color: var(--warning); }
.curate-row.is-saved { border-color: rgba(61, 220, 151, .5); }
.curate-thumb { position: relative; width: 64px; height: 64px; overflow: hidden; border-radius: 10px; background: var(--surface-2); grid-row: span 2; }
.curate-main { display: grid; gap: 4px; min-width: 0; }
.curate-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.curate-main .field-sm { width: 100%; }
.curate-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.star-input { display: inline-flex; }
.star-input button { padding: 2px; border: 0; background: none; color: var(--surface-3); font-size: 1.15rem; cursor: pointer; }
.star-input button.is-on { color: var(--star); }
.request-card { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.request-card.is-decided { opacity: .5; }
.request-card .owner-link { margin: 0; color: var(--text); }
.request-main p { margin: 0 0 6px; }
.request-main blockquote { margin: 0 0 6px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; color: #d6d6e2; }
.request-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.manage-split { display: grid; gap: 28px; }
.manage-split h3 { font-size: 1rem; }
.banner-thumb { display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: var(--surface-2); color: var(--muted); }

/* ---------- Comments from the original thread ---------- */
.comments-sheet .sheet-body { gap: 10px; }
.comments-sheet h2 { display: flex; align-items: center; gap: 8px; }
.post-list { display: grid; gap: 8px; max-height: 66svh; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.post { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); scroll-margin: 12px; }
.post.is-own { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.post.is-op { background: color-mix(in srgb, var(--accent-2) 8%, var(--surface)); }
.post.is-flash { animation: post-flash 1.2s var(--ease); }
@keyframes post-flash { 0%, 40% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } }
.post-body { min-width: 0; flex: 1; display: grid; gap: 4px; }
.post-body > p { margin: 0; }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.post-subject { margin: 0; font-weight: 700; }
.post-file { margin: 0; font-size: .85rem; color: #d6d6e2; overflow-wrap: anywhere; }
.post-file i { color: var(--muted); }
.post-text { font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; }
.post-text a { color: #7cc4ff; text-decoration: underline; text-underline-offset: 2px; }
.post-text a.quote { color: var(--accent); text-decoration: none; font-weight: 600; }
.post-text .greentext { color: #8fca6a; }
.post-text mark { background: rgba(255, 201, 77, .22); color: var(--star); border-radius: 4px; padding: 0 2px; }
.post-media { position: relative; flex: none; width: 72px; height: 72px; padding: 0; overflow: hidden; border: 0; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.post-media img, .post-media video { width: 100%; height: 100%; object-fit: cover; }
.post-media i { position: absolute; inset: auto 4px 4px auto; color: #fff; text-shadow: 0 1px 3px #000; }
.comment-compose { display: grid; }
.comment-compose .btn { justify-self: start; }
.comment-form { display: grid; gap: 6px; }
.comment-form textarea { font-size: 16px; }
.comment-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.comment-form-actions .muted { margin-right: auto; font-variant-numeric: tabular-nums; }
.comment-thread { display: grid; gap: 8px; }
.ucomment { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.ucomment.is-deleted { background: transparent; border-style: dashed; }
.ucomment .avatar-sm { width: 30px; height: 30px; font-size: .8rem; }
.comment-replies { display: grid; gap: 6px; margin-left: 28px; padding-left: 10px; border-left: 2px solid var(--border); }
.comment-replies:empty { display: none; }
.comment-actions { display: flex; gap: 14px; }
.comment-actions .link-btn { color: var(--muted); font-size: .8rem; }
.comment-actions .link-btn:hover { color: var(--text); }
.comment-actions .link-btn.danger:hover { color: var(--danger); }
.post-divider { margin: 6px 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tile-comments { position: absolute; right: 8px; bottom: 6px; padding: 2px 6px; border-radius: 999px; background: rgba(0, 0, 0, .6); font-size: .7rem; font-weight: 700; }
.is-selecting .tile-comments { display: none; }

/* ---------- Uploader ---------- */
.sheet-wide { max-width: 100%; }
.uploader { display: grid; gap: 12px; }
.dropzone {
  display: grid; justify-items: center; gap: 4px; padding: 28px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone i { font-size: 2rem; color: var(--accent); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 40svh; overflow-y: auto; }
.upload-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface); }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.upload-item > .muted { grid-column: 1; }
.upload-item > button, .upload-item > i { grid-column: 2; grid-row: 1 / span 3; }
.upload-bar { grid-column: 1; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.upload-bar span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.upload-item.is-done i { color: var(--success); }
.upload-item.is-dup i { color: var(--muted); }
.upload-item.is-error i, .upload-item.is-error .muted { color: var(--danger); }

@media (min-width: 900px) {
  .columns-control { display: inline-flex; }
  .bulk-filters { grid-template-columns: 2fr 2fr 1fr 1fr; }
  .bulk-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .bulk-actions { top: calc(var(--topbar-h) + 16px); bottom: auto; }
  .home-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; align-items: start; }
  .filter-panel {
    position: sticky; top: calc(var(--topbar-h) + 16px); left: auto; right: auto; bottom: auto; z-index: 1;
    max-height: calc(100vh - var(--topbar-h) - 32px); border-radius: var(--radius-lg); transform: none; transition: none; padding-bottom: 14px;
  }
  .filter-open, .filter-close, .filter-scrim { display: none; }
  .wide-only { display: inline; }
  .thread-actions { flex-wrap: nowrap; }
  .banner-strip:first-child { margin-top: 18px; }
  .thread-row { grid-auto-columns: calc((100% - (var(--cols, 3) - 1) * 16px) / var(--cols, 3)); gap: 16px; }
  .list-row { grid-auto-columns: 200px; }
  .curate-row { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .curate-thumb { grid-row: auto; }
  .request-card { grid-template-columns: 180px minmax(0, 1fr) auto; align-items: center; }
  .manage-split { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
  .sheet-wide { max-width: 640px; }
  .tabs { margin: 0 0 20px; padding: 0; flex-wrap: wrap; overflow: visible; }
  .stage[data-mode="popout"] { inset: 5vh 6vw; border-radius: var(--radius-lg); box-shadow: 0 30px 80px rgba(0, 0, 0, .7); }
}

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

.media-wrap { position: absolute; inset: 0; overflow: hidden; }

/* Compact player controls so the whole row fits a phone screen */
@media (max-width: 899px) {
  .stage-bottom { padding: 22px 8px 8px; }
  .stage-controls { gap: 4px; }
  .ctrl-group { gap: 2px; }
  .stage-controls .icon-btn { width: 36px; height: 36px; font-size: 1.05rem; }
  .ctrl-select { height: 36px; padding: 0 6px; }
  .ctrl-select i { display: none; }
  .segmented button { width: 32px; height: 30px; }
  .stage-rail { bottom: 84px; right: 8px; gap: 10px; }
  .rail-btn i { width: 42px; height: 42px; font-size: 1.2rem; }
}
@media (max-width: 360px) {
  .stage-controls .icon-btn { width: 32px; height: 32px; }
  .segmented button { width: 30px; }
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
