/* ---------- Tokens ---------- */
:root {
  --bg: #0d0f12;
  --bg-2: #14171c;
  --surface: #181c22;
  --surface-2: #1e232b;
  --sidebar: #12151a;
  --border: #2a313b;
  --border-2: #384250;
  --text: #e7ebf0;
  --text-dim: #9aa4b2;
  --text-faint: #6b7684;
  --accent: #ff7a1a;
  --accent-2: #ffab5e;
  --accent-ink: #1a1206;
  --focus: #6ea8ff;
  --tag-bg: #22303a;
  --tag-text: #8fc5d6;
  --error-bg: #3a1e1e;
  --error-text: #e08a8a;
  --success-bg: #17301f;
  --success-text: #7fce9d;
  --info-bg: #1a2436;
  --info-text: #86a8e0;
  --radius: 12px;
  --radius-sm: 8px;
  --wrap: 1080px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font);
}

* { box-sizing: border-box; }

/* Ensure [hidden] / .hidden win over display:flex/grid author rules below. */
[hidden] { display: none !important; }
.hidden { display: none !important; }
.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;
}

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

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(255, 122, 26, 0.10), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  font-size: 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
.page-pad { padding-block: 32px 56px; }

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

/* ---------- Disclaimer banner ---------- */
.disclaimer-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, rgba(255, 122, 26, 0.14), rgba(255, 122, 26, 0.06));
  border-bottom: 1px solid var(--border);
  padding: 10px 20px; font-size: 0.85rem; color: var(--text-dim);
}
.disclaimer-banner p { margin: 0; max-width: 1400px; margin-inline: auto; flex: 1; }
.disclaimer-banner strong { color: var(--text); }
.disclaimer-close {
  background: none; border: 1px solid var(--border-2); color: var(--text-dim);
  border-radius: 6px; cursor: pointer; width: 28px; height: 28px; flex: none; line-height: 1;
}
.disclaimer-close:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(13, 15, 18, 0.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { max-width: 1400px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.25rem; }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -0.01em; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--text-dim); padding: 7px 12px; border-radius: 8px; font-size: 0.92rem; font-weight: 500; }
.site-nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent-2); background: rgba(255, 122, 26, 0.10); }

/* ---------- Main / hero ---------- */
.site-main { flex: 1; }
.hero { text-align: center; margin: 8px auto 24px; max-width: 640px; }
.hero-sub { margin-bottom: 18px; }
.hero-title { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0 0 8px; letter-spacing: -0.02em; }
.hero-tagline { color: var(--text-dim); font-size: 1.02rem; margin: 0 auto; }
.hero-stats { color: var(--text-faint); font-size: 0.9rem; margin-top: 12px; }
.hero-stats strong { color: var(--accent-2); }
.crumbs { color: var(--text-faint); font-size: 0.85rem; margin-bottom: 8px; }
.crumbs a { color: var(--text-dim); }

/* ---------- Browse layout (sidebar + main) ---------- */
.browse-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 0;
  max-width: 1400px; margin-inline: auto; align-items: start;
}
.sidebar {
  position: sticky; top: 60px; align-self: start;
  height: calc(100dvh - 60px); overflow-y: auto;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 24px;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.filter-group > label:first-child {
  display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-faint); margin-bottom: 8px;
}
.filter-options { display: flex; flex-direction: column; gap: 2px; }
.filter-option {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px;
  cursor: pointer; font-size: 0.86rem; color: var(--text-dim);
  transition: background .12s, color .12s;
}
.filter-option:hover { background: var(--surface); color: var(--text); }
.filter-option input { accent-color: var(--accent); cursor: pointer; flex: none; }
.filter-count {
  margin-left: auto; font-size: 0.72rem; color: var(--text-faint);
  background: var(--surface); padding: 1px 7px; border-radius: 10px;
}
#search-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font: inherit; font-size: 0.9rem; outline: none;
}
#search-input:focus { border-color: var(--border-2); box-shadow: 0 0 0 3px rgba(110,168,255,.15); }
#search-input::placeholder { color: var(--text-faint); }
#clear-filters {
  margin-top: auto; width: 100%; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 9px; color: var(--text-dim); font: inherit; font-size: 0.85rem; cursor: pointer;
}
#clear-filters:hover { border-color: var(--accent); color: var(--accent-2); }

