:root {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --surface: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-ring: rgba(37, 99, 235, 0.12);
  --success: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.08);
  --header-h: 72px;
  --gold: #c9a227;
  --gold-light: #d4af37;
  --gold-dark: #a8841a;
  --gold-soft: #faf6eb;
  --gold-soft-end: #ffffff;
  --gold-border: rgba(201, 162, 39, 0.45);
  --gold-ring: rgba(201, 162, 39, 0.18);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-subtle: #131920;
  --surface: #171d26;
  --bg-card: #171d26;
  --bg-elevated: #1c2430;
  --border: #2a3441;
  --border-strong: #3d4a5c;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-ring: rgba(59, 130, 246, 0.2);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.4);
  --gold-soft: rgba(201, 162, 39, 0.1);
  --gold-soft-end: #171d26;
  --gold-border: rgba(212, 175, 55, 0.5);
  --gold-ring: rgba(212, 175, 55, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.container {
  width: min(1120px, 92vw);
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: 1rem;
}

.header-search-wrap {
  position: relative;
  flex: 1 1 10rem;
  max-width: 13rem;
  min-width: 8.5rem;
}

.header-search-wrap .directory-search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.header-search-wrap .directory-search-input {
  width: 100%;
  padding: 0.375rem 0.625rem 0.375rem 2rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.header-search-wrap .directory-search-input::placeholder {
  color: var(--text-muted);
}

.header-search-wrap .directory-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.nav-main {
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  height: 42px;
  width: auto;
  max-width: min(260px, 62vw);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.theme-icon {
  display: none;
}

[data-theme="light"] .theme-icon-sun,
[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.nav-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-main a:not(.btn) {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.nav-main a:not(.btn):hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav-admin {
  position: relative;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
}

.main-content {
  flex: 1;
  padding-bottom: 3rem;
  overflow: visible;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 2.5rem;
  background: var(--surface);
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer-logo {
  height: 30px;
  width: auto;
  opacity: 0.9;
}

.site-footer p {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.8125rem;
}

.top-bar {
  padding: 0.875rem 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  transition: transform 0.28s ease, opacity 0.28s ease, visibility 0.28s;
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

[data-theme="dark"] .top-bar {
  background: rgba(23, 29, 38, 0.92);
}

[data-theme="dark"] .site-header {
  background: rgba(11, 15, 20, 0.9);
}

.top-bar.is-hidden {
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.top-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-empty {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.pill-active {
  border-color: transparent;
  color: #ffffff;
  background: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.pill-active:hover {
  color: #ffffff;
  background: var(--accent-hover);
  border-color: transparent;
}

[data-theme="dark"] .pill-active {
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.pill-default {
  border-color: transparent;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.category-section[hidden] {
  display: none !important;
}

.group-card[hidden] {
  display: none !important;
}

.category-card-wrap[hidden] {
  display: none !important;
}

.category-section {
  padding: 0;
}

.directory-sections {
  padding: 2rem 0 3rem;
}

.directory-sections.view-all {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 1rem;
  row-gap: 2.75rem;
  align-items: stretch;
  padding-top: 3.5rem;
  overflow: visible;
}

.directory-sections.view-all.is-searching {
  padding-top: 4.5rem;
  row-gap: 3.25rem;
}

.view-all .category-section,
.view-all .card-grid {
  display: contents;
}

.view-all .category-header {
  display: none;
}

.view-all .category-run-label h2 {
  margin: 0 0 0.35rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.35;
}

.view-all .category-run-label .category-desc {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.view-all .category-run-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.65rem);
  margin: 0;
  padding: 0;
  pointer-events: none;
  z-index: 1;
}

.view-all .category-card-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  overflow: visible;
}

.view-all .category-card-wrap .group-card {
  flex: 1 1 auto;
  height: 100%;
  min-height: 100%;
  width: 100%;
}

.view-all .category-default {
  background: none;
}

.view-all .card-grid {
  display: contents;
}

.directory-sections:not(.view-all) .category-section {
  width: 100%;
  padding-bottom: 2.5rem;
}

.directory-sections:not(.view-all) .category-card-wrap {
  display: contents;
}

.directory-sections:not(.view-all) .category-run-label {
  display: none !important;
}

.directory-sections:not(.view-all) .category-section:last-child {
  padding-bottom: 0;
}

.directory-sections .category-section[hidden] {
  display: none !important;
}

.directory-sections .category-default {
  background: none;
}

.category-section + .category-section {
  border-top: none;
}

.category-default {
  background: linear-gradient(180deg, var(--accent-soft) 0%, transparent 55%);
}

.category-header {
  margin-bottom: 1.25rem;
}

.category-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.category-section-selected .category-header h2 {
  font-size: 1.375rem;
}

.category-section-selected {
  padding-top: 0.5rem;
}

.category-desc {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9375rem;
  max-width: 36rem;
}

.label-default {
  display: inline-block;
  margin-top: 0.625rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
}

.label-nsfw {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
  border-radius: var(--radius-sm);
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.field-checkbox {
  align-self: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .card-grid,
  .directory-sections.view-all {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .card-grid,
  .directory-sections.view-all {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .card-grid,
  .directory-sections.view-all {
    grid-template-columns: 1fr;
  }
}

.group-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  height: 100%;
  min-height: 100%;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--shadow-xs);
}

.group-card-pinned {
  background: linear-gradient(180deg, var(--gold-soft) 0%, var(--gold-soft-end) 100%);
  border-color: var(--gold-border);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--gold-ring);
}

.group-card-pinned .card-icon-img,
.group-card-pinned .card-icon-fallback {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 4px var(--gold-ring);
}

.group-card-pinned .card-title {
  color: var(--text);
}

.group-card-pinned .btn-primary {
  background: var(--accent);
}

.group-card-pinned .btn-primary:hover {
  background: var(--accent-hover);
}

.pin-badge {
  color: var(--gold-light);
  font-size: 0.875rem;
}

.card-pin-star {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--gold-light);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-full);
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.category-featured {
  padding: 2.5rem 0;
  background: linear-gradient(180deg, var(--gold-soft) 0%, var(--bg) 100%);
  border-top: none;
}

.category-featured .category-header h2 {
  color: var(--text);
}

.group-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.group-card-pinned:hover {
  border-color: var(--gold-light);
  box-shadow: var(--shadow-hover), 0 0 0 1px var(--gold-ring);
}

.card-icon-wrap {
  width: 88px;
  height: 88px;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.card-icon-img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
  box-shadow: var(--shadow-xs);
}

.card-icon-fallback {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b82f6, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 2rem;
  border: 2px solid var(--border);
}

.card-title {
  margin: 0 0 0.15rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

.card-handle {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  word-break: break-word;
}

.card-count {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.card-count-empty {
  visibility: hidden;
  margin-bottom: 0.75rem;
}

.card-desc {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  flex: 1;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc-empty {
  visibility: hidden;
  margin-bottom: 1rem;
}

.card-cta {
  margin-top: auto;
  width: 100%;
}

/* Legacy avatar classes (admin table) */
.tg-avatar-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.tg-avatar-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}

.tg-avatar,
.tg-avatar-fallback {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

.table-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.table-thumb-placeholder {
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.thumb-cell {
  width: 48px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.8125rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  background: rgba(242, 92, 84, 0.15);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.page-narrow {
  max-width: 520px;
  padding-top: 2rem;
}

.page-lead {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-xs);
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.label-spaced {
  margin-top: 0.75rem;
}

.suggested-category {
  font-weight: 600;
  color: var(--accent);
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.flash-wrap {
  padding-top: 1rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.flash-success {
  background: #ecfdf5;
  color: var(--success);
  border: 1px solid #a7f3d0;
}

.flash-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.empty-state {
  text-align: center;
  padding: 4rem 0;
}

.empty-state h2 {
  margin-bottom: 0.5rem;
}

/* Admin */
.admin-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  width: min(1200px, 92vw);
  margin: 2rem auto;
}

.admin-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
}

.admin-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: var(--bg-card);
  color: var(--text);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  min-width: 140px;
}

.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-warn .stat-num {
  color: var(--warn);
}

.admin-hint {
  color: var(--text-muted);
}

.sortable-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

.sortable-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: grab;
}

.sortable-item.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.drag-handle {
  color: var(--text-muted);
  user-select: none;
}

.sortable-body {
  flex: 1;
}

.sortable-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.sortable-thumb {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.sortable-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.sortable-item-group .sortable-body .muted {
  font-weight: 400;
}

.empty-inline {
  color: var(--text-muted);
  margin: 0 0 2rem;
  font-size: 0.95rem;
}

.muted,
.small {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.field-grow {
  flex: 1;
  min-width: 180px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.status {
  text-transform: capitalize;
  font-weight: 600;
  font-size: 0.8rem;
}

.status-approved {
  color: var(--success);
}

.status-pending {
  color: var(--warn);
}

.status-rejected {
  color: var(--danger);
}

.actions-cell {
  white-space: nowrap;
}

.inline-select {
  padding: 0.25rem;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
}

[data-theme="dark"] .link-row input {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

[data-theme="dark"] .input-prefix {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--bg-card);
  color: var(--text);
  max-width: 400px;
}

.modal-wide {
  max-width: 560px;
}

.edit-preview {
  margin: 0.75rem 0;
}

.edit-preview-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.nsfw-gate-modal {
  max-width: 440px;
}

.nsfw-gate-modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.nsfw-gate-lead {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
}

.pill-nsfw {
  border-color: rgba(220, 38, 38, 0.35);
}

.pill-nsfw.pill-active {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.5);
  color: #dc2626;
}

.login-page {
  padding-top: 4rem;
}

.submit-page {
  padding-top: 1.5rem;
}

.submit-back {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.submit-back a {
  color: var(--text-muted);
  font-weight: 500;
}

.link-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.link-row input {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
}

.preview-loading {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.submit-step-two {
  margin-top: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.45s ease, opacity 0.35s ease, margin-top 0.35s ease;
}

.submit-step-two.is-open {
  max-height: 2000px;
  opacity: 1;
  margin-top: 1rem;
}

.submit-step-two > .form-card,
.submit-step-two > .preview-card {
  margin-bottom: 1rem;
}

.preview-card-inner {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.preview-avatar-wrap {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  position: relative;
}

.preview-avatar-img,
.preview-avatar-fallback {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

.preview-avatar-img {
  object-fit: cover;
  display: block;
}

.preview-avatar-img[hidden],
.preview-avatar-fallback[hidden] {
  display: none !important;
}

.preview-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3b82f6, #6366f1);
  color: #fff;
  font-weight: 600;
  font-size: 1.75rem;
}

.preview-thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.preview-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3b82f6, #60a5fa);
  color: #fff;
  font-weight: 700;
  font-size: 1.75rem;
}

.preview-text h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.preview-username {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.preview-members {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.preview-members[hidden] {
  display: none;
}

.preview-description {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.preview-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.preview-badge-public {
  background: #ecfdf5;
  color: var(--success);
}

.preview-badge-private {
  background: #fff7ed;
  color: var(--warn);
}

.input-prefix-wrap {
  display: flex;
  align-items: stretch;
}

.input-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text-muted);
  font-weight: 600;
}

.input-prefix-wrap input {
  border-radius: 0 8px 8px 0;
  flex: 1;
}

@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-main {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
