/* ===========================================================================
   课程表 — 设计系统
   手机优先。所有颜色走变量，深色模式只换变量，不改结构。
   =========================================================================== */

:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f6;
  --text: #101828;
  --text-2: #667085;
  --text-3: #98a2b3;
  --line: #e7eaf0;
  --line-strong: #d5dae3;

  --brand: #2563eb;
  --brand-ink: #ffffff;
  --brand-soft: #eff4ff;
  --brand-line: #c7d8ff;

  --warn: #f59e0b;
  --warn-soft: #fff7e6;
  --danger: #e5484d;
  --danger-soft: #fdeeee;
  --ok: #10a37f;
  --ok-soft: #e8f8f3;
  --violet: #7c5cff;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --surface: #151a23;
    --surface-2: #1b212c;
    --surface-3: #222a37;
    --text: #e9edf5;
    --text-2: #9aa4b2;
    --text-3: #6b7686;
    --line: #232a36;
    --line-strong: #2f3949;

    --brand: #4c8dff;
    --brand-soft: #17233a;
    --brand-line: #24365c;

    --warn-soft: #2e2411;
    --danger-soft: #2f1a1b;
    --ok-soft: #10261f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

/* 浏览器默认的 [hidden] { display: none } 只是个弱规则，
   任何写了 display 的类（.overlay / .sheet …）都会把它顶掉。
   项目里大量用 hidden 控制显隐，这里统一加 !important 兜住。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }

/* ---------------------------------------------------------------- 布局 */

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.page {
  flex: 1;
  padding: 0 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  animation: page-in 0.22s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .page { animation: none; }
  * { transition: none !important; }
}

/* ---------------------------------------------------------------- 启动 */

.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-3);
  min-height: 70vh;
}

.boot-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 头部 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.topbar .sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: 0.15s;
}

.icon-btn:active { transform: scale(0.94); background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------------------------------------------------------------- 卡片 */

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

.card + .card { margin-top: 12px; }

.card-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.section-label {
  margin: 22px 4px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- 下一节课 */

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(135deg, #3b6ff5 0%, #2a54d6 55%, #6b46e5 100%);
  box-shadow: 0 10px 28px rgba(42, 84, 214, 0.28);
}

.hero.is-idle {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  box-shadow: 0 10px 28px rgba(55, 65, 81, 0.22);
}

.hero::after {
  content: "";
  position: absolute;
  right: -50px;
  top: -60px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  position: relative;
  z-index: 1;
}

.hero-tag .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.25);
}

.hero-title {
  position: relative;
  z-index: 1;
  margin: 14px 0 2px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-meta {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 14px;
  opacity: 0.86;
}

.hero-foot {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  opacity: 0.9;
}

.hero-countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- 课表条目 */

.day-list { display: flex; flex-direction: column; gap: 8px; }

.day-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--line-strong);
}

.lesson {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: 0.15s;
  text-align: left;
  width: 100%;
}

.lesson:active { transform: scale(0.995); background: var(--surface-2); }

