/* === Design Tokens (来自 design_handoff README) === */
:root {
  --primary:        #2563eb;
  --primary-light:  #eff6ff;
  --primary-dark:   #1e3a5f;
  --amber:          #d97706;
  --amber-light:    #fffbeb;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --text-primary:   #1e293b;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --border:         #e2e8f0;
  --bg:             #f8fafc;
  --card:           #ffffff;
  --shadow-sm: 0 1px 8px rgba(0,0,0,0.07);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: #f0f4f8;
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

#root {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.phone-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
}
@media (min-width: 431px) {
  #root { padding: 20px 0; align-items: center; }
  .phone-shell { min-height: 90vh; border-radius: 24px; }
}

.page { background: var(--bg); flex: 1; display: flex; flex-direction: column; }

/* Hero header (gallery & ranking) */
.hero {
  padding: 28px 20px 20px;
  position: relative;
  overflow: hidden;
  color: #fff;
}
.hero--gallery { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.hero--ranking { background: linear-gradient(135deg, #78350f 0%, #d97706 100%); }
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,0.06);
}
.hero::before { top: -30px; right: -30px; width: 120px; height: 120px; }
.hero::after  { bottom: -20px; left: 40px;  width: 80px;  height: 80px; }
.hero > * { position: relative; }
.hero .eyebrow { font-size: 11px; color: rgba(255,255,255,0.6); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px; }
.hero h1 { font-size: 24px; font-weight: 700; line-height: 1.2; }
.hero h1.alt { color: #93c5fd; margin-bottom: 14px; }
.hero .badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hero .badge-pill { background: rgba(255,255,255,0.15); border-radius: 20px; padding: 4px 12px; font-size: 12px; }
.hero .back-btn {
  background: rgba(255,255,255,0.15); border: none; border-radius: 20px; padding: 6px 14px;
  color: #fff; font-size: 13px; cursor: pointer; margin-bottom: 16px;
}
.hero p.sub { color: rgba(255,255,255,0.7); font-size: 13px; }
.hero a.admin-link {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 20px;
  font-size: 11px; color: rgba(255,255,255,0.85);
}

/* Toolbar (gallery) */
.toolbar {
  background: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 10;
}
.toolbar .seg { display: flex; gap: 6px; }
.toolbar .seg .pill {
  font-size: 12px; padding: 5px 12px; border-radius: 20px; border: none; cursor: pointer;
  background: #f1f5f9; color: var(--text-secondary); font-weight: 500; transition: all 0.2s;
}
.toolbar .seg .pill.active { background: var(--primary); color: #fff; }
.toolbar .ranking-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 5px 12px; border-radius: 20px; border: none;
  background: #fff7ed; color: var(--amber); cursor: pointer; font-weight: 600;
}

/* Gallery grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  flex: 1;
}
.card {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
  color: inherit;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card .poster-wrap { position: relative; }
.card .poster-wrap img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.card .poster-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.55); border-radius: 20px; padding: 2px 8px;
  font-size: 12px; color: #fbbf24; font-weight: 700;
  backdrop-filter: blur(4px);
}
.card .body { padding: 10px 10px 12px; }
.card .row1 { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.card .name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.card .class-name { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.card .desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .footer { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.card .progress-text { font-size: 10px; color: #cbd5e1; }

/* Tag chip & score badge */
.chip {
  font-size: 11px; background: var(--primary-light); color: var(--primary);
  border-radius: 20px; padding: 2px 8px; font-weight: 500; display: inline-block;
}
.score-badge {
  font-size: 11px; color: var(--text-muted); background: #f1f5f9;
  border-radius: 20px; padding: 2px 8px;
}
.score-badge.has {
  background: var(--amber-light); color: var(--amber); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 3px;
}
.score-badge.has small { font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* Detail page */
.topbar {
  background: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #f1f5f9;
  position: sticky; top: 0; z-index: 20;
}
.topbar .back { background: none; border: none; cursor: pointer; padding: 4px 8px 4px 0; font-size: 22px; color: #475569; line-height: 1; }
.topbar .title { flex: 1; font-weight: 600; font-size: 16px; }

.poster-large { position: relative; }
.poster-large img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.poster-large .gradient {
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
}
.poster-large .info {
  position: absolute; bottom: 14px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.poster-large .info .name { color: #fff; font-weight: 700; font-size: 18px; }
.poster-large .info .meta { color: rgba(255,255,255,0.75); font-size: 12px; }
.poster-large .info .score-big { color: #fbbf24; font-weight: 700; font-size: 22px; }
.poster-large .info .score-sub { color: rgba(255,255,255,0.7); font-size: 11px; }

.tabs { background: #fff; display: flex; border-bottom: 1px solid #f1f5f9; }
.tabs .tab {
  flex: 1; padding: 12px 0; border: none; background: none; cursor: pointer;
  font-size: 13px; color: var(--text-muted); font-weight: 400;
  border-bottom: 2px solid transparent;
}
.tabs .tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.tabs .tab .count { margin-left: 3px; font-size: 11px; background: var(--primary-light); color: #3b82f6; border-radius: 20px; padding: 1px 6px; }

.tab-content { flex: 1; padding: 16px; }
.panel { background: #fff; border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.panel .panel-label {
  font-size: 11px; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 8px; text-transform: uppercase;
}
.panel p { font-size: 14px; color: #374151; line-height: 1.8; }
.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f8fafc; }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { font-size: 13px; color: var(--text-muted); }
.kv-row .v { font-size: 13px; color: var(--text-primary); font-weight: 500; }

/* Score form */
.teacher-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.teacher-btn {
  padding: 10px 0; border-radius: 12px; border: 2px solid var(--border);
  background: #fff; color: #374151; font-size: 14px; cursor: pointer; transition: all 0.18s;
}
.teacher-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.teacher-btn small { font-size: 10px; display: block; color: var(--text-muted); margin-top: 2px; }
.input-text {
  width: 100%; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--border);
  font-size: 14px; font-family: inherit; outline: none; margin-top: 10px;
}
.input-text:focus { border-color: var(--primary); }

.score-row { display: flex; align-items: center; gap: 12px; }
.score-row input[type="number"] {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.score-row input[type="number"]::-webkit-outer-spin-button,
.score-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score-row input[type="number"]:focus { border-color: var(--primary); }
.score-row .grade {
  font-size: 24px; font-weight: 800; min-width: 56px; text-align: center; color: #cbd5e1;
}

textarea.input-text { resize: none; line-height: 1.7; color: #374151; font-size: 13px; padding: 12px 14px; margin-top: 0; }

.submit-btn {
  width: 100%; padding: 14px 0; border-radius: 14px; border: none;
  background: #e2e8f0; color: var(--text-muted); font-size: 16px; font-weight: 700;
  cursor: not-allowed; transition: all 0.2s;
}
.submit-btn.ready {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.submit-btn.ready:active { transform: scale(0.98); }

/* Submitted state */
.submitted-card {
  background: #fff; border-radius: 16px; padding: 24px; text-align: center;
}
.submitted-card .icon { font-size: 40px; margin-bottom: 12px; }
.submitted-card h3 { font-weight: 700; font-size: 16px; color: var(--text-primary); margin-bottom: 6px; }
.submitted-card .desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.submitted-card .score-big {
  font-size: 32px; font-weight: 800; color: var(--amber); margin: 8px 0 4px;
}
.submitted-card .grade-big { font-size: 14px; font-weight: 600; }
.submitted-card .quote {
  background: var(--bg); border-radius: 12px; padding: 12px;
  font-size: 13px; color: #475569; margin-top: 12px; text-align: left; line-height: 1.7;
}
.submitted-card .reset-link {
  display: inline-block; margin-top: 16px; font-size: 13px; color: #3b82f6; background: none; border: none; cursor: pointer;
}

/* Reviews list */
.empty {
  text-align: center; padding: 40px 0; color: var(--text-muted);
}
.empty .big-icon { font-size: 36px; margin-bottom: 12px; }
.review-card { background: #fff; border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.review-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.review-card .who { display: flex; align-items: center; gap: 8px; }
.review-card .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--primary);
}
.review-card .teacher-name { font-weight: 600; font-size: 14px; }
.review-card .score-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--amber);
}
.review-card .comment { font-size: 13px; color: #475569; line-height: 1.7; padding-left: 40px; }

/* Ranking */
.podium-bg { background: linear-gradient(180deg, #d97706 0%, #f8fafc 60%); padding: 20px 16px 0; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.podium .col { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.podium .medal { font-size: 20px; margin-bottom: 4px; }
.podium .col.first .medal { font-size: 28px; }
.podium img { border-radius: 50%; object-fit: cover; margin-bottom: 6px; }
.podium .col.first img { width: 72px; height: 72px; border: 3px solid #fbbf24; }
.podium .col.second img { width: 56px; height: 56px; border: 3px solid #94a3b8; }
.podium .col.third img { width: 56px; height: 56px; border: 3px solid #cd7f32; }
.podium .pname { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.podium .pavg { font-size: 12px; color: var(--amber); font-weight: 600; margin-bottom: 8px; }
.podium .stand { width: 100%; border-radius: 12px 12px 0 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; }
.podium .col.first .stand  { background: #fbbf24; height: 130px; font-size: 28px; }
.podium .col.second .stand { background: #94a3b8; height: 100px; font-size: 22px; }
.podium .col.third .stand  { background: #d97706; height: 85px;  font-size: 22px; }

.rank-list { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.rank-row {
  background: #fff; border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border: 1.5px solid transparent;
}
.rank-row.is-first { border-color: #fbbf24; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.rank-row .rank-no { width: 32px; text-align: center; font-size: 14px; font-weight: 700; color: #cbd5e1; }
.rank-row .rank-no.r1 { font-size: 18px; color: var(--amber); }
.rank-row .rank-no.r2 { font-size: 18px; color: #94a3b8; }
.rank-row .rank-no.r3 { font-size: 18px; color: #c2855b; }
.rank-row img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.rank-row .meta { flex: 1; min-width: 0; }
.rank-row .meta .top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.rank-row .meta .top .name { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.rank-row .meta .class-name { font-size: 11px; color: var(--text-muted); }
.rank-row .right { text-align: right; flex-shrink: 0; }
.rank-row .right .score-num { font-size: 18px; font-weight: 800; color: var(--amber); }
.rank-row .right .ppl { font-size: 10px; color: var(--text-muted); }
.rank-row .right .pending { font-size: 11px; color: #cbd5e1; }

/* Toast */
.toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  display: none;
  max-width: 80%;
  text-align: center;
}

/* spacer */
.spacer-bot { height: 20px; }
