:root {
  --bg-page: #eef5ff;
  --bg-card: #dfeafc;
  --bg-strong: #d8ebff;
  --surface: #edf6ff;
  --surface-2: #cfe2ff;
  --text: #2d4059;
  --subtle: #657a96;
  --line: #5b6d7d;
  --single: #bfe3ff;
  --single-strong: #9bc8f5;
  --double: #d7eafc;
  --double-strong: #bed8f7;
  --highlight: #9dd1ff;
  --button: #90bde9;
  --button-hover: #7baee2;
  --white: #fff;
  --tabHead: #92c0ee;
  --shadow: rgba(32, 56, 85, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
  color: var(--text);
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1200px);
  min-height: min(92vh, 920px);
  background: rgba(255, 255, 255, 0.34);
  border: 2px solid rgba(81, 97, 117, 0.3);
  box-shadow: 0 12px 28px rgba(78, 84, 108, 0.12);
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px 12px;
  background: rgba(191, 227, 255, 0.7);
  border-bottom: 2px solid rgba(71, 88, 108, 0.35);
}

.week-nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-btn,
.today-btn {
  min-width: 120px;
  padding: 10px 18px;
  border: 2px solid rgba(65, 91, 118, 0.4);
  background: linear-gradient(180deg, var(--white) 0%, #dfeafc 100%);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.nav-btn:hover,
.today-btn:hover {
  background: linear-gradient(180deg, #f2f8ff 0%, #cfe0f8 100%);
  box-shadow: 0 6px 14px rgba(80, 106, 142, 0.12);
}

.nav-btn:active,
.today-btn:active {
  transform: translateY(1px);
}

.week-indicator-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  text-align: center;
}

.week-label {
  font-size: 0.82rem;
  color: var(--subtle);
  margin-bottom: 4px;
}

#weekLabel {
  font-size: clamp(1.1rem, 2vw, 1.8rem);
  letter-spacing: 0.02em;
}

.today-btn {
  min-width: 92px;
  background: linear-gradient(180deg, #f4fbff 0%, #b8d8f6 100%);
}

.schedule-panel {
  flex: 1;
  background: var(--bg-card);
  padding: 0;
  overflow: hidden;
}

.schedule-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: var(--bg-card);
}

.course-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 800px;
  background: var(--bg-card);
}

.course-table th,
.course-table td {
  border: 2px solid rgba(50, 63, 79, 0.9);
  vertical-align: middle;
  text-align: center;
}

.course-table thead th {
  background: var(--bg-strong);
  background-color: var(--bg-strong);
  background-color: var(--tabHead) !important;
  color: var(--text);
  font-size: clamp(0.9rem, 1.5vw, 1.5rem);
  font-weight: 700;
  padding: 8px 6px;
  min-height: 58px;
  line-height: 1.3;
  position: sticky;
  top: 0;
  z-index: 3;
}

.date-tag {
  display: inline-block;
  font-size: clamp(0.62rem, 0.95vw, 0.9rem);
  font-weight: 600;
  opacity: 0.9;
}

.time-head {
  width: 10%;
  min-width: 90px;
  left: 0;
  background-color: var(--tabHead) !important;
  z-index: 4 !important;
}

.course-table tbody td {
  padding: 6px;
  background: rgba(233, 242, 255, 0.4);
  min-height: 100px;
}

.time-cell {
  padding: 10px 4px;
  background: var(--bg-card);
  background-color: var(--bg-card);
  background-color: var(--tabHead) !important;
  color: var(--text);
  font-weight: 700;
  font-size: clamp(0.72rem, 1vw, 1rem);
  line-height: 1.35;
  width: 10%;
  position: sticky;
  left: 0;
  z-index: 2;
}

.time-cell .period-name,
.time-cell .period-time {
  display: block;
}

.schedule-cell {
  position: relative;
  min-height: 110px;
}

.course-slot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 96px;
}

.course-item {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  border: 1px solid rgba(67, 82, 97, 0.45);
  color: var(--text);
  font-size: clamp(0.6rem, 0.8vw, 0.95rem);
  line-height: 1.3;
  text-align: center;
  word-break: break-word;
  transition:
    background 0.2s ease,
    transform 0.15s ease;
}

.course-item + .course-item {
  border-left: none;
}

.course-single,
.course-double {
  background: rgba(214, 230, 250, 0.72);
}

.course-item.is-active {
  background: var(--highlight);
  box-shadow: inset 0 0 0 2px rgba(71, 120, 176, 0.28);
}

.course-item.empty-slot {
  background: rgba(214, 230, 250, 0.72);
  color: rgba(45, 64, 89, 0.4);
}

.today-column {
  background: rgba(255, 204, 204, 0.7) !important;
  box-shadow: inset 0 0 0 2px rgba(200, 98, 98, 0.18);
}

.empty-cell {
  background: rgba(190, 217, 249, 0.26);
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  .app-shell {
    min-height: 96vh;
  }

  .top-bar {
    padding: 10px 10px 8px;
    gap: 8px;
  }

  .week-nav {
    gap: 8px;
  }

  .nav-btn,
  .today-btn {
    min-width: 76px;
    padding: 7px 8px;
    font-size: 0.75rem;
  }

  .week-indicator-wrap {
    min-width: 90px;
  }

  .course-table {
    min-width: 640px;
  }

  .time-head {
    min-width: 80px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    min-height: 100vh;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }

  .top-bar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .week-nav {
    width: 100%;
  }

  .course-table {
    min-width: 620px;
  }

  .course-item {
    font-size: 0.55rem;
    line-height: 1.2;
    padding: 3px 4px;
    min-height: 74px;
  }

  .time-cell {
    font-size: 0.64rem;
    padding: 6px 2px;
  }
}
