:root {
  --red: #b3282f;
  --red-deep: #8a1a20;
  --red-soft: #fbeceb;
  --gold: #d5a64a;
  --gold-soft: #f2ddb1;
  --cream: #fdf8f0;
  --paper: #fffdf8;
  --ink: #2f2621;
  --muted: #857468;
  --line: #eddfd0;
  --shadow-sm: 0 8px 24px -18px rgba(92, 40, 30, 0.5);
  --shadow-lg: 0 30px 60px -30px rgba(92, 40, 30, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    "Source Han Sans SC", sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.container {
  width: min(1180px, 100% - 48px);
  margin: 0 auto;
}

/* ==================== 投票前台 ==================== */

body.page-public {
  background:
    radial-gradient(circle at 10% 10%, rgba(213, 166, 74, 0.1), transparent 42%),
    radial-gradient(circle at 92% 4%, rgba(179, 40, 47, 0.07), transparent 38%),
    var(--cream);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 72px 24px 84px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 224, 170, 0.18), transparent 42%),
    linear-gradient(158deg, #ad2a30 0%, #941f25 46%, #731318 100%);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.hero::before {
  width: 520px;
  height: 520px;
  left: -180px;
  top: -220px;
  border: 1px solid rgba(242, 221, 177, 0.22);
  box-shadow: 0 0 0 46px rgba(242, 221, 177, 0.05), 0 0 0 94px rgba(242, 221, 177, 0.035);
}

.hero::after {
  width: 420px;
  height: 420px;
  right: -140px;
  bottom: -240px;
  border: 1px solid rgba(242, 221, 177, 0.18);
  box-shadow: 0 0 0 40px rgba(242, 221, 177, 0.05), 0 0 0 82px rgba(242, 221, 177, 0.03);
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--gold-soft);
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: "";
  width: 42px;
  height: 1px;
}

.hero-eyebrow::before {
  background: linear-gradient(90deg, transparent, rgba(242, 221, 177, 0.85));
}

.hero-eyebrow::after {
  background: linear-gradient(90deg, rgba(242, 221, 177, 0.85), transparent);
}

.hero-title {
  margin: 14px 0 10px;
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  font-size: clamp(42px, 8vw, 68px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: #fff;
  text-shadow: 0 12px 30px rgba(60, 8, 10, 0.35);
}

.hero-sub {
  margin: 0;
  font-size: 15px;
  color: rgba(255, 246, 232, 0.78);
  letter-spacing: 0.06em;
}

.hero-stats {
  display: inline-flex;
  align-items: center;
  gap: 36px;
  margin-top: 32px;
  padding: 14px 40px;
  border: 1px solid rgba(242, 221, 177, 0.32);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--gold-soft);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.stat-label {
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: rgba(255, 246, 232, 0.6);
}

.stat-divider {
  width: 1px;
  height: 34px;
  background: rgba(242, 221, 177, 0.28);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 48px 0 22px;
}

.section-head h2 {
  position: relative;
  margin: 0;
  padding-left: 16px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 26px;
  letter-spacing: 0.08em;
}

.section-head h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 6px;
  width: 4px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--red), var(--gold));
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 26px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: card-in 0.6s cubic-bezier(0.22, 0.8, 0.3, 1) backwards;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.card:hover {
  transform: translateY(-6px);
  border-color: rgba(213, 166, 74, 0.55);
  box-shadow: var(--shadow-lg);
}

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

.card-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: linear-gradient(160deg, #f7ebdc, #efdcc6);
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.card:hover .card-photo img {
  transform: scale(1.04);
}

.card-photo::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  background: linear-gradient(180deg, transparent, rgba(47, 38, 33, 0.22));
  opacity: 0.6;
  pointer-events: none;
}

.photo-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: "Songti SC", serif;
  font-size: 44px;
  color: var(--gold);
  background: radial-gradient(circle at 50% 40%, #fdf3e2, #f0ddc4);
}

