:root {
  --bg1: #fff7ed; --bg2: #fdf2f8; --bg3: #eff6ff;
  --card: #ffffff;
  --ink: #3d2c29; --ink2: #8a7a75;
  --accent: #ff8a3d; --accent2: #7c5cff; --good: #10b981; --bad: #f43f5e;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(255, 138, 61, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%);
  min-height: 100vh; padding-bottom: 84px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, .7);
}
.brand { font-size: 19px; letter-spacing: .5px; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.star-badge {
  background: linear-gradient(90deg, #fde68a, #fbbf24); color: #7c4a03;
  font-weight: 700; padding: 6px 14px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 3px 10px rgba(251, 191, 36, .4);
}

main { max-width: 640px; margin: 0 auto; padding: 6px 14px 20px; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-top: 1px solid #f1e7dd; padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav button {
  flex: 1; border: 0; background: none; color: var(--ink2);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; padding: 4px 0; border-radius: 12px;
}
.bottom-nav button i { font-style: normal; font-size: 22px; transition: transform .15s; }
.bottom-nav button.active { color: var(--accent); font-weight: 700; }
.bottom-nav button.active i { transform: scale(1.18); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 12px 0; border: 1px solid #fff;
}
.card h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.card h3 .sub { font-size: 12px; color: var(--ink2); font-weight: 400; margin-left: auto; }

/* ---------- 今日页 ---------- */
.today-head { display: flex; align-items: center; gap: 10px; margin: 14px 2px 4px; }
.today-head .hello { font-size: 20px; font-weight: 800; }
.today-head input[type="date"] {
  margin-left: auto; border: 1px solid #f0e2d6; border-radius: 10px; padding: 6px 8px;
  background: #fff; color: var(--ink); font-size: 13px;
}
.course-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: linear-gradient(135deg, #fff1e6, #ffe4f0); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-weight: 600;
}
.chip small { color: var(--ink2); font-weight: 400; }

.hw-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 4px;
  border-bottom: 1px dashed #f3e6da;
}
.hw-item:last-child { border-bottom: 0; }
.hw-check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #e8d5c4;
  background: #fff; cursor: pointer; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff;
}
.hw-item.done .hw-check { background: var(--good); border-color: var(--good); }
.hw-item.checked .hw-check { background: linear-gradient(135deg, #fbbf24, #f59e0b); border-color: #fbbf24; }
.hw-body { flex: 1; min-width: 0; }
.hw-title { font-size: 15px; word-break: break-all; }
.hw-item.done .hw-title, .hw-item.checked .hw-title { color: var(--ink2); }
.hw-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f5f0ff; color: var(--accent2); font-weight: 600; }
.tag.warn { background: #ffe4e6; color: var(--bad); }
.tag.ok { background: #dcfce7; color: var(--good); }
.tag.star { background: #fef3c7; color: #b45309; }
.hw-ops { display: flex; gap: 4px; }
.hw-ops button {
  border: 0; background: #faf5ef; border-radius: 8px; padding: 5px 8px; cursor: pointer; font-size: 14px;
}
.hw-ops button:hover { background: #f3e7dc; }

.add-bar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-bar select, .add-bar input {
  border: 1.5px solid #f0e2d6; border-radius: 12px; padding: 9px 12px; font-size: 14px; background: #fff; color: var(--ink);
}
.add-bar input.content { flex: 1; min-width: 140px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 11px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: transform .12s, box-shadow .12s; color: #fff;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff6b6b); box-shadow: 0 6px 16px rgba(255, 138, 61, .35); }
.btn.violet { background: linear-gradient(135deg, var(--accent2), #a78bfa); box-shadow: 0 6px 16px rgba(124, 92, 255, .3); }
.btn.ghost { background: #fff; color: var(--accent); border: 1.5px solid #ffd9bd; box-shadow: none; }
.btn.block { display: block; width: 100%; }
.btn.big { font-size: 17px; padding: 14px 22px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.radio-btn {
  background: linear-gradient(135deg, #7c5cff, #ff6b9d); color: #fff; border: 0;
  border-radius: 20px; padding: 16px; width: 100%; font-size: 17px; font-weight: 800;
  cursor: pointer; box-shadow: 0 8px 22px rgba(124, 92, 255, .35);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.radio-btn:active { transform: scale(.97); }

audio { width: 100%; margin-top: 10px; border-radius: 12px; }
.script-box {
  background: #faf7ff; border-radius: 12px; padding: 12px; margin-top: 10px;
  font-size: 13.5px; line-height: 1.9; white-space: pre-wrap; color: #5b4a66;
  max-height: 260px; overflow-y: auto;
}

/* ---------- 课表 ---------- */
.schedule-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.schedule {
  border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13px;
}
.schedule th { padding: 8px 4px; color: var(--ink2); font-size: 12px; }
.schedule th.today-col { color: var(--accent); }
.schedule td { padding: 3px; }
.scell { display: flex; flex-direction: column; gap: 3px; }
.scell input {
  width: 100%; border: 1.5px solid #f0e2d6; border-radius: 9px; padding: 7px 4px;
  text-align: center; font-size: 13px; background: #fff; color: var(--ink); min-width: 62px;
}
.scell input.teacher { font-size: 11px; color: var(--ink2); padding: 4px; }
.scell input.has {
  background: linear-gradient(135deg, #fff3e8, #ffe9f3); border-color: #ffd9c0; font-weight: 700; color: #c2410c;
}
.pd { text-align: center; color: #c4a68f; font-weight: 800; font-size: 12px; width: 34px; }

/* ---------- 成长 ---------- */
.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1; background: var(--card); border-radius: var(--radius); padding: 14px 8px;
  text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 800; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .lbl { font-size: 12px; color: var(--ink2); margin-top: 2px; }
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge {
  text-align: center; padding: 10px 4px; border-radius: 14px; background: #fff;
  border: 1.5px solid #f3e6da;
}
.badge .ico { font-size: 28px; filter: grayscale(1); opacity: .35; }
.badge .nm { font-size: 11px; color: var(--ink2); margin-top: 4px; }
.badge.got { border-color: #fbbf24; background: linear-gradient(160deg, #fffbeb, #fef3c7); }
.badge.got .ico { filter: none; opacity: 1; }
.badge.got .nm { color: #92400e; font-weight: 700; }

.history-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed #f3e6da; }
.history-item:last-child { border-bottom: 0; }
.history-item .dt { font-size: 13px; color: var(--ink2); width: 86px; flex-shrink: 0; }
.history-item .pv { color: var(--ink2); font-size: 13px; flex: 1; }
.history-item a { color: var(--accent2); text-decoration: none; font-size: 13px; }

/* ---------- 转盘 ---------- */
.wheel-box { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
#wheelCanvas { max-width: 100%; }
.wheel-status { margin: 14px 0 4px; text-align: center; }

/* ---------- 设置 ---------- */
.form-row { margin: 12px 0; }
.form-row label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #6b5550; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; border: 1.5px solid #f0e2d6; border-radius: 12px; padding: 10px 12px;
  font-size: 14px; background: #fff; color: var(--ink); font-family: inherit;
}
.form-row textarea { min-height: 110px; line-height: 1.8; }
.form-row .hint { font-size: 12px; color: var(--ink2); margin-top: 4px; line-height: 1.6; }
.form-row .hint a { color: var(--accent2); }
.inline { display: flex; gap: 8px; }
.inline .btn { flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
#modalRoot .mask {
  position: fixed; inset: 0; background: rgba(60, 40, 30, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s;
}
#modalRoot .sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 86vh; overflow-y: auto;
  animation: up .22s;
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet h3 { margin: 2px 0 12px; display: flex; align-items: center; }
.sheet h3 .close { margin-left: auto; border: 0; background: #f5efe9; border-radius: 50%; width: 30px; height: 30px; font-size: 14px; cursor: pointer; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.photo-grid .ph { position: relative; }
.photo-grid img { width: 100%; height: 92px; object-fit: cover; border-radius: 10px; display: block; }
.photo-grid .del {
  position: absolute; top: -6px; right: -6px; background: var(--bad); color: #fff;
  border: 0; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer;
}
.upload-btn {
  border: 1.5px dashed #d9c3ac; border-radius: 10px; height: 92px; display: flex;
  align-items: center; justify-content: center; color: var(--ink2); font-size: 22px; cursor: pointer; background: #fffdf9;
}
.mistake-row { background: #fff7f7; border: 1px solid #ffe0e3; border-radius: 12px; padding: 10px; margin: 8px 0; }
.mistake-row input, .mistake-row textarea {
  width: 100%; border: 1px solid #ffdfe3; border-radius: 8px; padding: 7px 9px; font-size: 13px; margin: 3px 0; font-family: inherit;
}
.mistake-row textarea { min-height: 54px; }
.ai-result { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 12px; margin: 10px 0; line-height: 1.7; font-size: 14px; }
.ai-result .score { font-size: 22px; font-weight: 800; color: var(--good); }

/* ---------- toast / confetti / pin ---------- */
#toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(50, 35, 28, .9); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; z-index: 90; max-width: 80vw; text-align: center;
}
.hidden { display: none !important; }

.pin-gate {
  position: fixed; inset: 0; z-index: 100; background: linear-gradient(160deg, var(--bg1), var(--bg2));
  display: flex; align-items: center; justify-content: center; overflow-y: auto;
}
.pin-card { background: #fff; border-radius: 24px; padding: 34px 30px; text-align: center; box-shadow: var(--shadow); width: 320px; }
.pin-emoji { font-size: 44px; }
.pin-card h2 { font-size: 18px; margin: 10px 0 16px; }
.pin-card input {
  width: 100%; border: 1.5px solid #f0e2d6; border-radius: 12px; padding: 11px; font-size: 15px;
  margin-bottom: 10px; text-align: center;
}
.pin-tip { font-size: 12px; color: var(--ink2); margin: 10px 0 0; line-height: 1.6; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button {
  flex: 1; border: 1.5px solid #f0e2d6; background: #fff; border-radius: 10px;
  padding: 9px 0; font-size: 14px; color: var(--ink2); cursor: pointer;
}
.auth-tabs button.on { background: linear-gradient(135deg, var(--accent), #ff6b6b); color: #fff; border-color: transparent; font-weight: 700; }

.top-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
  background: #f5f0ff; color: var(--accent2); font-size: 12.5px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; max-width: 110px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed #f3e6da; }
.user-row:last-child { border-bottom: 0; }
.user-row .nm { font-weight: 700; font-size: 14px; flex: 1; }
.user-row .nm small { display: block; color: var(--ink2); font-weight: 400; font-size: 11.5px; margin-top: 2px; }
.user-row .del {
  border: 0; background: #ffe4e6; color: var(--bad); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.user-row .adm-tag { font-size: 11px; background: #fef3c7; color: #b45309; border-radius: 6px; padding: 2px 8px; }

.confetti {
  position: fixed; top: -12px; z-index: 95; width: 9px; height: 14px; border-radius: 3px;
  pointer-events: none; animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .4; } }

.empty { text-align: center; color: var(--ink2); padding: 18px 0; font-size: 13.5px; }
.welcome-hero {
  background: linear-gradient(135deg, #7c5cff12, #ff8a3d12); border-radius: var(--radius);
  padding: 4px;
}
