/* ==========================================================================
   VexumHub — blue & black theme
   ========================================================================== */
:root {
  --bg: #03050b;
  --bg-deep: #010207;
  --surface: rgba(10, 20, 42, 0.55);
  --surface-2: rgba(16, 30, 60, 0.55);
  --surface-solid: #070e1f;
  --code-bg: #050a16;
  --line: rgba(110, 165, 255, 0.12);
  --line-strong: rgba(110, 165, 255, 0.24);
  --text: #ffffff;
  --muted: rgba(220, 232, 255, 0.68);
  --dim: rgba(220, 232, 255, 0.45);
  --accent: #3b7bff;
  --accent-soft: rgba(59, 123, 255, 0.14);
  --accent-line: rgba(59, 123, 255, 0.45);
  --accent-2: #38bdf8;
  --grad: linear-gradient(90deg, #f0f7ff 0%, #8cc4ff 40%, #3b7bff 100%);
  --danger: #ff6b8a;
  --ok: #34d399;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --nav-h: 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 12px); }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  display: flex; flex-direction: column; overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: rgba(59, 123, 255, 0.5); }
mark { background: rgba(59, 123, 255, 0.35); color: #fff; border-radius: 3px; padding: 0 2px; }
.ic { width: 16px; height: 16px; flex: none; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.link { color: #8cc4ff; font-weight: 600; }
.link:hover { text-decoration: underline; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* background */
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(110,165,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,165,255,0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 25%, transparent 75%);
}
.bg-glow {
  position: fixed; z-index: -1; pointer-events: none;
  left: 50%; top: -260px; width: min(1000px, 140vw); height: 620px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(59,123,255,0.28), transparent);
}

.container { width: 100%; max-width: 76rem; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 28px; padding-bottom: 72px; }
.narrow { max-width: 860px; margin: 0 auto; }
.narrow.wide { max-width: 980px; }

/* ==========================================================================
   Nav
   ========================================================================== */
.topbar-wrap { position: sticky; top: 0; z-index: 50; padding: 12px 16px 0; }
.topbar {
  max-width: 76rem; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 14px;
  background: rgba(2, 5, 12, 0.72);
  border: 1px solid var(--line); border-radius: var(--r);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.04em; font-size: 15.5px; flex: none; }
.brand-mark { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(59,123,255,0.6)); }
.nav-pills {
  display: flex; gap: 2px; padding: 3px; margin: 0 auto;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: var(--r);
}
.nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s;
}
.nav-pill:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-pill.active { background: var(--accent); color: #fff; box-shadow: 0 0 18px rgba(59,123,255,0.5); }
.nav-right { display: flex; align-items: center; gap: 6px; flex: none; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 600;
}

/* ==========================================================================
   Buttons, inputs, badges
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: rgba(255,255,255,0.04);
  font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .25s var(--ease), background .2s, box-shadow .25s, border-color .2s;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(140,196,255,0.4); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #6aa6ff, #3b7bff 50%, #2456e6);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12) inset, 0 6px 22px rgba(59,123,255,0.4);
}
.btn-primary:hover { background: linear-gradient(135deg, #84b7ff, #4f8bff 50%, #2f63f0); box-shadow: 0 0 0 1px rgba(255,255,255,0.2) inset, 0 8px 30px rgba(59,123,255,0.55); }
.btn-danger { border-color: rgba(255,107,138,0.4); color: #ffc2cf; background: rgba(255,107,138,0.07); }
.btn-danger:hover { background: rgba(255,107,138,0.16); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { border-color: transparent; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-xs { padding: 5px 7px; font-size: 12px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.icon-only { padding: 7px 9px; }
.danger-text { color: #ff9fb3; }
.danger-text:hover { background: rgba(255,107,138,0.12); }

.input, .select {
  background: rgba(0, 4, 14, 0.6); border: 1px solid var(--line-strong); border-radius: var(--r);
  padding: 10px 12px; outline: none; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.select { width: auto; cursor: pointer; padding-right: 30px; }
.select-sm { padding: 6px 28px 6px 10px; font-size: 13px; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,123,255,0.22); }
.input::placeholder { color: var(--dim); }
.select option { background: var(--surface-solid); }
textarea.input { resize: vertical; min-height: 100px; line-height: 1.55; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line-strong); background: rgba(0,0,0,0.3); line-height: 1.6;
}
.badge-script { color: #cfe2ff; border-color: var(--accent-line); background: var(--accent-soft); }
.badge-file { color: #c4ecff; border-color: rgba(56,189,248,0.45); background: rgba(56,189,248,0.1); }
.chip {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); line-height: 1.6;
}
.chip-dim { color: var(--dim); }
.chip-op { color: #cfe2ff; border-color: var(--accent-line); }
.role { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: rgba(255,255,255,0.08); line-height: 1.6; }
.role-owner { background: var(--grad); color: #020617; }
.role-admin { background: rgba(59,123,255,0.3); color: #dbe8ff; }
.role-uploader { background: rgba(56,189,248,0.2); color: #dff4ff; }
.role-member { color: var(--muted); }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 12.5px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #3b7bff, #1e3a8a);
  border: 1px solid rgba(140,196,255,0.35);
}

/* ==========================================================================
   Page structure
   ========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(26px, 4.5vw, 34px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.page-head p { margin-top: 4px; }
.section { margin-top: 44px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(220,232,255,0.82); }
.section > .section-head h2 { font-size: 15px; }
.section-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #8cc4ff; }
.link-more:hover { color: #fff; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); grid-column: 1 / -1; }
.empty.error { color: #ffc2cf; border-color: rgba(255,107,138,0.4); }
.loading { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 90px 0; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.more { display: flex; justify-content: center; margin-top: 20px; }
.more:empty { display: none; }

/* ==========================================================================
   Home
   ========================================================================== */
.hero { text-align: center; padding: 28px 0 8px; }
.hero-logo {
  width: clamp(96px, 15vw, 150px); height: auto; margin: 0 auto 8px;
  filter: drop-shadow(0 0 30px rgba(59,123,255,0.55));
  animation: float 6s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); filter: drop-shadow(0 0 44px rgba(59,123,255,0.8)); } }
.hero h1 { font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-size: clamp(42px, 9vw, 92px); text-shadow: 0 0 60px rgba(59,123,255,0.35); }
.hero h1 .grad { text-shadow: none; filter: drop-shadow(0 0 24px rgba(59,123,255,0.45)); }
.tagline { font-size: clamp(18px, 3vw, 28px); font-weight: 500; line-height: 1.25; margin: 12px 0 26px; color: rgba(255,255,255,0.88); }
.tagline span { color: #6aa6ff; }

.search-wrap { position: relative; max-width: 600px; margin: 0 auto; display: flex; align-items: center; }
.search-wrap > .ic { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--dim); pointer-events: none; }
.search {
  width: 100%; padding: 15px 104px 15px 46px;
  background: rgba(0,4,14,0.7); border: 1px solid var(--line-strong); border-radius: var(--r);
  font-size: 15px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59,123,255,0.2); }