.card-photo.photo-missing img {
  display: none;
}

.card-photo.photo-missing .photo-fallback {
  display: flex;
}

.rank {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(47, 38, 33, 0.55);
  color: #fff;
  font-family: "Songti SC", serif;
  font-size: 16px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
}

.rank-1 {
  background: linear-gradient(140deg, #e8bd63, #c3902c);
  color: #4a2c05;
  border-color: rgba(255, 255, 255, 0.6);
}

.rank-2 {
  background: linear-gradient(140deg, #dfe3e8, #a9b1bb);
  color: #3a4048;
  border-color: rgba(255, 255, 255, 0.6);
}

.rank-3 {
  background: linear-gradient(140deg, #d9a271, #a96a37);
  color: #3d1f08;
  border-color: rgba(255, 255, 255, 0.6);
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px 20px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.card-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.building-tag {
  margin-left: auto;
  max-width: 62%;
  overflow: hidden;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-intro {
  display: -webkit-box;
  min-height: 4.8em;
  margin: 0 0 16px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13.5px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.vote-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.vote-count strong {
  margin-left: 2px;
  color: var(--red);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.vote-percent {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.vote-bar {
  height: 6px;
  margin: 8px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #f4e9dc;
}

.vote-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), #d8763f, var(--gold));
  transition: width 0.6s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.vote-btn {
  height: 44px;
  margin-top: auto;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #c0333a, #a1222a);
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  cursor: pointer;
  box-shadow: 0 10px 20px -12px rgba(179, 40, 47, 0.8);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.vote-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px -12px rgba(179, 40, 47, 0.85);
}

.vote-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.vote-btn:disabled {
  background: #f0e7dc;
  color: #a99b8e;
  cursor: default;
  box-shadow: none;
}

.vote-btn.is-voted::before {
  content: "✓";
  margin-right: 6px;
}

.vote-btn.is-busy {
  opacity: 0.75;
  cursor: wait;
}

.page-note {
  margin: 36px 0 0;
  text-align: center;
  color: #a5958a;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

.site-footer {
  margin-top: 56px;
  padding: 28px 24px 40px;
  border-top: 1px solid rgba(213, 166, 74, 0.25);
  text-align: center;
  color: #9b8b7f;
  font-size: 12.5px;
  letter-spacing: 0.06em;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 64px 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: var(--paper);
  text-align: center;
  color: var(--muted);
}

/* ==================== 提示条 ==================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 100;
  max-width: min(84vw, 420px);
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(47, 38, 33, 0.92);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: rgba(150, 30, 36, 0.95);
}

/* ==================== 管理后台 ==================== */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 15% 15%, rgba(213, 166, 74, 0.16), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(179, 40, 47, 0.12), transparent 42%),
    linear-gradient(160deg, #fdf8f0, #f7ecdd);
}

.login-card {
  width: min(400px, 100%);
  padding: 44px 36px 36px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: linear-gradient(145deg, #c0333a, #8e1c22);
  color: #fff;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 10px 22px -12px rgba(142, 28, 34, 0.9);
  transform: rotate(-3deg);
}

.login-card h1 {
  margin: 0 0 6px;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 26px;
  letter-spacing: 0.12em;
}

.login-card > p {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
}

.login-card .field {
  text-align: left;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field > label {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.08em;
}

.field input:not([type="file"]),
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fffefb;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.field input:not([type="file"]):focus,
.field textarea:focus {
  border-color: rgba(179, 40, 47, 0.55);
  box-shadow: 0 0 0 3px rgba(179, 40, 47, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(135deg, #c0333a, #9c2027);
  color: #fff;
  box-shadow: 0 10px 20px -14px rgba(179, 40, 47, 0.9);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px -14px rgba(179, 40, 47, 0.9);
}

.btn-ghost {
  border-color: var(--line);
  background: #fff;
  color: #6b5d52;
}

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

.btn-block {
  width: 100%;
  height: 46px;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.btn-mini {
  height: 30px;
  padding: 0 14px;
  border-color: var(--line);
  background: #fff;
  color: #6b5d52;
  font-size: 13px;
}

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

.btn-mini.danger {
  border-color: #f0d3d1;
  background: #fdf6f5;
  color: #b3282f;
}

.btn-mini.danger:hover {
  border-color: #e2a9a6;
  background: #fbeceb;
}

.admin-shell {
  min-height: 100vh;
  background: var(--cream);
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seal.small {
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 10px;
  font-size: 21px;
}

.brand h1 {
  margin: 0;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 19px;
  letter-spacing: 0.1em;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.12em;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-summary {
  margin: 26px 0 16px;
  color: var(--muted);
  font-size: 13.5px;
}

.admin-summary strong {
  margin: 0 2px;
  color: var(--red);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.admin-table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.admin-table th:nth-child(1) {
  width: 22%;
}

.admin-table th:nth-child(2) {
  width: 20%;
}

.admin-table th:nth-child(3) {
  width: 31%;
}

.admin-table th:nth-child(4) {
  width: 11%;
}

.admin-table th:nth-child(5) {
  width: 16%;
}

.admin-table th {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: #faf3e9;
  color: #8d7a6c;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: left;
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 18px;
  border-bottom: 1px solid #f3e9dd;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: #fdf8f1;
}

.cand-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cand-cell strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex: none;
  overflow: hidden;
  border: 1px solid rgba(213, 166, 74, 0.4);
  border-radius: 50%;
  background: linear-gradient(150deg, #f6e9d8, #eed9bf);
  color: var(--gold);
  font-family: "Songti SC", serif;
  font-size: 18px;
}

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

.muted {
  color: var(--muted);
}

.truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.votes-pill {
  display: inline-block;
  min-width: 46px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.table-empty {
  padding: 46px 0 !important;
  color: var(--muted);
  text-align: center;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(47, 38, 33, 0.45);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(580px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 28px 30px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 40px 80px -30px rgba(40, 20, 15, 0.55);
  animation: modal-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal h2 {
  margin: 0 0 22px;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 22px;
  letter-spacing: 0.1em;
}

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

.photo-field {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.photo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  flex: none;
  overflow: hidden;
  border: 1px dashed #dcc9b2;
  border-radius: 12px;
  background: #fdf7ee;
  color: #b3a08e;
  font-size: 12px;
}

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

.photo-inputs {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.photo-inputs input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
}

.photo-inputs input:focus {
  border-color: rgba(179, 40, 47, 0.55);
  box-shadow: 0 0 0 3px rgba(179, 40, 47, 0.08);
}

.file-btn {
  align-self: flex-start;
  height: 34px;
  font-size: 13px;
  cursor: pointer;
}

/* ==================== 响应式 ==================== */

@media (max-width: 720px) {
  .container {
    width: calc(100% - 32px);
  }

  .hero {
    padding: 56px 18px 64px;
  }

  .hero-stats {
    gap: 24px;
    padding: 12px 26px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .section-head {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 36px;
  }

  .admin-header {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .admin-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .admin-table-wrap {
    overflow-x: auto;
  }

  .admin-table {
    min-width: 640px;
  }

  .modal {
    padding: 22px 20px;
  }

  .photo-field {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 860px) {
  .admin-table {
    min-width: 0;
  }

  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) {
    display: none;
  }

  .admin-table th:nth-child(1) {
    width: 32%;
  }

  .admin-table th:nth-child(2) {
    width: 25%;
  }

  .admin-table th:nth-child(4) {
    width: 13%;
  }

  .admin-table th:nth-child(5) {
    width: 30%;
  }

  .admin-table th,
  .admin-table td {
    padding: 12px 10px;
  }

  .row-actions {
    gap: 6px;
  }

  .btn-mini {
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
