:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #6f7b76;
  --line: #e3eae6;
  --paper: #ffffff;
  --wash: #f4f7f5;
  --green: #147c62;
  --green-dark: #0d5e4b;
  --green-soft: #e9f4ef;
  --row-height: 92px;
  --shadow: 0 14px 34px rgba(31, 54, 47, 0.07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--wash); }
body {
  margin: 0;
  color: var(--ink);
  background: #f4f7f5;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 50px 0 70px; }
.masthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding: 4px 8px 36px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 42px; line-height: 1.1; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 23px; line-height: 1.3; letter-spacing: 0; }
.subtitle { margin: 0; color: var(--muted); font-size: 15px; }
.grade-mark { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid #bdd8cd; border-radius: 8px; color: var(--green-dark); background: #fff; font-family: Georgia, serif; font-size: 28px; font-weight: 700; }

.query-panel, .result-section { background: var(--paper); box-shadow: var(--shadow); }
.query-panel { padding: 28px 30px; border-top: 4px solid var(--green); border-radius: 8px; }
.section-heading, .result-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.section-heading { margin-bottom: 22px; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field span { color: var(--muted); font-size: 13px; font-weight: 700; }
select { width: 100%; min-height: 48px; padding: 0 38px 0 13px; border: 1px solid #d5dfda; border-radius: 4px; color: var(--ink); background-color: #fff; outline: none; }
select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 124, 98, 0.13); }
select:disabled { color: #a0aaa5; background-color: #f5f7f6; cursor: not-allowed; }
.selection-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.reset-button { min-height: 36px; padding: 0 14px; border: 1px solid #cbd8d1; border-radius: 4px; color: #53645d; background: #fff; font-size: 13px; }
.reset-button:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }

.result-section { min-height: 280px; margin-top: 24px; border-radius: 8px; overflow: hidden; }
.empty-state { min-height: 280px; display: grid; place-items: center; padding: 44px 20px; text-align: center; }
.empty-icon { color: var(--green); font-size: 44px; line-height: 1; }
.empty-state h2 { margin: 22px 0 8px; font-size: 19px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; }
.schedule-view { padding: 28px 30px 30px; }
.result-heading { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.result-heading h2 { max-width: 760px; word-break: break-all; }
.result-meta { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.result-badge { flex: 0 0 auto; min-height: 30px; padding: 0 11px; display: inline-flex; align-items: center; border-radius: 999px; color: #6e5722; background: #f8f1dc; font-size: 12px; font-weight: 700; }

.schedule-scroll { width: 100%; padding-top: 22px; overflow-x: auto; overscroll-behavior-x: contain; }
.schedule-table { width: 100%; min-width: 760px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.schedule-header, .schedule-body { display: grid; grid-template-columns: 55px repeat(5, minmax(0, 1fr)); }
.schedule-header { min-height: 54px; background: #f6faf7; }
.time-head, .day-head, .time-cell, .day-slot { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.schedule-header > :last-child, .schedule-body > :last-child { border-right: 0; }
.time-head, .day-head { display: flex; align-items: center; justify-content: center; color: #253832; font-size: 13px; font-weight: 800; }
.day-head { color: var(--green-dark); }
.schedule-body { min-height: calc(var(--row-height) * 12); }
.time-column, .day-column { position: relative; min-width: 0; }
.time-cell { height: var(--row-height); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: #88938e; background: #fbfcfb; }
.period-no { color: #263832; font-size: 15px; line-height: 1; }
.period-caption { font-size: 10px; white-space: nowrap; }
.day-slot { height: var(--row-height); position: relative; background: #fff; }
.course-stack { position: absolute; left: 0; right: 0; z-index: 2; display: flex; flex-direction: column; gap: 4px; padding: 0 5px; }
.course-block { min-height: 0; flex: 1 1 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 6px; padding: 9px 8px; overflow: hidden; border: 0; border-radius: 7px; color: #17211f; text-align: left; box-shadow: 0 6px 13px rgba(31, 54, 47, 0.09); }
.course-block:hover, .course-block:focus-visible { filter: brightness(0.97); outline: 2px solid rgba(20, 124, 98, 0.55); outline-offset: 1px; }
.course-name, .course-room { display: block; width: 100%; overflow: hidden; }
.course-name { font-size: 13px; font-weight: 800; line-height: 1.35; }
.course-room { color: rgba(23, 33, 31, 0.73); font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.course-block.green { background: #b8d5be; }
.course-block.blue { background: #becae3; }
.course-block.olive { background: #d9d7a6; }
.course-block.rose { background: #e1bec1; }
.course-block.teal { background: #add3cc; }
.course-block.lilac { background: #d5c2d6; }
.source-note { margin: 19px 0 0; color: #89958f; font-size: 12px; line-height: 1.7; }

.course-dialog { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(18, 31, 27, 0.48); }
.course-dialog[hidden] { display: none; }
.dialog-panel { width: min(440px, 100%); padding: 25px; border-radius: 8px; background: #fff; box-shadow: 0 22px 58px rgba(14, 24, 21, 0.2); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-heading h2 { padding-right: 4px; word-break: break-word; }
.dialog-close { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid #dfe8e3; border-radius: 50%; color: #53645d; background: #f4f7f5; font-size: 25px; line-height: 1; }
.dialog-close:hover { color: var(--green-dark); border-color: #afd0c0; background: var(--green-soft); }
.dialog-details { margin-top: 20px; border-top: 1px solid var(--line); }
.detail-row { min-height: 49px; display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.detail-label { color: var(--muted); font-size: 13px; }
.detail-value { color: var(--ink); font-size: 14px; font-weight: 700; word-break: break-word; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; padding: 10px 15px; border-radius: 4px; color: #fff; background: #23313f; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 10px); transition: 0.2s ease; pointer-events: none; font-size: 13px; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  :root { --row-height: 82px; }
  .page-shell { width: min(100% - 24px, 560px); padding-top: 28px; }
  .masthead { gap: 16px; padding: 4px 4px 25px; }
  h1 { font-size: 34px; }
  .subtitle { font-size: 13px; }
  .grade-mark { width: 56px; height: 56px; font-size: 22px; }
  .query-panel, .schedule-view { padding: 20px; }
  .field-grid { grid-template-columns: 1fr; gap: 12px; }
  .result-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .result-badge { align-self: flex-start; }
  .schedule-scroll { margin-right: -20px; padding-right: 20px; }
  .schedule-table { min-width: 760px; }
  .course-name { font-size: 12px; }
  .course-room { font-size: 10px; }
  .dialog-panel { padding: 21px; }
}
