/* =========================================================================
   Prompt Gallery — "Quiet Editorial" interactive prototype
   Tokens, layout, and components. Light + dark, responsive 375 / 768 / 1024 / 1440.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  --bg: #f6f4f1;
  --bg-2: #f0ede7;
  --surface: #fcfbf9;
  --surface-2: #f3f0eb;
  --surface-3: #ebe7df;
  --surface-inverse: #17181b;

  --ink: #17181b;
  --ink-soft: #2c2a26;
  --muted: #5d5a52;
  --muted-2: #6e695f;
  --line: #e4dfd6;
  --line-2: #d6d0c5;

  --accent: #b0552f;
  --accent-2: #974425;
  --accent-soft: #f4dccd;
  --accent-ink: #ffffff;

  --ok: #3c6b5a;
  --ok-soft: #dceae3;
  --warn: #8a6216;
  --warn-soft: #f3e7c9;
  --danger: #a32c22;
  --danger-soft: #f6e1de;

  --ink-inverse: #f6f4f1;
  --toast-bg: #17181b;
  --toast-ink: #f8f6f1;

  --shadow-sm: 0 1px 2px rgba(23, 24, 27, 0.05);
  --shadow-md: 0 10px 30px -18px rgba(23, 24, 27, 0.24), 0 2px 6px -2px rgba(23, 24, 27, 0.08);
  --shadow-lg: 0 30px 80px -30px rgba(23, 24, 27, 0.34);
  --ring: 0 0 0 3px rgba(176, 85, 47, 0.26);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --pill: 999px;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 268px;
  --topbar-h: 66px;
  --bottombar-h: 66px;
  --maxw: 1200px;

  --dur-1: 140ms;
  --dur-2: 220ms;
  --dur-3: 300ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0c0d0f;
  --bg-2: #090a0c;
  --surface: #141619;
  --surface-2: #181b1f;
  --surface-3: #1f2328;
  --surface-inverse: #eceae5;

  --ink: #eceae5;
  --ink-soft: #dad7d0;
  --muted: #b9b4aa;
  --muted-2: #928d83;
  --line: #262a2f;
  --line-2: #33383f;

  --accent: #e08a62;
  --accent-2: #edb69c;
  --accent-soft: #3a2118;
  --accent-ink: #2a1108;

  --ok: #8fc0ad;
  --ok-soft: #1b2b25;
  --warn: #e0b65b;
  --warn-soft: #2c2412;
  --danger: #f0b3ad;
  --danger-soft: #301715;

  --ink-inverse: #0c0d0f;
  --toast-bg: #eceae5;
  --toast-ink: #121417;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 16px 38px -20px rgba(0, 0, 0, 0.72), 0 2px 6px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 36px 90px -34px rgba(0, 0, 0, 0.85);
  --ring: 0 0 0 3px rgba(224, 138, 98, 0.3);
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, p, figure { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.12; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--ink); }

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

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

.skip-link {
  position: fixed;
  top: 10px; left: 50%;
  transform: translate(-50%, -160%);
  z-index: 200;
  padding: 10px 18px;
  border-radius: var(--pill);
  background: var(--ink);
  color: var(--ink-inverse);
  font-size: 0.85rem;
  font-weight: 600;
  transition: transform var(--dur-2) var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

.noscript {
  margin: 40px auto;
  max-width: 520px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.icon {
  display: inline-block;
  width: var(--icon-size, 18px);
  height: var(--icon-size, 18px);
  flex: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -0.18em;
}
.icon-sm { --icon-size: 15px; }
.icon-lg { --icon-size: 22px; }
.icon-xl { --icon-size: 28px; }

.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.lede { color: var(--muted); font-size: 1rem; line-height: 1.65; max-width: 62ch; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.nowrap { white-space: nowrap; }
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.04;
}
.grow { flex: 1 1 auto; min-width: 0; }
.hairline { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.view {
  flex: 1 1 auto;
  padding: clamp(22px, 3.2vw, 44px) clamp(16px, 3vw, 40px) 96px;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}
.view:focus { outline: none; }

.screen {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 3vw, 34px);
  animation: fade-up var(--dur-3) var(--ease-out) both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 2px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background:
    radial-gradient(120% 120% at 25% 20%, var(--accent-2), var(--accent) 58%, #7e371d);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--shadow-sm);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-sub { font-size: 0.72rem; color: var(--muted-2); letter-spacing: 0.01em; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 0 12px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav-item .icon { color: var(--muted-2); transition: color var(--dur-1) var(--ease); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink-soft); }
.nav-item.is-active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  border-color: var(--line);
}
.nav-item.is-active .icon { color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-2);
  background: var(--surface-3);
  border-radius: var(--pill);
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.nav-item.is-active .count { color: var(--ink-soft); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.server-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.server-card:hover { border-color: var(--line-2); background: var(--surface-2); }
.server-dot {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.server-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.server-state { font-size: 0.78rem; font-weight: 600; }
.server-host { font-size: 0.72rem; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar .menu-btn { display: none; }
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 0;
}
.crumbs .sep { color: var(--line-2); }
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumbs .crumb-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-spacer { flex: 1 1 auto; }

.global-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(320px, 30vw);
}
.global-search .icon {
  position: absolute;
  left: 12px;
  color: var(--muted-2);
  pointer-events: none;
}
.global-search input {
  width: 100%;
  height: 38px;
  padding: 0 54px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.86rem;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.global-search input::placeholder { color: var(--muted-2); }
.global-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}
.global-search kbd {
  position: absolute;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--surface);
  pointer-events: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-2); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-2);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--muted-2); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: transparent; border-color: var(--line-2); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { min-height: 32px; padding: 0 11px; font-size: 0.8rem; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }

.btn-icon {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.is-active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 6px; }
.label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.label .opt { font-weight: 500; color: var(--muted-2); font-size: 0.74rem; }
.req { color: var(--accent); }

.input, .textarea, .select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.textarea { resize: vertical; min-height: 120px; }
.textarea.mono { font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.6; }
.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e695f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
html[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23928d83' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
}

.help { font-size: 0.76rem; color: var(--muted-2); line-height: 1.45; }
.error-text { font-size: 0.78rem; color: var(--danger); font-weight: 600; line-height: 1.4; }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select { border-color: var(--danger); }
.field.has-error .input:focus, .field.has-error .textarea:focus, .field.has-error .select:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .btn-icon { position: absolute; right: 3px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 40px; height: 23px; flex: none;
  border-radius: var(--pill);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  position: relative;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-2) var(--ease);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* Segmented control */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.seg:hover { color: var(--ink); }
