/* ================= 设计令牌 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #fafafc;
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --text-3: #c7c7cc;
  --line: rgba(60, 60, 67, .08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --shadow-md: 0 8px 28px rgba(10,132,255,.28);
  --header-bg: rgba(242,242,247,.82);
  --tabbar-bg: rgba(255,255,255,.82);
  --tabbar-h: calc(60px + env(safe-area-inset-bottom));
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --text: #f2f2f7;
    --text-2: #8e8e93;
    --text-3: #48484a;
    --line: rgba(84, 84, 88, .32);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --header-bg: rgba(0,0,0,.72);
    --tabbar-bg: rgba(22,22,24,.82);
  }
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ================= 背景：极光渐变（默认） ================= */
body::before {
  content: ''; position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 12% 8%,  rgba(94, 92, 230, .38), transparent 62%),
    radial-gradient(55% 45% at 88% 2%,  rgba(10, 132, 255, .34), transparent 62%),
    radial-gradient(50% 45% at 85% 88%, rgba(255, 45, 85, .2), transparent 62%),
    radial-gradient(55% 50% at 8% 92%,  rgba(52, 199, 89, .26), transparent 62%);
  animation: aurora 26s ease-in-out infinite alternate;
}
@keyframes aurora {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 1.5%, 0) scale(1.06); }
}
@media (prefers-color-scheme: dark) {
  body::before { opacity: .9; }
}

