/* ============================================================
   投票系统 - 移动端优先样式
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: #2c2c2c;
  background: linear-gradient(180deg, #f5f7fb 0%, #e8eef7 100%);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

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

/* ---------------- App Container (mobile frame) ---------------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: #fff;
  box-shadow: 0 0 24px rgba(0,0,0,0.06);
  padding-bottom: 70px;
}

@media (min-width: 768px) {
  body { background: #eef1f7; }
  .app { margin-top: 12px; margin-bottom: 12px; min-height: calc(100vh - 24px); border-radius: 18px; overflow: hidden; }
}

/* ---------------- Header ---------------- */
.header {
  background: linear-gradient(135deg, #1a4ca0 0%, #2670d8 100%);
  color: #fff;
  padding: 18px 16px 22px;
  position: relative;
  text-align: center;
  overflow: hidden;
}
.header::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.header::before {
  content: "";
  position: absolute;
  bottom: -50px; left: -50px;
  width: 160px; height: 160px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.header .title { font-size: 18px; font-weight: 700; letter-spacing: 1px; position: relative; z-index: 1; }
.header .subtitle { font-size: 12px; opacity: 0.85; margin-top: 4px; position: relative; z-index: 1; }
.header .track {
  display: inline-block;
  margin-top: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 12px;
  position: relative; z-index: 1;
}

/* ---------------- Progress / Total votes ---------------- */
.total-bar {
  margin: 14px 16px 6px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(31,91,168,0.08);
}
.total-bar .label { color: #666; font-size: 12px; }
.total-bar .value { color: #1a4ca0; font-weight: 700; font-size: 18px; }
.total-bar .value small { font-weight: 400; color: #888; font-size: 12px; margin-left: 4px; }

/* ---------------- Category Grid (首页 6 个维度) ---------------- */
.section-title {
  margin: 18px 16px 10px;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  display: flex; align-items: center;
}
.section-title::before {
  content: ""; display: inline-block;
  width: 4px; height: 14px;
  background: linear-gradient(180deg, #1a4ca0, #2670d8);
  border-radius: 2px;
  margin-right: 8px;
}

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

.cat-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px 8px 12px;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  overflow: hidden;
}
.cat-card:active { transform: scale(0.96); }
.cat-card.disabled { opacity: 0.55; }
.cat-card .cat-icon {
  width: 64px; height: 64px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #f5f7fb;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cat-card .cat-icon img { width: 100%; height: 100%; object-fit: cover; }
.cat-card .cat-name { font-size: 14px; font-weight: 700; }
.cat-card .cat-tickets {
  margin-top: 6px;
  font-size: 11px;
  color: #888;
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
}
.cat-card .ticket-pill {
  background: #f0f4ff;
  color: #1a4ca0;
  border-radius: 100px;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 11px;
}
.cat-card .ticket-pill.zero { background: #ffe7eb; color: #c92e44; }
.cat-card .cat-ribbon {
  position: absolute;
  top: 8px; right: -22px;
  background: #ff4d4f;
  color: #fff;
  font-size: 10px;
  padding: 2px 22px;
  transform: rotate(35deg);
}

/* ---------------- Hint ---------------- */
.hint-card {
  margin: 18px 16px 0;
  background: #fffbe6;
  border-left: 4px solid #faad14;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #874d00;
  line-height: 1.6;
}
.hint-card b { color: #d4380d; }

/* ---------------- Footer (admin link) ---------------- */
.footer {
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 14px 0 4px;
}
.footer a { color: #1a4ca0; }

/* ---------------- Voting Page ---------------- */
.vote-page { display: none; }
.vote-page.active { display: block; }
.home-page.hidden { display: none; }

.vote-header {
  background: linear-gradient(135deg, var(--cat-color, #1a4ca0), var(--cat-color2, #2670d8));
  color: #fff;
  padding: 16px 16px 22px;
  position: relative;
}
.vote-header .back {
  position: absolute;
  top: 12px; left: 12px;
  font-size: 13px;
  color: #fff;
  background: rgba(255,255,255,0.2);
  border-radius: 100px;
  padding: 4px 12px;
  display: flex; align-items: center; gap: 4px;
}
.vote-header .cat-info { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.vote-header .cat-icon-big {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.vote-header .cat-icon-big img { width: 100%; height: 100%; object-fit: cover; }
.vote-header .cat-name-big { font-size: 22px; font-weight: 800; }
.vote-header .cat-sub { font-size: 12px; opacity: 0.85; margin-top: 4px; }

.ticket-status {
  margin: 14px 16px 0;
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.ticket-status .ts-label { color: #666; font-size: 12px; }
.ticket-status .ts-value { font-weight: 700; font-size: 16px; }
.ticket-status .ts-pill {
  display: inline-flex; align-items: center;
  background: var(--cat-color, #1a4ca0);
  color: #fff;
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 12px;
  margin-left: 6px;
}

.search-block {
  margin: 14px 16px 0;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.search-block .input-wrap {
  position: relative;
}
.search-block input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px 12px 40px;
  border: 1.5px solid #e3e7ef;
  border-radius: 10px;
  outline: none;
  background: #f7f9fc;
  transition: border-color 0.15s, background 0.15s;
}
.search-block input[type="text"]:focus {
  border-color: var(--cat-color, #1a4ca0);
  background: #fff;
}
.search-block .search-icon {
  position: absolute;
  top: 50%; left: 14px;
  transform: translateY(-50%);
  color: #999;
  font-size: 16px;
}
.search-block .hint {
  margin-top: 8px;
  font-size: 11px;
  color: #999;
}

/* ---------------- Result list ---------------- */
.result-list {
  margin: 12px 16px 0;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  max-height: 50vh;
  overflow-y: auto;
}
.result-list .empty { padding: 30px 14px; text-align: center; color: #999; font-size: 13px; }
.result-item {
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid #f1f3f8;
  cursor: pointer;
  transition: background 0.12s;
}
.result-item:last-child { border-bottom: none; }
.result-item:active { background: #f5f7fb; }
.result-item .thumb {
  width: 56px; height: 40px;
  border-radius: 6px;
  background: #f0f0f0;
  object-fit: cover;
  flex-shrink: 0;
}
.result-item .info { flex: 1; min-width: 0; }
.result-item .code { font-weight: 700; color: #2c2c2c; font-size: 15px; }
.result-item .name { color: #888; font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-item .arrow { color: #ccc; font-size: 14px; }

/* ---------------- Work Modal (选中后展示作品) ---------------- */
.work-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}
.work-modal.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.work-modal .sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 16px 16px 24px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.work-modal .sheet .grab {
  width: 40px; height: 4px;
  background: #d0d0d0;
  border-radius: 2px;
  margin: 0 auto 14px;
}
.work-modal .sheet .work-img {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 10px;
  background: #f5f5f5;
}
.work-modal .sheet .work-meta {
  margin-top: 14px;
  text-align: center;
}
.work-modal .sheet .work-code {
  font-size: 22px;
  font-weight: 800;
  color: var(--cat-color, #1a4ca0);
}
.work-modal .sheet .work-title {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}
.work-modal .sheet .actions {
  margin-top: 18px;
  display: flex; gap: 10px;
}
.work-modal .sheet .actions button {
  flex: 1;
  padding: 13px 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  transition: opacity 0.15s;
}
.work-modal .sheet .actions .btn-cancel { background: #f0f2f6; color: #555; }
.work-modal .sheet .actions .btn-confirm { background: var(--cat-color, #1a4ca0); color: #fff; }
.work-modal .sheet .actions button:active { opacity: 0.7; }
.work-modal .sheet .actions .btn-confirm:disabled { background: #c0c8d6; color: #fff; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  max-width: 80vw;
  text-align: center;
  display: none;
  animation: fadeIn 0.2s;
}
.toast.active { display: block; }
.toast.success { background: #1a4ca0; }
.toast.error { background: #c92e44; }

/* ---------------- Modal Loader ---------------- */
.loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.6);
  display: none;
  align-items: center; justify-content: center;
  z-index: 150;
}
.loader.active { display: flex; }
.loader .spinner {
  width: 32px; height: 32px;
  border: 3px solid #d0d8ea;
  border-top-color: #1a4ca0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
