/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --bg: #0b0c10;
  --bg-elevated: #12141a;
  --bg-card: #151821;
  --bg-card-hover: #1a1e2a;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef0f6;
  --text-muted: #8b93a7;
  --text-faint: #5c6478;
  --accent: #ff5a9a;
  --accent-2: #5eead4;
  --accent-soft: rgba(255, 90, 154, 0.16);
  --accent-2-soft: rgba(94, 234, 212, 0.12);
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --header-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.hidden {
  display: none !important;
}

/* ─── Ambient glow ───────────────────────────────────────── */
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% -10%, rgba(255, 90, 154, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 35% at 90% 5%, rgba(45, 212, 191, 0.12), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(255, 90, 154, 0.08), transparent 55%);
}

/* ─── Header ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 12, 16, 0.75);
  backdrop-filter: blur(16px) saturate(1.4);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nav-pill {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: default;
}

.nav-pill.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(255, 90, 154, 0.35);
}

/* ─── Main layout ────────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ─── Hero ───────────────────────────────────────────────── */
.hero {
  display: grid;
  gap: 1.75rem;
  margin-bottom: 2rem;
}

.library-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
}

.library-tab {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 4.6rem;
  padding: 0.85rem 0.7rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-radius: 16px;
  cursor: pointer;
  line-height: 1.15;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transition:
    color 0.2s var(--ease),
    background 0.2s var(--ease),
    border-color 0.2s var(--ease),
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.tab-icon {
  display: block;
  flex-shrink: 0;
}

.tab-label {
  display: block;
}

.library-tab:hover {
  color: var(--text);
  border-color: rgba(255, 90, 154, 0.45);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.library-tab.active {
  color: #fff;
  background: linear-gradient(180deg, #ff79ad 0%, #ff4d8d 100%);
  border-color: transparent;
  box-shadow: 0 10px 28px rgba(255, 77, 141, 0.38);
}

.library-tab.active .tab-icon {
  color: #fff;
}

.library-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 0.65rem;
}

.hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 36rem;
}

/* ─── Search panel ───────────────────────────────────────── */
.search-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.7rem 0.95rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-field:focus-within {
  border-color: rgba(255, 90, 154, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-field input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.98rem;
  min-width: 0;
}

.search-field input::placeholder {
  color: var(--text-faint);
}

.search-hint {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
  line-height: 1.2;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  margin-top: 0.9rem;
  padding: 0 0.15rem;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-right: auto;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sort-group,
.filter-group,
.page-size-group,
.page-jump-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sort-group select,
.filter-group select,
.page-size-group select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  outline: none;
}

.sort-group select:focus,
.filter-group select:focus,
.page-size-group select:focus {
  border-color: rgba(255, 90, 154, 0.55);
}

.filter-group select {
  max-width: 11rem;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.page-jump input[type="number"] {
  width: 4.25rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 0.35rem 0.45rem;
  outline: none;
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.page-jump input[type="number"]::-webkit-outer-spin-button,
.page-jump input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-jump input[type="number"]:focus {
  border-color: rgba(255, 90, 154, 0.55);
}

.page-jump input[type="number"]:disabled,
.page-jump-go:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-jump-of {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page-jump-go {
  min-width: 2.5rem;
  height: 2.05rem;
  padding: 0 0.65rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.page-jump-go:hover:not(:disabled) {
  border-color: rgba(255, 90, 154, 0.45);
  background: var(--bg-card-hover);
}

/* ─── Card grid ──────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* Artist styles: name above, 1024×768 (4:3) image, prompt below */
.card-grid--artists {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card-grid--artists .card--artist {
  display: flex;
  flex-direction: column;
}

.card-grid--artists .card--artist .card-name {
  padding: 0.85rem 1rem 0.7rem;
  margin: 0;
  -webkit-line-clamp: 2;
}

.card-grid--artists .card--artist .card-preview {
  aspect-ratio: 4 / 3;
  border-radius: 0;
}

.card-grid--artists .card--artist .card-img {
  object-fit: contain;
  object-position: center;
}

.card-grid--artists .card--artist .card-body {
  padding: 0.75rem 1rem 1rem;
}

.card-grid--artists .card--artist .card-footer {
  justify-content: flex-end;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s var(--ease), transform 0.25s var(--ease), background 0.2s var(--ease);
  cursor: pointer;
}

.card:hover {
  border-color: rgba(255, 90, 154, 0.4);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-preview {
  aspect-ratio: 3 / 4;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #1e2230, #12141c 60%);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.modal-preview .card-img {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
}

.modal.is-artists .modal-preview .card-img {
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.card-preview-art {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.card-preview-art::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.9;
  background:
    radial-gradient(circle at 30% 25%, var(--glow-a, rgba(255, 90, 154, 0.45)), transparent 45%),
    radial-gradient(circle at 70% 70%, var(--glow-b, rgba(45, 212, 191, 0.3)), transparent 50%);
}

.card-initials {
  position: relative;
  z-index: 1;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.card-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 2;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(11, 12, 16, 0.7);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  max-width: calc(100% - 1.3rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.card-name {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-category {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-top: -0.25rem;
}

.card-tags {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.card-count {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-copy:hover {
  color: var(--text);
  border-color: rgba(255, 90, 154, 0.45);
  background: var(--accent-soft);
}

.btn-copy.copied {
  color: var(--accent-2);
  border-color: rgba(45, 212, 191, 0.4);
  background: var(--accent-2-soft);
}

/* ─── Empty ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.empty-state h2 {
  color: var(--text);
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
}

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2.25rem;
}

.page-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.55rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.page-btn:hover:not(:disabled):not(.active) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.page-btn.active {
  background: linear-gradient(135deg, var(--accent), #5b8def);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--text-faint);
  padding: 0 0.25rem;
  user-select: none;
}

.page-jump-inline {
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.page-jump-inline label {
  white-space: nowrap;
}

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--text-faint);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal {
  border: none;
  background: transparent;
  padding: 1rem;
  max-width: 100%;
  max-height: 100%;
}

.modal::backdrop {
  background: rgba(5, 6, 10, 0.75);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(720px, 100vw - 2rem);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 240px 1fr;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(11, 12, 16, 0.7);
  color: var(--text-muted);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-card);
}

.modal-preview {
  aspect-ratio: auto;
  min-height: 280px;
  background: linear-gradient(145deg, #1e2230, #12141c);
  position: relative;
}

.modal.is-artists .modal-panel {
  width: min(880px, 100vw - 2rem);
  grid-template-columns: minmax(320px, 0.95fr) minmax(300px, 1.05fr);
}

.modal.is-artists .modal-preview {
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.modal-preview .card-preview-art {
  height: 100%;
  min-height: 280px;
}

.modal-body {
  padding: 1.5rem 1.5rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-series {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
}

.modal-series[hidden] {
  display: none;
}

.modal-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  padding-right: 2rem;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.prompt-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.prompt-block {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 200px;
  overflow: auto;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b8def);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-card);
}

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ─── Responsive ─────────────────────────────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .modal-panel {
    grid-template-columns: 200px 1fr;
  }

  .card-grid--artists {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .modal.is-artists .modal-panel {
    grid-template-columns: minmax(240px, 0.95fr) minmax(240px, 1.05fr);
  }
}

/* Phones & small tablets */
@media (max-width: 720px) {
  :root {
    --header-h: 56px;
  }

  .header-inner {
    padding: 0 0.85rem;
    gap: 0.5rem;
  }

  .brand {
    gap: 0.55rem;
    min-width: 0;
  }

  .brand-mark svg {
    width: 26px;
    height: 26px;
  }

  .brand-text strong {
    font-size: 0.98rem;
  }

  .brand-text span {
    font-size: 0.65rem;
  }

  /* Compact model pills: scroll horizontally instead of vanishing */
  .header-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: min(52vw, 11.5rem);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-pill {
    font-size: 0.72rem;
    padding: 0.3rem 0.55rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .main {
    padding: 1.25rem 0.85rem 3rem;
  }

  .hero {
    gap: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .library-tabs {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .library-tab {
    min-height: 3.6rem;
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.7rem 0.55rem;
    font-size: 0.82rem;
    border-radius: 12px;
  }

  .tab-icon {
    width: 16px;
    height: 16px;
  }

  .eyebrow {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
  }

  .hero h1 {
    font-size: clamp(1.55rem, 7.2vw, 2.1rem);
    margin-bottom: 0.55rem;
  }

  /* Soften forced line break on narrow screens */
  .hero h1 br {
    display: none;
  }

  .lede {
    font-size: 0.95rem;
  }

  .search-panel {
    padding: 0.75rem;
    border-radius: var(--radius);
  }

  .search-field {
    padding: 0.65rem 0.8rem;
  }

  .search-field input {
    font-size: 1rem; /* avoids iOS zoom on focus */
  }

  .search-hint {
    display: none; /* "/" shortcut is desktop-only */
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-top: 0.75rem;
  }

  .stat {
    margin-right: 0;
  }

  .sort-group,
  .filter-group,
  .page-size-group,
  .page-jump-group {
    justify-content: space-between;
    width: 100%;
  }

  .sort-group select,
  .filter-group select,
  .page-size-group select {
    flex: 1;
    min-height: 2.5rem;
    min-width: 0;
    max-width: none;
    font-size: 0.9rem;
    padding: 0.45rem 0.6rem;
  }

  .page-jump {
    flex: 1;
    min-width: 0;
  }

  .page-jump input[type="number"] {
    flex: 1;
    min-height: 2.5rem;
    min-width: 4rem;
    font-size: 0.95rem;
  }

  .page-jump-go {
    min-height: 2.5rem;
    height: 2.5rem;
  }

  /* Two-up character grid on phones */
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .card-body {
    padding: 0.7rem 0.7rem 0.8rem;
    gap: 0.4rem;
  }

  .card-grid--artists .card--artist .card-name {
    padding: 0.7rem 0.7rem 0.55rem;
  }

  .card-grid--artists .card--artist .card-body {
    padding: 0.65rem 0.7rem 0.8rem;
  }

  .card-name {
    font-size: 0.88rem;
  }

  .card-tags {
    font-size: 0.65rem;
    -webkit-line-clamp: 2;
  }

  .card-badge {
    font-size: 0.6rem;
    top: 0.45rem;
    left: 0.45rem;
    max-width: calc(100% - 0.9rem);
    padding: 0.2rem 0.4rem;
  }

  .card-initials {
    font-size: 1.75rem;
  }

  .card-footer {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .btn-copy {
    min-height: 2rem;
    padding: 0.35rem 0.55rem;
  }

  .card:hover {
    transform: none; /* avoid sticky hover on touch */
  }

  .empty-state {
    padding: 2.5rem 0.75rem;
  }

  .pagination {
    gap: 0.3rem;
    margin-top: 1.5rem;
  }

  .page-btn {
    min-width: 2.5rem;
    height: 2.5rem;
    font-size: 0.9rem;
  }

  .page-jump-inline {
    flex-basis: 100%;
    justify-content: center;
    margin: 0.5rem 0 0;
    padding: 0.5rem 0 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .site-footer {
    padding: 0 0.85rem calc(1.75rem + env(safe-area-inset-bottom, 0px));
    font-size: 0.8rem;
  }

  /* Modal → full-screen sheet */
  .modal {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .modal[open] {
    display: flex;
    flex-direction: column;
  }

  .modal-panel {
    width: 100%;
    max-width: 100%;
    flex: 1;
    min-height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    grid-template-columns: 1fr;
  }

  .modal-preview {
    min-height: 0;
    aspect-ratio: 4 / 3;
    max-height: 42vh;
  }

  .modal.is-artists .modal-preview {
    aspect-ratio: 4 / 3;
    max-height: 42vh;
  }

  .modal-preview .card-img {
    min-height: 0;
    max-height: 42vh;
  }

  .modal-preview .card-preview-art {
    min-height: 0;
    height: 100%;
  }

  .modal-body {
    padding: 1.1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }

  .modal-body h2 {
    font-size: 1.2rem;
    padding-right: 2.5rem;
  }

  .modal-close {
    top: 0.6rem;
    right: 0.6rem;
    width: 2.5rem;
    height: 2.5rem;
  }

  .prompt-block {
    font-size: 0.8rem;
    max-height: min(28vh, 180px);
    padding: 0.75rem 0.85rem;
  }

  .modal-actions {
    flex-direction: column;
    margin-top: 0.85rem;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
  }

  .toast {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    right: 1rem;
    width: auto;
    max-width: none;
    transform: translateY(120%);
    text-align: center;
    font-size: 0.88rem;
    padding: 0.75rem 1rem;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .card-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .card-tags {
    -webkit-line-clamp: 3;
  }

  .header-nav {
    display: none;
  }

  .brand-text span {
    display: none;
  }

  .modal-preview {
    aspect-ratio: 1 / 1;
    max-height: 38vh;
  }

  .modal.is-artists .modal-preview {
    aspect-ratio: 4 / 3;
    max-height: 38vh;
  }
}

/* Touch devices: larger hit targets, no hover lift */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    transform: none;
  }

  .btn-copy,
  .page-btn,
  .btn {
    min-height: 2.5rem;
  }

  .search-hint {
    display: none;
  }
}

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