/* ==========================================================================
   Canvas Lite · 样式
   移动优先，浅色 / 深色跟随系统或手动切换
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --bg-glow: rgba(99, 102, 241, 0.1);
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9ecf5;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --border: #e5e8f0;
  --border-strong: #d5dae6;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --ok: #047857;
  --ok-soft: #e7f7f0;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #c2410c;
  --danger-soft: #fdeee8;
  --info: #0369a1;
  --info-soft: #e6f4fb;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 10px 30px -18px rgba(16, 24, 40, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 680px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0e17;
  --bg-glow: rgba(129, 140, 248, 0.12);
  --surface: #121926;
  --surface-2: #1a2333;
  --surface-3: #223048;
  --text: #e9edf5;
  --text-2: #cbd3e1;
  --muted: #93a0b5;
  --border: #222c3d;
  --border-strong: #303c52;
  --accent: #8b93fb;
  --accent-2: #b28dfb;
  --accent-soft: #1c2340;
  --on-accent: #0b1020;
  --ok: #4ade80;
  --ok-soft: #12291f;
  --warn: #fbbf24;
  --warn-soft: #2a2113;
  --danger: #fb923c;
  --danger-soft: #2c1a14;
  --info: #38bdf8;
  --info-soft: #0f2434;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

body.has-tabbar { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

.ico {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  display: inline-block;
  vertical-align: -0.18em;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--surface);
  padding: 10px 14px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
  outline: none;
}

.page {
  padding: calc(14px + env(safe-area-inset-top)) 0 8px;
  animation: fade-up 0.28s ease both;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.text-danger { color: var(--danger); }

/* ---------------------------------------------------------------- 通用块 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.list { overflow: hidden; }

.stack { display: flex; flex-direction: column; gap: 10px; }

.section { margin-top: 22px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-head h2 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.section-link {
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.section-link .ico { width: 14px; height: 14px; }

.section-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
}

.page-foot {
  margin: 26px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.9;
}

.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}
.empty-icon .ico { width: 22px; height: 22px; }
.empty-title { color: var(--text); font-weight: 600; font-size: 15px; }
.empty-hint { font-size: 13px; margin-top: 4px; }
.empty-inline { padding: 18px; text-align: center; color: var(--muted); font-size: 13.5px; }

.note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  border: 1px solid transparent;
}
.note .ico { width: 16px; height: 16px; margin-top: 2px; }
.note-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.note-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }

.error-box {
  text-align: center;
  padding: 30px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-top: 18px;
  background: var(--surface);
}
.error-icon { color: var(--danger); margin-bottom: 8px; }
.error-icon .ico { width: 30px; height: 30px; }
.error-title { font-weight: 600; }
.error-hint { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: left; }
.error-box .btn { margin-top: 16px; }

/* ---------------------------------------------------------------- 行 / 列表 */

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  min-height: 62px;
  position: relative;
  transition: background 0.15s ease;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row:active { background: var(--surface-2); }

.row-dot {
  width: 4px;
  height: 34px;
  border-radius: 4px;
  background: var(--accent);
  flex: none;
  opacity: 0.9;
}

.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title {
  font-size: 14.5px;
  font-weight: 550;
  letter-spacing: -0.005em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.row-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 4px; align-items: center; }
.row-icon { color: var(--muted); display: grid; place-items: center; }
.row-arrow { color: var(--muted); width: 16px; height: 16px; }
.list-row .row-icon .ico { width: 18px; height: 18px; }

.due { font-weight: 500; }
.due-normal { color: var(--muted); }
.due-warn { color: var(--warn); }
.due-danger { color: var(--danger); }
.due-muted { color: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip-muted { background: var(--surface-2); color: var(--muted); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 按钮 / 表单 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--accent) 70%, transparent);
}
[data-theme="dark"] .btn-primary { color: #0b1020; }
.btn-ghost { background: transparent; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.btn[disabled] { opacity: 0.65; pointer-events: none; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .ico { width: 19px; height: 19px; }
.icon-btn-light { color: rgba(255, 255, 255, 0.92); background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(6px); }
.icon-btn-light:hover { background: rgba(255, 255, 255, 0.24); }

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input::placeholder { color: var(--muted); opacity: 0.75; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 46px; }
.input-eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 顶部 */

.home-hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 20px 18px 16px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5 0%, #6d4bf0 45%, #a855f7 100%);
  box-shadow: 0 18px 40px -24px rgba(79, 70, 229, 0.8);
}
.home-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  pointer-events: none;
}
[data-theme="dark"] .home-hero {
  background: linear-gradient(135deg, #3730a3, #5b21b6 55%, #7e22ce);
}

.home-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.hero-greeting { font-size: 13px; opacity: 0.8; }
.hero-name { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.hero-sub { font-size: 12.5px; opacity: 0.78; margin-top: 4px; }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.45);
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-weight: 700;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.hero-stat { display: flex; flex-direction: column; gap: 1px; }
.hero-stat b { font-size: 19px; font-weight: 700; line-height: 1.15; }
.hero-stat span { font-size: 11.5px; opacity: 0.8; }


.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 12px;
}
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.page-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- 首页课程卡 */

.course-scroller {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  margin: 0 -2px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.course-scroller::-webkit-scrollbar { display: none; }

.course-card {
  position: relative;
  flex: none;
  width: 168px;
  scroll-snap-align: start;
  border-radius: 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 108px;
  overflow: hidden;
}
.course-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--c, var(--accent));
}
.course-card-code {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--c, var(--accent));
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.course-card-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 36px;
}
.course-card-foot { margin-top: auto; display: flex; align-items: baseline; gap: 5px; font-size: 11.5px; color: var(--muted); }
.course-card-foot b { font-size: 16px; color: var(--text); }

