:root {
  --bg: #f2f5fa;
  --bg-soft: #e9eef6;
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #f4f7fc;
  --line: #d7dfec;
  --line-soft: #e5eaf3;
  --text: #1c2538;
  --text-2: #4b5670;
  --muted: #78849c;
  --gold: #e89c1d;
  --gold-2: #8a5a08;
  --teal: #0f8f82;
  --blue: #2f6bff;
  --danger: #d93652;
  --ok: #1e9e68;
  --radius: 8px;
  --shadow: 0 10px 24px rgba(31, 44, 74, 0.10);
  --topbar-h: 54px;
  --bottomnav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

body { min-height: 100vh; }

img { max-width: 100%; display: block; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

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

.app-main {
  min-height: 100vh;
  padding-bottom: calc(var(--bottomnav-h) + 18px);
}

.app-main.login-view {
  padding: 0;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 0;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
}

.page-title .page-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #e6edfb, #d3def5);
  border: 1px solid var(--line);
  font-size: 20px;
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin: -6px 0 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stack > * + * { margin-top: 10px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar .brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), #d68d18);
  color: #151005;
  font-weight: 800;
  font-size: 15px;
}

.topbar .brand-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  font-size: 15px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  padding: 0;
}

.icon-btn:hover { border-color: var(--gold); }

.top-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-user .avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.top-user .top-user-name {
  max-width: 96px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

/* Avatar */
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dfe8fb, #c5d4f3);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  color: var(--blue);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.big { width: 72px; height: 72px; flex-basis: 72px; font-size: 24px; }

/* Bottom nav */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--bottomnav-h);
  display: flex;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.bottomnav a .nav-ico { font-size: 20px; line-height: 1; }

.bottomnav a.active {
  color: var(--gold-2);
  border-bottom-color: var(--gold);
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(28, 38, 66, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 61;
  width: min(78vw, 300px);
  background: #ffffff;
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.drawer.open { transform: translateX(0); }

.drawer .drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}

.drawer .drawer-nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }

.drawer a.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 15px;
}

.drawer a.drawer-link:hover,
.drawer a.drawer-link.active { background: var(--card-2); color: var(--gold-2); }

.drawer a.drawer-link .link-ico { font-size: 19px; width: 24px; text-align: center; }

.drawer .drawer-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--gold), #e19b1f);
  border-color: #d99a24;
  color: #171204;
}

.btn.teal {
  background: var(--teal);
  border-color: #25b3a3;
  color: #06221f;
}

.btn.danger {
  background: transparent;
  border-color: rgba(255, 100, 124, 0.55);
  color: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--text-2);
}

.btn.block { width: 100%; }

.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; }

.btn .btn-ico { font-size: 17px; line-height: 1; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottomnav-h) + 16px);
  z-index: 35;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gold), #d98f16);
  color: #171204;
  font-size: 26px;
  box-shadow: var(--shadow);
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 13px;
  color: var(--text-2);
}

.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--gold);
}

.textarea { min-height: 96px; resize: vertical; }

.searchbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.searchbar .input { flex: 1; min-width: 0; }

.searchbar .date-input { width: 128px; flex: 0 0 auto; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.form-actions .btn { flex: 1; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-2);
  white-space: nowrap;
}

.badge.gold { color: var(--gold-2); border-color: rgba(242, 182, 59, 0.5); }
.badge.teal { color: var(--teal); border-color: rgba(56, 214, 196, 0.5); }
.badge.blue { color: var(--blue); border-color: rgba(91, 140, 255, 0.5); }
.badge.ok { color: var(--ok); border-color: rgba(69, 217, 154, 0.5); }
.badge.warn { color: var(--gold); border-color: rgba(242, 182, 59, 0.5); }
.badge.danger { color: var(--danger); border-color: rgba(255, 100, 124, 0.5); }

.role-badge { font-size: 12px; }

/* Login */
.login-view {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.9)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='800' height='600'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='%23dbe7fb'/><stop offset='1' stop-color='%23c6d5f1'/></linearGradient></defs><rect width='800' height='600' fill='url(%23g)'/><path d='M0 420 Q200 340 420 420 T800 410 V600 H0 Z' fill='%23ffffff' opacity='0.55'/><path d='M0 470 Q220 420 480 480 T800 470 V600 H0 Z' fill='%23f2f7ff' opacity='0.7'/></svg>") center/cover no-repeat;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-brand .brand-mark { width: 42px; height: 42px; font-size: 21px; }

.login-brand h1 { font-size: 21px; margin: 0; }

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0 10px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.login-note {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
}

.guest-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 143, 130, 0.1);
  border: 1px solid rgba(15, 143, 130, 0.35);
  color: var(--teal);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* Feed */
.feed-list { display: flex; flex-direction: column; gap: 12px; }

.post-card { padding: 12px; }

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-head .post-meta { min-width: 0; flex: 1; }

.post-head .post-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-head .post-account {
  font-size: 12px;
  color: var(--muted);
}

.post-text {
  margin: 10px 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.post-images {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.post-images img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #eef2f8;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.post-images.one img { grid-column: span 1; max-width: 240px; aspect-ratio: 4 / 3; }

.post-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pending-queue .post-card {
  border-color: rgba(242, 182, 59, 0.45);
}

.review-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.upload-previews {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.upload-previews .preview-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.upload-previews img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eef2f8;
}

.upload-previews .remove-img {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-2);
  font-weight: 600;
}

.tab.active {
  background: var(--card-2);
  border-color: var(--gold);
  color: var(--gold-2);
}

.tab .tab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(242, 182, 59, 0.18);
  color: var(--gold-2);
  font-size: 11px;
}