.seg.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.seg.is-active .icon { color: var(--accent); }

/* Chips & badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 11px;
  border-radius: var(--pill);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.chip:hover { color: var(--ink); background: var(--surface-3); }
.chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.is-active:hover { background: var(--accent-2); }
.chip .count { font-size: 0.7rem; opacity: 0.72; }

.chip-static {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-soft { background: var(--accent-soft); color: var(--accent-2); }
html[data-theme="dark"] .chip-soft { color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--muted);
}
.badge-kind { background: var(--ok-soft); color: var(--ok); }
html[data-theme="dark"] .badge-kind { color: #b6d8cb; }
.badge-piece { background: var(--warn-soft); color: var(--warn); }
html[data-theme="dark"] .badge-piece { color: #f0d39a; }
.badge-count {
  min-width: 20px; justify-content: center;
  background: var(--surface-3); color: var(--muted-2);
  letter-spacing: 0; text-transform: none;
}

/* Avatar */
.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Art ---------- */
.art {
  position: relative;
  overflow: hidden;
  background-color: var(--art-base, #1b1512);
  background-image: var(--art-layers);
  background-size: cover;
  isolation: isolate;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 40%),
    radial-gradient(130% 90% at 50% 120%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 62%);
  pointer-events: none;
}
.art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.2;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  pointer-events: none;
}
.art > * { position: relative; z-index: 2; }

