/* ========== 基础 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fa;
  color: #333;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== 顶部栏 ========== */
.app-header {
  height: 48px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  z-index: 10;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 600;
  color: #333;
}
.icon-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 20px;
  color: #666;
  padding: 4px 8px;
  cursor: pointer;
}

/* ========== 日期标签行 ========== */
.date-bar {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  background: #fff;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  text-align: center;
  padding: 6px 0;
}
.date-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: #999;
}
.date-cell .weekday { font-weight: 500; }
.date-cell .date-num { font-size: 11px; }
.date-cell.active {
  color: #2d8cf0;
}
.date-cell.active .weekday {
  font-weight: 700;
}
.date-cell.today .date-num {
  background: #2d8cf0;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.date-bar .corner {
  /* 左上角空白 */
}

/* ========== 课表主体 ========== */
.schedule-wrapper {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}
.schedule-grid {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  grid-template-rows: repeat(14, 52px);
  min-height: 728px; /* 14 * 52 */
}

/* 小节标签列 */
.jie-label {
  grid-column: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-size: 11px;
  color: #bbb;
  padding-top: 4px;
  border-right: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
}

/* 网格单元格 */
.grid-cell {
  border-right: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.grid-cell.has-card {
  z-index: 3;
}

/* 课程卡片 */
.course-card {
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 2;
}
.course-card:active {
  transform: scale(0.98);
}
.course-name {
  font-weight: 600;
  font-size: 12px;
  color: rgba(0,0,0,0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.course-location {
  font-size: 10px;
  color: rgba(0,0,0,0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.course-teacher {
  font-size: 10px;
  color: rgba(0,0,0,0.45);
}

/* 课程颜色 */
.c0 { background: #ffe4e1; border-left: 3px solid #ff6b6b; }
.c1 { background: #e0f7fa; border-left: 3px solid #4ecdc4; }
.c2 { background: #fff3e0; border-left: 3px solid #ffa726; }
.c3 { background: #f3e5f5; border-left: 3px solid #ab47bc; }
.c4 { background: #e8f5e9; border-left: 3px solid #66bb6a; }
.c5 { background: #e3f2fd; border-left: 3px solid #42a5f5; }
.c6 { background: #fce4ec; border-left: 3px solid #ec407a; }
.c7 { background: #e0f2f1; border-left: 3px solid #26a69a; }
.c8 { background: #f1f8e9; border-left: 3px solid #8bc34a; }
.c9 { background: #fff8e1; border-left: 3px solid #ffca28; }

/* ========== 底部导航 ========== */
.bottom-bar {
  height: 52px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  padding: 0 12px;
  gap: 8px;
  z-index: 10;
}
.today-label {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  min-width: 60px;
}
.nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:active { background: #e0e0e0; }
.week-label {
  font-size: 13px;
  color: #666;
  background: #f5f6fa;
  padding: 6px 14px;
  border-radius: 16px;
  white-space: nowrap;
}
.view-btn {
  width: 40px;
  height: 32px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
}
.view-btn.active {
  background: #2d8cf0;
  color: #fff;
  border-color: #2d8cf0;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #333;
}
.modal-card p {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.5;
}
.modal-card p strong {
  color: #333;
  font-weight: 600;
}
.btn-primary {
  width: 100%;
  height: 44px;
  margin-top: 16px;
  background: #2d8cf0;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { background: #1a7de0; }
.btn-secondary {
  width: 100%;
  height: 44px;
  margin-top: 8px;
  background: #f0f0f0;
  color: #666;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:active { background: #e0e0e0; }
.date-input {
  width: 100%;
  height: 44px;
  margin: 12px 0;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}

/* ========== 菜单面板 ========== */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}
.menu-overlay[hidden] { display: none; }
.menu-panel {
  background: #fff;
  width: 260px;
  height: 100%;
  padding: 24px 16px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-panel h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #333;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: #f8f9fa;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.menu-item:active { background: #e8e9ea; }
.menu-icon { font-size: 18px; }

/* ========== 考试表格 ========== */
.exam-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.exam-table th {
  background: #f5f6fa;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #e0e0e0;
}
.exam-table td {
  padding: 12px 8px;
  border-bottom: 1px solid #f0f0f0;
  color: #555;
  line-height: 1.4;
}
.exam-table tr:last-child td {
  border-bottom: none;
}
.exam-table tr:active {
  background: #f8f9fa;
}
.day-view {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}
.day-view.active { display: flex; }
.day-course-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.day-time-tag {
  background: #f0f0f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
}
.day-info { flex: 1; }
.day-course-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}
.day-course-meta {
  font-size: 12px;
  color: #999;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #bbb;
  font-size: 14px;
}
