:root {
  --bg: #0d0f14;
  --surface: #151922;
  --surface-2: #1b2130;
  --border: #262d3d;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container { width: min(1140px, 100% - 2rem); margin-inline: auto; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13, 15, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); }

.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-right: auto; }
.nav a {
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--accent-soft); }

.auth { display: flex; align-items: center; gap: 0.5rem; }
.who { color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---------- buttons & badges ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: transparent; border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn.danger:hover { background: rgba(239, 68, 68, 0.12); filter: none; }

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.4);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.05rem 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.pill.discord { background: rgba(88, 101, 242, 0.18); color: #a5b0ff; border-color: rgba(88, 101, 242, 0.45); }
.pill.site { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.pill.locked { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover { color: #fca5a5; border-color: rgba(239, 68, 68, 0.5); }

.inline { display: inline; }

/* ---------- flash ---------- */
.flash-wrap { padding-top: 1rem; }
.flash {
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash.success { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); color: #bbf7d0; }
.flash.error { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.45); color: #fecaca; }

/* ---------- layout ---------- */
main.container { flex: 1; padding: 1.75rem 0 3rem; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin: 0.2rem 0 0.35rem; font-size: 1.7rem; line-height: 1.25; }
.title-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 0.88rem; }
.crumbs span { margin: 0 0.3rem; opacity: 0.6; }

.lede { color: var(--muted); margin: 0.25rem 0 0.75rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.86rem; margin: 0.4rem 0 0.8rem; }
.empty { color: var(--muted); padding: 0.5rem 0; margin: 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.6rem; }
.right { text-align: right; }

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.1rem; align-items: start; }
@media (max-width: 860px) { .grid-main { grid-template-columns: 1fr; } }

/* ---------- hero ---------- */
.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--surface) 0%, #131a2b 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.hero h1 { margin: 0 0 0.5rem; font-size: 2rem; }
.hero-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(90px, 1fr)); gap: 0.75rem; }
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  min-width: 96px;
}
.stat strong { display: block; font-size: 1.5rem; color: var(--accent); }
.stat span { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- panels & cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.panel-head .link { font-size: 0.86rem; }

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.stack.wide { gap: 1rem; }

.row-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.row-link:hover { border-color: var(--accent); text-decoration: none; }
.row-title { font-weight: 600; }
.row-meta { color: var(--muted); font-size: 0.85rem; }

.category { display: flex; justify-content: space-between; gap: 1.5rem; align-items: center; color: var(--text); }
.category:hover { border-color: var(--accent); text-decoration: none; }
.cat-main h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }
.cat-main p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.cat-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; color: var(--muted); font-size: 0.84rem; white-space: nowrap; }
.cat-stats strong { color: var(--text); }
@media (max-width: 620px) { .category { flex-direction: column; align-items: flex-start; } .cat-stats { align-items: flex-start; } }

/* ---------- announcements ---------- */
.announcement { background: var(--surface); }
.ann-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.ann-author { font-weight: 700; }
.ann-time { color: var(--muted); font-size: 0.84rem; }
.ann-delete { margin-left: auto; }
.ann-body { white-space: normal; overflow-wrap: anywhere; }
.ann-body a { word-break: break-word; }
.ann-attachments { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }
.ann-img { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.attachment {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
}
.ann-source { display: inline-block; margin-top: 0.7rem; font-size: 0.82rem; color: var(--muted); }
.ann-source:hover { color: var(--accent); }

/* ---------- forum ---------- */
.posts { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1.25rem; }
.post { background: var(--surface); }
.post-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(91, 140, 255, 0.4);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.post-author { font-weight: 700; }
.post-time { color: var(--muted); font-size: 0.84rem; margin-left: auto; }
.post-body { overflow-wrap: anywhere; }
.post-actions { margin-top: 0.6rem; display: flex; justify-content: flex-end; }
.post.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.reply-panel { margin-top: 0.5rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 0.5rem; }
.form label, .field label { font-weight: 600; font-size: 0.88rem; color: var(--muted); margin-top: 0.4rem; }
.form-row { display: grid; grid-template-columns: 1fr 200px; gap: 1rem; }
@media (max-width: 620px) { .form-row { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 0.5rem; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; }
.form .btn { align-self: flex-start; margin-top: 0.5rem; }

.auth-card { max-width: 440px; margin: 2rem auto; padding: 1.75rem; background: var(--surface); }
.auth-card h1 { margin-top: 0; font-size: 1.4rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--accent); line-height: 1; }

/* ---------- files ---------- */
.file-card { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.file-main { display: flex; gap: 0.8rem; align-items: flex-start; min-width: 0; }
.file-icon { font-size: 1.5rem; }
.file-name { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.file-name:hover { color: var(--accent); }
.file-meta { color: var(--muted); font-size: 0.84rem; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.file-desc { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; }
.file-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ---------- settings ---------- */
.status-card {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}
.status-card p { margin: 0.2rem 0 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 0.45rem; flex: none; }
.status-card.ok { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.4); }
.status-card.ok .status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-card.warn { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.4); }
.status-card.warn .status-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.status-card.off { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.35); }
.status-card.off .status-dot { background: var(--red); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 0.5rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 0.88rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 620px) { .kv { grid-template-columns: 1fr; } }
code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
}

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: none; }
td .inline { display: inline-flex; gap: 0.4rem; margin-left: 0.35rem; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.1rem 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.foot-wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 640px) {
  .nav-wrap { padding: 0.5rem 0; }
  .hero { padding: 1.4rem; }
  .hero h1 { font-size: 1.55rem; }
  .stats { grid-template-columns: repeat(4, 1fr); width: 100%; }
  .stat { min-width: 0; padding: 0.5rem; }
  .stat strong { font-size: 1.2rem; }
}

