:root {
  color-scheme: light dark;
  --page: #f6f7f9;
  --surface: #fdfefe;
  --text: #222b35;
  --muted: #586571;
  --line: #c5d1cc;
  --control-line: #81988c;
  --accent: #25664e;
  --tint: #edf5f0;
  --notice: #f4f1e6;
  --error: #9b3336;
  --error-bg: #fbf0f0;
  --map-paper: #f0f6f2;
  --map-ground: #e5efe6;
  --map-ground-line: #c0d3c4;
  --map-ink: #688775;
  --map-roof: #f9fcf9;
  --map-front: #e0ece3;
  --map-side: #c9dccf;
  --map-button-line: #74917d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button, input, select { color: var(--text); }
button { touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .65; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -60px; left: 16px; padding: 10px; background: var(--surface); z-index: 2; }
.skip-link:focus { top: 8px; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 32px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
h1 { font-size: 27px; line-height: 1.4; font-weight: 650; letter-spacing: -.5px; }
.page-header p { color: var(--muted); font-size: 14px; margin-top: 3px; }
.button { border: 1.5px solid var(--control-line); border-radius: 7px; padding: 8px 17px; min-height: 44px; background: var(--surface); white-space: nowrap; font-size: 15px; }
.button:hover { border-color: var(--accent); color: var(--accent); }
.button:active, .room-chip:active { background: var(--tint); }
.query-panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.date-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.date-tab { border: 0; border-right: 1px solid var(--line); border-bottom: 2px solid transparent; background: transparent; padding: 10px 8px 8px; text-align: center; min-height: 70px; }
.date-tab:last-child { border-right: 0; }
.date-tab strong { display: block; font-size: 16px; font-weight: 600; }
.date-tab span { display: block; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.date-tab:hover { background: var(--page); }
.date-tab[aria-pressed="true"] { background: var(--tint); border-bottom-color: var(--accent); color: var(--accent); }
.query-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; padding: 14px 16px 16px; margin: 0; border: 0; min-width: 0; }
.query-fields .field { flex: 0 1 310px; }
.query-hint { color: var(--muted); font-size: 13px; padding-bottom: 9px; }
.list-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; margin: 14px 0 0; padding: 0; border: 0; min-width: 0; }
.filter-hint { font-size: 12px; color: var(--muted); margin: 10px 0 16px; }
.field { display: grid; gap: 4px; min-width: 0; flex: 1 1 170px; }
.field > span { color: var(--muted); font-size: 13px; }
.field select, .field input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--control-line); border-radius: 6px; background: var(--surface); font-size: 16px; }
.field input::placeholder { color: var(--muted); opacity: 1; }
.field-search { flex: 1.2 1 180px; }
.check-field { display: flex; align-items: center; gap: 8px; min-height: 44px; white-space: nowrap; font-size: 15px; }
.check-field input { width: 19px; height: 19px; margin: 0; accent-color: var(--accent); }
.campus-overview { margin-top: 24px; }
.map-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; margin-bottom: 11px; }
.map-heading h2 { font-size: 19px; font-weight: 650; }
.map-heading p { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.map-shell { border: 1.5px solid var(--map-button-line); border-radius: 12px; overflow: hidden; background: var(--map-paper); }
.campus-map { position: relative; width: 100%; aspect-ratio: 1120 / 500; }
.campus-drawing { display: block; width: 100%; height: 100%; position: absolute; inset: 0; pointer-events: none; }
.campus-drawing--mobile { display: none; }
.map-ground { fill: var(--map-ground); stroke: var(--map-ground-line); stroke-width: 1.2; stroke-dasharray: 5 5; }
.map-walk-outline { fill: none; stroke: var(--map-ground-line); stroke-width: 17; }
.map-walk { fill: none; stroke: var(--surface); stroke-width: 12; }
.map-path { fill: none; stroke: var(--surface); stroke-width: 7; stroke-linejoin: round; }
.map-trees { fill: var(--map-ground-line); opacity: .7; }
.map-region, .map-north { fill: var(--muted); font: 14px sans-serif; }
.map-region { letter-spacing: 2px; }
.map-building path { stroke: var(--map-ink); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map-building .map-building-shadow { fill: var(--map-ground-line); stroke: none; opacity: .5; }
.map-building-front { fill: var(--map-front); }
.map-building-roof { fill: var(--map-roof); }
.map-building-side { fill: var(--map-side); }
.map-building-detail, .map-roof-detail { fill: none; }
.map-building .map-roof-detail { stroke-width: .8; }
.map-building.is-unconfirmed { opacity: .65; }
.map-building.is-selected path { stroke: var(--accent); stroke-width: 2; }
.map-connector path { fill: none; stroke: var(--map-ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.map-connector circle { fill: var(--map-paper); stroke: var(--map-ink); stroke-width: 1.4; }
.map-connector.is-selected path, .map-connector.is-selected circle { stroke: var(--accent); stroke-width: 2.2; }
.map-callout { position: absolute; left: var(--desktop-x); top: var(--desktop-y); width: 15.7143%; height: 15.2%; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px; border: 1.5px solid var(--map-button-line); border-radius: 9px; background: var(--surface); color: var(--text); }
.map-callout:hover, .map-callout[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); }
.map-callout[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.map-callout:disabled { opacity: 1; }
.map-callout-name { font-size: 16px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.map-value { display: flex; align-items: baseline; justify-content: center; gap: 5px; line-height: 1.2; }
.map-value strong { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 27px; font-weight: 650; color: var(--accent); }
.map-value small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.map-state { font-size: 13px; color: var(--muted); line-height: 1.5; white-space: nowrap; }
.map-callout.is-empty .map-value strong { color: var(--muted); }
.map-caption { padding: 10px 16px 13px; margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.notice { margin-top: 14px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--notice); font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice.is-error { color: var(--error); background: var(--error-bg); }
.notice .button { color: inherit; }
.results { margin-top: 30px; scroll-margin-top: 18px; }
.results-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.results-heading h2 { font-size: 20px; font-weight: 650; }
.results-heading p { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.building-group { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 16px; padding: 20px; margin-bottom: 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.building-heading h3 { font-size: 19px; font-weight: 600; }
.building-count { color: var(--muted); font-size: 14px; margin-top: 3px; }
.room-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 10px; align-content: start; }
.room-chip { min-width: 0; min-height: 50px; padding: 8px 6px; background: var(--surface); border: 1.5px solid #789482; border-radius: 7px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.room-chip:hover { border-color: var(--accent); background: var(--tint); color: var(--accent); }
.group-message { color: var(--muted); font-size: 14px; padding-top: 4px; }
.empty-state, .loading { padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.empty-state .button { margin-top: 10px; }
.page-footer { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 16px; color: var(--muted); font-size: 12px; }
.page-footer p { margin-bottom: 5px; }
.page-footer a { display: inline-block; margin-top: 3px; }
.room-dialog { width: min(620px, calc(100% - 32px)); max-height: min(84dvh, 780px); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); }
.room-dialog::backdrop { background: rgb(20 28 36 / 45%); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; background: var(--surface); padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 21px; }
.room-detail { padding: 18px 20px 24px; }
.detail-meta { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.room-detail h3 { font-size: 16px; margin: 20px 0 9px; }
.periods { display: flex; flex-wrap: wrap; gap: 7px; }
.period { background: var(--tint); border-radius: 4px; padding: 6px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.course-list { padding: 0; margin: 0; list-style: none; }
.course { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.course time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.course strong { display: block; font-size: 15px; font-weight: 500; }
.course small { color: var(--muted); }
.detail-note { margin-top: 20px; font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .campus-map { max-width: 440px; margin: 0 auto; aspect-ratio: 440 / 620; }
  .campus-drawing--desktop { display: none; }
  .campus-drawing--mobile { display: block; }
  .map-callout { left: var(--mobile-x); top: var(--mobile-y); width: 30.9091%; height: 13.871%; min-height: 60px; gap: 2px; }
  .map-callout-name { font-size: clamp(14px, 3.7vw, 16px); }
  .map-value strong { font-size: clamp(24px, 6.7vw, 28px); }
  .map-value small { font-size: 11px; }
  .map-state { font-size: 12px; }
}

@media (max-width: 640px) {
  .page { padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .page-header { margin-bottom: 14px; }
  h1 { font-size: 25px; }
  .query-fields { display: grid; grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .query-hint { display: none; }
  .list-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .field-search { grid-column: auto; }
  .check-field { grid-column: 1 / -1; min-height: 44px; }
  .date-tab { min-height: 64px; padding-inline: 3px; }
  .date-tab span { font-size: 12px; }
  .campus-overview { margin-top: 16px; }
  .map-heading { display: block; }
  .map-heading p { margin-top: 4px; }
  .map-heading h2 { font-size: 18px; }
  .map-caption { padding-inline: 10px; text-align: left; }
  .results { margin-top: 26px; }
  .results-heading { display: block; }
  .results-heading p { margin-top: 4px; }
  .building-group { grid-template-columns: minmax(0, 1fr); gap: 13px; padding: 14px 12px; }
  .building-heading { display: flex; gap: 10px; align-items: baseline; }
  .building-count { margin-top: 0; }
  .room-chip { min-height: 50px; padding-inline: 4px; font-size: 20px; }
  .room-list { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
  .notice { align-items: start; }
  .room-dialog { max-height: 88dvh; }
  .dialog-header, .room-detail { padding-inline: 16px; }
}

@media (prefers-color-scheme: dark) {
  :root { --page: #171c23; --surface: #202730; --text: #e5eaf0; --muted: #aab5c2; --line: #4b5e55; --control-line: #6d8b79; --accent: #88d3b3; --tint: #263c34; --notice: #333126; --error: #f0a3a6; --error-bg: #3c282c; --map-paper: #1d2c26; --map-ground: #283b30; --map-ground-line: #3d5647; --map-ink: #8cae99; --map-roof: #354a3c; --map-front: #2d4335; --map-side: #213528; --map-button-line: #658472; }
  .room-chip { border-color: #6d8b79; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
