:root {
  --ink: #2b2521;
  --ink-soft: #544a44;
  --muted: #8a7f77;
  --muted-light: #b9aea6;
  --paper: #f7f3ee;
  --paper-deep: #eee7df;
  --surface: #fffaf6;
  --surface-strong: #ffffff;
  --forest: #d97745;
  --forest-deep: #2b2521;
  --forest-soft: #a95735;
  --lime: #f4b78e;
  --blue: #64739f;
  --orange: #d97745;
  --green: #b86f49;
  --red: #ba5148;
  --red-soft: #fff1ed;
  --line: #e6ddd5;
  --line-strong: #d2c5bb;
  --shadow: 0 18px 48px rgba(79, 53, 35, .08);
  --display: "Noto Serif SC", "Songti SC", serif;
  --body: "Noto Sans SC", "PingFang SC", sans-serif;
  --mono: "DM Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before { display: none; }

button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(217, 119, 69, .38); outline-offset: 2px; }

.shell { display: flex; min-height: 100vh; }

.rail {
  position: fixed;
  z-index: 4;
  display: flex;
  flex-direction: column;
  width: 236px;
  height: 100vh;
  padding: 29px 20px 22px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.rail::after { display: none; }

.rail-brand { display: flex; align-items: center; gap: 12px; }
.rail-brand strong, .rail-brand span { display: block; }
.rail-brand strong { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: .03em; }
.rail-brand div > span { margin-top: 4px; color: var(--muted-light); font: 400 8px var(--mono); letter-spacing: .04em; }
.brand-mark { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 11px 11px 11px 3px; background: var(--forest); color: #fff; font: 700 24px var(--display); }

.rail-section-label { margin: 43px 9px 13px; color: var(--muted-light); font: 500 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.rail nav { display: grid; gap: 6px; }
.nav-item { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 47px; padding: 7px 10px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); text-decoration: none; transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
.nav-item:hover { border-color: rgba(217, 119, 69, .22); background: #fff4ec; color: var(--ink); transform: translateX(2px); }
.nav-item.active { border-color: rgba(217, 119, 69, .34); background: #fff0e5; color: var(--ink); }
.nav-item--disabled, .nav-item--disabled:hover { cursor: not-allowed; border-color: transparent; background: transparent; color: var(--muted-light); transform: none; }
.nav-item--disabled .nav-number, .nav-item--disabled .nav-arrow { color: var(--muted-light); }
.nav-item--disabled em { border-color: var(--line); color: var(--muted-light); }
.nav-number { align-self: start; color: var(--forest); font: 500 10px var(--mono); }
.nav-copy b, .nav-copy small { display: block; }
.nav-copy b { font-size: 12px; font-weight: 700; }
.nav-copy small { display: none; }
.nav-item.active .nav-copy small { color: var(--forest-soft); }
.nav-arrow { color: var(--forest); font-size: 16px; }
.nav-item em { padding: 3px 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); font-size: 8px; font-style: normal; white-space: nowrap; }
.rail-status { display: flex; align-items: center; gap: 9px; min-height: 54px; margin-top: auto; padding: 13px 10px; border-top: 1px solid var(--line); }
.status-dot, .topbar-signal, .live-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--forest); box-shadow: 0 0 0 4px rgba(217, 119, 69, .12); }
.rail-status b, .rail-status small { display: block; }
.rail-status b { font-size: 11px; }
.rail-status small { margin-top: 2px; color: var(--muted); font: 400 9px var(--mono); }
.rail-year { margin-left: auto; color: var(--forest-soft); font: 500 10px var(--mono); }

.workspace { width: calc(100% - 236px); min-width: 0; margin-left: 236px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 48px; border-bottom: 1px solid var(--line); background: rgba(247, 243, 238, .86); backdrop-filter: blur(12px); }
.topbar-context { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.topbar-context i { color: var(--line-strong); font-style: normal; }
.topbar-context b { color: var(--ink); font-weight: 700; }
.topbar-signal { width: 6px; height: 6px; flex-basis: 6px; box-shadow: none; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-button, .export, .week-switcher button, .metric-drilldown, .drawer-close, .load-person, .teacher-search-button { border: 0; font: inherit; }
.icon-button { display: grid; place-items: center; width: 33px; height: 33px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--ink-soft); font: 500 14px var(--mono); transition: background .18s ease, color .18s ease; }
.icon-button:hover { background: var(--forest); color: #fff; }
.export { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 7px; background: var(--forest); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; transition: background .18s ease, transform .18s ease; }
.export span { color: #fff3e9; font-size: 15px; }
.export:hover { background: var(--forest-soft); transform: translateY(-1px); }
.export:disabled, .export:disabled:hover { border: 1px solid var(--line); background: var(--paper-deep); color: var(--muted-light); opacity: 1; transform: none; }
.export:disabled span { color: var(--muted-light); }

.content { width: min(100%, 1580px); margin: 0 auto; padding: 34px 48px 54px; }
.load-state { padding: 20px 22px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--muted); }
.error-state { border-color: #e2b7a2; background: #fff7f0; color: #a5502e; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px; padding: 5px 0 25px; }
.hero-intro { position: relative; min-width: 0; }
.hero-intro::after { display: none; }
.hero-ribbon { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--forest-soft); font: 500 9px var(--mono); letter-spacing: .1em; }
.hero-ribbon span:first-child::before { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--red); content: ""; }
.hero-ribbon span:last-child { color: var(--muted-light); }
.hero h1 { margin: 0; color: var(--forest-deep); font: 700 clamp(32px, 4vw, 48px)/1.12 var(--body); letter-spacing: -.075em; }
.hero h1 em { color: var(--forest-soft); font-style: normal; }
.hero-intro > p { max-width: 470px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.hero-actions { display: grid; grid-template-columns: 150px 290px; align-items: end; gap: 10px; }
.hero-control-block { display: grid; gap: 7px; min-width: 0; }
.control-caption { display: block; color: var(--muted); font: 500 9px var(--mono); letter-spacing: .08em; }
.select-label { display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255, 254, 249, .72); color: var(--muted); font-size: 11px; white-space: nowrap; }
.select-label > span { color: var(--muted); font: 500 9px var(--mono); }
.select-label select, .select-label input { min-width: 0; width: 100%; outline: 0; border: 0; background: transparent; color: var(--ink); font: 700 11px var(--body); }
.team-filter { border-color: var(--forest); background: var(--forest); color: #fff; }
.team-filter > span { color: rgba(255, 255, 255, .64); }
.team-filter select { color: #fff; }
.team-filter option { color: var(--ink); }
.week-switcher { display: grid; grid-template-columns: 31px minmax(0, 1fr) 31px; align-items: center; gap: 8px; min-height: 40px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-strong); }
.week-switcher button { width: 30px; height: 30px; border-radius: 5px; background: var(--paper-deep); color: var(--forest-deep); font-size: 16px; transition: background .18s ease, color .18s ease; }
.week-switcher button:hover:not(:disabled) { background: var(--lime); }
.week-selector { display: grid; min-width: 0; gap: 1px; text-align: center; }
.week-selector label { color: var(--muted); font: 500 8px var(--mono); letter-spacing: .03em; }
.week-selector select { width: 100%; outline: 0; border: 0; background: transparent; color: var(--ink); font: 700 11px var(--body); text-align: center; }
.week-selector span { overflow: hidden; color: var(--muted); font: 400 9px var(--mono); text-overflow: ellipsis; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.metric-card { --metric-color: var(--forest); position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 145px; padding: 16px 17px 14px; overflow: hidden; border: 1px solid var(--line); border-top: 2px solid var(--metric-color); border-radius: 7px; background: var(--surface); box-shadow: none; }
.metric-card::after { display: none; }
.metric-card--capacity { --metric-color: var(--blue); }
.metric-card--low { --metric-color: var(--orange); }
.metric-card--headcount { --metric-color: var(--red); }
.metric-card--classes { --metric-color: var(--forest-soft); }
.metric-top { display: none; }
.metric-index { color: var(--metric-color); font: 500 10px var(--mono); }
.metric-state { color: var(--muted-light); font: 500 8px var(--mono); letter-spacing: .08em; }
.metric-card p { margin: 0; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.metric-card strong { display: block; margin: 5px 0 0; color: var(--forest-deep); font: 700 clamp(29px, 3.1vw, 38px)/1.08 var(--body); letter-spacing: -.06em; }
.metric-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-width: 0; min-height: 34px; margin-top: auto; padding-top: 13px; }
.metric-bottom > span { min-width: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.metric-drilldown { flex: 0 0 auto; padding: 4px 0; background: transparent; color: var(--forest-soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.metric-drilldown:hover:not(:disabled) { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }
.metric-mark { position: relative; z-index: 1; color: var(--metric-color) !important; font: 500 16px var(--mono) !important; white-space: nowrap; }
.metric-mark--bars { letter-spacing: -4px; }
.cool-dot::before, .warning-dot::before { display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0; border-radius: 50%; background: var(--orange); content: ""; }
.cool-dot::before { background: var(--blue); }
.live-dot { width: 6px; height: 6px; flex-basis: 6px; box-shadow: 0 0 0 4px rgba(217, 119, 69, .16); }

.board { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-strong); box-shadow: 0 10px 28px rgba(79, 53, 35, .06); }
.board-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(430px, .9fr); align-items: end; gap: 27px; padding: 22px 25px 20px; }
.board-heading { min-width: 0; }
.section-line { display: flex; align-items: center; gap: 11px; }
.section-line span { width: 48px; height: 1px; background: var(--lime); }
.section-kicker { margin: 0 0 8px; color: var(--forest-soft); font: 500 9px var(--mono); letter-spacing: .11em; }
.board h2 { max-width: 100%; margin: 0; overflow-wrap: anywhere; color: var(--forest-deep); font: 700 clamp(20px, 2.3vw, 27px)/1.2 var(--body); letter-spacing: -.055em; }
.board h2 span { color: var(--muted); font: 500 12px var(--body); letter-spacing: 0; }
.teacher-summary { max-width: 740px; margin: 10px 0 0; color: var(--ink-soft); font-size: 11px; font-weight: 600; line-height: 1.7; overflow-wrap: anywhere; }
.teacher-class-count { display: inline-flex; align-items: center; min-height: 28px; margin: 8px 0 0; padding: 4px 10px; border: 1px solid rgba(217, 119, 69, .28); border-radius: 5px; background: #fff1e7; color: #a95735; font-size: 11px; font-weight: 800; }
.other-department-summary { max-width: 100%; margin: 8px 0 0; padding: 7px 10px; border-left: 3px solid var(--red); background: var(--red-soft); color: #a63d38; font-size: 10px; font-weight: 800; line-height: 1.45; overflow-wrap: anywhere; }
.other-department-summary.zero { border-left-color: var(--line-strong); background: var(--paper); color: var(--muted); font-weight: 600; }
.board-tools { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: end; gap: 10px; min-width: 0; }
.tool-block { display: grid; gap: 7px; min-width: 0; }
.teacher-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 7px; min-width: 0; }
.teacher-picker .select-label { width: 100%; }
.teacher-search-label input { min-width: 0; width: 76px; }
.teacher-select select { min-width: 0; width: 100%; }
.teacher-search-button { min-height: 40px; padding: 0 10px; border: 1px solid var(--forest-soft); border-radius: 7px; background: var(--forest); color: #fff; font-size: 10px; font-weight: 800; white-space: nowrap; transition: background .18s ease; }
.teacher-search-button:hover { background: var(--forest-soft); }
.teacher-match-count { grid-column: 1 / -1; justify-self: end; color: var(--muted); font: 400 9px var(--mono); white-space: nowrap; }

.board-note { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px 16px; padding: 11px 25px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 9px; }
.board-note-line { display: flex; align-items: center; min-width: 0; gap: 8px; }
.board-note-line > span:not(.live-dot) { overflow-wrap: anywhere; }
.note-separator { width: 1px; height: 13px; margin: 0 3px; background: var(--line-strong); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.l-blue { background: var(--blue); }
.l-orange { background: var(--orange); }
.l-green { background: var(--green); }
.l-gray { background: #9da59b; }
.l-red { background: var(--red); }
.unassigned-note { grid-column: 1 / -1; margin: 0; padding-top: 9px; border-top: 1px dashed var(--line-strong); color: var(--muted); font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }
.warning-text { color: #a85a31; }

.schedule-wrap { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-color: var(--forest-soft) var(--paper); scrollbar-width: thin; }
.schedule { display: grid; grid-template-columns: 158px repeat(7, minmax(150px, 1fr)); min-width: 1208px; background: var(--surface-strong); }
.schedule > div { min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.schedule > div:nth-child(8n) { border-right: 0; }
.corner, .day { min-height: 76px; padding: 15px 14px; background: #fcf8f4; }
.corner { display: flex; flex-direction: column; justify-content: center; }
.corner span { color: var(--muted); font: 500 9px var(--mono); letter-spacing: .06em; }
.corner b { margin-top: 5px; color: var(--forest-deep); font-size: 11px; }
.day { position: relative; }
.day b, .day span { display: block; }
.day b { color: var(--forest-deep); font: 700 14px var(--display); }
.day span { margin-top: 4px; color: var(--muted); font: 400 10px var(--mono); }
.day em { margin-left: 5px; padding: 2px 5px; border-radius: 3px; background: var(--lime); color: var(--forest-deep); font: 700 8px var(--body); font-style: normal; }
.weekend { background: #fff4eb; }
.time-cell { display: flex; flex-direction: column; justify-content: center; min-height: 176px; padding: 13px 14px; background: #fcf8f4; }
.time-cell b { color: var(--forest-deep); font: 500 13px var(--mono); }
.time-cell span { margin-top: 3px; color: var(--muted); font: 400 10px var(--mono); }
.time-cell small { margin-top: 8px; color: var(--muted-light); font-size: 9px; }
.cell { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 176px; padding: 10px; background: linear-gradient(90deg, transparent 0 49.6%, rgba(230, 221, 213, .55) 49.6% 50.4%, transparent 50.4%), rgba(255, 255, 255, .84); }
.cell:nth-child(8n + 1) { background-color: #fffaf7; }
.course { position: relative; display: grid; min-width: 0; min-height: 0; gap: 6px; padding: 11px 12px; overflow: hidden; border: 1px solid rgba(73, 55, 45, .12); border-left: 4px solid; border-radius: 8px; box-shadow: 0 3px 9px rgba(79, 53, 35, .06); cursor: default; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.course b { display: -webkit-box; min-width: 0; min-height: 2.55em; overflow: hidden; color: inherit; font-size: 11px; font-weight: 800; line-height: 1.28; overflow-wrap: anywhere; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.course > span { display: block; min-width: 0; overflow: hidden; color: inherit; font-size: 9px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.course-campus { font-size: 10px !important; font-weight: 800; }
.course-department { font-size: 9px !important; font-weight: 700; opacity: .86; }
.course-time { font: 400 9px var(--mono) !important; }
.course.blue { border-color: var(--blue); background: #edf1ff; color: #344fae; }
.course.orange { border-color: var(--orange); background: #fff2e7; color: #a65d2e; }
.course.green { border-color: var(--green); background: #fff1e8; color: #9a5434; }
.course.gray { border-color: #9da59b; background: #eef0ed; color: #586158; box-shadow: none; }
.course.red { border-color: var(--red); background: var(--red-soft); color: #a63d38; box-shadow: 0 4px 12px rgba(201, 76, 69, .12); }
.course:hover, .course:focus { z-index: 6; outline: 0; transform: translateY(-2px); box-shadow: 0 9px 18px rgba(79, 53, 35, .16); }

#matching-view { animation: workspace-in .42s ease both; }
.matching-hero { padding-bottom: 25px; }
.matching-hero-note { display: grid; min-width: 220px; gap: 4px; padding: 13px 15px 14px; border-left: 3px solid var(--forest); background: #fff4eb; color: var(--ink-soft); }
.matching-note-index { color: var(--forest-soft); font: 500 9px var(--mono); letter-spacing: .09em; }
.matching-hero-note strong { color: var(--ink); font-size: 12px; }
.matching-hero-note small { color: var(--muted); font-size: 10px; }
.matching-panel, .matching-results { border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-strong); box-shadow: 0 10px 28px rgba(79, 53, 35, .06); }
.matching-panel { padding: 24px 25px 21px; }
.matching-panel-heading, .matching-results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.matching-panel-heading h2, .matching-results-head h2 { margin: 0; color: var(--forest-deep); font: 700 clamp(21px, 2.4vw, 29px)/1.2 var(--body); letter-spacing: -.06em; }
.matching-snapshot { color: var(--muted-light); font: 400 9px var(--mono); white-space: nowrap; }
.matching-form { display: grid; grid-template-columns: minmax(245px, 1.35fr) minmax(190px, 1fr) minmax(230px, 1.25fr) minmax(125px, .75fr) minmax(130px, .75fr) auto; align-items: end; gap: 12px; margin-top: 22px; }
.matching-field { display: grid; min-width: 0; gap: 7px; padding: 0; border: 0; }
.matching-field--dates, .matching-field--weekdays, .matching-field--time { min-width: 0; }
.matching-date-pair, .matching-time-pair { display: grid; grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); align-items: center; gap: 5px; }
.matching-date-pair .select-label, .matching-time-pair .select-label { padding-right: 7px; padding-left: 8px; }
.matching-date-pair input, .matching-time-pair input { font-family: var(--mono) !important; font-size: 10px !important; }
.matching-arrow { color: var(--muted-light); font: 500 11px var(--mono); text-align: center; }
.weekday-picker { display: grid; grid-template-columns: repeat(7, minmax(24px, 1fr)); gap: 4px; min-height: 40px; }
.weekday-option { position: relative; display: grid; place-items: center; min-width: 0; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--paper); color: var(--muted); cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
.weekday-option:hover { border-color: var(--forest-soft); color: var(--ink); transform: translateY(-1px); }
.weekday-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.weekday-option span { font: 700 11px var(--body); }
.weekday-option input:checked + span { color: #fff; }
.weekday-option:has(input:checked) { border-color: var(--forest); background: var(--forest); box-shadow: 0 4px 10px rgba(217, 119, 69, .18); }
.matching-field > .select-label { width: 100%; }
.matching-field > .select-label select { min-width: 0; }
.matching-submit { display: inline-flex; align-items: center; justify-content: space-between; gap: 13px; min-height: 40px; padding: 0 13px 0 14px; border: 1px solid var(--forest-soft); border-radius: 7px; background: var(--forest); color: #fff; font-size: 11px; font-weight: 800; white-space: nowrap; transition: background .18s ease, transform .18s ease, box-shadow .18s ease; }
.matching-submit b { color: #ffe4d5; font-size: 16px; }
.matching-submit:hover { background: var(--forest-soft); box-shadow: 0 6px 16px rgba(169, 87, 53, .18); transform: translateY(-1px); }
.matching-validation { margin: 15px 0 0; padding: 9px 11px; border-left: 3px solid var(--red); background: var(--red-soft); color: #a63d38; font-size: 10px; font-weight: 700; }
.matching-results { margin-top: 22px; padding: 24px 25px 28px; }
.matching-results-head { align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.matching-result-counts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.result-count { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 3px 8px; border-radius: 4px; font-size: 9px; white-space: nowrap; }
.result-count b { font: 700 13px var(--mono); }
.result-count--available { background: #edf3ff; color: #344fae; }
.result-count--partial { background: #fff1e7; color: #a95735; }
.result-count--excluded { background: var(--paper); color: var(--muted); }
.matching-group { margin-top: 23px; }
.matching-group + .matching-group { margin-top: 28px; }
.matching-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 11px; }
.matching-group-heading > div { display: flex; align-items: center; gap: 8px; }
.matching-group-heading h3 { margin: 0; color: var(--ink); font-size: 15px; letter-spacing: -.025em; }
.matching-group-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.matching-group-mark { width: 8px; height: 8px; border-radius: 2px; background: var(--blue); }
.matching-group--partial .matching-group-mark { background: var(--orange); }
.matching-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.matching-group-empty { grid-column: 1 / -1; margin: 0; padding: 15px; border: 1px dashed var(--line); background: var(--paper); color: var(--muted); font-size: 10px; }
.matching-card { min-width: 0; padding: 13px 14px 12px; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; background: #fffdfb; transition: border-color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease; animation: rise-in .3s ease both; }
.matching-card--partial { border-left-color: var(--orange); background: #fffaf6; }
.matching-card:hover { border-color: var(--line-strong); box-shadow: 0 7px 17px rgba(79, 53, 35, .09); transform: translateY(-2px); }
.matching-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.matching-teacher-link { min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 14px; font-weight: 800; text-align: left; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; transition: color .18s ease, text-decoration-color .18s ease; }
.matching-teacher-link:hover, .matching-teacher-link:focus-visible { color: var(--forest-soft); text-decoration-color: currentColor; outline: 0; }
.matching-teacher-link::after { display: inline-block; margin-left: 5px; color: var(--forest-soft); content: '↗'; font: 500 13px var(--mono); }
.matching-card-stats { flex: 0 0 auto; text-align: right; }
.matching-card-stats strong, .matching-card-stats span { display: block; }
.matching-card-stats strong { color: var(--forest-deep); font: 700 17px var(--mono); letter-spacing: -.07em; }
.matching-card-stats span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.matching-card-meta { margin-top: 7px; color: var(--muted); font: 400 9px/1.5 var(--mono); overflow-wrap: anywhere; }
.matching-card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.matching-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 4px; background: var(--paper); color: var(--muted); font-size: 9px; font-weight: 700; }
.matching-tag--conflict { background: #fff1e7; color: #a95735; }
.matching-tag--risk { background: var(--red-soft); color: #a63d38; }
.matching-details { margin-top: 9px; border-top: 1px dashed var(--line-strong); color: var(--muted); font-size: 9px; }
.matching-details summary { padding-top: 8px; cursor: pointer; color: var(--forest-soft); font-weight: 800; }
.matching-details summary::marker { color: var(--forest-soft); }
.matching-details ul { display: grid; gap: 5px; margin: 8px 0 0; padding: 0 0 0 15px; }
.matching-details li { padding-left: 1px; line-height: 1.45; }
.matching-details li strong { color: var(--ink-soft); font-weight: 800; }
.matching-empty { display: grid; place-items: center; gap: 6px; min-height: 135px; margin-top: 18px; border: 1px dashed var(--line-strong); background: var(--paper); color: var(--muted); text-align: center; }
.matching-empty strong { color: var(--ink-soft); font-size: 13px; }
.matching-empty span { font-size: 10px; }

.floating-tooltip { position: fixed; z-index: 30; width: min(330px, calc(100vw - 24px)); padding: 14px; border: 1px solid var(--forest-soft); border-radius: 7px; background: var(--forest-deep); color: #fff; box-shadow: 0 15px 28px rgba(79, 53, 35, .2); pointer-events: none; }
.floating-tooltip strong { display: block; color: var(--lime); font: 700 13px/1.45 var(--body); overflow-wrap: anywhere; }
.floating-tooltip p { margin: 5px 0 10px; color: rgba(255, 255, 255, .67); font-size: 10px; }
.floating-tooltip dl { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 5px 9px; margin: 0; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .16); font-size: 10px; }
.floating-tooltip dt { color: rgba(255, 255, 255, .55); }
.floating-tooltip dd { min-width: 0; margin: 0; color: #fff; font: 400 9px var(--mono); overflow-wrap: anywhere; }

.board-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 55px; padding: 0 30px; color: var(--muted); font-size: 10px; }
.board-footer > span { min-width: 0; overflow-wrap: anywhere; }
.board-footer-actions { display: flex; align-items: center; gap: 18px; white-space: nowrap; }
.board-footer-actions > span { color: var(--muted-light); font: 400 9px var(--mono); }
.board-footer button { border: 0; background: transparent; color: var(--forest-soft); font-size: 10px; font-weight: 800; }
.board-footer button:hover { color: var(--red); }
.board-footer button b { margin-left: 5px; color: var(--forest); font-size: 14px; }

.drawer-backdrop { position: fixed; z-index: 10; inset: 0; background: rgba(43, 37, 33, .3); backdrop-filter: blur(5px); }
.load-drawer { position: fixed; z-index: 11; top: 0; right: 0; display: flex; flex-direction: column; width: min(430px, 94vw); height: 100vh; padding: 30px 26px; background: var(--surface-strong); box-shadow: -18px 0 46px rgba(79, 53, 35, .2); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.drawer-head h2 { margin: 0; color: var(--forest-deep); font: 700 25px var(--display); letter-spacing: -.04em; }
.drawer-close { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: var(--paper-deep); color: var(--forest); font-size: 22px; line-height: 1; }
.drawer-close:hover { background: var(--lime); }
.drawer-summary { margin: 14px 0 20px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.load-list { display: grid; gap: 9px; margin: 0; padding-left: 25px; overflow: auto; }
.load-list li { padding-left: 4px; }
.load-person { display: flex; flex-direction: column; width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.load-person:hover, .load-person:focus { border-color: var(--forest-soft); background: #fff4eb; outline: 0; transform: translateX(2px); }
.load-person strong { font-size: 13px; }
.load-person span { margin-top: 5px; color: var(--muted); font: 400 10px/1.55 var(--mono); overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 20; right: 25px; bottom: 25px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 15px; border: 1px solid rgba(217, 119, 69, .35); border-radius: 7px; background: var(--forest-deep); color: #fff; box-shadow: 0 12px 28px rgba(79, 53, 35, .24); font-size: 11px; opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
.toast.shown { opacity: 1; transform: translateY(0); }

#dashboard-view { animation: workspace-in .42s ease both; }
.metric-card { animation: rise-in .38s ease both; }
.metric-card:nth-child(2) { animation-delay: .04s; }
.metric-card:nth-child(3) { animation-delay: .08s; }
.metric-card:nth-child(4) { animation-delay: .12s; }
.board { animation: rise-in .48s .12s ease both; }
.course { animation: course-in .28s ease both; }
.status-dot, .topbar-signal { animation: signal-pulse 2.6s ease-in-out infinite; }

@keyframes workspace-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes course-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes signal-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(217, 119, 69, .14); }
  50% { box-shadow: 0 0 0 6px rgba(217, 119, 69, .03); }
}

@media (max-width: 1250px) {
  .content { padding-right: 32px; padding-left: 32px; }
  .topbar { padding-right: 32px; padding-left: 32px; }
  .hero { gap: 25px; }
  .hero-actions { grid-template-columns: 135px 270px; }
  .board-head { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .board-tools { grid-template-columns: 116px minmax(360px, 1fr); max-width: 680px; justify-self: end; width: 100%; }
  .matching-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .matching-field--dates { grid-column: span 2; }
  .matching-field--weekdays { grid-column: span 1; }
  .matching-field--time { grid-column: span 2; }
  .matching-submit { min-width: 118px; }
}

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .hero-actions { grid-template-columns: 150px minmax(250px, 290px); justify-self: start; }
  .matching-hero-note { justify-self: start; }
  .matching-list { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { display: block; }
  .rail { position: relative; width: 100%; height: auto; min-height: 0; padding: 18px 18px 15px; overflow: visible; }
  .rail::after { display: none; }
  .rail-section-label { display: none; }
  .rail nav { display: flex; order: 3; width: 100%; margin-top: 16px; gap: 6px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; grid-template-columns: 21px auto auto; min-height: 45px; padding: 7px 9px; }
  .nav-copy small { display: none; }
  .nav-copy b { font-size: 11px; }
  .nav-item em { font-size: 8px; }
  .rail-status { margin: 0 0 0 auto; padding: 0; border-top: 0; }
  .rail-year { display: none; }
  .workspace { width: 100%; margin-left: 0; }
  .topbar { min-height: 58px; padding: 0 18px; }
  .topbar-context span:not(.topbar-signal), .topbar-context i { display: none; }
  .content { padding: 30px 18px 42px; }
  .hero { padding-top: 0; }
  .hero h1 { font-size: clamp(39px, 12vw, 58px); }
  .hero-actions { grid-template-columns: 1fr; width: 100%; }
  .week-switcher { width: 100%; }
  .matching-hero { gap: 19px; }
  .matching-hero-note { width: 100%; }
  .matching-panel, .matching-results { padding-right: 18px; padding-left: 18px; }
  .matching-form { grid-template-columns: 1fr; gap: 13px; }
  .matching-field--dates, .matching-field--weekdays, .matching-field--time { grid-column: auto; }
  .matching-submit { justify-content: center; }
  .matching-results-head { align-items: flex-start; flex-direction: column; }
  .matching-result-counts { justify-content: flex-start; }
  .matching-group-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .metrics { gap: 9px; margin-bottom: 18px; }
  .metric-card { min-height: 156px; padding: 15px; }
  .metric-card p { margin-top: 13px; }
  .metric-card strong { font-size: 32px; }
  .metric-bottom { align-items: flex-start; flex-direction: column; gap: 5px; }
  .metric-mark { display: none; }
  .board-head { padding: 22px 18px 20px; }
  .board-tools { grid-template-columns: 1fr; max-width: none; justify-self: stretch; }
  .teacher-picker { grid-template-columns: minmax(0, 1fr) auto; }
  .teacher-select { grid-column: 1 / -1; }
  .teacher-match-count { justify-self: start; }
  .board-note { grid-template-columns: 1fr; padding: 12px 18px; }
  .legend { justify-content: flex-start; }
  .board-footer { align-items: flex-start; flex-direction: column; gap: 6px; padding: 13px 18px; }
  .board-footer-actions { width: 100%; justify-content: space-between; }
}

@media (max-width: 520px) {
  .top-actions .icon-button { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 142px; }
  .metric-bottom { flex-direction: row; align-items: flex-end; }
  .board h2 span { display: block; margin-top: 4px; }
  .teacher-picker { grid-template-columns: 1fr; }
  .teacher-search-button, .teacher-select { grid-column: auto; }
  .teacher-match-count { grid-column: auto; }
  .board-note-line { align-items: flex-start; flex-wrap: wrap; }
  .note-separator { display: none; }
  .legend { gap: 6px 9px; }
  .legend-item { font-size: 9px; }
  .board-footer-actions { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