/* ---------------------------------------------------------------- 搜索 / 分段 */

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 12px;
  height: 44px;
  margin-bottom: 12px;
  color: var(--muted);
}
.search-box .ico { width: 17px; height: 17px; }
.search-box input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  min-width: 0;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.segmented a {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented a.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented.sticky {
  position: sticky;
  top: 0;
  z-index: 12;
  margin: 0 0 14px;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-radius: 0;
  padding: 8px 0;
}

/* ---------------------------------------------------------------- 课程列表 */

.course-row .course-badge {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--c, var(--accent));
  overflow: hidden;
}

.grade-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}
.grade-pill small { font-size: 11px; color: var(--muted); font-weight: 500; }

.grade-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.grade-summary.single { margin-bottom: 12px; }
.big-score { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 2px; }
.big-score small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.grade-legend { font-size: 12px; color: var(--muted); }

.grade-list { padding: 4px 0; }
.grade-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; }
.grade-row + .grade-row { border-top: 1px solid var(--border); }
.grade-row:active { background: var(--surface-2); }
.grade-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.grade-row-head .row-title { font-size: 14px; }
.grade-num { font-size: 13.5px; font-weight: 650; white-space: nowrap; }
.grade-num small { font-weight: 400; color: var(--muted); font-size: 11.5px; }

.progress {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }

/* ---------------------------------------------------------------- 课程详情 */