/* ================= 背景：自定义照片 ================= */
/* 照片放在 fixed 的 ::before 里（规避 iOS background-attachment:fixed 的兼容问题），叠加磨砂遮罩保证可读 */
body.has-photo::before {
  animation: none; inset: 0;
  background:
    linear-gradient(rgba(242, 242, 247, .72), rgba(242, 242, 247, .72)),
    var(--photo) center / cover no-repeat;
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
}
@media (prefers-color-scheme: dark) {
  body.has-photo::before {
    background:
      linear-gradient(rgba(0, 0, 0, .68), rgba(0, 0, 0, .68)),
      var(--photo) center / cover no-repeat;
    opacity: 1;
  }
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

#app { padding-bottom: var(--tabbar-h); }
.view { padding: 0 16px 24px; min-height: calc(100vh - var(--tabbar-h)); }
.view > * { animation: fadeUp .38s cubic-bezier(.22,.9,.3,1) backwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

/* ================= 大号标题头部（iOS 风格） ================= */
.page-header {
  position: sticky; top: 0; z-index: 10;
  margin: 0 -16px 14px;
  padding: calc(env(safe-area-inset-top) + 20px) 20px 12px;
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: .5px solid var(--line);
}
.ph-eyebrow {
  font-size: .76rem; font-weight: 600; letter-spacing: .04em;
  color: var(--text-2); margin-bottom: 3px;
}
.ph-title { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }

/* ================= 底部 Tab（毛玻璃） ================= */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: .5px solid var(--line);
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none;
  font-size: .64rem; font-weight: 500; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: color .2s;
}
.tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.tab.active { color: var(--primary); }
.tab.active svg { transform: scale(1.08); }
.tab:active svg { transform: scale(.88); }

/* ================= 今日页 · 下一节课 Hero 卡 ================= */
.next-card {
  position: relative; overflow: hidden;
  background: linear-gradient(140deg, #5e5ce6 0%, #0a84ff 100%);
  color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.next-card::after { /* 装饰光斑 */
  content: ''; position: absolute; right: -40px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 70%);
}
.nc-top { display: flex; justify-content: space-between; align-items: center; }
.nc-label { font-size: .76rem; font-weight: 600; letter-spacing: .06em; opacity: .85; text-transform: uppercase; }
.nc-slot { font-size: .72rem; font-weight: 600; background: rgba(255,255,255,.22); padding: 3px 10px; border-radius: 999px; }
.nc-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; margin: 10px 0 6px; }
.nc-meta { font-size: .86rem; opacity: .92; line-height: 1.7; }
.nc-countdown {
  margin-top: 14px; display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; font-weight: 600;
  background: rgba(255,255,255,.2); border: .5px solid rgba(255,255,255,.35);
  padding: 6px 14px; border-radius: 999px;
  backdrop-filter: blur(8px);
}
.next-card.none {
  background: var(--card); color: var(--text-2); box-shadow: var(--shadow-sm);
  border: none; text-align: center; padding: 30px 20px; font-size: .92rem;
}
.next-card.none::after { display: none; }

/* ================= 今日页 · 课程时间轴卡 ================= */
.section-title {
  font-size: .8rem; font-weight: 600; color: var(--text-2);
  margin: 20px 4px 10px; letter-spacing: .03em;
}

/* 可折叠的星期分组头 */
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 4px 10px; cursor: pointer; user-select: none;
  -webkit-user-select: none;
}
.day-head .t { font-size: .8rem; font-weight: 600; color: var(--text-2); letter-spacing: .03em; }
.day-head .today-tag {
  display: inline-block; margin-left: 8px; font-size: .64rem; font-weight: 600;
  color: var(--primary); background: rgba(0,122,255,.1);
  padding: 2px 8px; border-radius: 999px; vertical-align: 1px;
}
.day-chev {
  color: var(--text-3); font-weight: 600; font-size: .9rem;
  display: inline-block; transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.day-chev.open { transform: rotate(90deg); }
.course-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; gap: 13px; align-items: stretch;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, opacity .2s;
}
.course-card:active { transform: scale(.98); }
.course-card.past { opacity: .4; }
.cc-time {
  width: 52px; flex-shrink: 0; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.cc-time b { font-size: .86rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cc-time span { font-size: .72rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cc-bar { width: 4px; border-radius: 4px; flex-shrink: 0; }
.cc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.cc-name { font-weight: 600; font-size: .95rem; letter-spacing: -.01em; line-height: 1.4; }
.cc-detail { font-size: .78rem; color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.cc-chev { align-self: center; color: var(--text-3); font-size: 1.05rem; font-weight: 600; }

.badge { display: inline-block; font-size: .64rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1.5px; }
.badge.cancel { background: rgba(255,59,48,.12); color: var(--red); }
.badge.change { background: rgba(255,149,0,.14); color: #c93400; }
.badge.note { background: rgba(0,122,255,.1); color: var(--primary); }

.empty-tip { text-align: center; color: var(--text-2); padding: 36px 0; font-size: .88rem; }

.setup-banner {
  background: rgba(255,204,0,.14); border: .5px solid rgba(255,204,0,.4); color: #8a6100;
  border-radius: 14px; padding: 12px 14px; font-size: .82rem; margin-bottom: 14px; line-height: 1.65;
}
.setup-banner button {
  border: none; background: #ffcc00; color: #4d3800; font-weight: 600;
  border-radius: 999px; padding: 5px 14px; font-size: .78rem; margin-left: 6px;
}

/* ================= 课表页 ================= */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nav-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: var(--card); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); transition: transform .15s;
}
.nav-btn:active { transform: scale(.9); }
.nav-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.wn-center { text-align: center; }
.wn-week { font-weight: 700; font-size: 1.08rem; letter-spacing: -.01em; }
.wn-week .now { color: var(--primary); font-size: .72rem; font-weight: 600; margin-left: 4px; vertical-align: 1px; }
.wn-sub { font-size: .72rem; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.back-week {
  display: block; margin: -4px auto 12px; border: none;
  background: rgba(0,122,255,.1); color: var(--primary);
  font-size: .76rem; font-weight: 600; padding: 6px 16px; border-radius: 999px;
}

.grid { display: grid; grid-template-columns: 30px repeat(7, 1fr); gap: 4px; }
.grid .head {
  border-radius: 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 7px 1px; color: var(--text-2); line-height: 1.3;
}
.grid .head .gh-d { font-size: .6rem; font-weight: 500; }
.grid .head .gh-n { font-size: .78rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.grid .head.today-col { background: var(--primary); }
.grid .head.today-col .gh-d, .grid .head.today-col .gh-n { color: #fff; }
.grid .head.gh-corner .gh-d { font-size: .58rem; }
.grid .slot-head {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); line-height: 1.4; padding: 4px 0;
}
.grid .slot-head b { color: var(--text-2); font-size: .64rem; font-weight: 600; }
.grid .slot-head span { font-size: .56rem; font-variant-numeric: tabular-nums; }
.cell {
  background: var(--card); border-radius: 12px; min-height: 92px; padding: 3px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--shadow-sm);
}
.cell-course {
  border-radius: 9px; padding: 5px 3px; flex: 1;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  text-align: center; overflow: hidden; cursor: pointer;
  transition: transform .15s, filter .15s;
}
.cell-course:active { transform: scale(.94); filter: brightness(.95); }
.cell-course .n {
  font-weight: 600; font-size: .64rem; line-height: 1.32; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cell-course .r { font-size: .6rem; opacity: .8; font-weight: 500; font-variant-numeric: tabular-nums; }
.cell-course.canceled { opacity: .38; }
.cell-course.canceled .n { text-decoration: line-through; }
.cell-course .flag { font-size: .54rem; opacity: .75; }

.legend { margin-top: 14px; font-size: .72rem; color: var(--text-2); text-align: center; line-height: 1.6; }

/* ================= 我的页（iOS 分组列表） ================= */
.me-group {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.me-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: .5px solid var(--line);
  font-size: .9rem; gap: 10px; min-height: 48px;
}
.me-row:last-child { border-bottom: none; }
.me-row .k { color: var(--text); flex-shrink: 0; font-weight: 500; }
.me-row input[type="date"], .me-row input[type="text"], .me-row select {
  border: none; border-radius: 9px; padding: 7px 10px; font-size: .84rem;
  background: var(--card-2); color: var(--text); max-width: 168px; text-align: right;
  font-family: inherit; outline: none;
}

/* iOS 开关 */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; width: 50px; height: 30px; flex-shrink: 0;
  background: rgba(120,120,128,.24); border-radius: 999px;
  transition: background .28s; cursor: pointer;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.22);
  transition: transform .28s cubic-bezier(.34,1.3,.64,1);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

.course-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: .5px solid var(--line);
  font-size: .88rem; transition: background .15s;
}
.course-item:last-child { border-bottom: none; }
.course-item:active { background: var(--card-2); }
.course-item .sub { font-size: .71rem; color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.course-item .chev { color: var(--text-3); font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 4px; margin-right: 8px; vertical-align: 0; }

.btn-primary {
  display: block; width: 100%; border: none; background: var(--primary); color: #fff;
  border-radius: 16px; padding: 14px; font-size: .92rem; font-weight: 600; margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(0,122,255,.28);
  transition: transform .15s;
}
.btn-primary:active { transform: scale(.98); }
.btn-ghost {
  display: block; width: 100%; border: none; background: var(--card); color: var(--primary);
  border-radius: 16px; padding: 13px; font-size: .88rem; font-weight: 500; margin-bottom: 10px;
  box-shadow: var(--shadow-sm); transition: transform .15s;
}
.btn-ghost:active { transform: scale(.98); }
.btn-ghost.danger { color: var(--red); }

.btn-mini {
  border: none; background: rgba(0,122,255,.1); color: var(--primary);
  font-weight: 600; border-radius: 999px; padding: 7px 14px; font-size: .78rem;
  transition: transform .15s;
}
.btn-mini:active { transform: scale(.94); }
.btn-mini.gray { background: var(--card-2); color: var(--text-2); }

/* ================= 弹层（底部上滑卡片） ================= */
.sheet-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.32);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: maskIn .25s;
}
@keyframes maskIn { from { opacity: 0; } }
.sheet {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 88vh; overflow-y: auto;
  animation: sheetUp .32s cubic-bezier(.22,.9,.3,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: .4; } }
.grabber {
  width: 38px; height: 5px; border-radius: 999px;
  background: var(--text-3); margin: 4px auto 14px;
}
.sheet h3 { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 14px; }
.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: .76rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.form-row input, .form-row select {
  width: 100%; border: none; border-radius: 12px;
  padding: 12px 14px; font-size: .9rem; background: var(--card-2); color: var(--text);
  font-family: inherit; outline: none;
  transition: box-shadow .2s;
}
.form-row input:focus, .form-row select:focus { box-shadow: 0 0 0 2px rgba(0,122,255,.35); }
.form-row .hint { font-size: .68rem; color: var(--text-3); margin-top: 4px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 10px; }
.sheet .actions button {
  flex: 1; border-radius: 14px; padding: 13px; font-size: .9rem; border: none;
  font-weight: 600; transition: transform .15s;
}
.sheet .actions button:active { transform: scale(.96); }
.sheet .actions .cancel { background: var(--card-2); color: var(--text); }
.sheet .actions .ok { background: var(--primary); color: #fff; }
.sheet .actions .danger { background: rgba(255,59,48,.12); color: var(--red); }
.radio-row { display: flex; flex-direction: column; gap: 12px; font-size: .88rem; }
.radio-row label { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.radio-row input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }
.radio-row input[type="text"], .radio-row select {
  flex: 1; border: none; border-radius: 10px; padding: 8px 10px;
  font-size: .84rem; background: var(--card-2); color: var(--text); font-family: inherit; outline: none;
}
.detail-kv { font-size: .9rem; line-height: 2.1; margin-bottom: 10px; }
.detail-kv .k { color: var(--text-2); display: inline-block; width: 60px; font-size: .8rem; font-weight: 600; }