/* Category filter chips (sidebar) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  padding: 5px 11px; border-radius: 999px; font: inherit; font-size: 0.82rem; cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.chip:hover { color: var(--text); border-color: var(--border-2); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-count { opacity: 0.65; font-size: 0.9em; }

.browse-main { padding: 24px 28px 56px; min-width: 0; }

/* ---------- Toolbar / sort ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-standalone { margin-top: 8px; }
.result-count { font-size: 0.85rem; color: var(--text-faint); }
.sort-controls { display: flex; align-items: center; gap: 8px; }
.sort-controls label { font-size: 0.82rem; color: var(--text-faint); }
#sort-select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; outline: none;
}
#sort-select:focus { border-color: var(--border-2); }
/* search field used on category toolbar */
.search-field {
  position: relative; flex: 1; min-width: 200px; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 16px 0 14px;
}
.search-field:focus-within { border-color: var(--border-2); box-shadow: 0 0 0 3px rgba(110,168,255,.15); }
.search-icon { color: var(--text-faint); flex: none; }
.search-field input { flex: 1; background: none; border: 0; color: var(--text); font: inherit; padding: 11px 10px; outline: none; }
.search-field input::placeholder { color: var(--text-faint); }

/* ---------- Card grid & cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-content: start; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.card-thumb { width: 100%; aspect-ratio: 16 / 9; background: var(--bg-2); position: relative; overflow: hidden; flex: none; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb.thumb-error img, .card-thumb.thumb-empty img { display: none; }
.thumb-placeholder {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
}
.card-thumb.thumb-error .thumb-placeholder, .card-thumb.thumb-empty .thumb-placeholder { display: flex; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-category {
  align-self: flex-start; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 3px 8px; border-radius: 5px;
  /* Hue set inline per category via the categoryColor filter (--cat-h). */
  background: hsl(var(--cat-h, 220) 32% 17%);
  color: hsl(var(--cat-h, 220) 60% 72%);
}
.card-title { margin: 0; font-size: 1rem; line-height: 1.32; font-weight: 600; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent-2); text-decoration: none; }
.card-ext { color: var(--text-faint); font-size: 0.85em; }
.card-desc {
  margin: 0; color: var(--text-dim); font-size: 0.86rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag {
  background: var(--tag-bg); color: var(--tag-text); border: 0; font: inherit; font-size: 0.72rem;
  padding: 3px 9px; border-radius: 999px; cursor: pointer; transition: filter .12s;
}
.tag:hover { filter: brightness(1.25); }
.card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.72rem; color: var(--text-faint); padding-top: 8px;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.card-creator { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-date { flex: none; }
.no-results { text-align: center; color: var(--text-faint); padding: 48px 0; font-size: 1rem; }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 18px; display: flex; flex-direction: column; gap: 4px; color: var(--text);
  transition: border-color .14s, transform .14s;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.cat-card-name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.cat-card-count { color: var(--text-faint); font-size: 0.85rem; }

/* ---------- Forms (submit) ---------- */
.submit-form { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.field label { font-size: 0.9rem; font-weight: 500; color: var(--text-dim); }
.field .req { color: var(--accent); }
.field .opt { color: var(--text-faint); font-weight: 400; }
.field input, .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; padding: 11px 13px; outline: none; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--border-2); box-shadow: 0 0 0 3px rgba(110,168,255,.15); }
.field textarea { resize: vertical; }
.btn { font: inherit; font-weight: 600; border-radius: 999px; padding: 12px 22px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--accent-ink); align-self: flex-start; }
.btn-primary:hover { background: var(--accent-2); }
.form-note { font-size: 0.82rem; color: var(--text-faint); margin: 0; }

/* ---------- Prose (about) ---------- */
.prose { max-width: 680px; }
.prose h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: 0; }
.prose h2 { font-family: var(--font-display); font-size: 1.2rem; margin-top: 28px; color: var(--accent-2); }
.prose p { color: var(--text-dim); }
.prose strong { color: var(--text); }
.prose-meta { font-size: 0.85rem; color: var(--text-faint); margin-top: 28px; border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-2); padding-block: 24px; }
.site-footer .wrap { max-width: 1400px; }
.footer-inner { display: flex; flex-direction: column; gap: 10px; }
.footer-note { color: var(--text-faint); font-size: 0.82rem; margin: 0; max-width: 760px; }
.footer-meta { color: var(--text-faint); font-size: 0.82rem; margin: 0; }
.footer-meta a { color: var(--text-dim); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .browse-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border);
    flex-direction: row; flex-wrap: wrap; gap: 18px; align-items: flex-start;
  }
  .sidebar .filter-group { min-width: 160px; flex: 1; }
  #clear-filters { margin-top: 0; width: auto; }
  .browse-main { padding: 20px; }
}
@media (max-width: 620px) {
  .header-inner { height: auto; flex-direction: column; align-items: flex-start; padding-block: 10px; gap: 6px; }
  .site-header { position: static; }
  .card-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; }
}

