:root {
  --bg: #101216;
  --panel: #181c23;
  --panel-2: #222833;
  --line: #303846;
  --text: #edf2ff;
  --muted: #a8b1c2;
  --brand: #67d3b0;
  --brand-2: #7c9cff;
  --danger: #ff6b7a;
  --warning: #ffd166;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
textarea { resize: vertical; min-height: 96px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 72px minmax(0, 1fr); }
.community-rail { background: #0a0c10; border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 10px; align-items: center; position: sticky; top: 0; height: 100vh; }
.rail-logo, .rail-community, .rail-action { width: 48px; height: 48px; border-radius: 8px; display: grid; place-items: center; background: var(--panel); color: var(--text); font-weight: 800; border: 1px solid transparent; overflow: hidden; }
.rail-logo { background: var(--brand); color: #07120f; }
.rail-action { color: var(--brand); border-color: var(--line); }
.rail-community:hover, .rail-action:hover { border-color: var(--brand); }
.rail-community img { width: 100%; height: 100%; object-fit: cover; }

.main-frame { min-width: 0; display: flex; min-height: 100vh; flex-direction: column; }
.top-nav { height: 64px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: rgba(16,18,22,.94); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand span { font-size: 20px; font-weight: 850; }
.brand small { color: var(--muted); }
.top-nav nav, .actions, .chat-actions, .inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-nav nav a { color: var(--muted); }
.content { width: min(1380px, 100%); margin: 0 auto; padding: 24px; flex: 1; }
.footer { color: var(--muted); border-top: 1px solid var(--line); padding: 18px 24px; display: flex; gap: 18px; flex-wrap: wrap; }

.button, button.button { border: 0; background: var(--brand); color: #07120f; border-radius: var(--radius); padding: 11px 16px; font-weight: 750; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
.button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.button.small { min-height: 32px; padding: 7px 10px; font-size: 14px; }
.link-button { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; }
.icon-button { width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; display: inline-grid; place-items: center; }

.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 24px; align-items: stretch; min-height: calc(100vh - 170px); }
.hero > div { display: flex; flex-direction: column; justify-content: center; }
.hero h1 { font-size: clamp(48px, 9vw, 112px); line-height: .9; margin: 0 0 16px; letter-spacing: 0; }
.hero p { color: var(--muted); font-size: 19px; max-width: 680px; }
.hero-panel, .panel, .auth-card, .community-card, .stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.hero-panel { min-height: 340px; }
.eyebrow { color: var(--brand); text-transform: uppercase; font-size: 13px; font-weight: 800; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h1 { margin: 0 0 6px; font-size: 32px; }
.section-head p, .panel p, .community-card p { color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card strong { display: block; font-size: 28px; }
.stat-card span, .meta, small { color: var(--muted); }

.form-stack, .form-grid { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; color: var(--muted); }
input, textarea, select { width: 100%; background: #0e1117; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-height: 40px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; min-height: auto; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
fieldset { border: 1px solid var(--line); }
legend { padding: 0 8px; font-weight: 800; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; flex: 1; }
.list { display: grid; gap: 8px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.02); align-items: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
code, pre { background: #0b0e13; border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 6px; color: #dbe7ff; white-space: pre-wrap; }
pre { display: block; padding: 12px; overflow: auto; }

.flash { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); background: var(--panel-2); }
.flash.success { border-color: var(--brand); }
.flash.error { border-color: var(--danger); }
.warning { border-left: 4px solid var(--warning); padding-left: 12px; color: var(--text); }
.empty-state { display: grid; place-items: center; text-align: center; min-height: 280px; }
.auth-card { width: min(460px, 100%); margin: 8vh auto; }
.ad-placeholder { border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; color: var(--muted); text-align: center; margin: 12px 0; }

.community-hero { min-height: 250px; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 18px; background: linear-gradient(135deg, rgba(103,211,176,.2), rgba(124,156,255,.16)); background-size: cover; background-position: center; position: relative; overflow: hidden; }
.community-hero::before { content: ""; position: absolute; inset: 0; background: rgba(10,12,16,.55); }
.community-hero > * { position: relative; z-index: 1; }
.community-hero h1 { font-size: 44px; margin: 0 0 8px; }
.card-banner { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius); margin-bottom: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.meta span { background: rgba(255,255,255,.06); border-radius: var(--radius); padding: 4px 8px; }
.member-list { display: grid; gap: 8px; }
.member { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.member small { margin-left: auto; }
.presence { width: 10px; height: 10px; border-radius: 50%; background: #596171; }
.presence.online { background: var(--brand); }
.presence.idle { background: var(--warning); }
.presence.offline { background: #596171; }

.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.subnav a { padding: 8px 10px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.rule-row, .appeal-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.health-list { display: grid; grid-template-columns: 220px 1fr; gap: 10px; }
.health-list dt { color: var(--muted); }

.chat-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr) 240px; min-height: calc(100vh - 128px); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.channel-sidebar, .member-sidebar { background: #12161d; padding: 16px; overflow-y: auto; }
.channel-sidebar { border-right: 1px solid var(--line); }
.member-sidebar { border-left: 1px solid var(--line); }
.channel-sidebar a { display: block; padding: 9px 10px; border-radius: var(--radius); color: var(--muted); }
.channel-sidebar a.active, .channel-sidebar a:hover { background: var(--panel-2); color: var(--text); }
.chat-main { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; min-width: 0; }
.chat-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-topbar h1 { margin: 0; font-size: 20px; }
.chat-topbar p { margin: 2px 0 0; color: var(--muted); }
.pinned { padding: 10px 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.03); }
.messages { overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.message { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; }
.message-avatar { width: 42px; height: 42px; border-radius: var(--radius); background: var(--brand-2); color: #07101d; display: grid; place-items: center; font-weight: 850; }
.message header { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.message p { margin: 3px 0 0; color: var(--text); overflow-wrap: anywhere; }
.message-gif { max-width: 320px; border-radius: var(--radius); display: block; margin-top: 8px; }
.composer { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding: 12px; background: #12161d; }
.composer textarea { min-height: 42px; max-height: 140px; flex: 1; }
.file-input { max-width: 160px; }
.modal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(0,0,0,.65); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 55vh; overflow: auto; }
.gif-tile { border: 1px solid var(--line); background: #0e1117; border-radius: var(--radius); padding: 8px; cursor: pointer; min-height: 120px; display: grid; place-items: center; color: var(--muted); }
.gif-tile img { max-width: 100%; border-radius: var(--radius); }

.avatar-preview { width: 112px; height: 112px; border-radius: var(--radius); background: var(--panel-2); display: grid; place-items: center; font-size: 42px; font-weight: 850; overflow: hidden; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 56px minmax(0, 1fr); }
  .community-rail { width: 56px; padding: 8px 6px; }
  .rail-logo, .rail-community, .rail-action { width: 40px; height: 40px; }
  .grid.two, .grid.three, .hero, .form-grid, .chat-shell { grid-template-columns: 1fr; }
  .member-sidebar { display: none; }
  .channel-sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 240px; }
  .content { padding: 16px; }
  .top-nav { height: auto; min-height: 64px; flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  .community-hero { flex-direction: column; }
  .file-input { display: none; }
}
