:root {
  --purple-950: #21074d;
  --purple-800: #3d1377;
  --purple-650: #5a2a91;
  --gold-500: #f4b800;
  --gold-300: #ffd75a;
  --ink-950: #17151d;
  --slate-600: #667085;
  --surface: #ffffff;
  --canvas: #f7f6fa;
  --border: #ded9e7;
  --shadow-sm: 0 1px 2px rgb(33 7 77 / 0.06), 0 7px 24px rgb(33 7 77 / 0.07);
  --shadow-md: 0 18px 48px rgb(33 7 77 / 0.12);
  --radius-sm: 0.5rem;
  --radius-md: 0.85rem;
  --radius-lg: 1.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  color: var(--ink-950);
  background: var(--canvas);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--purple-800);
}

/*
 * Two-color focus halo contrast (WCAG relative-luminance calculation):
 * #21074d against #ffffff: 17.47:1
 * #21074d against #f7f6fa: 16.23:1
 * #ffffff against #3d1377: 13.48:1
 * The white inner ring remains visible on purple surfaces; the purple outer
 * ring remains visible on white and canvas surfaces. Every pairing exceeds 3:1.
 */
:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 7px #21074d;
}

.site-header {
  color: var(--surface);
  background: var(--purple-950);
  border-bottom: 4px solid var(--gold-500);
}

.header-inner,
.page-shell,
.site-footer p {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5.25rem;
  gap: 1rem;
  padding-block: 0.65rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 0.75rem;
  color: var(--surface);
  text-decoration: none;
}

.brand img {
  width: 3.5rem;
  height: 3.5rem;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.25);
}

.brand span {
  display: grid;
  line-height: 1.2;
}

.brand strong {
  font-size: clamp(0.95rem, 3.7vw, 1.2rem);
  letter-spacing: -0.015em;
}

.brand small {
  margin-top: 0.25rem;
  color: var(--gold-300);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.025em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button-header {
  flex: 0 0 auto;
  color: var(--surface);
  background: transparent;
  border-color: rgb(255 255 255 / 0.62);
}

.button-header:hover {
  background: rgb(255 255 255 / 0.12);
  border-color: var(--surface);
}

.page-shell {
  padding-block: clamp(2rem, 5vw, 4rem) 4rem;
}

.intro {
  max-width: 47rem;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--purple-650);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.65rem;
  color: var(--purple-950);
  font-size: clamp(2rem, 7vw, 3.65rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

h2 {
  color: var(--purple-950);
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.intro-copy {
  margin-bottom: 0;
  color: var(--slate-600);
  font-size: clamp(1rem, 2.3vw, 1.18rem);
}

.search-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--purple-650);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.search-panel::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 6rem;
  height: 0.3rem;
  background: var(--gold-500);
  content: "";
}

.panel-heading {
  display: grid;
  gap: 0.35rem 2rem;
  margin-bottom: 1.3rem;
}

.panel-heading h2,
.panel-heading p {
  margin-bottom: 0;
}

.panel-heading > p {
  color: var(--slate-600);
}

.search-fields {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  color: var(--ink-950);
  font-size: 0.88rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  color: var(--ink-950);
  background: var(--surface);
  border: 1px solid #9a91aa;
  border-radius: var(--radius-sm);
}

.field input::placeholder {
  color: #6d6579;
}

.field input:hover,
.field select:hover {
  border-color: var(--purple-650);
}

.results-section {
  padding-top: 2.5rem;
}

.results-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

.results-heading-row h2,
.results-heading-row p {
  margin-bottom: 0;
}

#result-count,
#action-status {
  color: var(--slate-600);
  font-size: 0.92rem;
  font-weight: 650;
}

#action-status {
  min-height: 1.5rem;
  margin-bottom: 1rem;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-card {
  display: flex;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  padding: clamp(1.1rem, 3vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.category-badge {
  align-self: flex-start;
  margin-bottom: 0.75rem;
  padding: 0.28rem 0.55rem;
  color: var(--purple-950);
  background: #eee7f7;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.result-card h3 {
  margin: 0 0 0.55rem;
  color: var(--ink-950);
  font-size: 1.08rem;
  line-height: 1.35;
}

.worksheet-id {
  overflow-wrap: anywhere;
  margin-bottom: 1.25rem;
  color: var(--slate-600);
  font-size: 0.82rem;
}

.card-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: auto;
}

.button-primary {
  color: var(--surface);
  background: var(--purple-800);
}

.button-primary:hover {
  background: var(--purple-950);
}

.button-secondary {
  color: var(--purple-950);
  background: var(--surface);
  border-color: var(--purple-650);
}

.button-secondary:hover {
  background: #f0eaf8;
}

.source-link {
  align-self: flex-start;
  min-height: 44px;
  margin-top: 0.8rem;
  padding-block: 0.65rem;
  color: var(--purple-800);
  font-size: 0.82rem;
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.pagination[hidden] {
  display: none;
}

.pagination p {
  min-width: 7rem;
  margin: 0;
  color: var(--slate-600);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.site-footer {
  padding-block: 1.25rem;
  color: #d9cdea;
  background: var(--purple-950);
}

.site-footer p {
  margin-block: 0;
  font-size: 0.82rem;
}

.site-footer a {
  margin-inline-start: 0.55rem;
  color: var(--surface);
  font-weight: 750;
  text-underline-offset: 0.18em;
}

.site-footer span {
  margin-inline-start: 0.55rem;
  color: var(--gold-300);
}

.document-page {
  max-width: 52rem;
}

.document-card > :last-child,
.document-card section > :last-child {
  margin-bottom: 0;
}

.document-card section + section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.document-card h2 {
  margin-bottom: 0.65rem;
}

.document-card li + li {
  margin-top: 0.5rem;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgb(33 7 77 / 0.98), rgb(61 19 119 / 0.93)),
    var(--purple-950);
}

.login-shell {
  width: min(100%, 28rem);
}

.login-card {
  padding: clamp(1.5rem, 6vw, 2.5rem);
  background: var(--surface);
  border-top: 6px solid var(--gold-500);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgb(0 0 0 / 0.32);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.login-brand img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: contain;
}

.login-card h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.65rem, 8vw, 2.25rem);
  letter-spacing: -0.035em;
}

.login-school {
  margin: 0;
  color: var(--purple-650);
  font-size: 0.82rem;
  font-weight: 750;
}

.login-copy {
  margin-bottom: 1.35rem;
  color: var(--slate-600);
}

.login-form {
  display: grid;
  gap: 0.6rem;
}

.login-form label {
  font-size: 0.88rem;
  font-weight: 750;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  color: var(--ink-950);
  border: 1px solid #9a91aa;
  border-radius: var(--radius-sm);
}

.login-form .button {
  margin-top: 0.45rem;
}

#login-status {
  min-height: 1.5rem;
  margin: 1rem 0 0;
  color: #8a1538;
  font-size: 0.9rem;
  font-weight: 650;
}

@media (min-width: 560px) {
  .card-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 760px) {
  .header-inner,
  .page-shell,
  .site-footer p {
    width: min(100% - 4rem, 72rem);
  }

  .panel-heading {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.72fr);
    align-items: end;
  }

  .search-fields {
    grid-template-columns: minmax(0, 2fr) minmax(13rem, 1fr);
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