/* ---------- Admin console ---------- */
.admin-layout { max-width: 920px; margin: 0 auto; padding: 24px 20px 56px; display: flex; flex-direction: column; gap: 20px; }
.admin-intro { color: var(--text-dim); font-size: 0.9rem; }
.admin-warn {
  background: var(--error-bg); border: 1px solid #5a3030; color: var(--error-text);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.85rem;
}
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.admin-section h2 { font-size: 0.98rem; font-weight: 700; margin: 0; border-bottom: 1px solid var(--border); padding-bottom: 10px; color: var(--text); }
.admin-section p, .admin-section .hint { font-size: 0.84rem; color: var(--text-dim); margin: 0; }
.admin-section .hint { color: var(--text-faint); font-style: italic; }
.admin-section code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.admin-section input[type="text"], .admin-section input[type="url"], .admin-section input[type="date"],
.admin-section input[type="file"], .admin-section textarea, .admin-section select {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--text); font: inherit; font-size: 0.86rem; outline: none; width: 100%;
}
.admin-section input:focus, .admin-section textarea:focus, .admin-section select:focus { border-color: var(--accent); }
.admin-section textarea { resize: vertical; min-height: 70px; }
.admin-section button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 16px; color: var(--text-dim); font: inherit; font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.admin-section button:hover { border-color: var(--border-2); color: var(--text); }
.btn-accent { background: rgba(255,122,26,.14) !important; border-color: var(--accent) !important; color: var(--accent-2) !important; font-weight: 600; }
.btn-accent:hover { background: var(--accent) !important; color: var(--accent-ink) !important; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 0.74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.form-grid .full-width { grid-column: 1 / -1; }
.action-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.action-row #entry-count { font-size: 0.82rem; color: var(--text-faint); flex: 1; }
.status-msg { font-size: 0.82rem; border-radius: var(--radius-sm); padding: 7px 11px; display: none; }
.status-msg.visible { display: block; }
.status-msg.error { background: var(--error-bg); color: var(--error-text); }
.status-msg.success { background: var(--success-bg); color: var(--success-text); }
.status-msg.info { background: var(--info-bg); color: var(--info-text); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.admin-table th { text-align: left; padding: 6px 8px; color: var(--text-faint); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--text-dim); vertical-align: middle; }
.admin-table .btn-del { background: transparent; border-color: #5a3030; color: var(--error-text); padding: 3px 9px; font-size: 0.75rem; }
.admin-table .btn-del:hover { background: var(--error-bg); }
.admin-table .btn-edit { background: transparent; border-color: #2f3f5a; color: var(--info-text); padding: 3px 9px; font-size: 0.75rem; }
.admin-table .btn-edit:hover { background: var(--info-bg); }
.channel-item-dupe { opacity: 0.45; text-decoration: line-through; }
.preview-card { max-width: 300px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* Manage entries: controls / bulk bar / pager */
.manage-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.manage-controls input[type="search"] { flex: 1; min-width: 180px; }
.manage-controls select { width: auto; }
.manage-controls #mng-count { margin-left: auto; }
.bulk-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: rgba(255,122,26,.08); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 12px;
}
.bulk-bar input[type="text"] { width: auto; }
.bulk-bar strong { color: var(--accent-2); }
.bulk-sep { width: 1px; align-self: stretch; background: var(--border-2); margin: 0 2px; }
.bulk-progress {
  display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
  background: var(--info-bg); color: var(--info-text); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.85rem;
}
.admin-table td .row-cb, .admin-table th #page-selectall { cursor: pointer; }
.admin-table tr.row-broken td { background: rgba(224,138,138,.06); }
.admin-table tr.row-broken td:nth-child(3) { color: var(--text-faint); text-decoration: line-through; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; }
.pager button { min-width: 64px; }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager .pager-info { font-size: 0.85rem; color: var(--text-dim); min-width: 120px; text-align: center; }
