:root {
  --bg: #f5f8fd;
  --card: #ffffff;
  --text: #22314e;
  --muted: #7d8ca6;
  --primary: #5b8def;
  --primary-dark: #4477dd;
  --line: #dce5f1;
  --soft: #eef3fb;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(48, 77, 130, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 42px;
}

/* 顶部导航 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 0 10px;
  background: rgba(245, 248, 253, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand-badge {
  font-size: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tab {
  flex: 1;
  min-height: 44px;
  border: none;
  border-radius: 13px;
  background: var(--soft);
  color: #5b6d8a;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 141, 239, 0.3);
}

/* 页面切换 */
.page {
  display: none;
  padding-top: 18px;
  animation: fade 0.25s ease;
}

.page.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 首页 */
.hero {
  padding: 18px 8px 14px;
  text-align: center;
}

.hero h1 {
  font-size: 26px;
  letter-spacing: 1px;
}

.hero p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.tip-banner {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #d8e7ff;
  border-radius: 14px;
  background: #edf5ff;
  color: #3d6bb3;
  font-size: 14px;
  text-align: center;
}

.search-box {
  position: relative;
  margin: 14px 0;
}

.search-box .search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #91a2bd;
  font-size: 20px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 50px;
  padding: 0 16px 0 44px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  box-shadow: var(--shadow);
}

.search-box input:focus {
  border-color: var(--primary);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 2px 12px;
}

.section-head h2 {
  font-size: 19px;
}

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

.works-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.work-card {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.work-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--soft);
}

.work-info {
  padding: 10px 12px 12px;
}

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

.work-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

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

/* 通用按钮 */
.vote-btn {
  min-width: 66px;
  min-height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  touch-action: manipulation;
}

.vote-btn:active {
  background: var(--primary-dark);
}

.vote-btn:disabled {
  cursor: default;
}

.vote-btn.voted {
  background: #e8edf5;
  color: #97a4ba;
}

.primary-btn {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(91, 141, 239, 0.28);
  touch-action: manipulation;
}

.primary-btn:active {
  background: var(--primary-dark);
}

.primary-btn:disabled {
  opacity: 0.65;
  box-shadow: none;
}

/* 排行榜 */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.rank-no {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--soft);
  color: #677a99;
  font-size: 14px;
  font-weight: 800;
}

.rank-card.top1 .rank-no {
  background: #ffe8b3;
  color: #b26a00;
}

.rank-card.top2 .rank-no {
  background: #e8edf5;
  color: #64768f;
}

.rank-card.top3 .rank-no {
  background: #f3ddd2;
  color: #a15f2c;
}

.rank-thumb {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border-radius: 13px;
  object-fit: cover;
  background: var(--soft);
}

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

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

.rank-votes {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

/* 上传 */
.card {
  margin: 14px 0;
  padding: 18px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.form-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
}

.form-card label em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
}

.form-card input[type="text"] {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.form-card input[type="text"]:focus {
  border-color: var(--primary);
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  margin: 16px 0 8px;
  overflow: hidden;
  border: 1.5px dashed #b9c9e4;
  border-radius: 14px;
  background: #f8faff;
  color: #7185a5;
  cursor: pointer;
  font-size: 15px;
  text-align: center;
}

.upload-box:active {
  background: #eef4fd;
}

.upload-preview {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
}

.hint {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.rule-mini h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.rule-mini ul {
  padding-left: 0;
  list-style: none;
}

.rule-mini li {
  padding: 5px 0;
  color: #4d5f7e;
  font-size: 14px;
}

/* 规则页 */
.rule-list {
  margin: 16px 0;
  padding-left: 0;
  list-style: none;
}

.rule-list li {
  padding: 9px 0;
  border-bottom: 1px solid #eef2f8;
  font-size: 15px;
}

.rule-list li:last-child {
  border-bottom: none;
}

.rule-list .ok {
  color: #2f6b3f;
}

.rule-list .no {
  color: #b4473a;
}

.example-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 13px;
  background: #f4f7fc;
}

.example-box span {
  color: var(--muted);
  font-size: 13px;
}

.example-box b {
  color: var(--primary-dark);
  font-size: 16px;
  letter-spacing: 1px;
}

/* 空状态 */
.empty {
  padding: 40px 20px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.empty p {
  margin-bottom: 6px;
  color: #4f6180;
  font-size: 16px;
  font-weight: 700;
}

.footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid #e4ebf5;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 100;
  max-width: 86vw;
  padding: 12px 18px;
  border-radius: 14px;
  background: #25334f;
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
}

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

@media (min-width: 560px) {
  .works-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