.art-1 {
  --art-base: #1b1512;
  --art-layers:
    radial-gradient(88% 78% at 22% 16%, rgba(224, 138, 98, 0.94), rgba(176, 85, 47, 0) 60%),
    radial-gradient(72% 82% at 86% 84%, rgba(92, 44, 21, 0.9), rgba(92, 44, 21, 0) 64%),
    radial-gradient(42% 42% at 72% 26%, rgba(255, 216, 182, 0.62), rgba(255, 216, 182, 0) 70%),
    linear-gradient(158deg, #271a13, #0d0a08);
}
.art-2 {
  --art-base: #0d1719;
  --art-layers:
    radial-gradient(80% 90% at 26% 78%, rgba(71, 128, 114, 0.92), rgba(47, 91, 83, 0) 62%),
    radial-gradient(70% 66% at 82% 18%, rgba(150, 194, 177, 0.55), rgba(150, 194, 177, 0) 64%),
    radial-gradient(30% 30% at 60% 44%, rgba(210, 236, 226, 0.28), rgba(210, 236, 226, 0) 70%),
    linear-gradient(160deg, #12211f, #070f0e);
}
.art-3 {
  --art-base: #e7dccd;
  --art-layers:
    radial-gradient(78% 82% at 24% 22%, rgba(196, 118, 77, 0.92), rgba(196, 118, 77, 0) 60%),
    radial-gradient(72% 80% at 82% 82%, rgba(104, 122, 104, 0.68), rgba(104, 122, 104, 0) 66%),
    radial-gradient(36% 36% at 70% 24%, rgba(250, 240, 226, 0.8), rgba(250, 240, 226, 0) 70%),
    linear-gradient(150deg, #f0e8dc, #d7c7b2);
}
.art-4 {
  --art-base: #101620;
  --art-layers:
    radial-gradient(82% 86% at 22% 80%, rgba(70, 96, 126, 0.95), rgba(59, 80, 104, 0) 62%),
    radial-gradient(64% 70% at 84% 18%, rgba(196, 150, 116, 0.62), rgba(183, 138, 106, 0) 64%),
    radial-gradient(34% 34% at 60% 50%, rgba(214, 228, 244, 0.24), rgba(214, 228, 244, 0) 72%),
    linear-gradient(160deg, #17202c, #090e15);
}
.art-5 {
  --art-base: #12160f;
  --art-layers:
    radial-gradient(80% 84% at 28% 28%, rgba(88, 110, 72, 0.92), rgba(70, 88, 58, 0) 60%),
    radial-gradient(70% 76% at 82% 80%, rgba(204, 190, 140, 0.6), rgba(194, 178, 128, 0) 66%),
    radial-gradient(30% 30% at 66% 62%, rgba(230, 238, 214, 0.22), rgba(230, 238, 214, 0) 72%),
    linear-gradient(158deg, #1b2117, #090c07);
}
.art-6 {
  --art-base: #1d1113;
  --art-layers:
    radial-gradient(82% 84% at 24% 22%, rgba(140, 54, 62, 0.95), rgba(122, 47, 54, 0) 60%),
    radial-gradient(70% 80% at 84% 84%, rgba(214, 146, 98, 0.58), rgba(208, 138, 90, 0) 66%),
    radial-gradient(32% 32% at 64% 30%, rgba(255, 214, 186, 0.24), rgba(255, 214, 186, 0) 72%),
    linear-gradient(158deg, #2a1618, #11090a);
}
.art-7 {
  --art-base: #efe9df;
  --art-layers:
    radial-gradient(60% 70% at 30% 30%, rgba(26, 27, 30, 0.9), rgba(26, 27, 30, 0) 58%),
    radial-gradient(66% 72% at 84% 82%, rgba(176, 85, 47, 0.72), rgba(176, 85, 47, 0) 64%),
    radial-gradient(30% 30% at 66% 24%, rgba(255, 250, 242, 0.9), rgba(255, 250, 242, 0) 70%),
    linear-gradient(150deg, #f4efe6, #dcd3c3);
}

.cover { position: relative; border-radius: var(--radius); overflow: hidden; }
.cover-initial {
  position: absolute;
  left: 12px;
  bottom: 4px;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.28);
}
.cover.art-3 .cover-initial,
.cover.art-7 .cover-initial { color: rgba(23, 24, 27, 0.7); text-shadow: none; }

/* ---------- Home ---------- */
.hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 4px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 4.2vw, 3.3rem);
  letter-spacing: -0.028em;
  line-height: 1.02;
  max-width: 22ch;
}
.hero .lede { font-size: 1.02rem; max-width: 58ch; }

.hero-search {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 620px;
  margin-top: 4px;
}
.hero-search .icon { position: absolute; left: 16px; color: var(--muted-2); pointer-events: none; }
.hero-search input {
  width: 100%;
  height: 52px;
  padding: 0 60px 0 46px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.hero-search input::placeholder { color: var(--muted-2); }
.hero-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.hero-search kbd {
  position: absolute; right: 14px;
  font-family: var(--font-mono); font-size: 0.74rem;
  color: var(--muted-2);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; background: var(--surface-2);
}

.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat {
  background: var(--surface);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-cap { font-size: 0.78rem; color: var(--muted); }
.stat-delta { font-size: 0.72rem; color: var(--ok); font-weight: 600; }

.section { display: flex; flex-direction: column; gap: 12px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 2px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.018em;
}
.section-head .sub { font-size: 0.8rem; color: var(--muted-2); }
.section-head .more {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.8rem; font-weight: 600; color: var(--accent);
  background: none; border: 0; cursor: pointer; padding: 4px 2px;
}
.section-head .more:hover { color: var(--accent-2); }

.rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  margin: -2px -2px 0;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { flex: none; scroll-snap-align: start; }

/* Mini prompt card */
.mini-card {
  width: 272px;
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.mini-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.mini-card .cover { width: 62px; height: 62px; flex: none; border-radius: 10px; }
.mini-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mini-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mini-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mini-model { font-size: 0.72rem; color: var(--muted-2); }

/* Collection card */
.collection-card {
  width: 244px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.collection-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.collection-card .cover { height: 118px; border-radius: 0; }
.collection-card .cover-initial { font-size: 3.4rem; left: 16px; bottom: 6px; }
.cc-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 5px; }
.cc-title { font-size: 0.96rem; font-weight: 600; line-height: 1.25; }
.cc-desc {
  font-size: 0.78rem; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-meta { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--muted-2); }

/* Model strip */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.model-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.model-tile:hover { border-color: var(--line-2); background: var(--surface-2); }
.model-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
}
.model-tile .name { font-size: 0.86rem; font-weight: 600; }
.model-tile .count { margin-left: auto; font-size: 0.74rem; color: var(--muted-2); }

/* Prompt list row card */
.prompt-card {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.prompt-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pc-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.pc-title {
  font-size: 0.98rem; font-weight: 600; line-height: 1.3;
  padding-right: 64px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.74rem; color: var(--muted-2); }
.pc-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 2px; }
.pc-cover { width: 76px; height: 76px; flex: none; border-radius: 10px; }
.pc-actions {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
  display: flex; gap: 2px;
}
.pc-actions .btn-icon { width: 30px; height: 30px; min-height: 30px; border-radius: 8px; }

/* overlay hit target for card-like articles that also hold action buttons */
.card-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}
.card-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid-card { position: relative; }
.card-remove {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
  width: 28px; height: 28px; min-height: 28px;
  border-radius: 50%;
  background: rgba(12, 13, 15, 0.62);
  color: #f6f4f1;
}
.card-remove:hover { background: rgba(12, 13, 15, 0.82); color: #fff; }

/* text-only button used inside tables */
.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.linklike:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.dot-sep {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--line-2);
  vertical-align: middle;
  flex: none;
}

.mobile-cards { display: none; }
.hide-sm { display: inline; }
.table-only { display: inline-flex; }

/* Prompt grid card */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.grid-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.grid-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.grid-card .cover { height: 150px; border-radius: 0; }
.gc-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 7px; }
.gc-title {
  font-size: 0.95rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gc-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 0.72rem; color: var(--muted-2); }

/* ---------- Explore toolbar ---------- */
.screen-head {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}
.screen-head .head-title { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.screen-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.024em;
  line-height: 1.03;
}
.screen-head .head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-row .grow { flex: 1 1 240px; }

.search-input { position: relative; display: flex; align-items: center; width: 100%; }
.search-input .icon { position: absolute; left: 13px; color: var(--muted-2); pointer-events: none; }
.search-input input {
  width: 100%;
  height: 42px;
  padding: 0 42px 0 40px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.9rem;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.search-input input::placeholder { color: var(--muted-2); }
.search-input input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.search-input .btn-icon { position: absolute; right: 3px; width: 34px; height: 34px; min-height: 34px; }

.filter-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}
.filter-summary strong { color: var(--ink); font-weight: 700; }
.filter-summary .clear {
  margin-left: auto;
  background: none; border: 0; color: var(--accent);
  font-weight: 600; font-size: 0.8rem; cursor: pointer; padding: 4px 2px;
}
.filter-summary .clear:hover { color: var(--accent-2); }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 6px 2px 9px;
  border-radius: var(--pill);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 0.72rem; font-weight: 600;
}
html[data-theme="dark"] .filter-pill { color: var(--accent); }
.filter-pill button {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.08); color: inherit; cursor: pointer;
}

.tag-rail-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tag-rail {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-width: 0;
}
.tag-rail::-webkit-scrollbar { display: none; }
.tag-rail > * { flex: none; }

.match-all {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.76rem; color: var(--muted); white-space: nowrap;
  cursor: pointer;
}
.match-all input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- Table ---------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .cell-title { font-weight: 600; color: var(--ink); }
.table .cell-click { cursor: pointer; }
.table .cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table .thumb { width: 36px; height: 36px; border-radius: 7px; flex: none; }
.table .t-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.table .linklike { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ---------- Empty / notice / skeleton ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 56px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty .empty-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.empty h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.empty p { font-size: 0.88rem; color: var(--muted); max-width: 46ch; line-height: 1.55; }

.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.notice .icon { color: var(--muted-2); margin-top: 1px; }
.notice-warn { background: var(--warn-soft); border-color: transparent; color: var(--ink-soft); }
.notice-warn .icon { color: var(--warn); }

.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--radius-sm); }
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  animation: shimmer 1.3s infinite;
}
html[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-card { height: 96px; border-radius: var(--radius); }

/* ---------- Prompt detail ---------- */
.detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.detail-top .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 7px;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
}
.back-btn:hover { color: var(--ink); border-color: var(--line-2); background: var(--surface-2); }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}
.detail-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  font-weight: 600;
  letter-spacing: -0.026em;
  line-height: 1.06;
}
.detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted-2); }
.detail-meta .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); }
.chip-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.gallery { display: flex; flex-direction: column; gap: 8px; }
.gallery-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: zoom-in;
  border: 0;
  padding: 0;
  background: none;
  width: 100%;
}
.gallery-hero .art { position: absolute; inset: 0; }
.gallery-hero .zoom-hint {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--pill);
  background: rgba(12, 13, 15, 0.6); color: #f6f4f1;
  font-size: 0.7rem; font-weight: 600;
}
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumb {
  width: 76px; height: 54px; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--line); padding: 0; background: none; cursor: pointer;
  position: relative;
}
.gallery-thumb .art { position: absolute; inset: 0; }
.gallery-thumb.is-active { outline: 2px solid var(--accent); outline-offset: 1px; }

