/* Shared base for every page. Neutral palette; blue/amber/green are accents only. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --subtle: #f4f4f5;        /* light gray tags, hovers */
  --ink: #27272a;           /* dark buttons */
  --ink-text: #ffffff;
  --blue: #3b82f6;
  --blue-text: #2563eb;
  --blue-soft: #eff6ff;
  --blue-line: #bfdbfe;
  --amber: #f59e0b;
  --amber-text: #b45309;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --surface: #141416;
    --text: #fafafa;
    --muted: #a1a1aa;
    --faint: #71717a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --subtle: #1f1f23;
    --ink: #fafafa;
    --ink-text: #18181b;
    --blue: #60a5fa;
    --blue-text: #93c5fd;
    --blue-soft: #172036;
    --blue-line: #1e3a8a;
    --amber: #fbbf24;
    --amber-text: #fbbf24;
    --green: #4ade80;
    --red: #f87171;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
header, main, footer { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
a { color: var(--blue-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---- Top bar + page title ---------------------------------------------- */
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; margin-right: 12px; padding: 5px 0 !important; color: var(--text) !important; font-weight: 600 !important; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { background: none !important; }
.brand-logo { width: 24px; height: 24px; border-radius: 50%; flex: none; display: block; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--ink); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--blue); }
.nav a, .nav b {
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--subtle); text-decoration: none; }
.nav b { color: var(--text); background: var(--subtle); }
.lang-switch {
  margin-left: auto;
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--subtle);
  border-radius: 8px;
}
.lang-switch button {
  white-space: nowrap;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

h1 { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 6px 0 20px; max-width: 680px; }

/* ---- Form controls ------------------------------------------------------ */
input[type="search"], select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 0;
  height: 34px;
  transition: border-color .12s, box-shadow .12s;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2371717a' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
input[type="search"]:hover, select:hover { border-color: var(--border-strong); }
input[type="search"]:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
input[type="checkbox"] { accent-color: var(--ink); width: 14px; height: 14px; margin: 0; }

/* Search box: the main entry point on both pages. */
.search { position: relative; display: block; }
.search input[type="search"] {
  width: 100%;
  height: 44px;
  padding-left: 40px;
  font-size: 15px;
  border-radius: 10px;
}
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }

/* ---- Main search page --------------------------------------------------- */
.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 10px 12px;
  align-items: end;
}
.filters .search { grid-column: 1 / -1; margin-bottom: 4px; }
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.filters label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; height: 34px; white-space: nowrap; }

.summary { color: var(--muted); font-size: 13px; margin: 20px 0 10px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.layout.with-detail { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
#results tbody tr { cursor: pointer; transition: background .1s; }
#results tbody tr:hover { background: var(--subtle); }
#results tbody tr.selected { background: var(--blue-soft); box-shadow: inset 2px 0 0 var(--blue); }
.code { font-weight: 600; white-space: nowrap; }
.title { color: var(--muted); font-size: 13px; }

.tag {
  display: inline-block;
  font-size: 11.5px;
  line-height: 18px;
  padding: 0 7px;
  margin: 0 4px 4px 0;
  border-radius: 5px;
  background: var(--subtle);
  color: var(--muted);
  white-space: nowrap;
}
/* GPA: weight carries the emphasis; only a high GPA gets a touch of green. */
.gpa { font-weight: 600; font-variant-numeric: tabular-nums; }
.gpa.good { color: var(--green); }

#more { display: block; width: 100%; padding: 12px; font: inherit; font-weight: 500; color: var(--text); background: none; border: 0; border-top: 1px solid var(--border); cursor: pointer; }
#more:hover { background: var(--subtle); }

aside#detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}
aside h2 { margin: 0 0 2px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
aside h3 { margin: 24px 0 8px; font-size: 13px; font-weight: 600; }
aside .close { float: right; width: 28px; height: 28px; font: inherit; font-size: 18px; line-height: 1; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
aside .close:hover { background: var(--subtle); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; }
.stat { padding: 10px 14px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
aside table th, aside table td { padding: 7px 8px; font-size: 13px; }
aside table th:first-child, aside table td:first-child { padding-left: 0; }
aside tbody tr { cursor: default; }
.empty { color: var(--muted); font-size: 13px; }
.review { border-left: 2px solid var(--border-strong); padding: 2px 12px; margin: 10px 0; }
.review small { color: var(--muted); }

footer { color: var(--faint); font-size: 12px; line-height: 1.7; padding-top: 32px; padding-bottom: 40px; }
footer a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }

@media (max-width: 860px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label.check { grid-column: 1 / -1; height: auto; }
  .layout.with-detail { grid-template-columns: minmax(0, 1fr); }
  aside#detail { position: static; max-height: none; order: -1; }
  .hide-sm { display: none; }
}
@media (max-width: 480px) {
  header, main, footer { padding: 0 16px; }
  .nav { height: 52px; margin-bottom: 16px; }
  .nav a, .nav b { padding: 5px 8px; }
  .brand { margin-right: 4px; }
  .brand span[data-i18n] { display: none; } /* logo mark only on phones */
  th, td { padding: 9px 10px; }
}

/* A rate coloring (>= 90% green, < 70% red), used on every page */
.a-hi { color: var(--green) !important; }
.a-lo { color: var(--red) !important; }

/* Link from a course on the all-courses page to the WAF visualization */
.waf-link { margin: 12px 0 0; font-size: 13px; line-height: 1.6; }
.waf-link a { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; font-weight: 600; color: var(--text); }
.waf-link a span { color: var(--faint); font-weight: 400; }
.waf-link a:hover { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-text); text-decoration: none; }
.waf-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--faint); }