/* ---------- upgrade additions ---------- */
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.82rem; border-radius: 7px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
.small { font-size: 0.84rem; }
.grow { flex: 1 1 auto; }

.nav-search { margin-left: auto; }
.nav-search input {
  width: 150px;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.nav-search input:focus { outline: none; border-color: var(--accent); }
@media (max-width: 720px) { .nav-search { margin-left: 0; width: 100%; } .nav-search input { width: 100%; } }

.who { text-decoration: none; border-radius: 999px; padding: 0.15rem 0.4rem 0.15rem 0.15rem; }
.who:hover { background: var(--surface-2); text-decoration: none; }

.avatar-xs,
.avatar-xl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 700;
  overflow: hidden;
}
.avatar-xs { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2.2rem; }
img.avatar-xs, img.avatar-xl { background: #0b0d12; }

.role-badge { font-weight: 700; }
.pill.pinned { background: rgba(91, 140, 255, 0.15); color: #b9c9ff; border-color: rgba(91, 140, 255, 0.4); margin-right: 0.15rem; }
.pill.banned { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.45); }

.thumb-xs { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); flex: none; background: var(--surface-2); }
.file-icon-sm { display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.row-link.file-row { flex-direction: row; align-items: center; gap: 0.7rem; }
.row-main { display: flex; flex-direction: column; min-width: 0; }

.post-avatar { display: inline-flex; border: 2px solid transparent; border-radius: 50%; flex: none; }
.post-avatar:hover { text-decoration: none; }
.post-edited { color: var(--muted); font-size: 0.78rem; font-style: italic; }

.post-actions { justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.post-buttons { display: flex; align-items: center; gap: 0.35rem; }
.reactions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.4;
}
.reaction:hover { border-color: var(--accent); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction:disabled { opacity: 0.65; cursor: default; }
.reaction-count { font-size: 0.78rem; color: var(--muted); font-weight: 700; }

.post-attachments { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.7rem; }
.post-attachment { display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; max-width: 260px; }
.post-attachment:hover { border-color: var(--accent); text-decoration: none; }
.post-attachment img { display: block; max-width: 100%; max-height: 220px; object-fit: cover; }

.embed { margin: 0.8rem 0; }
.embed-ratio { position: relative; width: 100%; max-width: 560px; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.embed-ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-ratio.embed-vertical { aspect-ratio: 9 / 16; max-width: 320px; }
.embed figcaption { color: var(--muted); font-size: 0.78rem; margin-top: 0.3rem; }

.file-thumb { display: inline-flex; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); flex: none; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb:hover { border-color: var(--accent); }

.stats-5 { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin-bottom: 1.1rem; }
.stats-5 .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; }

.member-cell { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); }
.member-cell:hover { text-decoration: none; color: var(--accent); }
.role-form { display: inline-flex; gap: 0.35rem; align-items: center; }
.role-form select { padding: 0.25rem 0.4rem; font-size: 0.85rem; border-radius: 7px; }

.profile-head { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; }
.profile-avatar { border: 2px solid transparent; border-radius: 50%; padding: 3px; display: inline-flex; }
.profile-info h1 { margin: 0 0 0.25rem; font-size: 1.5rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.profile-bio { margin: 0.3rem 0; max-width: 65ch; overflow-wrap: anywhere; }
.profile-stats { display: flex; gap: 1rem; color: var(--muted); font-size: 0.88rem; margin-top: 0.4rem; flex-wrap: wrap; }
.profile-stats strong { color: var(--text); }
.post-card .row-meta { display: block; margin-top: 0.3rem; }
.clamp { max-height: 8.5em; overflow: hidden; }

.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.role-card { display: flex; flex-direction: column; gap: 0.6rem; }
.role-main { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.role-perms { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.role-actions { display: flex; gap: 0.4rem; margin-top: auto; }

.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0.4rem 0; display: flex; flex-direction: column; gap: 0.3rem; }
.perm-group legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.84rem; font-weight: 700; }
.perm-title { margin: 0.5rem 0 0.15rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text); margin: 0; }
.checkbox input { width: auto; margin: 0; accent-color: var(--accent); }
.form label.checkbox { color: var(--text); }
.color-row { display: flex; align-items: center; gap: 0.6rem; }
.color-row input[type="color"] { width: 52px; height: 36px; padding: 0.15rem; }
.search-form .form-row { grid-template-columns: 1fr 200px; }

.table-wrap table .empty { padding: 1rem; }
