:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #111;
  --line: #292929;
  --text: #eee;
  --muted: #999;
  --accent: #8ac7ff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { max-width: 1040px; min-width: 320px; margin: 0 auto; padding: 0 24px; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: #21496b; }

header, footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
header { height: 64px; border-bottom: 1px solid var(--line); }
.wordmark { font-weight: 700; letter-spacing: -0.02em; }
.muted-link, footer { color: var(--muted); font-size: 12px; }

main { padding: 48px 0 72px; }
.intro { margin-bottom: 32px; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: -0.035em; }
.intro p { margin: 8px 0 0; color: var(--muted); }

.controls { padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.search { position: relative; display: block; }
.search input { width: 100%; height: 44px; padding: 0 42px 0 12px; border: 1px solid var(--line); border-radius: 0; background: var(--bg); color: var(--text); }
.search input::placeholder { color: #777; }
kbd { position: absolute; right: 11px; top: 11px; padding: 2px 7px; border: 1px solid var(--line); color: #777; font: 11px ui-monospace, monospace; }

.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.filters label { min-width: 0; }
.filters label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
select { width: 100%; min-width: 0; max-width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 0; background: var(--bg); color: var(--text); }

.results { margin-top: 32px; }
.results-heading { display: flex; align-items: center; justify-content: space-between; min-height: 42px; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
#reset { border: 0; padding: 4px 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
#reset:hover { color: var(--text); }

.department-group { margin-top: 42px; }
.department-group:first-child { margin-top: 8px; }
.department-group h3 { margin: 0; padding-bottom: 10px; border-bottom: 1px solid #444; font-size: 17px; letter-spacing: -0.015em; }
.subject-group { padding: 17px 0 0; border-bottom: 1px solid var(--line); }
.subject-group h4 { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 12px 10px; font-size: 14px; font-weight: 600; }
.subject-group h4 span { min-width: 0; overflow-wrap: anywhere; }
.subject-group code { flex: 0 1 46%; color: var(--muted); font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; text-align: right; }
.paper-row { display: grid; grid-template-columns: 64px 1fr 44px; gap: 14px; align-items: center; min-height: 38px; padding: 6px 12px; border-top: 1px solid #1d1d1d; }
.paper-row:hover { background: var(--surface); }
.year { color: var(--text); font-size: 12px; }
.exam { color: var(--muted); font-size: 12px; }
.open { color: var(--accent); font-size: 12px; text-align: right; }
.open.disabled { color: #666; }

.empty { padding: 64px 12px; border-bottom: 1px solid var(--line); color: var(--muted); text-align: center; }
.load-more { width: 100%; margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--text); cursor: pointer; }
.load-more:hover { border-color: #555; }

footer { min-height: 68px; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  body { padding: 0 16px; }
  main { padding-top: 36px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .department-group { margin-top: 34px; }
  .department-group h3 { font-size: 15px; }
  .subject-group h4 { align-items: flex-start; flex-direction: column; gap: 4px; margin-inline: 4px; }
  .subject-group code { max-width: none; text-align: left; }
  .paper-row { grid-template-columns: 52px minmax(0, 1fr) 40px; gap: 8px; padding: 6px 4px; }
}

@media (max-width: 560px) {
  .filters { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