.lesson-time {
  flex: 0 0 52px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.lesson-time .start {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lesson-time .end {
  font-size: 11.5px;
  color: var(--text-3);
}

.lesson-time .sec {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}

.lesson-body { flex: 1; min-width: 0; }

.lesson-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lesson-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-bar {
  flex: 0 0 3px;
  border-radius: 3px;
  background: var(--brand);
  opacity: 0.9;
}

.lesson.is-now {
  border-color: var(--brand-line);
  background: var(--brand-soft);
}

.lesson.is-now .lesson-bar { background: var(--brand); }

.lesson.is-past { opacity: 0.55; }

/* 状态徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-moved-in { background: var(--warn-soft); color: #a86100; }
.badge-moved-out { background: var(--surface-3); color: var(--text-3); }
.badge-substitute { background: #f3efff; color: #5b3fd6; }
.badge-suspended { background: var(--surface-3); color: var(--text-3); }
.badge-event { background: #f3efff; color: #5b3fd6; }

@media (prefers-color-scheme: dark) {
  .badge-moved-in { color: #f3c66b; }
  .badge-substitute, .badge-event { background: #241c42; color: #b6a6ff; }
}

.lesson.is-moved-out .lesson-title { text-decoration: line-through; color: var(--text-3); }
.lesson.is-suspended .lesson-title { text-decoration: line-through; color: var(--text-3); }

/* ---------------------------------------------------------------- 提示条 */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.banner svg { flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px; }
.banner-holiday { background: var(--ok-soft); color: #0a6b52; }
.banner-makeup { background: var(--warn-soft); color: #96600a; }
.banner-suspended { background: var(--danger-soft); color: #a3282c; }
.banner-info { background: var(--brand-soft); color: #1d4ed8; }

@media (prefers-color-scheme: dark) {
  .banner-holiday { color: #6ee7b7; }
  .banner-makeup { color: #f3c66b; }
  .banner-suspended { color: #ff9a9d; }
  .banner-info { color: #8bb4ff; }
}

/* ---------------------------------------------------------------- 周视图 */

.week-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 14px;
}

.week-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.week-title small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
  margin-top: 1px;
}

.day-block + .day-block { margin-top: 18px; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px 8px;
}

.day-head .wd {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.day-head .dt {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.day-head.is-today .wd { color: var(--brand); }
.day-head.is-today::after {
  content: "今天";
  font-size: 10.5px;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--brand);
  padding: 1px 6px;
  border-radius: 5px;
  margin-left: 2px;
}

/* ---------------------------------------------------------------- 表单 */

.field { margin-bottom: 14px; }

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input, .select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: 0.15s;
  appearance: none;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
}

.input:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.input::placeholder { color: var(--text-3); }

.input-sm { height: 38px; font-size: 14px; }

.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

.hint.is-error { color: var(--danger); }

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost:hover { background: var(--surface-2); }

.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: 9px; }

.btn svg { width: 17px; height: 17px; }

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

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  width: 100%;
}

.row:last-child { border-bottom: none; }

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 550; }
.row-sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.row-tail { color: var(--text-3); font-size: 13px; flex: 0 0 auto; }
.row-chevron { color: var(--text-3); flex: 0 0 auto; }
.row-chevron svg { width: 18px; height: 18px; display: block; }

/* ---------------------------------------------------------------- 标签栏 */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  z-index: 40;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text-3);
  transition: color 0.15s;
}

.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--brand); }
.tab:active { opacity: 0.7; }

/* ---------------------------------------------------------------- 空状态 */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}

.empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-3);
}

.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; font-weight: 650; color: var(--text); }
.empty p { margin: 0 0 18px; font-size: 13.5px; line-height: 1.6; }

/* ---------------------------------------------------------------- 登录 */

.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-b));
  max-width: 460px;
  margin: 0 auto;
}

.auth-logo {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  background: linear-gradient(135deg, #3b6ff5, #6b46e5);
  display: grid;
  place-items: center;
  color: #fff;
  margin-bottom: 22px;
  box-shadow: 0 10px 24px rgba(59, 111, 245, 0.3);
}

.auth-logo svg { width: 30px; height: 30px; }

.auth h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth .lead {
  margin: 0 0 28px;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.6;
}

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-2);
}

.auth-switch button {
  color: var(--brand);
  font-weight: 600;
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- 设置分组 */

.group {
  margin-top: 20px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 9px;
}

.group-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.group-head button {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

/* ---------------------------------------------------------------- Toast */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  width: max-content;
  max-width: min(88vw, 440px);
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  background: #1d2433;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  text-align: center;
}

.toast.is-error { background: var(--danger); }
.toast.is-ok { background: #10805f; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- 遮罩 / 弹层 */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.45);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
  max-height: 88dvh;
  overflow-y: auto;
  animation: sheet-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
  margin: -6px auto 14px;
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.sheet .sheet-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- 工具类 */

.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
.wrap-anywhere { overflow-wrap: anywhere; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
}

.chip-ok { background: var(--ok-soft); color: #0a6b52; border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: #96600a; border-color: transparent; }

.seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.seg button {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-2);
  transition: 0.15s;
}

.seg button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 650;
}

.color-dots { display: flex; gap: 10px; flex-wrap: wrap; }

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  transition: 0.15s;
}

.color-dot.is-active {
  border-color: var(--text);
  transform: scale(1.08);
}