.md-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.md-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.md-toolbar .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.md-toolbar .meta { font-size: 0.74rem; color: var(--muted-2); }
.md-body { padding: clamp(16px, 2.4vw, 26px); }
.md-source {
  margin: 0;
  padding: clamp(16px, 2.4vw, 26px);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--ink-soft);
}

/* Markdown */
.md { font-size: 1rem; line-height: 1.7; color: var(--ink-soft); }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 1.4em 0 0.5em;
  line-height: 1.15;
}
.md h1 { font-size: 1.55rem; }
.md h2 { font-size: 1.22rem; }
.md h3 { font-size: 1.04rem; }
.md p { margin: 0 0 0.9em; }
.md ul, .md ol { margin: 0 0 0.9em; padding-left: 1.3em; }
.md li { margin: 0.25em 0; }
.md li::marker { color: var(--accent); }
.md strong { color: var(--ink); font-weight: 700; }
.md em { font-style: italic; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--ink);
}
.md pre {
  margin: 0 0 1em;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--line);
  overflow-x: auto;
}
.md pre code { background: none; padding: 0; font-size: 0.82rem; line-height: 1.6; }
.md blockquote {
  margin: 0 0 1em;
  padding: 6px 0 6px 16px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.md hr { height: 1px; border: 0; background: var(--line); margin: 1.4em 0; }
.md table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-size: 0.86rem; }
.md th, .md td { text-align: left; padding: 8px 10px; border: 1px solid var(--line); }
.md th { background: var(--surface-2); font-weight: 700; color: var(--ink); }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-aside { display: flex; flex-direction: column; gap: 12px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel h3 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2);
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.82rem; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; color: var(--ink); font-weight: 600; text-align: right; }
.panel-actions { display: flex; flex-direction: column; gap: 4px; }
.action-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 8px;
  border: 0; border-radius: 9px; background: none;
  color: var(--ink-soft); font-size: 0.86rem; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.action-row:hover { background: var(--surface-2); }
