/* R113 style.css */
:root {
  --contact-footer-h: 72px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --content-max-width: 480px;
  --card-radius: 12px;
  --gap: 12px;
  --primary: #FF6B35;
  --secondary: #4A90D9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #1E293B;
  --text-secondary: #64748B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: var(--content-max-width);
  margin: 0 auto;
  min-height: 100vh;
}
body.has-contact-footer {
  padding-bottom: calc(var(--contact-footer-h) + var(--safe-area-bottom) + 56px);
}

#app { padding-bottom: 56px; }
.nav-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.06);
  position: sticky; top: 0; z-index: 50;
}
.nav-logo { font-weight: 700; font-size: 15px; flex: 1; text-align: center; }
.nav-btn { background: none; border: none; font-size: 18px; padding: 8px; cursor: pointer; }

.course-tabs-wrap { position: relative; background: var(--card); border-bottom: 1px solid #eee; }
.course-tabs { display: flex; overflow-x: auto; gap: 4px; padding: 8px 12px; scrollbar-width: none; }
.course-tab {
  flex: 0 0 auto; border: none; background: #f1f5f9; border-radius: 20px; padding: 8px 14px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.course-tab.active { background: var(--primary); color: #fff; }
.tab-color { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.tab-indicator {
  position: absolute; bottom: 0; height: 3px; background: var(--primary);
  transition: transform .3s cubic-bezier(.4,0,.2,1), width .3s;
}

.view-container { padding: 12px; min-height: 50vh; }
.page-title { font-size: 18px; margin-bottom: 12px; }

.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--contact-footer-h) + var(--safe-area-bottom));
  width: 100%; max-width: var(--content-max-width); display: flex; background: var(--card);
  border-top: 1px solid #eee; z-index: 90;
}
.bottom-tab {
  flex: 1; border: none; background: none; padding: 8px 4px; font-size: 11px; color: var(--text-secondary); cursor: pointer;
}
.bottom-tab.active { color: var(--primary); font-weight: 600; }
.bottom-tab span { display: block; margin-top: 2px; }

.fab-checkin {
  position: fixed; right: 16px; bottom: calc(var(--contact-footer-h) + var(--safe-area-bottom) + 64px);
  background: var(--primary); color: #fff; border: none; border-radius: 28px; padding: 12px 20px;
  font-size: 15px; box-shadow: 0 4px 16px rgba(255,107,53,.4); z-index: 85; cursor: pointer;
  animation: breathe 2s ease-in-out infinite;
}

