:root {
  --bg: #0c0f15;
  --bg-elev: #141923;
  --bg-card: #171e2b;
  --bg-hover: #1e2738;
  --border: #2b354a;
  --border-gold: rgba(201, 162, 75, 0.42);
  --gold: #d4ad56;
  --gold-bright: #f0cf7b;
  --gold-dim: #9a7830;
  --prexus-blue: #4e8fd8;
  --text: #e7eaf2;
  --text-muted: #9aa6be;
  --text-dim: #73809b;
  --danger: #d9534f;
  --success: #4ea86d;
  --radius: 10px;
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top center, #162238 0%, #0c0f15 55%) fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

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

a:hover {
  color: var(--gold-bright);
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Header & Nav */
.site-header {
  background: rgba(12, 15, 21, 0.92);
  border-bottom: 1px solid var(--border-gold);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none !important;
}

.brand-crest {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--prexus-blue);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 7px 13px;
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(212, 173, 86, 0.12);
  color: var(--gold-bright);
  border-color: var(--border-gold);
}

.nav-cta {
  background: linear-gradient(135deg, #b88b32, #8d661f);
  color: #fff8e7 !important;
  border: 1px solid var(--gold);
  font-weight: 600;
}

.nav-cta:hover {
  background: linear-gradient(135deg, #d4ad56, #a57926);
  color: #fff !important;
}

/* Main Layout */
.main-content {
  padding: 24px 0 48px;
}

.welcome-banner {
  background: linear-gradient(135deg, rgba(25, 42, 70, 0.75), rgba(20, 25, 35, 0.95));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.welcome-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.welcome-banner h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.65rem;
  color: var(--gold-bright);
}

.welcome-banner p {
  margin: 0;
  color: var(--text);
  max-width: 760px;
}

.welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.stats-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-pill {
  background: rgba(12, 15, 21, 0.65);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
}

.stat-pill strong {
  color: var(--gold-bright);
}

/* Grid with Sidebar */
.hall-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 22px;
  align-items: start;
}

/* Controls & Tabs */
.board-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.cat-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-tab {
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.cat-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.cat-tab.active {
  border-color: var(--gold);
  background: rgba(212, 173, 86, 0.14);
  color: var(--gold-bright);
}

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

/* Cards & Thread List */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
  max-width: 100%;
}

.card-gold {
  border-color: var(--border-gold);
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thread-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color 0.15s, background 0.15s;
}

.thread-row:hover {
  background: var(--bg-hover);
  border-color: #3b4a68;
}

.thread-row.pinned {
  border-color: var(--border-gold);
  background: linear-gradient(90deg, rgba(212, 173, 86, 0.08), var(--bg-card));
}

.thread-main {
  min-width: 0;
  flex: 1;
}

.thread-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.thread-title {
  display: block;
  font-size: 1.07rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.thread-title:hover {
  color: var(--gold-bright);
}

.thread-meta {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.thread-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  min-width: 90px;
  text-align: right;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.reply-count {
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 1.05rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge-pin {
  background: rgba(212, 173, 86, 0.18);
  color: var(--gold-bright);
  border-color: var(--border-gold);
}

.badge-lock {
  background: rgba(217, 83, 79, 0.16);
  color: #f08a87;
  border-color: rgba(217, 83, 79, 0.35);
}

.badge-cat {
  background: rgba(78, 143, 216, 0.15);
  color: #8cc0fa;
  border-color: rgba(78, 143, 216, 0.3);
}

.badge-era {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border-color: var(--border);
}

.badge-class-plate {
  background: rgba(189, 134, 65, 0.18);
  color: #f2c47d;
  border-color: rgba(189, 134, 65, 0.4);
}

.badge-class-priest {
  background: rgba(92, 184, 92, 0.16);
  color: #8ee08e;
  border-color: rgba(92, 184, 92, 0.35);
}

.badge-class-silk {
  background: rgba(155, 114, 207, 0.18);
  color: #cfb0f7;
  border-color: rgba(155, 114, 207, 0.38);
}

.badge-class-chain {
  background: rgba(66, 165, 245, 0.16);
  color: #8ccbfa;
  border-color: rgba(66, 165, 245, 0.35);
}

.badge-class-leather {
  background: rgba(230, 159, 69, 0.16);
  color: #f3bc71;
  border-color: rgba(230, 159, 69, 0.35);
}

.badge-class-neutral {
  background: rgba(154, 166, 190, 0.15);
  color: #c5cedf;
  border-color: var(--border);
}

/* Sidebar */
.sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold-bright);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.mini-roster-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mini-roster-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.mini-roster-name {
  font-weight: 600;
  color: var(--text);
}

.mini-roster-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Thread Detail & Posts */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
}

.post-card.op {
  border-color: var(--border-gold);
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.post-author {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.post-alts {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.post-body {
  color: var(--text);
  word-break: break-word;
}

.post-body p:first-child {
  margin-top: 0;
}

.post-body p:last-child {
  margin-bottom: 0;
}

.post-image-wrap {
  margin-top: 14px;
}

.post-image {
  max-width: 100%;
  max-height: 460px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.req {
  color: var(--gold-bright);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #0d121b;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.94rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 173, 86, 0.2);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.field-hint {
  font-size: 0.79rem;
  color: var(--text-dim);
}

.honeypot-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #273247;
  border-color: #46577a;
}

.btn-primary {
  background: linear-gradient(135deg, #c39337, #966d20);
  border-color: var(--gold);
  color: #fffaf0;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #dbad50, #aa7d28);
}

.btn-danger {
  background: rgba(217, 83, 79, 0.18);
  border-color: rgba(217, 83, 79, 0.5);
  color: #f6a09d;
}

.btn-danger:hover {
  background: rgba(217, 83, 79, 0.32);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Roster & Gallery */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-thumb {
  width: 100%;
  height: 190px;
  object-fit: cover;
  cursor: zoom-in;
  background: #0a0d13;
}

.gallery-info {
  padding: 12px 14px;
  font-size: 0.86rem;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(78, 168, 109, 0.15);
  border-color: rgba(78, 168, 109, 0.45);
  color: #a3e4b8;
}

.alert-danger {
  background: rgba(217, 83, 79, 0.15);
  border-color: rgba(217, 83, 79, 0.45);
  color: #f5a6a3;
}

.section-heading {
  font-family: var(--font-display);
  color: var(--gold-bright);
  margin: 0 0 12px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 94vw;
  max-height: 90vh;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--gold-bright);
  font-size: 1.3rem;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table th {
  color: var(--gold-bright);
  font-weight: 600;
}

.inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 32px;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

.turnstile-wrap {
  margin: 10px 0 14px;
}

.hidden-panel {
  display: none;
}

.w-full { width: 100%; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 22px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 22px; }
.my-1 { margin: 6px 0; }
.my-2 { margin: 10px 0; }
.m-0 { margin: 0; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-body { color: var(--text); }
.text-sm { font-size: 0.85rem; }
.text-md { font-size: 0.92rem; }
.fw-600 { font-weight: 600; }
.heading-md { font-size: 1.18rem; }
.heading-lg { font-size: 1.42rem; }
.overflow-x { overflow-x: auto; max-width: 100%; }
.auth-card { max-width: 440px; margin: 32px auto; }
.notice-card { max-width: 600px; margin: 32px auto; }
.roster-filter-row { margin-bottom: 18px; flex-wrap: wrap; }
.roster-search-input { flex: 1; min-width: 220px; }
.roster-class-select { width: auto; min-width: 180px; }
.roster-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.roster-author-lg { font-size: 1.12rem; }
.gallery-title { font-weight: 600; margin-bottom: 4px; }
.gallery-meta { color: var(--text-muted); font-size: 0.82rem; }
.nav-inline-form { display: inline; margin: 0; }
.nav-logout-btn { background: transparent; cursor: pointer; font-family: var(--font-sans); }
.recovery-box {
  background: rgba(212, 173, 86, 0.12);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.recovery-code-display {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  background: #0d121b;
  border: 1px solid var(--border-gold);
  border-radius: 6px;
  padding: 8px 14px;
  word-break: break-all;
}
.copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
}
.register-card { max-width: 720px; margin: 16px auto; }
.welcome-main { flex: 1; min-width: 260px; }
.classic-logo-link {
  display: block;
  flex-shrink: 0;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-gold);
  background: #ffffff;
  padding: 4px 6px;
}
.classic-logo-preview {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
}
.archive-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.archive-strip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.archive-card {
  background: #0f141e;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.archive-thumb {
  width: 100%;
  height: 145px;
  object-fit: cover;
  cursor: zoom-in;
  background: #0a0d13;
}
.archive-caption {
  padding: 9px 11px;
  font-size: 0.85rem;
}
@media (max-width: 960px) {
  .archive-strip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 540px) {
  .archive-strip-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 860px) {
  .account-grid, .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .hall-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .thread-row {
    flex-direction: column;
  }
  .thread-stats {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }
}