.action-row .icon { color: var(--muted-2); }
.action-row.danger { color: var(--danger); }
.action-row.danger .icon { color: var(--danger); }
.action-row.danger:hover { background: var(--danger-soft); }

/* ---------- Editor ---------- */
.editor-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.editor-head .right { margin-left: auto; display: flex; gap: 8px; }
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}
.editor-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.editor-aside { display: flex; flex-direction: column; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-card > h3 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2);
}
.tag-input-row { display: flex; gap: 8px; align-items: flex-start; }
.tag-input-row .field { flex: 1; }
.tag-edit-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-edit {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 5px 4px 10px;
  border-radius: var(--pill);
  background: var(--secondary-soft, var(--surface-2));
  color: var(--ink-soft);
  font-size: 0.76rem; font-weight: 600;
}
.tag-edit button {
  display: grid; place-items: center;
  width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.08); color: inherit; cursor: pointer;
}
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestion {
  padding: 3px 10px; border-radius: var(--pill);
  border: 1px dashed var(--line-2); background: transparent;
  color: var(--muted); font-size: 0.74rem; font-weight: 600; cursor: pointer;
}
.suggestion:hover { border-style: solid; color: var(--ink); border-color: var(--muted-2); }

.check-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: 8px;
  font-size: 0.84rem; cursor: pointer;
}
.check-row:hover { background: var(--surface-2); }
.check-row input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check-row .count { margin-left: auto; font-size: 0.72rem; color: var(--muted-2); }

.image-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.image-edit {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
}
.image-edit .art { position: absolute; inset: 0; }
.image-edit .rm {
  position: absolute; top: 4px; right: 4px; z-index: 3;
  width: 22px; height: 22px; min-height: 22px;
  border-radius: 50%; border: 0;
  background: rgba(12, 13, 15, 0.62); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.image-add {
  aspect-ratio: 1 / 1; border-radius: 10px;
  border: 1px dashed var(--line-2); background: var(--surface-2);
  color: var(--muted-2); display: grid; place-items: center; gap: 4px;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
}
.image-add:hover { border-color: var(--accent); color: var(--accent); }

.editor-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 16px;
  min-height: 160px;
  max-height: 380px;
  overflow: auto;
}
.char-count { font-size: 0.72rem; color: var(--muted-2); text-align: right; }

/* ---------- Collections ---------- */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.collections-grid .collection-card { width: auto; }

.collection-banner {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  padding: 24px;
  border: 1px solid var(--line);
}
.collection-banner .art { position: absolute; inset: 0; }
.collection-banner .banner-body { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 8px; max-width: 640px; color: #fff; }
.collection-banner.art-3 .banner-body, .collection-banner.art-7 .banner-body { color: #17181b; }
.collection-banner h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.024em;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
}
.collection-banner .banner-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 0.8rem; color: rgba(255, 255, 255, 0.86); }
.collection-banner.art-3 h1, .collection-banner.art-7 h1 { color: #17181b; text-shadow: none; }
.collection-banner.art-3 .banner-meta, .collection-banner.art-7 .banner-meta { color: rgba(23, 24, 27, 0.78); }

.art-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.art-swatch {
  width: 44px; height: 44px; border-radius: 10px; overflow: hidden;
  border: 2px solid transparent; padding: 0; cursor: pointer; position: relative;
}
.art-swatch .art { position: absolute; inset: 0; }
.art-swatch.is-active { border-color: var(--accent); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-card h2 {
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 600;
  letter-spacing: -0.014em;
}
.settings-card .desc { font-size: 0.82rem; color: var(--muted); line-height: 1.55; }
.settings-card .row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.settings-card .row-between .lbl { font-size: 0.86rem; font-weight: 600; }
.settings-card .row-between .sub { font-size: 0.76rem; color: var(--muted-2); }
.settings-card.danger-zone { border-color: var(--line-2); }
.session-line { display: flex; align-items: center; gap: 9px; font-size: 0.86rem; }
.session-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.about-version { font-size: 0.78rem; color: var(--muted-2); }
.about-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent); font-size: 0.82rem; font-weight: 600;
}
.about-link:hover { color: var(--accent-2); }

