:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e7ebf2;
  --text: #1a2030;
  --muted: #6f7889;
  --accent: #a3203b;
  --accent-strong: #831c31;
  --accent-soft: rgba(163, 32, 59, 0.07);
  --accent-line: rgba(163, 32, 59, 0.24);
  --today: #15855c;
  --today-soft: rgba(21, 133, 92, 0.09);
  --shadow-sm: 0 1px 2px rgba(22, 28, 46, 0.05);
  --shadow: 0 10px 30px rgba(30, 40, 66, 0.09);
  --radius: 18px;
  --radius-sm: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, #fbfcfe 0%, var(--bg) 320px);
  color: var(--text);
  padding: 0 0 48px;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 700px; margin: 0 auto; padding: 16px 16px 60px; }

.hero { padding: 14px 2px 4px; }
.hero::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  margin-top: 14px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 14px, var(--line) 14px 18px);
}
.kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
h1 {
  margin: 8px 0 6px;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.12;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
.sub { color: var(--muted); font-size: 14px; margin: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin: 14px 0;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.panel:hover { box-shadow: var(--shadow); }

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 8px;
}
.panel .label:first-child { margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.12s, box-shadow 0.18s;
  font-family: inherit;
}
.chip:hover { border-color: #c9d0dd; transform: translateY(-1px); }
.chip:active { transform: scale(0.97); }
.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 650;
}

.selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.selects > div { min-width: 0; }
select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
button.primary, button.ghost {
  font-family: inherit;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, box-shadow 0.18s;
}
button.primary {
  border: 0;
  background: var(--accent);
  color: #fff;
  flex: 1;
}
button.primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
button.primary:active { transform: scale(0.98); }
button.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}
button.ghost:hover { background: #f6f8fb; border-color: #c9d0dd; transform: translateY(-1px); }
button.ghost:active { transform: scale(0.98); }

.weekrow { display: flex; align-items: center; gap: 8px; }
.weekbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
  margin: 4px 0 6px;
  flex: 1;
  min-width: 0;
}
.weekbar::-webkit-scrollbar { display: none; }
.nav {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
  font-family: inherit;
}
.nav:hover:not(:disabled) { background: #f6f8fb; border-color: #c9d0dd; transform: translateY(-1px); }
.nav:active:not(:disabled) { transform: scale(0.94); }
.nav:disabled { opacity: 0.4; cursor: default; }
.week {
  flex: 0 0 auto;
  border-radius: 14px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.12s, box-shadow 0.18s;
}
.week:hover { border-color: #c9d0dd; transform: translateY(-1px); }
.week:active { transform: scale(0.97); }
.week.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
  font-weight: 650;
}
.week small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-top: 2px; }
.week.active small { color: var(--accent); }

.now { background: linear-gradient(180deg, #fff 0%, #fff4f6 100%); border-color: var(--accent-line); }
.now-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.now-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}
.now-clock {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.now-item { padding: 8px 0; border-top: 1px dashed var(--accent-line); }
.now-item:first-of-type { border-top: 0; padding-top: 0; }
.now-kicker {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 3px;
}
.now-time { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.now-subj { font-size: 16px; font-weight: 650; margin: 2px 0; }
.now-meta { color: var(--muted); font-size: 13px; }
.now-item.live .now-time { color: var(--today); }
.now-item.live .now-kicker { color: var(--today); }
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--today);
  margin-right: 6px;
  vertical-align: 1px;
}
.now-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}
.now-hint { color: var(--muted); font-size: 13px; padding: 2px 0; }

.lesson.live {
  background: var(--today-soft);
  box-shadow: inset 3px 0 0 var(--today);
}
.live-badge {
  display: inline-block;
  vertical-align: 2px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--today);
  border-radius: 999px;
  padding: 2px 8px;
}
.day.past { opacity: 0.8; }
.day.past h2 { color: var(--muted); }
.today-tag.past-tag { color: var(--muted); }
.past-toggle {
  width: 100%;
  margin: 16px 0 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s;
}
.past-toggle:hover { border-color: #c9d0dd; background: #f6f8fb; }
.past-toggle .chev { color: var(--muted); font-size: 12px; transition: transform 0.25s ease; }
.past-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.past-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease;
}
.past-body.open { max-height: 5000px; }
.past-body .day { margin-top: 12px; }

.board-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 6px 2px 2px;
  color: var(--muted);
  font-size: 12px;
}
.board-label strong { color: var(--text); font-weight: 650; }

#board { transition: opacity 0.18s ease; }
#board.fading { opacity: 0; }
.day { margin: 16px 0; animation: dayIn 0.28s ease both; }
@keyframes dayIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.day h2 {
  margin: 0 0 4px;
  padding-bottom: 8px;
  font-size: 17px;
  font-weight: 650;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px dashed var(--line);
}
.day h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 30px;
  height: 2px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 14px);
}
.day h2 span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}
.day.today { border-color: var(--accent-line); }
.day.today h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--today);
  align-self: center;
}
.day h2 .today-tag { color: var(--today); }

.lesson {
  display: grid;
  grid-template-columns: 6px 86px 1fr;
  gap: 12px;
  padding: 13px 8px;
  margin: 0 -8px;
  border-top: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.18s ease, transform 0.18s ease;
}
.lesson:hover { background: rgba(163, 32, 59, 0.05); transform: translateX(3px); }
.lesson:first-of-type { border-top: 0; }
.strip {
  position: relative;
  width: 6px;
  align-self: stretch;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.strip-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: height 0.6s ease;
}
.lesson.live .strip-fill { background: var(--today); }
.when {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  line-height: 1.25;
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}
.subject { font-size: 16px; line-height: 1.32; font-weight: 600; }
.meta { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.room {
  display: inline-block;
  margin-right: 8px;
  margin-bottom: 2px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.empty, .status {
  color: var(--muted);
  font-size: 14px;
  padding: 26px 8px;
  text-align: center;
}
.status {
  color: var(--accent);
  font-weight: 550;
}

.footer {
  margin-top: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 420px) {
  .selects { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .day { animation: none; }
}