:root {
  --wine: #8b1f2f;
  --wine-deep: #641523;
  --gold: #c6a15b;
  --cream: #f6f1e8;
  --paper: #ece3d6;
  --white: #fffdf9;
  --ink: #1d1916;
  --ink-soft: #6f655c;
  --rule: rgba(29, 25, 22, .14);
  --serif: 'Noto Serif TC', serif;
  --sans: 'Noto Sans TC', sans-serif;
  --latin: 'Cormorant Garamond', serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }

.utility-inner,
.nav-inner,
.page-shell {
  width: min(1240px, calc(100% - 48px));
  margin-inline: auto;
}

.utility-bar {
  background: var(--ink);
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  letter-spacing: .04em;
}
.utility-inner {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.utility-links { display: flex; gap: 22px; }
.utility-links a { text-decoration: none; }
.utility-links a:hover { color: #fff; }

.main-nav {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in oklch, var(--cream) 94%, white);
}
.nav-inner {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand img {
  display: block;
  width: 290px;
  height: auto;
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-link.primary { background: var(--wine); color: #fff; }
.nav-link.primary:hover { background: var(--wine-deep); }
.nav-link.ghost:hover { background: var(--paper); }

.page-shell { padding-bottom: 72px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  gap: 56px;
  align-items: stretch;
  padding: 56px 0 42px;
}
.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 300px;
  padding: 10px 0 12px;
}
.eyebrow,
.section-kicker,
.tool-kicker {
  font-family: var(--latin);
  font-style: italic;
  text-transform: uppercase;
}
.eyebrow {
  margin-bottom: 16px;
  color: var(--wine);
  font-size: 13px;
  letter-spacing: .24em;
}
.hero h1 {
  max-width: 690px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 4.2vw, 66px);
  line-height: 1.16;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.hero-lead {
  max-width: 620px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.8;
  text-wrap: pretty;
}
.semester-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 30px;
  color: var(--ink-soft);
  font-size: 13px;
}
.semester-line strong { color: var(--ink); font-weight: 600; }

.tool-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 320px;
  padding: 34px 36px 30px;
  background: var(--wine);
  color: #fff;
}
.tool-panel::after {
  content: 'E118';
  position: absolute;
  right: -8px;
  top: -48px;
  color: rgba(255, 255, 255, .06);
  font-family: var(--latin);
  font-size: 170px;
  font-style: italic;
  line-height: 1;
  pointer-events: none;
}
.tool-kicker {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  letter-spacing: .2em;
}
.tool-title {
  position: relative;
  z-index: 1;
  margin: 19px 0 0;
  font-family: var(--serif);
  font-size: clamp(26px, 2.5vw, 36px);
  line-height: 1.35;
  letter-spacing: -.02em;
}
.tool-desc {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 12px 0 0;
  color: rgba(255, 255, 255, .78);
  font-size: 14px;
  line-height: 1.75;
}
.tool-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}
.tool-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, .38);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.tool-button.main { border-color: #fff; background: #fff; color: var(--wine-deep); }
.tool-button:hover { border-color: var(--gold); }
.tool-button.main:hover { background: var(--gold); border-color: var(--gold); }
.tool-download {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: rgba(255, 255, 255, .78);
  text-underline-offset: 4px;
  font-size: 13px;
}

.directory {
  border-top: 1px solid var(--rule);
  padding-top: 30px;
}
.directory-head {
  display: grid;
  grid-template-columns: minmax(250px, .7fr) minmax(440px, 1.3fr);
  gap: 40px;
  align-items: end;
}
.section-kicker {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .23em;
}
.directory h2,
.past-section h2 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: clamp(25px, 2.7vw, 36px);
  line-height: 1.35;
  letter-spacing: -.02em;
}
.search-area { display: grid; gap: 12px; }
.search-box { position: relative; }
.search-box svg {
  position: absolute;
  left: 17px;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  min-height: 52px;
  padding: 0 18px 0 50px;
  border: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
}
.search-box input:focus { border-color: var(--wine); box-shadow: inset 0 -2px var(--wine); }
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.filter-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.filter-button[aria-pressed='true'] { border-color: var(--wine); background: var(--wine); color: #fff; }
.result-count { margin-left: auto; color: var(--ink-soft); font-size: 12px; }

.course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 24px;
  border: 1px solid var(--rule);
  background: var(--rule);
}
.course-card {
  min-height: 270px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 24px 24px 21px;
  background: var(--white);
  color: inherit;
  text-decoration: none;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.course-card:hover {
  position: relative;
  z-index: 2;
  background: #fff;
  transform: translateY(-4px);
  box-shadow: 0 14px 28px rgba(60, 35, 23, .12);
}
.course-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.course-code {
  color: var(--wine);
  font-family: var(--latin);
  font-size: 13px;
  font-style: italic;
  letter-spacing: .12em;
}
.course-type { color: var(--ink-soft); font-size: 11px; letter-spacing: .06em; }
.course-main { padding: 20px 0 13px; }
.course-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.48;
  letter-spacing: -.015em;
  text-wrap: pretty;
}
.course-teacher { margin-top: 8px; color: var(--ink-soft); font-size: 14px; }
.course-signals { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 14px; }
.signal {
  padding: 2px 8px;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 11px;
  white-space: nowrap;
}
.signal.report { border-color: rgba(139, 31, 47, .3); color: var(--wine); }
.signal.syllabus { border-color: rgba(198, 161, 91, .6); color: #80641d; }
.signal.empty { border-style: dashed; }
.course-meta {
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.course-time { color: var(--ink-soft); font-size: 12px; line-height: 1.65; }
.course-time strong { display: block; color: var(--ink); font-weight: 500; }
.course-arrow {
  flex: 0 0 auto;
  color: var(--wine);
  font-family: var(--latin);
  font-size: 24px;
  line-height: 1;
  transition: transform .18s ease;
}
.course-card:hover .course-arrow { transform: translateX(5px); }

.empty-state {
  display: none;
  padding: 54px 20px;
  text-align: center;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-top: 0;
  background: var(--white);
}

.past-section { padding-top: 48px; }
.past-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.past-note { color: var(--ink-soft); font-size: 13px; }
.catalog-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--rule);
  text-decoration: none;
  font-size: 13px;
}
.catalog-link:hover { border-color: var(--wine); color: var(--wine); }
details.past { margin-top: 14px; }
details.past > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--rule);
  background: var(--white);
  font-family: var(--serif);
  font-size: 15px;
}
details.past > summary::-webkit-details-marker { display: none; }
details.past > summary .n {
  color: var(--ink-soft);
  font-family: var(--latin);
  font-size: 13px;
  font-style: italic;
}
.rows { border: 1px solid var(--rule); border-top: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 16px;
  color: inherit;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 253, 249, .7);
  text-decoration: none;
  font-size: 14px;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--white); }