.btn { border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #ddd; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; margin-top: 8px; text-align: center; text-decoration: none; }

.card { background: var(--card); border-radius: var(--card-radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.search-input, textarea { width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }

.kpi-row { display: flex; gap: 8px; margin-bottom: 12px; }
.kpi-card { flex: 1; background: var(--card); border-radius: 10px; padding: 10px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.kpi-val { display: block; font-size: 20px; font-weight: 700; color: var(--primary); }
.kpi-label { font-size: 11px; color: var(--text-secondary); }

.course-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.course-card {
  background: var(--card); border-radius: var(--card-radius); padding: 14px; text-align: left;
  border: none; cursor: pointer; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.course-card .card-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--primary)); }
.course-card h3 { font-size: 15px; margin-bottom: 6px; padding-left: 8px; }
.card-meta { font-size: 12px; color: var(--text-secondary); padding-left: 8px; }
.card-progress { height: 4px; background: #eee; border-radius: 2px; margin-top: 8px; margin-left: 8px; }
.card-progress div { height: 100%; background: var(--secondary); border-radius: 2px; }
.add-card { border: 2px dashed #cbd5e1; background: transparent; color: var(--text-secondary); min-height: 100px; }

.student-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.student-avatar {
  background: var(--card); border: 2px solid #e2e8f0; border-radius: 12px; padding: 10px 6px;
  cursor: pointer; transition: transform .2s;
}
.student-avatar:hover { transform: scale(1.05); }
.student-avatar.checked { border-color: var(--success); animation: greenPulse .8s; }
.avatar-emoji { font-size: 28px; display: block; }
.avatar-name { font-size: 12px; display: block; margin-top: 4px; }
.stu-status { font-size: 10px; margin-top: 4px; display: block; }

.status-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.chip-success { background: #d1fae5; color: #065f46; }
.chip-warning { background: #fef3c7; color: #92400e; }
.chip-info { background: #dbeafe; color: #1e40af; }
.chip-danger { background: #fee2e2; color: #991b1b; }
.chip-muted { background: #f1f5f9; color: #64748b; }

.confirm-bar {
  position: sticky; bottom: calc(var(--contact-footer-h) + 56px); background: var(--card);
  padding: 12px; display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #eee; margin: 0 -12px;
}
.checkin-main-btn { animation: breathe 2s ease-in-out infinite; }

.mode-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.mode-tab { padding: 8px 12px; border-radius: 16px; border: 1px solid #e2e8f0; background: #fff; cursor: pointer; font-size: 13px; }
.mode-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chart-box { min-height: 220px; }
.att-list ul { list-style: none; }
.att-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }

.avatar-picker, .color-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.avatar-pick, .color-dot { width: 40px; height: 40px; border-radius: 10px; border: 2px solid #eee; background: #fff; cursor: pointer; font-size: 20px; }
.avatar-pick.selected, .color-dot.selected { border-color: var(--primary); transform: scale(1.1); }
.color-dot { border-radius: 50%; }

.ring-text { font-size: 22px; font-weight: bold; fill: var(--text); }
.ring-sub { font-size: 11px; fill: var(--text-secondary); }
.progress-ring { transition: stroke-dashoffset 1.5s ease-out; }

.badges-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.badge-item { text-align: center; padding: 10px; background: var(--card); border-radius: 10px; font-size: 24px; }
.badge-item.locked { opacity: .35; filter: grayscale(1); }
.flame-card { text-align: center; font-size: 18px; }
.flame { animation: flicker 1s ease-in-out infinite; }

.theme-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-btn { padding: 6px 10px; border-radius: 8px; border: 1px solid #ddd; background: #fff; font-size: 11px; cursor: pointer; }
.theme-btn.active { border-color: var(--primary); color: var(--primary); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; }

.warn-item { padding: 8px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.warn-mid { background: #fef3c7; }
.warn-high { background: #fee2e2; }

.toast-container { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--contact-footer-h) + 80px); z-index: 200; }
.toast-item { background: rgba(30,41,59,.9); color: #fff; padding: 10px 18px; border-radius: 20px; margin-top: 6px; opacity: 0; transition: opacity .3s; font-size: 13px; }
.toast-item.show { opacity: 1; }
.toast-error { background: var(--danger); }

.modal-container.hidden { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 20px; }
.modal-box { background: var(--card); border-radius: 14px; padding: 20px; max-width: 320px; width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.checkin-code { font-size: 36px; letter-spacing: 8px; text-align: center; font-weight: bold; color: var(--primary); margin: 12px 0; }

/* 分享页 */
body.share-page, body.invite-page { padding-top: 12px; }
.share-main { padding: 16px; }
.share-landing-card { background: var(--card); border-radius: 14px; padding: 20px 16px; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.share-eyebrow { color: var(--primary); font-size: 13px; }
.share-tagline, .share-desc { color: var(--text-secondary); margin: 8px 0; font-size: 14px; }
.share-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 14px 0; }
.share-stat { text-align: center; background: rgba(255,107,53,.08); border-radius: 8px; padding: 8px 4px; }
.share-stat strong { display: block; font-size: 16px; color: var(--primary); }
.share-stat span { font-size: 10px; color: var(--text-secondary); }
.share-cta { display: block; text-align: center; text-decoration: none; margin-top: 8px; }
.share-qr-block { text-align: center; margin-top: 16px; padding: 12px; background: var(--bg); border-radius: 10px; }

.contact-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101;
  background: #1a1a1a; padding: 8px 12px calc(6px + var(--safe-area-bottom));
}
.contact-footer__btns {
  display: grid; grid-template-columns: repeat(3, minmax(0, 88px));
  justify-content: center; gap: 8px; max-width: 320px; margin: 0 auto 4px;
}
.contact-footer__cta {
  background: #c41e1e !important; color: #fff !important; text-align: center;
  border-radius: 6px; padding: .48rem .2rem; font-size: .72rem; text-decoration: none;
}
.contact-footer__btn {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 6px; padding: .48rem .2rem; font-size: .72rem; cursor: pointer; text-decoration: none; text-align: center;
}
.contact-footer__brand { text-align: center; font-size: .62rem; color: rgba(255,255,255,.5); margin: 0; }
body.has-contact-footer .zw-root .zw-fab { bottom: calc(var(--contact-footer-h) + var(--safe-area-bottom) + 8px); }

@keyframes checkBounce { 0%{transform:scale(0);opacity:0} 50%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }
@keyframes greenPulse { 0%{box-shadow:0 0 0 0 var(--success)} 100%{box-shadow:0 0 0 16px transparent} }
@keyframes flicker { 0%,100%{opacity:.85;transform:scaleY(1)} 50%{opacity:1;transform:scaleY(1.08)} }
@keyframes breathe { 0%,100%{box-shadow:0 0 0 0 rgba(255,107,53,.4)} 50%{box-shadow:0 0 0 12px transparent} }
@keyframes cardFadeInUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
.card-in { animation: cardFadeInUp .5s ease forwards; animation-delay: calc(var(--i, 0) * .08s); }
.domino-in { animation: checkBounce .4s ease forwards; animation-delay: calc(var(--i, 0) * 50ms); }

/* P2 防作弊 + AI */
.mode-tab-p2 { font-size: 12px; }
.p2-panel { margin-top: 8px; }
.p2-video, .p2-preview { width: 100%; max-width: 320px; border-radius: 10px; background: #000; display: block; margin: 8px auto; }
.p2-canvas { display: none; }
.p2-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.p2-sign-pad { width: 100%; max-width: 300px; border: 2px dashed var(--text-secondary); border-radius: 8px; background: #fff; touch-action: none; display: block; margin: 8px auto; }
.p2-live-face { font-size: 64px; text-align: center; margin: 12px 0; }
.p2-ai-section { margin-bottom: 12px; }
.p2-badge { font-size: 10px; background: var(--primary); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.p2-ai-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.p2-ai-card { text-align: center; background: rgba(255,107,53,.08); border-radius: 8px; padding: 10px 4px; }
.p2-ai-val { display: block; font-size: 20px; font-weight: bold; color: var(--primary); }
.p2-ai-card span:last-child { font-size: 11px; color: var(--text-secondary); }
.p2-health-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.p2-health-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.p2-health-bar div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 4px; }
.p2-schedule { background: var(--bg); border-radius: 8px; padding: 10px; margin-top: 10px; }
.p2-schedule p { font-size: 13px; color: var(--text-secondary); margin: 4px 0 0; }

@media (min-width: 769px) {
  :root { --content-max-width: 720px; }
  .course-grid { grid-template-columns: repeat(3, 1fr); }
}
