/* 暴打选举 — 共享外壳：设计令牌、顶栏、按钮、弹窗、toast、页脚 */
@import url('https://fonts.googleapis.com/css2?family=Bangers&family=JetBrains+Mono:wght@500;700;800&family=Noto+Sans+SC:wght@400;500;700;900&family=ZCOOL+KuaiLe&display=swap');

:root {
  --paper: #F4EDDF;
  --paper-2: #EAE0CC;
  --card: #FFFCF5;
  --ink: #15120F;
  --ink-2: #4B443C;
  --ink-3: #8C8274;
  --line: #15120F;
  --dem: #2B59FF;
  --dem-soft: #DCE4FF;
  --rep: #FF3B30;
  --rep-soft: #FFE0DD;
  --pow: #FFD60A;
  --pig: #FF8FB8;
  --pig-soft: #FFE1EC;
  --up: #0FA968;
  --down: #E5372B;
  --shadow: 4px 4px 0 var(--line);
  --shadow-sm: 2px 2px 0 var(--line);
  --shadow-lg: 7px 7px 0 var(--line);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'ZCOOL KuaiLe', 'Noto Sans SC', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --font-comic: 'Bangers', 'ZCOOL KuaiLe', Impact, sans-serif;
  --topbar-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  /* 报纸网点 */
  background-image: radial-gradient(rgba(21, 18, 15, 0.07) 1px, transparent 1.2px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 3px solid var(--pow); outline-offset: 2px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.comic { font-family: var(--font-comic); letter-spacing: 0.04em; }
.display { font-family: var(--font-display); font-weight: 400; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── 卡片 / 按钮 / 标签 ─────────────────────────── */
.card {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  background: var(--card); color: var(--ink);
  border: 2.5px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn-dem { background: var(--dem); color: #fff; }
.btn-rep { background: var(--rep); color: #fff; }
.btn-pow { background: var(--pow); }
.btn-pig { background: var(--pig); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--paper-2); box-shadow: none; transform: none; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 17px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tag-d, .tag-r {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  border: 2px solid var(--line); color: #fff; font: 800 12px/1 var(--font-mono);
}
.tag-d { background: var(--dem); }
.tag-r { background: var(--rep); }

.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--down); box-shadow: 0 0 0 0 rgba(229, 55, 43, .6);
  animation: live-pulse 1.6s infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 55, 43, .55); }
  70% { box-shadow: 0 0 0 8px rgba(229, 55, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 55, 43, 0); }
}

/* ── 顶栏 ─────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  border-bottom: 2.5px solid var(--line);
}
.topbar-inner {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; flex-shrink: 0;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--pow); border: 2.5px solid var(--line); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; font-size: 21px;
  transform: rotate(-8deg);
  transition: transform .2s cubic-bezier(.3, 1.8, .5, 1);
}
.brand:hover .brand-logo { transform: rotate(14deg) scale(1.08); }
.brand-name { font-family: var(--font-display); font-size: 25px; line-height: 1; }
.brand-tag {
  font: 800 10px/1 var(--font-mono); letter-spacing: .12em;
  padding: 4px 6px; border-radius: 5px; background: var(--ink); color: var(--pow);
}
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav a {
  padding: 7px 12px; border-radius: 999px; text-decoration: none; white-space: nowrap;
  font-weight: 700; font-size: 14px; color: var(--ink-2);
}
@media (max-width: 960px) {
  .brand-tag { display: none; }
}
.topnav a:hover { background: var(--paper-2); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.topbar-spacer { flex: 1; }
.topbar-live {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.topbar-live b { color: var(--ink); font-weight: 800; }
.tl-party { display: inline-flex; align-items: center; gap: 5px; }
.tl-party .tag-d, .tl-party .tag-r { min-width: 18px; height: 18px; padding: 0 4px; border-width: 1.5px; font-size: 10px; border-radius: 5px; }
.topbar-auth { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.me-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 12px 3px 3px; border: 2.5px solid var(--line); border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm); cursor: pointer;
}
.me-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: var(--pow); border: 2px solid var(--line);
}
.me-meta { display: flex; flex-direction: column; line-height: 1.15; }
.me-name { font-weight: 800; font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-level { font-size: 11px; color: var(--ink-3); }
.sticker-beaten {
  font: 400 12px/1 var(--font-display);
  padding: 5px 8px; border-radius: 999px; transform: rotate(-6deg);
  background: var(--pig); border: 2px solid var(--line);
}
.me-menu {
  position: absolute; right: 16px; top: calc(var(--topbar-h) - 4px);
  min-width: 220px; padding: 10px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.me-menu[hidden] { display: none; }
.me-menu .row { display: flex; justify-content: space-between; padding: 6px 8px; font-size: 13px; }
.me-menu hr { border: 0; border-top: 2px dashed var(--paper-2); margin: 6px 0; }
.me-menu button { width: 100%; }

@media (max-width: 860px) {
  .topbar-live { display: none; }
}
@media (max-width: 640px) {
  :root { --topbar-h: 58px; }
  .brand-name { font-size: 21px; }
  .brand-tag, .me-meta, .sticker-beaten { display: none; }
  .topnav { margin-left: 0; }
  .topnav a { padding: 6px 9px; font-size: 13px; }
  .me-chip { padding: 3px; }
}
@media (max-width: 440px) {
  .topnav { display: none; }
}
/* 手机：英文品牌名太长，收起"Log in"（注册弹窗里有登录页），品牌名缩一号 */
@media (max-width: 480px) {
  .topbar-auth [data-auth="login"] { display: none; }
  .brand-name { font-size: 18px; }
  .brand-logo { width: 34px; height: 34px; font-size: 19px; }
}

/* ── 弹窗（选民登记）──────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(21, 18, 15, .55);
  display: grid; place-items: center; padding: 16px;
  animation: fade-in .15s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--card); border: 3px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: pop-in .25s cubic-bezier(.3, 1.6, .5, 1);
}
.modal-head {
  position: relative; padding: 18px 20px 14px;
  border-bottom: 2.5px dashed var(--line);
  background: repeating-linear-gradient(-45deg, var(--pow) 0 14px, #FFE45C 14px 28px);
  border-radius: 15px 15px 0 0;
}
.modal-head h2 { margin: 0; font: 400 26px/1.1 var(--font-display); }
.modal-head p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.modal-close {
  position: absolute; right: 12px; top: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid var(--line); background: var(--card); cursor: pointer; font-size: 16px; font-weight: 900;
}
.modal-body { padding: 16px 20px 20px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button {
  flex: 1; min-height: 38px; border: 2.5px solid var(--line); border-radius: 999px;
  background: var(--card); font-weight: 800; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.field input {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 2.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; font: inherit; font-size: 16px;
}
.field input:focus { outline: none; box-shadow: 0 0 0 3px var(--pow); }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.avatar-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer; font-size: 10.5px; line-height: 1.2; color: var(--ink-2);
}
.avatar-grid button .e { font-size: 24px; line-height: 1.1; }
.avatar-grid button[aria-pressed="true"] { background: var(--pow); color: var(--ink); box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.form-error { min-height: 20px; margin: 0 0 8px; color: var(--down); font-size: 13px; font-weight: 700; }
.modal .btn[type="submit"] { width: 100%; }
.oath { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* ── toast ────────────────────────────────────── */
#toasts {
  position: fixed; left: 50%; bottom: 20px; z-index: 200;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px; border: 2.5px solid var(--line); border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow);
  font-weight: 700; font-size: 14px; text-align: center;
  animation: pop-in .25s cubic-bezier(.3, 1.6, .5, 1);
}
.toast.pow { background: var(--pow); }
.toast.pig { background: var(--pig); }
.toast.error { background: var(--ink); color: var(--paper); }
.toast.leaving { animation: fade-out .3s ease forwards; }

/* ── 页脚 ─────────────────────────────────────── */
#footer {
  margin-top: 48px; padding: 24px 0 32px;
  border-top: 2.5px solid var(--line); background: var(--paper-2);
  font-size: 12.5px; color: var(--ink-2);
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; align-items: flex-start; }
.footer-inner p { margin: 0; max-width: 680px; }
.footer-inner strong { color: var(--ink); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