.course-hero {
  border-radius: 26px;
  padding: 14px 18px 18px;
  color: #fff;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(135deg, var(--c, #4f46e5), color-mix(in srgb, var(--c, #4f46e5) 55%, #111827));
  box-shadow: 0 20px 40px -26px color-mix(in srgb, var(--c, #4f46e5) 80%, transparent);
}
.course-hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-nav { display: flex; gap: 6px; }
.course-hero-code { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.82; margin-top: 12px; font-weight: 600; }
.course-hero h1 { font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.course-hero-meta { font-size: 12.5px; opacity: 0.82; margin-top: 6px; }
.course-hero-grade {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
}
.course-hero-grade b { font-size: 17px; }
.course-hero-grade span { font-size: 11.5px; opacity: 0.85; }

.course-body { min-height: 200px; }

/* ---------------------------------------------------------------- 作业详情 */

.subpage-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.subpage-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subpage-spacer { flex: 1; }

.detail-title { padding: 4px 2px 16px; }
.detail-course { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.detail-title h1 { font-size: 23px; line-height: 1.3; font-weight: 700; letter-spacing: -0.02em; margin: 10px 0 6px; }
.detail-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.detail-meta .ico { width: 15px; height: 15px; }

.attach-list { margin-bottom: 14px; }

.detail-desc { padding: 16px; margin-bottom: 16px; }

.rich-text { font-size: 14.5px; line-height: 1.68; color: var(--text-2); overflow-wrap: anywhere; }
.rich-text > *:first-child { margin-top: 0; }
.rich-text > *:last-child { margin-bottom: 0; }
.rich-text p { margin: 0 0 0.7em; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4 { color: var(--text); line-height: 1.35; margin: 1.1em 0 0.5em; font-weight: 650; }
.rich-text h1 { font-size: 20px; }
.rich-text h2 { font-size: 18px; }
.rich-text h3 { font-size: 16px; }
.rich-text h4 { font-size: 15px; }
.rich-text ul, .rich-text ol { padding-left: 1.3em; margin: 0 0 0.8em; }
.rich-text li { margin: 0.2em 0; }
.rich-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.rich-text img { border-radius: 10px; height: auto; }
.rich-text blockquote {
  margin: 0.8em 0;
  padding: 6px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.rich-text pre, .rich-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--surface-2);
  border-radius: 6px;
}
.rich-text pre { padding: 12px; overflow-x: auto; }
.rich-text code { padding: 1px 5px; }
.rich-text pre code { padding: 0; background: none; }
.rich-text table { border-collapse: collapse; margin: 0.8em 0; width: 100%; font-size: 13.5px; }
.rich-text th, .rich-text td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.rich-text th { background: var(--surface-2); }
.rich-text hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }

/* ---------------------------------------------------------------- 公告 / 模块 */

.announcement { padding: 0 14px; }
.announcement summary, .module summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.announcement summary::-webkit-details-marker, .module summary::-webkit-details-marker { display: none; }
.ann-title { font-size: 14.5px; font-weight: 600; padding-right: 20px; }
.ann-meta { font-size: 12px; color: var(--muted); }
.announcement summary::after, .module summary::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s ease;
}
.announcement[open] summary::after, .module[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.ann-body { padding: 4px 0 12px; border-top: 1px solid var(--border); margin-top: 2px; padding-top: 12px; }
.inline-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--accent);
  padding-bottom: 14px;
}
.inline-link .ico { width: 13px; height: 13px; }

.module { padding: 0 14px; }
.module.module-focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.module summary { flex-direction: row; align-items: center; gap: 8px; }
.module-name { font-size: 14.5px; font-weight: 600; flex: 1; padding-right: 14px; }
.module-count { font-size: 11.5px; color: var(--muted); }
.module-items { border-top: 1px solid var(--border); padding: 4px 0 8px; }
.module-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 2px;
  font-size: 13.5px;
  color: var(--text-2);
}
.module-item + .module-item { border-top: 1px solid var(--border); }
.module-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.module-file .module-item-title { max-width: 100%; }
.module-file .row-icon { flex: none; color: var(--muted); }
.module-file {
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.module-file:active { background: var(--surface-2); }
.module-file:disabled { opacity: 0.6; }
.module-item-type {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 6px;
  flex: none;
}

/* ---------------------------------------------------------------- 我的 */

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
}
.profile-card .avatar { width: 60px; height: 60px; background: var(--surface-2); border-color: var(--border); }
.profile-card .avatar-fallback { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.profile-main { min-width: 0; }
.profile-name { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.profile-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  min-height: 52px;
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
}
.setting-row + .setting-row, .setting-row + .help-row, .help-row + .setting-row, .help-row + .help-row { border-top: 1px solid var(--border); }
.setting-row.as-button { cursor: pointer; }
.setting-row.as-button:active { background: var(--surface-2); }
.setting-label { font-size: 14px; }
.setting-value { font-size: 12.5px; color: var(--muted); max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.setting-value .ico { width: 15px; height: 15px; }

.mini-seg { display: flex; gap: 3px; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.mini-seg-btn {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
}
.mini-seg-btn .ico { width: 14px; height: 14px; }
.mini-seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.help-row summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.help-row summary::-webkit-details-marker { display: none; }
.help-row summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg);
  flex: none;
  transition: transform 0.2s ease;
}
.help-row[open] summary::after { transform: rotate(-135deg); }
.help-body { padding: 0 14px 14px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.help-body p + p { margin-top: 8px; }
.help-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* ---------------------------------------------------------------- 设置页 */

.setup-page { padding-top: calc(26px + env(safe-area-inset-top)); }
.setup-brand { text-align: center; margin-bottom: 22px; }
.setup-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  box-shadow: 0 16px 32px -16px rgba(79, 70, 229, 0.75);
}
.setup-logo .ico { width: 30px; height: 30px; }
.setup-brand h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.03em; }
.setup-brand p { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

.form-card { padding: 18px 16px 16px; }
.advanced { margin: 2px 0 16px; }
.advanced summary { font-size: 12.5px; color: var(--muted); cursor: pointer; padding: 4px 0; }
.advanced-body { padding-top: 8px; }

.help-card { margin-top: 16px; padding: 14px 16px; }
.help-card summary { font-size: 13.5px; font-weight: 550; cursor: pointer; }
.steps { margin: 10px 0 0; padding-left: 1.2em; font-size: 13px; color: var(--muted); line-height: 1.7; }
.steps b { color: var(--text-2); }
.steps code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.setup-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 20px; opacity: 0.85; }

/* ---------------------------------------------------------------- 底栏 / toast */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 0 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.15s ease;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active svg { fill: color-mix(in srgb, var(--accent) 12%, transparent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 13px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}
[data-theme="dark"] .toast { background: rgba(240, 244, 255, 0.95); color: #0b1020; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: rgba(4, 120, 87, 0.95); color: #fff; }
.toast-danger { background: rgba(185, 28, 28, 0.95); color: #fff; }
[data-theme="dark"] .toast-ok, [data-theme="dark"] .toast-danger { color: #fff; }

/* ---------------------------------------------------------------- 骨架 */

.sk {
  border-radius: 10px;
  background: linear-gradient(100deg, var(--surface-3) 20%, var(--border-strong) 38%, var(--surface-3) 56%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.loading-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 12px 0 2px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-hero { height: 168px; border-radius: 26px; }
.sk-card { height: 64px; margin-top: 10px; }
.sk-line { height: 12px; margin: 10px 0; }
.sk-title { height: 26px; width: 70%; margin: 16px 0 12px; }

.is-offline .page-foot::after { content: " · 离线"; }

@media (min-width: 720px) {
  body { font-size: 15.5px; }
  .page { padding-top: 22px; }
  .tabbar { border-radius: 22px 22px 0 0; }
}

/* ---------------------------------------------------------------- 补充：首页顶栏 / 行内截断 */

.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 10px;
}
.brand-mark {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.row-course {
  max-width: 64%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dot-sep { opacity: 0.55; }
.setup-logo svg { width: 34px; height: 34px; }