.test-result { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--danger); }
.test-result .spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth ---------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(70% 60% at 50% 0%, var(--surface-2), rgba(0, 0, 0, 0) 70%),
    var(--bg);
}
.auth-inner { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-brand .brand-mark { width: 54px; height: 54px; border-radius: 16px; }
.auth-brand .brand-mark svg { width: 30px; height: 30px; }
.auth h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 2.8rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.auth .tagline { font-size: 0.92rem; color: var(--muted); max-width: 40ch; line-height: 1.6; }
.auth-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
}
.auth-card h2 { font-size: 0.98rem; font-weight: 700; }
.auth-server {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.auth-server .icon { color: var(--accent); }
.auth-server strong { color: var(--ink); font-weight: 600; }
.input[readonly] { color: var(--muted); background: var(--surface-2); cursor: default; }
.input[readonly]:focus { border-color: var(--line); box-shadow: none; }
.auth-foot { font-size: 0.76rem; color: var(--muted-2); text-align: center; line-height: 1.55; max-width: 42ch; }
.demo-hint {
  font-size: 0.73rem; color: var(--muted-2);
  background: var(--surface-2); border: 1px dashed var(--line-2);
  border-radius: 8px; padding: 7px 10px; line-height: 1.5;
}

/* ---------- Drawer / bottom bar ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(8, 9, 11, 0.5);
  animation: fade-in var(--dur-2) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.bottombar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--line);
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  max-width: 110px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted-2);
  font-size: 0.64rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}
.tab .icon { --icon-size: 21px; }
.tab.is-active { color: var(--accent); }
.tab:hover { color: var(--ink); }

/* ---------- Dialog ---------- */
dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(86dvh, 720px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog::backdrop { background: rgba(8, 9, 11, 0.58); }
dialog[open] { animation: dialog-in var(--dur-2) var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.dialog-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 18px 12px;
}
.dialog-head h2 {
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 600;
  letter-spacing: -0.018em;
}
.dialog-head .sub { font-size: 0.82rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.dialog-head .btn-icon { margin-left: auto; margin-top: -4px; }
.dialog-body { padding: 0 18px 4px; display: flex; flex-direction: column; gap: 14px; max-height: 56dvh; overflow-y: auto; }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px 18px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(6, 7, 9, 0.94);
  display: flex; flex-direction: column;
  color: #f6f4f1;
  animation: fade-in var(--dur-2) var(--ease);
}
.lb-top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  flex: none;
}
.lb-counter { font-size: 0.82rem; color: rgba(246, 244, 241, 0.7); font-variant-numeric: tabular-nums; }
.lb-top .right { margin-left: auto; display: flex; gap: 4px; }
.lb-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: rgba(255, 255, 255, 0.1); color: #f6f4f1;
  display: grid; place-items: center; cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px 20px;
  overflow: hidden;
  touch-action: none;
}
.lb-frame {
  flex: none;
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  transform-origin: center center;
  background: #05060a;
  box-shadow: 0 30px 90px -30px rgba(0, 0, 0, 0.9);
  will-change: transform;
}
.lb-frame.is-animating { transition: transform var(--dur-2) var(--ease); }
.lightbox.is-video .lb-stage { touch-action: auto; }
@media (max-width: 700px) {
  .lb-stage { padding: 0; }
  .lb-frame { border-radius: 0; box-shadow: none; }
}
.lb-frame .art { position: absolute; inset: 0; }
.lb-frame .cover-initial { font-size: 4rem; left: 24px; bottom: 12px; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.12); color: #f6f4f1;
  display: grid; place-items: center; cursor: pointer;
  z-index: 5;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lb-nav[disabled] { opacity: 0.25; cursor: default; }