.search-btn { position: absolute; right: 6px; }
.search-wrap.sm > .ic { left: 12px; width: 16px; height: 16px; }
.search-sm { padding-left: 36px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 36px; }
.stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.stat-icon { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid var(--accent-line); color: #8cc4ff; }
.stat b { display: block; font-size: 20px; font-weight: 800; line-height: 1.1; }
.stat small { color: var(--dim); font-size: 12px; font-weight: 600; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color .2s, background .2s, transform .3s var(--ease);
}
.cat-tile:hover { border-color: var(--accent-line); background: var(--surface-2); transform: translateY(-2px); }
.cat-icon { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3); color: var(--accent-2); }
.cat-text { flex: 1; min-width: 0; }
.cat-text b { display: block; font-size: 14.5px; }
.cat-text small { display: block; color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-count { font-size: 12px; font-weight: 800; color: var(--muted); background: rgba(255,255,255,0.06); border-radius: 999px; padding: 2px 9px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: transform .35s var(--ease), border-color .25s, box-shadow .35s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: 0 16px 44px rgba(0,0,0,0.4), 0 0 24px rgba(59,123,255,0.18); }
.thumb { aspect-ratio: 16 / 9; background: rgba(0,0,0,0.5); overflow: hidden; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.card:hover .thumb img { transform: scale(1.04); }
.thumb-ph { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(140,196,255,0.55); background: radial-gradient(circle at 50% 120%, rgba(59,123,255,0.28), transparent 65%); }
.thumb-ph .ic { width: 34px; height: 34px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card h3 { font-size: 15.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); }
.card-meta b { color: var(--muted); font-weight: 600; }
.card-stat { display: inline-flex; align-items: center; gap: 4px; }
.card-stat .ic { width: 13px; height: 13px; }

/* ==========================================================================
   Forum
   ========================================================================== */
.forum { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.sidebar { position: sticky; top: calc(var(--nav-h) + 12px); display: flex; flex-direction: column; gap: 18px; }
.side-title { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; padding-left: 2px; }
.side-list { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.side-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.side-link.active { background: var(--accent-soft); border-color: var(--accent-line); color: #fff; }
.side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { font-size: 11.5px; font-weight: 700; color: var(--dim); }
.side-link.active .side-count { color: #8cc4ff; }
.sidebar > .btn { align-self: flex-start; }

.seg { display: inline-flex; gap: 3px; padding: 3px; background: rgba(0,4,14,0.6); border: 1px solid var(--line); border-radius: var(--r); }
.seg-full { display: flex; }
.seg-full .seg-btn { flex: 1; }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px;
  font-weight: 700; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: #fff; }
.seg-btn.active { background: var(--accent); color: #fff; box-shadow: 0 0 16px rgba(59,123,255,0.4); }

.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.result-label { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.result-label b { color: #fff; }

.thread-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); transition: opacity .2s; }
.thread-list.is-loading { opacity: .5; }
.thread-list > .empty { border: 0; border-radius: 0; }
.thread-head, .thread { display: grid; grid-template-columns: 64px minmax(0, 1fr) 70px 82px 62px 88px; gap: 14px; align-items: center; }
.thread-head {
  padding: 9px 16px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  background: rgba(0,4,14,0.55); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.thread-head span:first-child { grid-column: 1 / 3; }
.thread-head span:not(:first-child) { text-align: center; }
.thread { padding: 12px 16px; border-top: 1px solid var(--line); transition: background .15s; }
.thread:first-child { border-top: 0; }
.thread:hover { background: rgba(59,123,255,0.06); }
.thread.pinned { background: linear-gradient(90deg, rgba(59,123,255,0.1), transparent 60%); }
.thread-thumb { width: 64px; height: 42px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,0.5); border: 1px solid var(--line); display: grid; place-items: center; color: rgba(140,196,255,0.6); }
.thread-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thread-main { min-width: 0; }
.thread-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; line-height: 1.35; }
.thread-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread:hover .thread-title > span:last-child { color: #cfe2ff; }
.pin-tag { display: inline-grid; place-items: center; color: #8cc4ff; flex: none; }
.pin-tag .ic { width: 14px; height: 14px; }
.pin-tag.lg .ic { width: 22px; height: 22px; }
.thread-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.thread-meta b { color: var(--text); font-weight: 600; }
.meta-mobile { display: none; align-items: center; gap: 4px; color: var(--dim); }
.meta-mobile .ic { width: 13px; height: 13px; }
.meta-mobile .ic + .ic, .meta-mobile .ic:nth-of-type(2) { margin-left: 6px; }
.thread-num { text-align: center; line-height: 1.2; }
.thread-num b { display: block; font-size: 14.5px; }
.thread-num small { display: none; }
.thread-activity { text-align: center; font-size: 12.5px; color: var(--dim); }

/* ==========================================================================
   Post page
   ========================================================================== */
.post { display: flex; flex-direction: column; gap: 16px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--dim); }
.crumbs a:hover { color: #fff; }
.post-head h1 { display: flex; align-items: center; gap: 10px; font-size: clamp(26px, 4.5vw, 38px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; overflow-wrap: anywhere; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.post-meta b { color: #fff; }
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
.post-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.post-side { position: sticky; top: calc(var(--nav-h) + 12px); }
.side-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.info { display: flex; flex-direction: column; margin-top: 6px; }
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); font-size: 13px; }
.info-label { display: inline-flex; align-items: center; gap: 7px; color: var(--dim); }
.info-label .ic { width: 14px; height: 14px; }
.info-value { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.author { display: inline-flex; align-items: center; gap: 6px; }
.owner-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.owner-actions .btn { flex: 1; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; color: rgba(235,242,255,0.92); }

.gallery { display: flex; flex-direction: column; gap: 8px; }
.gal-stage { position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); background: #000; display: grid; place-items: center; }
.gal-main { max-height: 520px; width: auto; max-width: 100%; cursor: zoom-in; }
.gal-hint { position: absolute; right: 10px; bottom: 10px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,0.6); color: var(--muted); opacity: 0; transition: opacity .2s; pointer-events: none; }
.gal-stage:hover .gal-hint { opacity: 1; }
.gal-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.gal-thumb { flex: none; width: 92px; aspect-ratio: 16/10; padding: 0; border-radius: 9px; overflow: hidden; border: 2px solid transparent; background: #000; cursor: pointer; opacity: .6; transition: opacity .2s, border-color .2s; }
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gal-thumb:hover { opacity: 1; }
.gal-thumb.active { border-color: var(--accent); opacity: 1; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(1,3,9,0.94); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(6px); }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 80px rgba(0,0,0,0.6); }
.lb-close, .lb-nav { position: absolute; border: 1px solid var(--line-strong); background: rgba(0,0,0,0.55); color: #fff; border-radius: 50%; width: 44px; height: 44px; font-size: 24px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 700; color: var(--muted); }

.code-wrap { display: flex; max-height: 560px; overflow: auto; border-radius: var(--r); background: var(--code-bg); border: 1px solid var(--line); }
.code-wrap pre { margin: 0; padding: 14px 16px; font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 4; }
.gutter { flex: none; text-align: right; color: rgba(140,170,220,0.3); user-select: none; border-right: 1px solid var(--line); position: sticky; left: 0; background: var(--code-bg); padding-right: 12px !important; }
.code { flex: 1; min-width: 0; }
.t-kw { color: #5aa2ff; font-weight: 600; }
.t-str { color: #a5e8a0; }
.t-num { color: #ffb86c; }
.t-com { color: #5d6b86; font-style: italic; }
.t-bi { color: #67e0ff; }
.t-fn { color: #ffd479; }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(0,4,14,0.4); }
.file-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: rgba(56,189,248,0.12); color: var(--accent-2); }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.replies { display: flex; flex-direction: column; }
.reply { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.reply:first-child { border-top: 0; padding-top: 0; }
.reply-body { flex: 1; min-width: 0; }
.reply-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.reply-del { margin-left: auto; color: var(--dim); }
.reply-del:hover { color: #ff9fb3; }
.reply-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: rgba(235,242,255,0.9); }
.reply-form { display: flex; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.reply-form-main { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.reply-form textarea { min-height: 80px; }
.reply-form-foot { display: flex; justify-content: flex-end; }
#replies > .note { margin-top: 14px; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field .select { width: 100%; }
.label { font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: rgba(220,232,255,0.75); }
.hint { font-size: 12.5px; color: var(--dim); margin-bottom: 10px; }
.field .hint { margin: 0; }
.panel > .input { display: block; }
.code-input { font-family: var(--mono); font-size: 13px; background: var(--code-bg); min-height: 300px; white-space: pre; tab-size: 4; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row .hint { margin: 0; }

.drop { border: 1.5px dashed var(--accent-line); border-radius: var(--r); padding: 14px; background: rgba(59,123,255,0.04); transition: background .2s, border-color .2s; }
.drop.over { background: rgba(59,123,255,0.14); border-color: var(--accent); }
.drop-hint { text-align: center; color: var(--dim); font-size: 12.5px; padding-top: 10px; }
.drop-hint b { color: var(--muted); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.img-tile { position: relative; aspect-ratio: 16/10; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); background: #000; }
.img-tile img { width: 100%; height: 100%; object-fit: cover; }
.img-tile .x, .file-row .x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,0.75); color: #fff; cursor: pointer; font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.img-tile .x:hover, .file-row .x:hover { background: var(--danger); }
.img-tile .tag { position: absolute; left: 6px; bottom: 6px; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 5px; background: var(--accent); }
.add-tile {
  aspect-ratio: 16/10; border-radius: 10px; border: 1.5px dashed var(--line-strong); background: transparent;
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
}
.add-tile:hover { border-color: var(--accent); color: #fff; }
.add-tile .ic { width: 20px; height: 20px; }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.file-list:empty { display: none; }
.file-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 44px 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,4,14,0.5); }
.file-row .fname { flex: 1; }
.file-row .x { top: 50%; transform: translateY(-50%); right: 8px; }

.form-error { color: #ffc2cf; font-weight: 600; font-size: 13.5px; }
.form-error:empty { display: none; }
.progress { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: hidden; flex: 1; min-width: 100px; }
.progress > div { height: 100%; width: 0; background: var(--grad); transition: width .15s; }
.form-foot {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; background: rgba(3,6,14,0.85); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.form-foot-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.inline-form { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; }
.inline-form.cats { grid-template-columns: 1fr 2fr auto; }
.inline-form + .form-error { margin-top: 8px; }

.auth { max-width: 400px; margin: 24px auto 0; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,0.4); }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 10px; filter: drop-shadow(0 0 18px rgba(59,123,255,0.6)); }
.auth h1 { font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 12px; }
.auth .form { margin-top: 16px; gap: 14px; }
.auth .switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.auth .switch a { color: #8cc4ff; font-weight: 700; }
.note { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: #dbe8ff; }

/* ==========================================================================
   Manage
   ========================================================================== */
.roles-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.roles-legend div { padding: 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 800; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: center; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }
.cat-rows { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: grid; grid-template-columns: auto 1fr 2fr auto auto; gap: 8px; align-items: center; }
.cat-move { display: flex; flex-direction: column; }
.cat-move .btn { padding: 1px 5px; }
.cat-posts { white-space: nowrap; min-width: 56px; text-align: right; }

/* ==========================================================================
   Toast & footer
   ========================================================================== */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: var(--r); background: rgba(5,10,22,0.96); border: 1px solid var(--accent-line); box-shadow: 0 10px 40px rgba(0,0,0,0.5); font-size: 13.5px; font-weight: 600; animation: pop .35s var(--ease); }
.toast.err { border-color: rgba(255,107,138,0.6); color: #ffd0da; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.footer { padding-top: 22px; padding-bottom: 28px; border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; text-align: center; }
.footer b { color: #fff; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1000px) {
  .thread-head, .thread { grid-template-columns: 64px minmax(0, 1fr) 70px 82px; }
  .thread-head span:nth-child(4), .thread-head span:nth-child(5),
  .thread > .thread-num:nth-of-type(5), .thread-activity { display: none; }
}
@media (max-width: 900px) {
  .forum { grid-template-columns: 1fr; gap: 14px; }
  .sidebar { position: static; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
  .sidebar .side-block:first-child { grid-column: 1 / -1; }
  .sidebar .side-title { display: none; }
  .side-block:nth-child(2) { grid-column: 1 / -1; }
  .side-block:nth-child(3) { grid-column: 1 / -1; }
  .side-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .side-list::-webkit-scrollbar { display: none; }
  .side-link { width: auto; flex: none; border-color: var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; }
  .seg-full { display: inline-flex; }
  .post-layout { grid-template-columns: 1fr; }
  .post-side { position: static; order: -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  :root { --nav-h: 116px; }
  .topbar { flex-wrap: wrap; }
  .nav-right { margin-left: auto; }
  .nav-pills { order: 3; width: 100%; margin: 0; }
  .nav-pill { flex: 1; justify-content: center; padding: 7px 6px; }
  .thread-head { display: none; }
  .thread-list { border-radius: var(--r-lg); }
  .thread, .thread:first-child { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .thread-thumb { width: 56px; height: 40px; }
  .thread-num { display: none; }
  .meta-mobile { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form, .inline-form.cats { grid-template-columns: 1fr; }
  .cat-row { grid-template-columns: auto 1fr auto; }
  .cat-row > .input:nth-of-type(2) { grid-column: 2 / 3; grid-row: 2; }
  .cat-posts { display: none; }
  .hide-sm { display: none; }
  .panel { padding: 16px; }
}
@media (max-width: 480px) {
  .user-name { display: none; }
  .user-chip { padding-right: 6px; }
  .nav-pill .ic { display: none; }
  .search { padding-right: 16px; }
  .search-btn { display: none; }
  .stat { padding: 12px; }
  .stat-icon { width: 32px; height: 32px; }
  .grid { grid-template-columns: 1fr; }
  .owner-actions .btn { flex: 1 1 40%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
