:root {
  color-scheme: light;
  --blue: #236a9b;
  --blue-deep: #173f5c;
  --ink: #203747;
  --muted: #637886;
  --line: #d7e1e7;
  --canvas: #f2f6f8;
  --white: #fff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Arial, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.site-header {
  min-height: 66px;
  display: flex;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1320px) / 2));
  background: var(--blue-deep);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #ffffff55;
  border-radius: 4px;
  background: #ffffff12;
  font-size: 13px;
}
.brand small { display: block; margin-top: 1px; color: #c4d9e6; font-size: 11px; font-weight: 500; }
.analytics-consent { position: fixed; z-index: 30; right: 18px; bottom: 18px; width: min(440px, calc(100% - 28px)); padding: 14px; border: 1px solid #c9d9e3; border-radius: 5px; background: #fff; box-shadow: 0 8px 28px #173f5c24; }
.analytics-consent p { margin: 0 0 11px; color: #435f70; font-size: 13px; }
.analytics-consent>div { display: flex; justify-content: flex-end; gap: 8px; }
.analytics-consent button { min-height: 34px; padding: 0 11px; border: 1px solid #c8d6df; border-radius: 4px; background: #fff; color: #36586f; font-size: 12px; }
.analytics-consent #analytics-accept { border-color: var(--blue); background: var(--blue); color: #fff; }

.page-shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 48px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.eyebrow { color: #5c7d91; font-size: 11px; font-weight: 700; }
h1 { margin: 4px 0 4px; font-size: 30px; line-height: 1.3; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.snapshot-note { padding-bottom: 3px; color: #536d7c; font-size: 13px; font-weight: 600; text-align: right; }

.search-row { position: relative; display: block; margin: 0 0 18px; }
.search-row input {
  width: 100%;
  height: 52px;
  padding: 0 108px 0 48px;
  border: 1px solid #bfcfd9;
  border-radius: 4px;
  outline: none;
  background: var(--white);
  color: var(--ink);
  font-size: 15px;
}
.search-row input::placeholder { color: #788b97; }
.search-row input:focus, .filter-grid select:focus { border-color: #4783a8; box-shadow: 0 0 0 3px #236a9b18; }
.search-symbol { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: #55788e; font-size: 21px; }
.search-hint { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: #718591; font-size: 12px; }

.filter-panel { padding: 13px 0 17px; border-top: 1px solid #d3dfe5; border-bottom: 1px solid #d3dfe5; }
.filter-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: #304f62; font-size: 14px; font-weight: 700; }
.filter-heading button { padding: 3px 0; border: 0; background: none; color: var(--blue); font-size: 13px; font-weight: 600; }
.filter-heading button:hover { color: var(--blue-deep); }
.filter-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.filter-grid label { display: grid; gap: 5px; min-width: 0; color: #536c7a; font-size: 12px; font-weight: 600; }
.filter-grid select {
  width: 100%;
  height: 40px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid #cbd8df;
  border-radius: 3px;
  outline: none;
  background: var(--white);
  color: #294354;
  font-size: 13px;
}

.results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 11px; color: #5d7380; font-size: 13px; }
.results-toolbar #result-count { color: #29485c; font-size: 15px; font-weight: 700; }
.results-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.programme-row {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #d5e0e6;
  border-radius: 4px;
  background: var(--white);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.programme-row:hover { border-color: #9eb8c8; box-shadow: 0 3px 12px #183d520d; }
.programme-university {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 13px;
  border-bottom: 1px solid #e6edf1;
  background: #f8fafb;
  color: #355c74;
  font-size: 12px;
  font-weight: 700;
}
.programme-university span { max-width: 58%; overflow: hidden; color: #657b88; font-size: 11px; font-weight: 500; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.programme-info { flex: 1; padding: 13px 14px 9px; }
.programme-info h2 { min-height: 48px; margin: 0; color: #203d50; font-size: 16px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.teaching-badge { display: inline-block; vertical-align: 2px; padding: 2px 6px; border-radius: 3px; background: #e6f3ef; color: #286653; font-size: 11px; font-weight: 700; white-space: nowrap; }
.approval-badge { display: inline-block; vertical-align: 2px; padding: 2px 6px; border-radius: 3px; background: #fff3df; color: #87550b; font-size: 11px; font-weight: 700; white-space: nowrap; }
.programme-en { min-height: 36px; margin: 4px 0 8px; color: #657987; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.programme-department { margin: 0; color: #506b7a; font-size: 12px; line-height: 1.55; }
.programme-facts { display: grid; grid-template-columns: 1.15fr 1fr .8fr; gap: 8px; padding: 10px 14px; border-top: 1px solid #e7edf1; }
.programme-facts > div { min-width: 0; display: grid; align-content: start; gap: 3px; }
.programme-facts span { color: #71838d; font-size: 11px; }
.programme-facts b { color: #2d4656; font-size: 12px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.detail-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 14px;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid #e7edf1;
  background: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}
.detail-button span { font-size: 17px; }
.detail-button:hover { color: var(--blue-deep); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 22px 0; }
.pager button { min-width: 88px; height: 38px; border: 1px solid #bfced8; border-radius: 3px; background: #fff; color: #365a70; font-size: 13px; font-weight: 600; }
.pager button:disabled { color: #8c9ba4; background: #f5f7f8; cursor: default; }
.pager span { min-width: 54px; color: #536c7a; font-size: 13px; text-align: center; }
.source-note { margin: 6px 0 0; padding-top: 12px; border-top: 1px solid #d6e1e6; color: #647986; font-size: 12px; line-height: 1.7; }
.empty-state, .loading-state { grid-column: 1 / -1; padding: 38px 18px; background: #fff; text-align: center; color: #617783; }

.programme-dialog { width: min(780px, calc(100% - 28px)); max-height: 88vh; overflow: auto; padding: 0; border: 1px solid #cbd8df; border-radius: 5px; background: #fff; color: var(--ink); box-shadow: 0 18px 60px #102c4033; }
.programme-dialog::backdrop { background: #102a3c80; }
.dialog-content { padding: 24px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.detail-head span { color: #55788e; font-size: 12px; font-weight: 600; }
.detail-head h2 { margin: 5px 0 3px; font-size: 22px; line-height: 1.4; }
.detail-head p { margin: 0; color: #627884; font-size: 13px; }
.dialog-close { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid #d2dde3; border-radius: 3px; background: #f6f8f9; color: #405d6d; font-size: 22px; line-height: 1; }
.detail-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px 0; }
.detail-summary > div { display: grid; gap: 4px; padding: 3px 10px; border-left: 2px solid #72a1bc; }
.detail-summary span, .requirement-list dt { color: #667c88; font-size: 12px; }
.detail-summary b, .requirement-list dd { color: #2d4b60; font-size: 14px; font-weight: 700; }
.detail-status { margin: 0 0 12px; color: #536f80; font-size: 13px; }
.detail-section { padding: 14px 0; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 11px; font-size: 16px; }
.detail-field { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 14px; padding: 11px 0; border-top: 1px solid #e9eef1; }
.detail-field h4 { margin: 0; color: #566f7d; font-size: 13px; font-weight: 600; }
.detail-entry { min-width: 0; margin-bottom: 11px; }
.detail-entry:last-child { margin-bottom: 0; }
.detail-entry strong { font-size: 13px; }
.detail-entry p { margin: 4px 0; color: #3d5665; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-entry small { display: block; margin-top: 4px; color: #6d808b; font-size: 12px; }
.detail-entry a { display: inline-block; margin-top: 6px; color: var(--blue); font-size: 12px; font-weight: 600; }
.requirement-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.requirement-list > div { display: grid; gap: 4px; padding: 7px 0; border-bottom: 1px solid #e4ebef; }
.requirement-list dd { margin: 0; }
.detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 15px; border-top: 1px solid var(--line); }
.detail-actions small, .source-missing { color: #637985; font-size: 12px; line-height: 1.6; }
.official-link { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 3px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 700; }
.official-link:hover { background: var(--blue-deep); }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .site-header { min-height: 60px; padding: 0 16px; }
  .brand { gap: 9px; font-size: 16px; }
  .brand-mark { width: 32px; height: 32px; font-size: 12px; }
  .brand small { font-size: 10px; }
  .page-shell { width: calc(100% - 32px); padding: 22px 0 34px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 7px; margin-bottom: 16px; }
  h1 { font-size: 26px; }
  .page-heading p { font-size: 13px; }
  .snapshot-note { padding: 0; font-size: 12px; text-align: left; }
  .search-row { margin-bottom: 14px; }
  .search-row input { height: 48px; padding-right: 16px; font-size: 14px; }
  .search-hint { display: none; }
  .filter-panel { padding: 11px 0 14px; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filter-grid label { font-size: 12px; }
  .filter-grid select { height: 40px; padding: 0 8px; font-size: 12px; }
  .results-toolbar { align-items: flex-start; flex-direction: column; gap: 2px; padding: 15px 0 9px; }
  .results-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .programme-info { padding: 12px 13px 8px; }
  .programme-info h2 { min-height: 0; font-size: 16px; }
  .programme-en { min-height: 0; margin-bottom: 7px; }
  .programme-facts { grid-template-columns: 1.1fr 1fr .8fr; gap: 6px; padding: 9px 13px; }
  .programme-facts span { font-size: 10px; }
  .programme-facts b { font-size: 11px; }
  .detail-button { margin: 0 13px; }
  .dialog-content { padding: 18px; }
  .detail-head h2 { font-size: 19px; }
  .detail-field { grid-template-columns: 1fr; gap: 5px; }
  .detail-summary { gap: 7px; }
  .detail-summary > div { padding: 3px 7px; }
  .detail-summary b, .requirement-list dd { font-size: 12px; }
  .detail-actions { align-items: flex-start; flex-direction: column; }
  .requirement-list { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 360px) {
  .page-shell { width: calc(100% - 24px); }
  .filter-grid { gap: 9px 7px; }
  .filter-grid select { padding: 0 5px; font-size: 11px; }
  .programme-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