.lb-hint { text-align: center; font-size: 0.72rem; color: rgba(246, 244, 241, 0.5); padding-bottom: 14px; flex: none; }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  z-index: 120;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast .icon { color: var(--toast-ink); opacity: 0.9; }
.toast.is-out { animation: toast-out var(--dur-2) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .app { display: block; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: min(300px, 84vw);
    height: 100dvh;
    transform: translateX(-102%);
    transition: transform var(--dur-3) var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: 60;
  }
  .sidebar.is-open { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .global-search { display: none; }
  .bottombar { display: flex; }
  .view { padding-bottom: calc(var(--bottombar-h) + 56px + env(safe-area-inset-bottom, 0px)); }
  .detail-aside { position: static; }
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .detail-aside { order: 2; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  :root { --topbar-h: 60px; }
  .view { padding: clamp(18px, 4vw, 26px) 16px calc(var(--bottombar-h) + 48px + env(safe-area-inset-bottom, 0px)); }
  .screen { gap: 22px; }
  .hero h1 { font-size: clamp(1.9rem, 7vw, 2.5rem); }
  .hero-search input { height: 48px; }
  .stat { padding: 14px 16px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .table-wrap { display: none; }
  .mobile-cards { display: grid; gap: 12px; }
  .hide-sm { display: none; }
  .table-only { display: none; }
  .crumbs .crumb-root, .crumbs .sep { display: none; }
  .topbar .avatar { display: none; }
  .screen-head h1 { font-size: clamp(1.7rem, 6vw, 2.1rem); }
  .toolbar { padding: 12px; }
  .detail-title { font-size: clamp(1.7rem, 6vw, 2.2rem); }
  .gallery-hero { aspect-ratio: 4 / 3; }
  .toast-region { left: 16px; right: 16px; bottom: calc(var(--bottombar-h) + 16px + env(safe-area-inset-bottom, 0px)); align-items: center; }
  .toast { max-width: 100%; width: 100%; }
  .collection-banner { min-height: 180px; padding: 18px; }
  .section-head h2 { font-size: 1.16rem; }
  .mini-card { width: 240px; }
  .collection-card { width: 224px; }
}

@media (max-width: 420px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .screen-head .head-actions { margin-left: 0; width: 100%; }
}

/* Tables become cards on small screens via a separate render path in app.js.
   Keep the table only for >=768px. */

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
/* ---------- Media: public images & video ---------- */
.media-cover { display: block; background: var(--surface-2); }
.media-cover .cover-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-play {
  position: absolute; right: 8px; bottom: 8px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(12, 13, 15, 0.64); color: #fff;
  display: grid; place-items: center;
}
.mini-card .cover-play { width: 20px; height: 20px; right: 5px; bottom: 5px; }

.media-section { display: flex; flex-direction: column; gap: 10px; }
.media-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.media-head h3 { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.01em; }
.media-head .meta { font-size: 0.74rem; color: var(--muted-2); }
.media-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.media-tile {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); padding: 0;
  background: var(--surface-2); cursor: pointer; display: block;
}
.media-tile img, .media-tile video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-tile.is-video { background: #0a0b0d; }
.media-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; background: rgba(8, 9, 11, 0.28);
}
.media-play .icon { width: 34px; height: 34px; }
.media-grid.refs-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.media-empty {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: var(--radius);
  color: var(--muted); font-size: 0.84rem; line-height: 1.5; background: var(--surface-2);
}
.media-empty .icon { color: var(--muted-2); flex: none; }

.lb-media {
  width: 100%; height: 100%; object-fit: contain; display: block;
  background: #05060a;
  user-select: none; -webkit-user-select: none;
  -webkit-user-drag: none; -webkit-touch-callout: none;
}

.image-preview { position: absolute; inset: 0; }
.image-preview img, .image-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-edit.is-pending .image-pending {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 6px; text-align: center; font-size: 0.62rem; color: var(--muted-2); background: var(--surface-2);
  overflow: hidden; word-break: break-word;
}
.image-edit.is-pending .image-pending .icon { color: var(--accent); }

.boot {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); font-size: 0.86rem;
}
.boot .spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.session-line .dot.muted { background: var(--muted-2); box-shadow: 0 0 0 3px var(--line); }
.auth-lede { font-size: 0.84rem; color: var(--muted); line-height: 1.55; }

@media (max-width: 640px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .media-grid.refs-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
}

/* ================= Public gallery shell ================= */
.app-public { display: block; min-height: 100dvh; }

.pubbar {
  position: sticky; top: 0; z-index: 90;
  height: 60px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 clamp(10px, 3vw, 26px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.pubbar-spacer { flex: 1 1 auto; }
.pub-btn {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--pill);
  background: transparent; color: var(--ink); cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.pub-btn:hover { background: var(--surface-2); }
.pub-btn:active { transform: scale(0.94); }
.pub-avatar {
  width: 40px; height: 40px; flex: 0 0 auto; margin-left: 4px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--surface-inverse); color: var(--ink-inverse);
  transition: transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.pub-avatar:hover { opacity: 0.88; }
.pub-avatar:active { transform: scale(0.94); }
.pub-avatar span { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; }
.pub-avatar .icon { width: 18px; height: 18px; }

.view-public {
  max-width: 1680px; margin: 0 auto;
  padding: clamp(16px, 2.4vw, 30px) clamp(12px, 2.6vw, 32px) 96px;
  scroll-margin-top: 60px;
}

/* ---------- Masonry ---------- */
.gallery-screen { width: 100%; }
.masonry {
  columns: 4; column-gap: clamp(10px, 1.1vw, 16px);
}
.masonry-item {
  break-inside: avoid; -webkit-column-break-inside: avoid;
  margin: 0 0 clamp(10px, 1.1vw, 16px);
}
.tile {
  display: block; width: 100%; padding: 0; margin: 0;
  border: 0; border-radius: var(--radius-lg); overflow: hidden;
  position: relative; cursor: zoom-in; text-align: left;
  background: var(--surface-2); color: #fff;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.tile:hover { box-shadow: var(--shadow-md); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tile-media { display: block; position: relative; overflow: hidden; background: var(--surface-3); }
.tile-img {
  display: block; width: 100%; height: auto; min-height: 96px;
  object-fit: cover; background: var(--surface-3);
  transition: transform var(--dur-3) var(--ease-out);
}
.tile:hover .tile-img { transform: scale(1.035); }
.tile-art { display: block; width: 100%; }

.tile-overlay {
  position: absolute; inset: auto 0 0 0;
  display: flex; flex-direction: column; gap: 3px;
  padding: 44px 14px 14px;
  background: linear-gradient(to top, rgba(9, 10, 12, 0.86), rgba(9, 10, 12, 0.36) 55%, rgba(9, 10, 12, 0));
  opacity: 0; transform: translateY(10px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
  pointer-events: none;
}
.tile:hover .tile-overlay,
.tile:focus-visible .tile-overlay { opacity: 1; transform: none; }
.tile-title {
  font-family: var(--font-display); font-size: 1.02rem; font-weight: 600;
  line-height: 1.2; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-excerpt {
  font-size: 0.76rem; line-height: 1.45; color: rgba(255, 255, 255, 0.82);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tile-tag {
  font-size: 0.64rem; letter-spacing: 0.02em; padding: 2px 7px;
  border-radius: var(--pill); background: rgba(255, 255, 255, 0.16); color: #fff;
}
.tile-kind {
  align-self: flex-start; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 2px 7px; border-radius: var(--pill); background: var(--accent); color: var(--accent-ink);
}
.tile-play {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(9, 10, 12, 0.6); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.tile-play .icon { width: 14px; height: 14px; fill: currentColor; stroke: none; transform: translateX(1px); }

@media (hover: none) {
  .tile-overlay { opacity: 1; transform: none; padding-top: 30px;
    background: linear-gradient(to top, rgba(9, 10, 12, 0.68), rgba(9, 10, 12, 0) 62%); }
  .tile-excerpt, .tile-tags { display: none; }
}

/* ---------- Empty + filter ---------- */
.gallery-filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 12px; border-radius: var(--pill);
  background: var(--surface-2); border: 1px solid var(--line); font-size: 0.78rem; color: var(--ink);
}
.filter-pill button {
  width: 22px; height: 22px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--surface-3); color: var(--muted); cursor: pointer;
}
.filter-pill button:hover { color: var(--ink); }
.gallery-empty {
  min-height: 46vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; color: var(--muted); padding: 40px 20px;
}
.gallery-empty svg { width: 42px; height: 42px; opacity: 0.55; }
.gallery-empty h2 { margin: 0; font-family: var(--font-display); font-size: 1.5rem; color: var(--ink); }
.gallery-empty p { margin: 0; max-width: 42ch; font-size: 0.9rem; line-height: 1.55; }
.gallery-empty .btn { margin-top: 10px; }

/* ---------- Slide menu ---------- */
.menu-backdrop, .search-backdrop {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(8, 9, 11, 0.42);
  opacity: 0; transition: opacity var(--dur-2) var(--ease);
}
.search-backdrop { background: rgba(8, 9, 11, 0.16); }
.menu-backdrop.is-open, .search-backdrop.is-open { opacity: 1; }
.menu-panel {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
  width: min(324px, 88vw);
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 14px 18px;
  background: var(--surface); border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform var(--dur-3) var(--ease-out);
  overflow-y: auto;
}
.menu-panel.is-open { transform: none; }
.menu-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; }
.menu-title {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em;
}
.menu-nav { display: flex; flex-direction: column; gap: 2px; }
.menu-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font: inherit; font-size: 0.92rem;
  text-align: left; cursor: pointer; width: 100%;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.menu-link .icon { color: var(--muted); }
.menu-link:hover { background: var(--surface-2); }
.menu-link.is-active { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.menu-link.is-active .icon { color: var(--accent); }
.menu-sep { height: 1px; background: var(--line); margin: 2px 6px; }
.menu-foot {
  margin-top: auto; padding: 12px 8px 0;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2);
}

/* ---------- Search overlay ---------- */
.search-panel {
  position: fixed; top: 68px; left: 50%; z-index: 120;
  width: min(700px, 94vw);
  padding: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translate(-50%, -8px);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease-out);
}
.search-panel.is-open { opacity: 1; transform: translate(-50%, 0); }
.search-top {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 2px 10px; border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.search-top input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 1.05rem; outline: none;
}
.search-top input::placeholder { color: var(--muted-2); }
.search-filters {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 10px; flex-wrap: wrap;
}
.search-count { font-size: 0.76rem; color: var(--muted-2); }
.screen-narrow { max-width: 640px; }

@media (max-width: 1200px) { .masonry { columns: 3; } }
@media (max-width: 820px) { .masonry { columns: 2; } }
@media (max-width: 520px) {
  .masonry { columns: 2; column-gap: 8px; }
  .masonry-item { margin-bottom: 8px; }
  .tile { border-radius: var(--radius); }
  .search-panel { top: 66px; }
}
@media (max-width: 380px) { .masonry { columns: 1; } }

@media (prefers-reduced-motion: reduce) {
  .masonry-item, .menu-panel, .search-panel, .menu-backdrop, .search-backdrop, .tile-img, .tile-overlay {
    animation: none !important; transition: none !important;
  }
}
