/* =============================================
   设计系统 · Design Tokens
   ============================================= */
:root {
  /* 暗色主题 */
  --bg: #0A0E1A;
  --bg-2: #0E1422;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ECEFF5;
  --text-2: #B8C0D1;
  --text-muted: #6B7589;
  --accent: #818CF8;
  --accent-2: #C084FC;
  --accent-grad: linear-gradient(135deg, #818CF8 0%, #C084FC 100%);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.48);
  --shadow-glow: 0 0 64px rgba(129, 140, 248, 0.18);
}

[data-theme="light"] {
  --bg: #F7F8FB;
  --bg-2: #FFFFFF;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-2: rgba(255, 255, 255, 0.92);
  --surface-3: rgba(245, 247, 252, 0.92);
  --border: rgba(15, 23, 42, 0.06);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0F172A;
  --text-2: #475569;
  --text-muted: #94A3B8;
  --accent: #6366F1;
  --accent-2: #8B5CF6;
  --accent-grad: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.10);
  --shadow-glow: 0 0 64px rgba(99, 102, 241, 0.16);
}

/* =============================================
   Reset & Base
   ============================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.5s ease, color 0.5s ease;
  line-height: 1.5;
}

/* =============================================
   背景装饰
   ============================================= */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  animation: float 20s ease-in-out infinite;
}

.bg-orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #6366F1 0%, transparent 70%);
  top: -200px;
  right: -100px;
}

.bg-orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #8B5CF6 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
  animation-delay: -7s;
}

.bg-orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #EC4899 0%, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
  opacity: 0.3;
}

[data-theme="light"] .bg-orb {
  opacity: 0.35;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 80%);
}

[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.05); }
  66% { transform: translate(-30px, 40px) scale(0.95); }
}

/* =============================================
   Layout
   ============================================= */
.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

@media (max-width: 720px) {
  .app { padding: 20px 16px 48px; }
}

/* =============================================
   顶部栏
   ============================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  animation: slideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  position: relative;
}

.brand-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.time-display {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.clock {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.date-info {
  text-align: right;
  font-size: 12px;
  color: var(--text-2);
}

.weekday {
  font-weight: 600;
  color: var(--text);
}

.date {
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.theme-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 16px; }
  .header-right { width: 100%; justify-content: space-between; }
  .clock { font-size: 18px; }
  .date-info { font-size: 11px; }
}

/* =============================================
   下一节课卡片
   ============================================= */
.next-card {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 28px 32px;
  margin-bottom: 24px;
  overflow: hidden;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-glow {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  background: var(--accent-grad);
  opacity: 0.18;
  filter: blur(80px);
  pointer-events: none;
}

.next-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  position: relative;
}

.next-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.countdown {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.countdown-num {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 6px;
  min-width: 32px;
  text-align: center;
}

.countdown-unit {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}

.next-body {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

.next-empty {
  color: var(--text-muted);
  font-size: 15px;
  padding: 8px 0;
}

.next-bar {
  width: 4px;
  height: 64px;
  border-radius: 4px;
  background: var(--course-color, var(--accent));
  box-shadow: 0 0 16px var(--course-color, var(--accent));
}

.next-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.next-name {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.next-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: var(--text-2);
}

.next-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.next-meta-icon {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.next-time-block {
  text-align: right;
}

.next-time {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}

.next-day {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 720px) {
  .next-card { padding: 20px; }
  .next-body { grid-template-columns: auto 1fr; gap: 16px; }
  .next-time-block { grid-column: 1 / -1; text-align: left; padding-top: 12px; border-top: 1px solid var(--border); }
  .next-time { font-size: 22px; }
  .next-name { font-size: 20px; }
  .next-meta { font-size: 13px; gap: 12px; }
}

/* =============================================
   统计
   ============================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s ease;
}

.stat:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.stat-num {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-num { font-size: 22px; }
}

/* =============================================
   本周课表
   ============================================= */
.schedule-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.section-title-wrap { flex: 1; min-width: 0; }

.section-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 50%;
  justify-content: flex-end;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.legend-item:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.schedule-container {
  overflow-x: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 72px repeat(7, 1fr);
  /* 第 1 行是表头；2~13 行对应 12 个节次 */
  grid-template-rows: 36px repeat(12, minmax(72px, auto));
  min-width: 880px;
  gap: 4px;
}

.grid-corner {
  background: transparent;
}

.grid-header {
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.grid-header.today {
  color: var(--accent);
}

.grid-header.today::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.grid-period {
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--border);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.grid-period-num {
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
}

.grid-period-time {
  font-size: 10px;
  opacity: 0.7;
}

.grid-cell {
  min-height: 76px;
  border-radius: 8px;
  padding: 6px;
  background: var(--surface-3);
  border: 1px solid transparent;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.grid-cell:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.grid-cell.is-today {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.06) 0%, rgba(129, 140, 248, 0.02) 100%);
}

.grid-cell.is-now {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.12) 0%, rgba(192, 132, 252, 0.06) 100%);
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(129, 140, 248, 0.25);
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 24px rgba(129, 140, 248, 0.25); }
  50% { box-shadow: 0 0 32px rgba(129, 140, 248, 0.4); }
}

.grid-cell.is-past {
  opacity: 0.45;
}

.course-chip {
  height: 100%;
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--course-color);
  color: white;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
}

.course-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, transparent 50%);
  pointer-events: none;
}

.course-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.course-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  position: relative;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-loc {
  font-size: 10px;
  opacity: 0.9;
  font-weight: 500;
  margin-top: auto;
  position: relative;
}

.course-week-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 720px) {
  .schedule-section { padding: 16px; border-radius: 18px; }
  .legend { max-width: 100%; }
}

/* =============================================
   Footer
   ============================================= */
.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-dot { opacity: 0.4; }