: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;
  overscroll-behavior-x: none;
}

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; }

.masked-id {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  vertical-align: middle;
}

.masked-id-text {
  font: inherit;
  font-weight: inherit;
  white-space: nowrap;
}

.id-eye {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.id-eye:active {
  background: var(--bg-soft);
}

/* 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); }

.filter-badge { cursor: pointer; }
.filter-badge.active {
  box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.18);
  font-weight: 800;
}

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

/* Login */
.login-view {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 26px 16px;
  background:
    linear-gradient(160deg, rgba(231, 238, 250, 0.92), rgba(255, 255, 255, 0.98) 54%, rgba(232, 240, 252, 0.92)),
    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 {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(248, 251, 255, 0.98));
  border: 1px solid rgba(212, 221, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 22px 52px rgba(30, 45, 76, 0.16), 0 4px 14px rgba(30, 45, 76, 0.08);
  padding: 24px 22px 20px;
}

.login-card-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #b97e12, #e6a51d 24%, #f5ce70 50%, #46a99a 86%, #2f8f82);
}

.login-brand {
  text-align: center;
  padding: 18px 0 4px;
}

.login-emblem {
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f5b93d, #d99016 62%, #a9690d);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 8px 20px rgba(197, 133, 16, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.login-emblem .emblem-swords {
  font-size: 31px;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(67, 42, 4, 0.2);
}

.login-brand h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
}

.login-slogan {
  margin: 7px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.login-body {
  padding-top: 16px;
}

.login-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 15px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.login-head-row .login-sub {
  margin: 0;
  color: var(--text-2);
  font-weight: 700;
  font-size: 14px;
}

.login-head-register {
  border: none;
  background: transparent;
  color: var(--teal);
  font-weight: 600;
  font-size: 13px;
  padding: 4px 0;
}

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

.login-input-wrap {
  position: relative;
}

.login-input-wrap .input {
  min-height: 48px;
  padding-left: 42px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 44, 74, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input-wrap .input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 182, 59, 0.16);
}

.login-input-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.78;
  pointer-events: none;
}

.login-forgot-row {
  text-align: right;
  margin: -6px 0 0;
}

.login-forgot {
  border: none;
  background: transparent;
  padding: 4px 0 2px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.login-forgot:hover {
  color: var(--teal);
  text-decoration: underline;
}

.forgot-pwd-tip {
  margin: 0;
  padding: 8px 0 4px;
  text-align: center;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.7;
}

.login-go {
  min-height: 48px;
  margin-top: 3px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 9px 20px rgba(212, 139, 18, 0.22);
}

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

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

.guest-login {
  margin-top: 10px;
  background: rgba(15, 143, 130, 0.05);
  border-color: rgba(15, 143, 130, 0.26);
  color: var(--teal);
}

.guest-login:hover {
  background: rgba(15, 143, 130, 0.1);
}

.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-videos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.post-video {
  width: 100%;
  max-height: 460px;
  border-radius: 8px;
  background: #000;
}

.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: flex-start;
  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.flagged {
  border-color: rgba(255, 100, 124, 0.65);
  background: rgba(255, 100, 124, 0.07);
}

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

.user-row .user-name {
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

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

.user-row .user-meta {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.allowed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 430px;
  overflow-y: auto;
}

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

.allowed-id-item.missing {
  border-color: rgba(255, 100, 124, 0.65);
  background: rgba(255, 100, 124, 0.07);
}

.allowed-id-item.missing .allowed-id-line b {
  color: var(--danger);
}

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

.allowed-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.allowed-id-line b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.allowed-id-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.allowed-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.allowed-actions .btn {
  padding: 0 10px;
  font-size: 13px;
}

.flag-mark {
  margin-left: 8px;
  vertical-align: 1px;
  display: inline-flex;
}

@media (max-width: 480px) {
  .user-row {
    flex-wrap: wrap;
  }

  .user-row .user-info {
    flex: 1 1 calc(100% - 54px);
  }

  .user-row .user-meta {
    flex-basis: 100%;
    width: 100%;
    align-items: stretch;
    padding-left: 0;
  }

  .user-row .user-meta .role-badge {
    align-self: flex-start;
  }

  .user-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .user-actions .btn {
    width: 100%;
    min-width: 0;
    padding: 0 8px;
    min-height: 38px;
    white-space: nowrap;
  }

  .user-actions .btn:only-child {
    grid-column: 1 / -1;
  }
}

/* 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 */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #94a3b8;
}

.sync-status.sync-online { color: #15803d; }

.sync-status.sync-online .sync-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.sync-status.sync-offline { color: #dc2626; }

.sync-status.sync-offline .sync-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.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-row.mine {
  border-color: rgba(242, 182, 59, 0.72);
  background: linear-gradient(90deg, rgba(242, 182, 59, 0.1), rgba(255, 255, 255, 0.72));
  box-shadow: 0 5px 14px rgba(197, 133, 16, 0.1);
}

.mine-chip {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gold);
  color: #171204;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.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;
  transition: transform 0.35s ease, opacity 0.25s ease;
  transform-origin: left center;
}

.lightbox img.flip-out-next {
  transform: rotateY(-24deg) scale(0.97);
  opacity: 0.35;
}

.lightbox img.flip-out-prev {
  transform: rotateY(24deg) scale(0.97);
  opacity: 0.35;
}

.lightbox img.flip-in {
  transform: rotateY(16deg);
  opacity: 0.45;
}

.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;
}

/* Wheel */
.prize-row { display: flex; flex-wrap: wrap; gap: 8px; }

.prize-chip {
  padding: 6px 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
}

.wheel-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 12px;
}

.wheel-box { position: relative; padding: 12px 8px 4px; }

.wheel-pointer {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 20px solid var(--danger);
}

.wheel-wrap {
  position: relative;
  width: min(340px, 92vw);
  margin: 0 auto;
}

.wheel-wrap svg { width: 100%; display: block; }

.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #e0a02a);
  color: #171204;
  font-weight: 800;
  font-size: 16px;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.wheel-center.muted {
  width: auto;
  height: auto;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  transform: translate(-50%, -50%);
}

.wheel-side { display: flex; flex-direction: column; gap: 12px; }

.wheel-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.winner-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 7px 9px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.winner-name {
  flex: 1 1 90px;
  min-width: 70px;
  max-width: 100%;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.winner-prize {
  flex: 0 1 110px;
  min-width: 50px;
  max-width: 50%;
  color: var(--gold-2);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prize-queue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
  font-size: 14px;
  margin-bottom: 6px;
}

.prize-queue-row.current {
  border-color: var(--gold);
  background: rgba(242, 182, 59, 0.08);
}

.prize-queue-row .muted { flex: 0 0 auto; }
.prize-queue-row b { flex: 1; min-width: 0; }

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

/* 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; }
}

/* Latest activity images */
.lme-latest-card { padding: 14px; }

.lme-photo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.lme-photo {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-2);
}

.lme-photo:hover { border-color: var(--gold); }

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

.lme-photo-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  color: #fff;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.62);
}

@media (max-width: 640px) {
  .lme-photo-grid {
    grid-template-columns: 1fr;
  }
}
