:root {
  color-scheme: light;
  --bg: #f5f4ed; --paper: #fffcf4; --ink: #1c302c;
  --muted: #50665d; --line: #d3dbcf; --green: #16463b; --tint: #e7eddf;
  font: 16px/1.45 system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100dvh; }
.masthead {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: 1rem max(1rem, calc((100% - 900px) / 2)); border-bottom: 1px solid var(--line);
}
.brand, .account { display: flex; align-items: center; gap: .65rem; }
.brand { font-size: 1.15rem; line-height: 1.15; font-weight: 750; white-space: nowrap; }
.brand small { display: block; font-size: .73rem; font-weight: 500; color: var(--muted); margin-top: .2rem; }
.account { text-align: right; font-size: .85rem; min-width: 0; }
#account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { width: min(900px, calc(100% - 2rem)); margin: 2rem auto; }
h1 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.65rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
p { margin: .4rem 0 0; overflow-wrap: anywhere; }
.muted, small { color: var(--muted); }
a { color: var(--green); text-underline-offset: .18em; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button {
  background: var(--paper); color: var(--green); border: 1px solid var(--line);
  padding: .62rem .85rem; min-height: 44px; border-radius: .65rem; font-weight: 700;
}
button:hover { border-color: var(--green); }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #34735d; outline-offset: 3px; }
.primary { color: #fffdf6; background: var(--green); border-color: var(--green); }
.quiet { background: transparent; }
nav { display: flex; gap: .4rem; margin-bottom: 1.75rem; }
nav button { background: transparent; }
nav button[aria-current="page"] { color: var(--green); border-color: #9fb6a4; background: var(--tint); }
.sheet, .entry { background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.login { width: min(100%, 410px); margin: 3rem auto; padding: 1.4rem; }
form { display: grid; gap: .8rem; margin: .85rem 0 0; }
label { min-width: 0; display: block; font-weight: 650; }
label small { font-weight: 400; }
input, textarea, select {
  display: block; min-height: 44px; width: 100%; margin-top: .28rem; max-width: 100%;
  border: 1px solid #aebdaf; border-radius: .55rem; background: #fffefa; color: var(--ink);
  padding: .45rem .55rem;
}
textarea { resize: vertical; }
form > button { justify-self: start; }
.login button { width: 100%; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.section-head button { flex-shrink: 0; }
.list { display: grid; gap: .65rem; margin: .85rem 0; }
.entry { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr) minmax(125px, auto); align-items: center; }
.entry p { white-space: pre-wrap; }
.badge { color: var(--green); background: var(--tint); padding: .3rem .6rem; border-radius: .5rem; justify-self: end; }
.hint, #notice { padding: .65rem .8rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--tint); margin: .85rem 0; }
#notice.error { background: #fbece3; border-color: #dfbbb0; color: #752f22; }
#booking .sheet { margin-top: .8rem; }
.booking-date-panel form { display: flex; align-items: flex-end; gap: .65rem; margin-top: 0; }
.booking-date-panel input { min-width: 0; }
.booking-legend { display: flex; flex-wrap: wrap; gap: .4rem .8rem; font-size: .79rem; margin-top: .9rem; }
.booking-legend span { display: flex; align-items: center; gap: .3rem; }
.booking-legend span::before { content: ""; width: .9rem; height: .64rem; border: 1px solid #575865; border-radius: .18rem; background: #22232a; }
.booking-legend .occupied::before { background: #743238; border-color: #b94a52; }
.booking-legend .mine::before { background: #775221; border-color: #a56b26; }
.booking-map-panel { max-width: 570px; }
#floor-tabs { margin: 0 0 .65rem; }
#floor-tabs [aria-pressed="true"] { background: var(--tint); border-color: #9fb6a4; }
#floor-map svg { width: 100%; height: auto; display: block; border-radius: .8rem; background: #15161e; }
#floor-map text {
  text-anchor: middle; dominant-baseline: middle; fill: #eeedf3; font-size: 15px; font-weight: 650;
  pointer-events: none; user-select: none;
}
#floor-map .map-corridor { fill: #20212b; stroke: #494a5a; }
#floor-map .map-corridor-label { fill: #9192a0; font-size: 11px; letter-spacing: 1.5px; }
.map-room { outline: none; }
.map-room[role="button"] { cursor: pointer; }
.room-outline { fill: #22232c; stroke: #555664; stroke-width: 1.5px; }
.map-room.mine .room-outline { fill: #775221; stroke: #ecc272; }
.map-room.occupied .room-outline { fill: #743238; stroke: #ed8e94; }
.map-room.wayfinding .room-outline { fill: #191a23; stroke: #383947; }
#floor-map .map-room.wayfinding text { fill: #9d9dac; }
.map-room[role="button"]:hover .room-outline, .map-room:focus-visible .room-outline { stroke: #c3c4ff; stroke-width: 3px; }
.room-door { stroke: #9c9da9; stroke-width: 2.5px; stroke-linecap: round; pointer-events: none; }
#booking-status { min-height: 1.5em; margin-top: .65rem; }
#booking-dialog {
  box-sizing: border-box; width: min(94vw, 550px); max-height: 90dvh; padding: 1rem;
  border: 1px solid var(--line); border-radius: 1rem; color: var(--ink); background: var(--paper);
  overscroll-behavior: contain;
}
#booking-dialog::backdrop { background: #172923a9; }
body:has(#booking-dialog[open]) { overflow: hidden; }
.dialog-title { display: flex; align-items: center; gap: 1rem; justify-content: space-between; }
.dialog-title button { min-width: 44px; }
.booking-slots h3, .new-booking h3 { margin: 0; font-size: 1rem; }
.booking-slots { margin-top: .75rem; }
.slot {
  margin-top: .45rem; padding: .5rem; border: 1px solid #e2c2bf; border-radius: .55rem;
  background: #fae9e7; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem;
}
.slot.mine { background: #fff0cc; border-color: #e9c989; }
.slot p { margin: 0; }
.slot-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.slot-actions button { padding: .4rem .55rem; font-size: .8rem; }
.new-booking { border-top: 1px solid var(--line); padding-top: .85rem; }
.interval-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.new-booking button { width: 100%; }
.conflict-preview, #booking-message { font-size: .88rem; }
.conflict-preview ul { margin: .25rem 0 0; padding-left: 1.25rem; }
.booking-error { color: #752f22; }
.booking-success { color: #206146; }
@media (max-width: 480px) {
  main { margin-top: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  nav { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; margin-bottom: 1.25rem; }
  nav button { padding-inline: .3rem; font-size: .88rem; }
  #booking .sheet { padding: .7rem; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry > select, .badge { justify-self: start; width: auto; }
}

.priority { display: inline-block; margin-top: .35rem; padding: .2rem .5rem; border-radius: .4rem; font-size: .78rem; font-weight: 650; }
.priority.weak { background: #e8eee1; color: #355747; }
.priority.medium { background: #f5ebd7; color: #664a26; }
.priority.high { background: #fae5df; color: #8b332c; }
#roster-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: .6rem; margin-top: .8rem; }
#roster-state { margin: .75rem 0; }
.roster-student-button { text-align: left; }
.roster-dialog {
  box-sizing: border-box; width: min(94vw, 600px); max-height: 90dvh; padding: 1rem;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 1rem;
  overscroll-behavior: contain;
}
.roster-dialog::backdrop { background: #172923a9; }
body:has(.roster-dialog[open]) { overflow: hidden; }
.roster-dialog .dialog-title form { margin: 0; }
.student-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr); gap: .45rem .8rem; }
.student-fields dt, .student-fields dd { overflow-wrap: anywhere; }
.student-fields dt { color: var(--muted); font-size: .9rem; }
.student-fields dd { margin: 0; }
.roster-long-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.roster-comments { margin: 1rem 0; }
.roster-comments h3 { margin: 0; font-size: 1rem; }
.roster-comment { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .55rem; margin-top: .5rem; }
.roster-comment .muted { font-size: .82rem; margin: 0; }
.student-form-pair { display: grid; gap: .65rem; grid-template-columns: 1fr 1.5fr; }
.roster-comment-form button { width: 100%; }
@media (max-width: 480px) {
  #main-tabs { display: flex; flex-wrap: wrap; }
  #main-tabs button { flex: 1 0 auto; padding-inline: .5rem; }
  .student-fields { grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr); gap: .45rem .55rem; }
}

#pairing-picker { margin-top: .8rem; max-width: 430px; }
.intake-card { min-width: 0; }
.intake-card-button { display: grid; gap: .3rem; text-align: left; padding: .8rem 1rem; }
.intake-card-button strong, .intake-card-button span { overflow-wrap: anywhere; }
.intake-card-button .muted, .intake-incoming span { font-size: .88rem; font-weight: 500; }
.intake-incoming { background: #e7f2e7; border-color: #9cbda9; }
.intake-incoming .intake-incoming-label { color: #236449; font-weight: 700; }
.intake-subjects, .intake-pairing-fields {
  min-inline-size: 0; border: 1px solid var(--line); border-radius: .65rem; padding: .55rem .65rem;
}
.intake-subjects legend, .intake-pairing-fields legend { font-weight: 650; padding-inline: .2rem; }
.intake-pairing-fields { display: grid; gap: .65rem; }
.intake-subject-choice { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: .2rem .55rem; }
.intake-subject-choice + .intake-subject-choice { border-top: 1px solid var(--line); }
.intake-subject-choice select { margin: .2rem 0; font-size: .9rem; }
.intake-check { display: flex; align-items: center; gap: .5rem; min-height: 44px; cursor: pointer; overflow-wrap: anywhere; }
.intake-check input { flex: 0 0 1.15rem; width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--green); }
#intake-dialog-body h3, .intake-assignment-form h3 { margin: 0; font-size: 1rem; }
.intake-assignment-form { margin: 0; }
.intake-assignment-form p { margin: 0; }
@media (max-width: 360px) {
  .intake-subject-choice { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

.roster-progress { margin: .85rem 0; border-top: 1px solid var(--line); padding-top: .65rem; }
.roster-progress h3, .progress-homework h4 { margin: 0 0 .4rem; font-size: 1rem; }
.progress-homework { margin-top: .85rem; }
.progress-stats { margin: .7rem 0 0; padding-left: 1.2rem; }
.progress-link { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .7rem; margin-bottom: .6rem; }
.progress-link p { overflow-wrap: anywhere; }
.progress-link button { flex-shrink: 0; }
#edit-student-form input::placeholder, #edit-student-form textarea::placeholder { color: var(--muted); }

.roster-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.roster-archive-entry { gap: .45rem; }
.roster-archive-entry strong { overflow-wrap: anywhere; }
.roster-remove { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: 1.15rem; }
.roster-remove .roster-remove-button { color: #752f22; }

.roster-edit-button { margin-top: .75rem; }
.student-edit-actions {
  position: sticky; top: -.1rem; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
  padding: .5rem 0; background: var(--paper); border-bottom: 1px solid var(--line);
}
.student-edit-actions p:empty { display: none; }
.student-edit-actions p { width: 100%; margin-top: 0; }
#edit-student-form input, #edit-student-form textarea { scroll-margin-block: 4.5rem 1rem; }
