
:root {
  color-scheme: light;
  --free-day: #a51d2d;
  --window: #fafafb;
  --surface: #fff;
  --field: #fff;
  --text: #252529;
  --muted: #59595f;
  --line: rgb(0 0 6 / 13%);
  --hover: rgb(0 0 6 / 7%);
  --pressed: rgb(0 0 6 / 12%);
  --accent: #3584e4;
  --accent-text: #0461be;
  --warning: #905400;
  --warning-tint: rgb(229 165 10 / 15%);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --free-day: #ff9b9f;
    --window: #222226;
    --surface: #2e2e32;
    --field: #1d1d20;
    --text: #fff;
    --muted: #bebec3;
    --line: rgb(255 255 255 / 16%);
    --hover: rgb(255 255 255 / 8%);
    --pressed: rgb(255 255 255 / 14%);
    --accent-text: #81d0ff;
    --warning: #ffc252;
    --warning-tint: rgb(205 147 9 / 15%);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--window); color: var(--text); font: 16px/1.5 Inter, system-ui, sans-serif; }
header { background: var(--surface); border-bottom: 1px solid var(--line); }
header .masthead, main { max-width: 900px; margin: auto; padding: 20px 24px; }
header .masthead, .controls, .row, .status { display: flex; align-items: center; gap: 12px; }
header strong { font-size: clamp(21px, 3vw, 26px); letter-spacing: -.03em; }
header summary { font-size: clamp(16px, 2vw, 20px); line-height: 1.3; color: var(--muted); }
main { padding-top: 36px; }
h1,h2,p { margin: 0; }
h1 { font-size: clamp(27px,5vw,44px); letter-spacing: -.055em; line-height: 1.07; margin-bottom: 22px; }
h2 { font-size: 24px; letter-spacing: -.035em; }
.controls { flex-wrap: wrap; }
.controls label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.controls :is(select,input) { font: inherit; color: inherit; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-height: 42px; }
.controls select { min-width: 170px; }
button { font: inherit; color: inherit; border: 0; background: transparent; cursor: pointer; }
:where(button,a,input,select):focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
nav > button { display: grid; place-items: center; border-radius: 50%; width: 38px; height: 38px; padding: 0; }
nav, .day { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); }
#week-number { text-align: center; white-space: nowrap; color: var(--muted); font-size: 14px; }
nav { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 7px; margin: 20px 0 14px; }
nav > button::before { content: ""; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); }
#prev::before { transform: rotate(135deg); }
.week { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.week button { display: grid; justify-items: center; gap: 2px; padding: 3px 0; border-radius: 9px; }
.week span { color: var(--muted); font-weight: 600; font-size: 12px; }
.week b { display: grid; place-items: center; width: min(100%,32px); aspect-ratio: 1; border-radius: 50%; font-size: 16px; line-height: 1; font-variant-numeric: tabular-nums; }
.week [aria-pressed=true] b { background: var(--accent); color: white; }
.week .free-day :is(span,b) { color: var(--free-day); }
.week .free-day[aria-pressed=true] b { background: var(--free-day); color: var(--surface); }
@media (hover:hover) { button:hover { background: var(--hover); } }
button:active { background: var(--pressed); }
.day { padding: 22px; margin: 12px 0; }
.status { font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.row { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; align-items: flex-start; gap: 18px; }
.slot { min-width: 88px; font-size: 13px; }
.slot b { display: block; font-size: 16px; }
.row strong { font-size: 18px; line-height: 1.3; }
.sub,.old { font-size: 14px; color: var(--muted); }
.old { margin-top: 4px; }
.badge,.notice { color: var(--warning); background: var(--warning-tint); }
.badge { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; margin: 3px 0; }
.notice { padding: 12px 15px; border-radius: 8px; margin: 10px 0; }
.empty { margin-top: 16px; }
a { color: var(--accent-text); text-underline-offset: 3px; }
.row a:not(.badge) { font-size: 13px; }
@media (max-width:520px) {
  header .masthead { flex-direction: column; align-items: flex-start; gap: 2px; }
  header .masthead, main { padding-left: 15px; padding-right: 15px; }
  nav { padding: 5px 3px; gap: 1px; }
  nav > button { width: 38px; }
  .day { padding: 15px; }
  .controls select { min-width: 140px; }
  .row {
    display: grid;
    grid-template-columns: 5.25rem minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    overflow-wrap: anywhere;
  }
  .slot { min-width: 0; font-variant-numeric: tabular-nums; }
  .slot span { display: block; }
  .row strong { font-size: 16px; }
}
[hidden] { display:none !important; }
.controls label { max-width:100%; min-width:0; }
.controls select { max-width:100%; }
.campuses { display:inline-flex; gap:3px; padding:3px; background:var(--hover); border-radius:10px; margin-bottom:16px; }
.campuses button,.info-button,.close { min-height:40px; border-radius:8px; padding:6px 13px; }
.campuses [aria-pressed=true] { background:var(--surface); color:var(--accent-text); box-shadow:0 1px 3px var(--line); }
.department-control,.group-control { display:flex; align-items:end; gap:6px; max-width:100%; }
.department-control label,.group-control label { flex:1; }
#department,#group { min-width:0; width:100%; max-width:24em; }
.info-button,.close { background:var(--hover); color:var(--accent-text); font-size:14px; font-weight:600; }
dialog { width:min(410px,95vw); padding:24px; background:var(--surface); color:var(--text); border:1px solid var(--line); border-radius:16px; }
dialog::backdrop { background:rgb(0 0 0 / 45%); }
dialog address { font-style:normal; margin:12px 0; }
dialog p { margin:8px 0; }
dialog form { margin:18px 0 0; text-align:right; }
@media(max-width:520px){
 .campuses { display:flex; } .campuses button { flex:1; }
 .department-control,.group-control { width:100%; }
 dialog { inset:auto 0 0; margin:0 auto; width:100%; max-width:100%; border-radius:16px 16px 0 0; }
}

header .masthead { flex-direction: row; align-items: center; justify-content: space-between; }
.masthead a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.masthead a::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid var(--muted);
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
}
.masthead #groups-link::after { order: -1; transform: rotate(-135deg); }
@media (hover: hover) { .masthead a:hover { background: var(--pressed); } }
.masthead a:active { box-shadow: inset 0 0 0 1px var(--line); }


@media (max-width: 520px) {
  #books button { flex: 1 0 auto; padding-inline: 8px; }
  #books + .controls label { width: 100%; }

}

.teacher-picker { position: relative; width: min(100%, 25rem); }
.teacher-picker input { width: 100%; margin-top: 4px; }
#teacher-options { position: absolute; z-index: 2; inset-inline: 0; top: 100%; max-height: 16rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px var(--line); }
#teacher-options > * { padding: 9px 12px; }
#teacher-options [role=option] { cursor: pointer; }
#teacher-options [aria-selected=true] { color: var(--accent-text); }
#teacher-options [role=option]:hover, #teacher-options .active { background: var(--hover); }

#subjects-list dt { font-weight: 600; margin-top: 12px; }
#subjects-list dd { margin: 2px 0 0; color: var(--muted); }