/* Hero/intro */
.alliance-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #dfe7f5;
}

.alliance-hero .hero-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: center;
}

.alliance-hero .hero-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 14px;
  background: linear-gradient(transparent, rgba(6, 11, 22, 0.88));
}

.alliance-hero h2 { margin: 0; font-size: 22px; color: #ffffff; }

.content-text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.benefit-block { display: flex; flex-direction: column; gap: 8px; }

.benefit-block .benefit-img {
  width: 100%;
  border-radius: 6px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #eef2f8;
  border: 1px solid var(--line);
}

/* Leaders */
.leader-card { text-align: center; }

.leader-card .leader-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef2f8;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.leader-card h3 { margin: 10px 0 4px; }

.leader-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.leader-tools {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* Announcements */
.ann-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
}

.ann-item + .ann-item { margin-top: 10px; }

.ann-item h4 { margin: 0 0 4px; font-size: 15px; }

.ann-item .ann-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
}

.file-item + .file-item { margin-top: 8px; }

.file-item .file-ico {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 18px;
}

.file-item .file-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  word-break: break-word;
}

.file-item .file-size { font-size: 12px; color: var(--muted); }

/* Profile */
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-head .profile-info { min-width: 0; flex: 1; }

.profile-head h2 { margin: 0 0 4px; font-size: 20px; }

.avatar-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card-2);
  overflow: hidden;
  padding: 0;
}

.avatar-option img { width: 100%; height: 100%; object-fit: cover; }

.avatar-option.selected { border-color: var(--gold); }

.my-post {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
}

.my-post + .my-post { margin-top: 8px; }

.my-post .my-post-text {
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.my-post .my-post-imgs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.my-post .my-post-imgs img {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  object-fit: contain;
  background: #eef2f8;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* Accounts table/list */
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
}

.user-row + .user-row { margin-top: 8px; }

.user-row .user-info { flex: 1; min-width: 0; }

.user-row .user-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row .user-account { font-size: 12px; color: var(--muted); }

/* Home grid */
.home-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.home-hero h2 { margin: 0; font-size: 20px; }

.home-hero p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.fn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fn-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}

.fn-card .fn-ico {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: 20px;
}

.fn-card .fn-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fn-card .fn-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fn-card .fn-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--gold);
  color: #171204;
  font-size: 12px;
  font-weight: 800;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(28, 38, 66, 0.38);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-head h3 { margin: 0; font-size: 17px; }

.modal .stack > * + * { margin-top: 12px; }

/* Toast */
.toast-root {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 88vw;
  padding: 10px 16px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease;
}

.toast.ok { border-color: rgba(69, 217, 154, 0.6); color: var(--ok); }
.toast.err { border-color: rgba(255, 100, 124, 0.6); color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Empty */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: 14px;
}

.empty .empty-ico { font-size: 34px; display: block; margin-bottom: 8px; }

/* Kill rank */
.kb-list { display: flex; flex-direction: column; gap: 6px; }

.kb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kb-rank {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 14px;
}

.kb-rank.r1 {
  background: linear-gradient(135deg, var(--gold), #e0a02a);
  color: #171204;
  border-color: #d99a24;
}

.kb-rank.r2 {
  background: linear-gradient(135deg, #c8d0dc, #9aa6b8);
  color: #1c2538;
  border-color: #8b96a8;
}

.kb-rank.r3 {
  background: linear-gradient(135deg, #e6b98a, #c2824f);
  color: #2a1606;
  border-color: #b27442;
}

.kb-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-kills { font-weight: 800; color: var(--gold-2); white-space: nowrap; }

.post-images img,
.benefit-img,
.my-post-imgs img,
.alliance-hero .hero-img,
.leader-img { cursor: zoom-in; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(5, 10, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 22px;
  display: grid;
  place-items: center;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 26px;
  display: grid;
  place-items: center;
}

.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }

.lightbox-count {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 12px;
  border-radius: 999px;
}

.lightbox-save {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), #e0a02a);
  color: #171204;
  font-weight: 700;
  font-size: 14px;
}

/* Utility */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.hidden { display: none !important; }

/* Desktop */
@media (min-width: 820px) {
  body { background: var(--bg); }

  .page { padding: 20px 22px 0; }

  .alliance-hero .hero-img {
    max-height: 420px;
  }

  .bottomnav { display: none; }

  .app-main {
    padding-bottom: 28px;
  }

  .desktop-nav {
    position: sticky;
    top: var(--topbar-h);
    z-index: 30;
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line-soft);
    padding: 10px 18px;
    overflow-x: auto;
  }

  .desktop-nav a {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text-2);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
  }

  .desktop-nav a.active {
    border-color: var(--gold);
    color: var(--gold-2);
  }

  .fn-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .leaders-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .feed-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }

  .feed-grid .post-card { margin: 0; }

  .modal-overlay { align-items: center; }

  .modal {
    width: min(560px, 94vw);
    border-radius: var(--radius);
  }

  .modal.wide { width: min(760px, 96vw); }

  .home-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 14px;
    align-items: start;
  }

  .home-layout .card { margin-top: 0; }
}

@media (max-width: 819px) {
  .desktop-nav { display: none; }
  .leaders-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
