:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel-2: #18233d;
  --text: #e8eefc;
  --muted: #9aa8c7;
  --accent: #4da3ff;
  --online: #3ecf8e;
  --offline: #ff6b6b;
  --border: #24314f;
  --layout-max: min(1680px, calc(100vw - 32px));
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, sans-serif;
  background: linear-gradient(180deg, #0a0f1c 0%, #10182b 100%);
  color: var(--text);
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(10, 15, 28, 0.9);
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: 28px; }
.subtitle { margin: 8px 0 0; color: var(--muted); }
.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.nav-btn,
a.nav-btn,
.detail-header button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.nav-btn:hover,
a.nav-btn:hover,
.detail-header button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat {
  min-width: 90px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.stat strong { font-size: 20px; }

.container {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 20px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input,
.toolbar select,
.toolbar button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.toolbar input[type="search"],
.toolbar input:not([type="checkbox"]):not([type="radio"]) {
  min-width: 260px;
  flex: 1;
}
.toolbar label.checkbox {
  flex: 0 0 auto;
  white-space: nowrap;
}
.toolbar label.checkbox input[type="checkbox"] {
  flex: 0 0 auto;
  min-width: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}
.toolbar button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #04101f;
  font-weight: 600;
}
#add-server-btn {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
#add-server-btn:hover {
  border-color: var(--accent);
}

.add-server-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
  background: var(--panel);
  color: var(--text);
}
.add-server-dialog::backdrop {
  background: rgba(4, 8, 18, 0.75);
}
.add-server-dialog form {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.add-server-dialog h2 { margin: 0; font-size: 20px; }
.add-server-hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.add-server-ports {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.add-server-dialog .auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.add-server-dialog .auth-field input,
.add-server-dialog .auth-field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}
.add-server-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.add-server-dialog .auth-error.visible { display: block; }
.add-server-dialog .auth-error {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.15);
  color: var(--offline);
  font-size: 13px;
}
.add-server-dialog .auth-submit {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #04101f;
  font-weight: 600;
  cursor: pointer;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
}

.mine-banner {
  margin: 10px 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}
