* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: #f3f4f8;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: #1f2937;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

/* ========== 顶部标题栏 ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  margin: 0 -12px 16px;
  padding: 14px 16px 16px;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25);
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  flex: 0 0 40px;
}

.logo-text {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-meta {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.92;
}

/* ========== 卡片 ========== */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px 14px 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.05);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: #111827;
  position: relative;
}

.step-dot {
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 26px;
}

.title-icon {
  font-size: 20px;
}

.btn-back {
  margin-left: auto;
  border: none;
  background: #eef2ff;
  color: #4f46e5;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 32px;
}

.btn-back:active {
  background: #e0e7ff;
}

/* ========== 搜索 ========== */
.search-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  background: #f9fafb;
  transition: all 0.2s;
  min-height: 44px;
}

.search-input:focus {
  border-color: #6366f1;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* ========== 选择项网格 ========== */
.select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 2px;
}

.select-item {
  background: #f9fafb;
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 14px 10px;
  font-size: 14px;
  text-align: center;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: #374151;
  word-break: break-word;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  -webkit-user-select: none;
  user-select: none;
}

.select-item:active {
  transform: scale(0.96);
  background: #eef2ff;
}

.select-item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.select-item .badge {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.75;
  font-weight: 500;
}

/* ========== 周次切换 ========== */
.week-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  overflow: hidden;
}

.week-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  -webkit-user-select: none;
  user-select: none;
}

.week-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 8px rgba(99, 102, 241, 0.3);
}

.week-btn:active {
  transform: scale(0.96);
}

.week-scroll {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.week-scroll::-webkit-scrollbar {
  height: 3px;
}

.week-scroll::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.week-hint {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  margin-bottom: 10px;
}

/* ========== 课表 ========== */
.schedule {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  gap: 4px;
  font-size: 12px;
}

.schedule .head {
  text-align: center;
  font-weight: 700;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 8px 2px;
  font-size: 12px;
}

.schedule .head.empty {
  background: transparent;
}

.schedule .period-label {
  text-align: center;
  color: #9ca3af;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 11px;
  padding: 4px 2px;
  line-height: 1.25;
  min-height: 72px;
}

.course-cell {
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  color: #3730a3;
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 11px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s;
  word-break: break-word;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.course-cell:active {
  transform: scale(0.96);
}

.course-cell.color-0 { background: linear-gradient(135deg, #e0e7ff, #ede9fe); color: #3730a3; }
.course-cell.color-1 { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; }
.course-cell.color-2 { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }
.course-cell.color-3 { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.course-cell.color-4 { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #155e75; }
.course-cell.color-5 { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #9d174d; }
.course-cell.color-6 { background: linear-gradient(135deg, #e0f2fe, #bae6fd); color: #075985; }
.course-cell.color-7 { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); color: #6b21a8; }

.course-cell .cname {
  font-weight: 700;
  margin-bottom: 2px;
  font-size: 11.5px;
  line-height: 1.3;
}

.course-cell .cinfo {
  font-size: 10px;
  opacity: 0.85;
  line-height: 1.35;
}

/* 占位空单元格 */
.schedule .cell {
  min-height: 72px;
  background: #fafafa;
  border-radius: 8px;
}

/* ========== 课程详情 ========== */
.course-detail {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 13px;
}

.course-detail .d-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: #111827;
}

.course-detail .d-row {
  color: #4b5563;
  margin: 2px 0;
  line-height: 1.6;
}

.course-detail .d-row b {
  color: #111827;
  font-weight: 600;
  margin-right: 4px;
}

/* ========== 空状态 ========== */
.empty {
  text-align: center;
  padding: 40px 10px;
  color: #9ca3af;
  font-size: 14px;
}

.empty-icon {
  font-size: 52px;
  margin-bottom: 12px;
}

/* ========== 底部 ========== */
.footer {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  padding: 20px 10px 0;
  line-height: 1.6;
}

/* ========== 手机端优化 (宽度 ≤ 480px) ========== */
@media (max-width: 480px) {
  .logo-text { font-size: 18px; }
  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
    border-radius: 8px;
    flex: 0 0 36px;
  }

  .select-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 65vh;
  }
  .select-item {
    padding: 12px 8px;
    font-size: 13px;
    min-height: 52px;
  }

  .schedule {
    grid-template-columns: 28px repeat(7, 1fr);
    gap: 3px;
    font-size: 11px;
  }
  .schedule .head { padding: 6px 1px; font-size: 11px; border-radius: 6px; }
  .schedule .period-label {
    font-size: 10px;
    min-height: 64px;
    padding: 2px 1px;
    border-radius: 6px;
    writing-mode: horizontal-tb;
  }
  .course-cell {
    font-size: 10px;
    min-height: 64px;
    padding: 4px 3px;
    border-radius: 6px;
  }
  .course-cell .cname { font-size: 11px; }
  .course-cell .cinfo { font-size: 9.5px; }
  .schedule .cell { min-height: 64px; border-radius: 6px; }

  .search-input {
    padding: 10px 12px;
    font-size: 14px;
    min-height: 42px;
  }

  .week-btn {
    padding: 7px 12px;
    font-size: 12.5px;
    min-height: 34px;
    border-radius: 18px;
  }
  .week-switch { gap: 6px; margin-bottom: 10px; }
}

/* ========== 小屏幕 (≤ 360px) ========== */
@media (max-width: 360px) {
  .app { padding: 0 8px 32px; }
  .header { padding: 12px 12px 14px; margin: 0 -8px 14px; }
  .card { padding: 14px 10px 16px; }
  .schedule {
    grid-template-columns: 26px repeat(7, 1fr);
  }
  .schedule .period-label,
  .course-cell,
  .schedule .cell {
    min-height: 58px;
  }
  .course-cell .cname { font-size: 10px; }
  .course-cell .cinfo { font-size: 9px; }
  .logo-text { font-size: 16px; }
}