.row .nm { flex: 1; min-width: 0; font-family: var(--serif); line-height: 1.45; }
.row .badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border: 1px solid rgba(139, 31, 47, .3);
  color: var(--wine);
  font-size: 11px;
  white-space: nowrap;
}
.row .badge.v { border-color: rgba(198, 161, 91, .6); color: #80641d; }
.row .arrow { color: var(--ink-soft); }

.upload-link {
  min-height: 74px;
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 20px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}
.upload-link:hover { background: var(--paper); }
.upload-link strong { font-family: var(--serif); font-size: 17px; }
.upload-link span { color: var(--ink-soft); font-size: 13px; }
.upload-link b { color: var(--wine); font-size: 18px; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 40px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .08em;
}

@media (max-width: 1040px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .hero-copy { min-height: 0; }
  .directory-head { grid-template-columns: 1fr; gap: 20px; }
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .utility-inner,
  .nav-inner,
  .page-shell { width: min(100% - 28px, 1240px); }
  .utility-inner { min-height: 38px; }
  .utility-inner > span { display: none; }
  .utility-links { width: 100%; justify-content: space-between; gap: 10px; }
  .nav-inner { min-height: 70px; }
  .brand img { width: 205px; }
  .nav-link.ghost { display: none; }
  .nav-link { min-height: 42px; padding-inline: 13px; font-size: 13px; }
  .hero { padding: 36px 0 34px; }
  .hero h1 { font-size: 38px; }
  .hero-lead { margin-top: 18px; font-size: 15px; }
  .semester-line { margin-top: 22px; }
  .tool-panel { min-height: 0; padding: 28px 23px 24px; }
  .tool-title { font-size: 27px; }
  .tool-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tool-button { min-width: 0; padding-inline: 8px; font-size: 13px; white-space: nowrap; }
  .tool-download { grid-column: 1 / -1; justify-content: center; }
  .directory { padding-top: 26px; }
  .filter-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; scrollbar-width: none; }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-button { flex: 0 0 auto; }
  .result-count { display: none; }
  .course-grid { grid-template-columns: 1fr; }
  .course-card { min-height: 252px; }
  .past-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .row { padding-inline: 13px; }
  .row .badge { display: none; }
  footer { flex-direction: column; gap: 5px; }
}