.mine-banner img {
  display: block;
  width: 100%;
  height: auto;
}
.mine-banner.hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
table.servers-table {
  min-width: 1180px;
  table-layout: auto;
}
table.servers-table th,
table.servers-table td {
  padding: 10px 12px;
}
table.servers-table .col-fav {
  width: 40px;
  padding-left: 8px;
  padding-right: 4px;
}
table.servers-table .col-status { white-space: nowrap; width: 1%; }
table.servers-table .col-players { white-space: nowrap; width: 1%; }
table.servers-table .col-rank { white-space: nowrap; width: 1%; }
table.servers-table .col-region { white-space: nowrap; width: 1%; }
table.servers-table .col-latency { white-space: nowrap; width: 1%; }
table.servers-table .col-connect { white-space: nowrap; width: 1%; }
table.servers-table .col-server {
  min-width: 200px;
  max-width: 380px;
}
table.servers-table .col-map {
  min-width: 120px;
  max-width: 260px;
  word-break: break-word;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-2);
}
th .sortable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  user-select: none;
}
th .sortable:hover { color: var(--text); }
th .sortable::after {
  content: "↕";
  opacity: 0.35;
  font-size: 11px;
}
th .sortable.sort-active::after {
  opacity: 1;
  color: var(--accent);
}
th .sortable.sort-active.sort-asc::after { content: "↑"; }
th .sortable.sort-active.sort-desc::after { content: "↓"; }
tr:hover td { background: rgba(77, 163, 255, 0.06); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.online { background: rgba(62, 207, 142, 0.15); color: var(--online); }
.badge.offline { background: rgba(255, 107, 107, 0.15); color: var(--offline); }
.badge.unknown { background: rgba(154, 168, 199, 0.15); color: var(--muted); }

.server-name { font-weight: 600; }
.server-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tag {
  display: inline-block;
  margin-right: 4px;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(77, 163, 255, 0.12);
  color: #b9d7ff;
  font-size: 11px;
}
.tag.pin {
  background: rgba(62, 207, 142, 0.2);
  color: var(--online);
}
tr.row-pin td {
  background: rgba(62, 207, 142, 0.06);
}
.linkish {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.col-fav { width: 36px; text-align: center; }
.btn-fav {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.btn-fav.active { color: #f0c040; }
.connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.btn-connect,
.btn-copy {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(77, 163, 255, 0.12);
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.btn-copy {
  font: inherit;
  color: var(--text);
  background: rgba(154, 168, 199, 0.1);
}
.btn-connect:hover,
.btn-copy:hover { filter: brightness(1.15); }
.detail-connect { margin-bottom: 12px; }
.alert-panel {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}
.alert-panel h3 { margin: 0 0 10px; font-size: 15px; }
.alert-form .auth-field { margin-bottom: 8px; }
.alert-form .checkbox { display: block; margin-bottom: 8px; }

.detail {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.detail.hidden { display: none; }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.detail-charts { margin-bottom: 16px; }
.charts-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.charts-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-range {
  display: flex;
  gap: 4px;
}
.chart-range-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chart-range-btn:hover { color: var(--text); border-color: #3a4f75; }
.chart-range-btn.active {
  background: rgba(77, 163, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chart-panel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0d1424;
}
.chart-panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.stat-chart {
  display: block;
  width: 100%;
  height: 200px;
  border-radius: 6px;
}
.chart-meta {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.chart-panel.empty-rank .stat-chart { opacity: 0.35; }
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}
.detail-meta { color: var(--muted); font-size: 13px; }
.detail-meta a { color: var(--accent); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.detail-card {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.detail-card .label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.detail-card strong { font-size: 14px; word-break: break-word; }

.detail-mods { margin-top: 12px; }
.detail-mods h3 { margin: 0 0 8px; font-size: 16px; }
.mods-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.mods-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mods-table th, .mods-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.mods-table th { background: var(--panel-2); color: var(--muted); }
.mods-table code { font-size: 11px; color: #b9d7ff; }

.list-meta { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}
.pagination button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination.hidden { display: none; }

.footer {
  max-width: var(--layout-max);
  margin: 24px auto;
  padding: 0 20px 32px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.footer p { margin: 0 0 8px; }
.footer-note { font-size: 12px; color: var(--muted); }
.footer a { color: var(--accent); }

.nav-auth {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.lang-switcher {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, #2a3348);
}
.lang-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: var(--accent);
  color: #fff;
}
.nav-user {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.nav-btn.nav-active {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.disc-auth-gate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}
.disc-auth-gate.hidden { display: none; }
.disc-auth-gate p { margin: 0; color: var(--muted); flex: 1 1 100%; }
.disc-guest-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.disc-guest-fields.hidden { display: none; }
.disc-guest-label {
  font-size: 13px;
  color: var(--muted);
}
.disc-guest-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.disc-posting-as.hidden { display: none; }
.disc-posting-as {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.game-stats-view.hidden { display: none; }
#view-servers.hidden { display: none; }

.stats-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stats-page-header h2 { margin: 0 0 6px; font-size: 22px; }
.stats-page-sub { margin: 0; color: var(--muted); font-size: 14px; }
.stats-page-sub a { color: var(--accent); }

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stats-summary-grid .detail-card strong { font-size: 18px; }

.stats-charts { margin-bottom: 16px; }
.stats-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stats-panel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.stats-panel h3 { margin: 0 0 12px; font-size: 14px; }
.stats-table { width: 100%; border-collapse: collapse; min-width: 0; }
.stats-table th, .stats-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}
.stats-table th { color: var(--muted); background: var(--panel-2); }

.feature-bars { display: flex; flex-direction: column; gap: 12px; }
.feature-row { font-size: 13px; }
.feature-row-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--muted);
}
.feature-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
}
.feature-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

@media (max-width: 900px) {
  .stats-panels { grid-template-columns: 1fr; }
}

.news-view.hidden { display: none; }

.news-header { margin-bottom: 20px; }
.news-header h2 { margin: 0 0 6px; font-size: 22px; }
.news-sub { margin: 0; color: var(--muted); font-size: 14px; }
.news-sub a { color: var(--accent); }

.news-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.news-loading, .news-empty, .news-error {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 14px;
}

.news-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.news-card:hover { border-color: var(--accent); }
.news-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.news-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--panel-2);
}
.news-card-img-placeholder {
  min-height: 140px;
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
}
.news-card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.news-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.news-card-cat {
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.news-card-title { margin: 0; font-size: 16px; line-height: 1.35; }
.news-card-summary {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-read { margin-top: auto; font-size: 12px; color: var(--accent); font-weight: 600; }

.news-load-more {
  display: block;
  margin: 20px auto 0;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.news-load-more.hidden { display: none; }
.news-load-more:hover { border-color: var(--accent); }

.discussions-view.hidden { display: none; }

.discussions-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}
.discussions-main h2 { margin: 0 0 6px; font-size: 22px; }
.discussions-sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

.disc-compose {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.disc-compose input,
.disc-compose select,
.disc-compose textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}
.disc-compose textarea { resize: vertical; min-height: 100px; }
.disc-compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.disc-publish {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #04101f !important;
}
.disc-publish:disabled { opacity: 0.5; cursor: not-allowed; }

.disc-feed { display: flex; flex-direction: column; gap: 12px; }
.disc-post {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.disc-post-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
.disc-author { color: var(--text); }
.disc-sep { color: var(--muted); }
.disc-server-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.disc-time { color: var(--muted); margin-left: auto; font-size: 12px; }
.disc-body { margin: 0; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.disc-loading, .disc-empty, .disc-error { color: var(--muted); text-align: center; padding: 24px; }
.disc-load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.disc-load-more:hover { border-color: var(--accent); color: var(--accent); }
.disc-load-more.hidden { display: none; }

.discussions-side { display: flex; flex-direction: column; gap: 12px; }
.disc-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.disc-side-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.disc-side-list li:last-child { border-bottom: none; }
.disc-side-list em { color: var(--muted); font-style: normal; }
.disc-side-list .muted { color: var(--muted); }
.disc-side-server {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
}
.disc-side-server.linkish { font-weight: 600; }

@media (max-width: 900px) {
  .discussions-layout { grid-template-columns: 1fr; }
}

/* —— Mobile / narrow screens —— */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
  }

  .header-brand {
    width: 100%;
    min-width: 0;
  }

  h1 { font-size: 22px; }
  .subtitle { font-size: 13px; line-height: 1.4; }

  .header-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
  }

  .header-nav .nav-btn,
  .header-nav a.nav-btn {
    width: 100%;
    min-height: 40px;
    padding: 10px 8px;
    font-size: 12px;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
  }

  /* Long external link: full row */
  .header-nav a.nav-btn[href*="rust-arma-ref0rger-game-server"] {
    grid-column: 1 / -1;
  }

  .nav-auth {
    grid-column: 1 / -1;
    margin-left: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: stretch;
  }

  .lang-switcher {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
    padding: 6px;
  }

  .lang-switcher .lang-btn {
    min-width: 44px;
    min-height: 36px;
    font-size: 12px;
  }

  .nav-auth .nav-user {
    flex: 1 1 100%;
    text-align: center;
    padding: 4px 0;
  }

  .nav-auth .nav-btn {
    flex: 1;
    min-width: 0;
  }

  .stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat {
    min-width: 0;
    padding: 10px 12px;
  }

  .stat strong { font-size: 17px; }

  .container { padding: 14px; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar input,
  .toolbar select,
  .toolbar button,
  .toolbar #add-server-btn {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .toolbar label.checkbox {
    width: 100%;
    padding: 8px 4px;
  }

  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .detail-actions {
    width: 100%;
    justify-content: stretch;
  }

  .detail-actions .nav-btn,
  .detail-actions button {
    flex: 1;
  }

  .charts-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .chart-range {
    flex-wrap: wrap;
    justify-content: center;
  }

  .chart-range-btn {
    flex: 1;
    min-width: 3.5rem;
    text-align: center;
  }

  .stats-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-page-header .chart-range {
    width: 100%;
  }

  .charts-grid,
  .stats-charts {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 8px;
  }

  .pagination button {
    flex: 1;
    min-width: 7rem;
  }

  #page-info {
    flex: 1 1 100%;
    text-align: center;
    font-size: 13px;
  }

  .disc-auth-gate {
    flex-direction: column;
    align-items: stretch;
  }

  .disc-auth-gate .nav-btn {
    width: 100%;
    text-align: center;
  }

  .disc-compose-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .disc-publish {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .header-nav {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }
}

/* ===== Light Mode ===== */
html.light {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #1a1a2e;
  --muted: #4a5568;
  --border: #e2e8f0;
}

html.light body {
  background: #f5f7fa;
}

html.light .header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
}

html.light .footer {
  background: #f0f2f5;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

html.light .toolbar {
  background: var(--panel);
  border: 1px solid var(--border);
}

html.light .servers-table thead {
  background: #f0f2f5;
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 10px;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s;
}
.theme-toggle-btn:hover {
  background: var(--panel);
  border-color: var(--muted);
}
