:root {
  color-scheme: dark;
  --bg: #1e1b4b;
  --bg-deep: #171342;
  --panel: rgba(49, 46, 129, 0.62);
  --panel-strong: rgba(49, 46, 129, 0.86);
  --panel-soft: rgba(67, 56, 202, 0.32);
  --line: rgba(129, 140, 248, 0.42);
  --line-strong: rgba(251, 191, 36, 0.48);
  --text: #ffffff;
  --muted: #c7d2fe;
  --dim: #a5b4fc;
  --amber: #f59e0b;
  --amber-bright: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.18);
  --emerald: #34d399;
  --rose: #fb7185;
  --radius: 16px;
  --radius-small: 10px;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
  --header-height: 70px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
a[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: #312e81; /* indigo-900 — matches the React portal header (PublicSite.jsx) */
  border-bottom: 1px solid #3730a3; /* indigo-800 */
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand img {
  height: 20px;
  width: auto;
  flex: 0 0 auto;
}

.brand-name {
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.brand:hover .brand-name,
.brand:focus-visible .brand-name {
  color: var(--amber-bright);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.top-nav > a,
.text-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.top-nav > a {
  display: inline-flex;
  align-items: center;
}

.top-nav > a:hover,
.top-nav > a:focus-visible,
.text-button:hover,
.text-button:focus-visible {
  border-color: rgba(251, 191, 36, 0.32);
  color: var(--amber-bright);
}

.top-nav > a.is-current {
  color: var(--amber-bright);
}

/* Mobile hamburger toggle (hidden on desktop; revealed in the <=760 media query). Matches the React portal. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
}
.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(67, 56, 202, 0.6);
}
.nav-toggle .ico-close { display: none; }
.site-header.nav-open .nav-toggle .ico-menu { display: none; }
.site-header.nav-open .nav-toggle .ico-close { display: inline; }

.primary-button,
.secondary-button,
.ghost-button,
.coffee-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 900;
  line-height: 1.1;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.coffee-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  padding: 0 18px;
  background: linear-gradient(135deg, var(--amber-bright), var(--amber));
  color: #1e1b4b;
  box-shadow: 0 14px 32px rgba(245, 158, 11, 0.24);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
}

.secondary-button,
.ghost-button {
  padding: 0 15px;
  border-color: rgba(129, 140, 248, 0.46);
  background: rgba(49, 46, 129, 0.54);
  color: #eef2ff;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(67, 56, 202, 0.64);
}

.coffee-button {
  padding: 0 18px;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #1e1b4b;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(49, 46, 129, 0.78);
  color: #ffffff;
}

.primary-button svg,
.secondary-button svg,
.ghost-button svg,
.coffee-button svg,
.icon-button svg,
.search-box svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2.2;
}

.search-hero {
  position: relative;
  isolation: isolate;
  min-height: min(760px, calc(100svh - var(--header-height) - 36px));
  display: grid;
  background:
    linear-gradient(rgba(30, 27, 75, 0.9), rgba(30, 27, 75, 0.94)),
    url("study-desk-banner.png") center / cover;
}

.search-hero::before {
  content: "";
  position: absolute;
  top: 26px;
  left: 50%;
  width: min(740px, calc(100% - 44px));
  height: 6px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--amber-bright) 0 16%, transparent 16% 18%, rgba(67, 56, 202, 0.92) 18% 35%, transparent 35% 37%, rgba(67, 56, 202, 0.92) 37% 54%, transparent 54% 56%, rgba(67, 56, 202, 0.92) 56% 73%, transparent 73% 75%, rgba(67, 56, 202, 0.92) 75% 100%);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.16);
}

.hero-overlay {
  display: none;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(420px, 0.74fr);
  align-items: center;
  gap: 36px;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 70px 0 44px;
}

.hero-copy {
  max-width: 640px;
}

.eyebrow,
.kicker {
  margin: 0 0 10px;
  color: var(--amber-bright);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  max-width: 640px;
  font-size: 3.75rem;
  line-height: 1;
}

.hero-copy p {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.search-panel,
.paper-card,
.bulk-actions,
.donation-box,
.modal-shell,
.empty-state {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.search-panel {
  width: 100%;
  padding: 22px;
  border-radius: 22px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h2,
.section-heading h2,
.bulk-copy h2,
.support-copy h2,
.modal h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.55rem;
  line-height: 1.15;
  font-weight: 900;
}

.panel-intro {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.search-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.search-steps span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 14px;
  background: rgba(30, 27, 75, 0.54);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.search-steps strong {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--amber-bright);
  color: #1e1b4b;
  font-size: 0.76rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin: 18px 0 10px;
  padding: 0 16px;
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 14px;
  background: rgba(30, 27, 75, 0.78);
  color: var(--dim);
}

.search-box:focus-within {
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font-size: 1rem;
}

.search-box input::placeholder {
  color: #818cf8;
}

.example-searches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--dim);
  font-size: 0.82rem;
  font-weight: 850;
}

.example-searches button,
.quick-filters button,
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber-bright);
  font-size: 0.8rem;
  font-weight: 900;
}

.example-searches button:hover,
.example-searches button:focus-visible,
.quick-filters button:hover,
.quick-filters button.is-active,
.filter-chip:hover {
  border-color: rgba(251, 191, 36, 0.68);
  background: rgba(245, 158, 11, 0.28);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--dim);
  font-size: 0.8rem;
  font-weight: 850;
}

select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 44px;
  min-width: 0;
  border: 1px solid rgba(129, 140, 248, 0.48);
  border-radius: 12px;
  background: rgba(30, 27, 75, 0.82);
  color: #ffffff;
  padding: 0 12px;
  outline: 0;
}

textarea {
  min-height: 88px;
  padding: 11px 12px;
  resize: vertical;
}

select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* Goal-first entry: level/subject quick-pick + collapsed "Filters" disclosure (UX overhaul). */
.quick-pick {
  margin: 4px 0 2px;
}
.qp-label {
  margin: 12px 0 8px;
  color: var(--dim);
  font-size: 0.82rem;
  font-weight: 850;
}
.more-filters {
  margin: 16px 0 2px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.more-filters > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  color: var(--amber-bright);
  font-size: 0.86rem;
  font-weight: 900;
}
.more-filters > summary::-webkit-details-marker {
  display: none;
}
.more-filters > summary .chev {
  margin-left: auto;
  transition: transform 0.2s ease;
}
.more-filters[open] > summary .chev {
  transform: rotate(180deg);
}
.more-filters .filter-grid {
  margin-top: 14px;
}

.search-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(52, 211, 153, 0.34);
  border-radius: 16px;
  background: rgba(6, 78, 59, 0.32);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.search-feedback.is-updated {
  border-color: rgba(251, 191, 36, 0.64);
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.16);
  transform: translateY(-1px);
}

.feedback-hint {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 2px;
  flex: 1 1 150px;
  min-width: 0;
}

.feedback-hint strong {
  color: #ecfdf5;
  font-size: 0.98rem;
  line-height: 1.2;
}

.feedback-hint span:last-child {
  grid-column: 2;
  color: #a7f3d0;
  font-size: 0.82rem;
  font-weight: 750;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--emerald);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
}

.search-feedback .secondary-button {
  min-height: 40px;
  padding: 0 12px;
  white-space: nowrap;
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.browse-school-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--amber-bright);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
}
.browse-school-link:hover {
  text-decoration: underline;
}

.filter-chip svg {
  width: 15px;
  height: 15px;
  margin-left: 4px;
  opacity: 0.85;
}

.catalog-section,
.support-section,
.bulk-band {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.catalog-section {
  padding: 52px 0 30px;
}

.result-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-weight: 850;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  margin: 18px 0 8px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.paper-card {
  display: grid;
  gap: 14px;
  min-height: 220px;
  padding: 17px;
  border-radius: 18px;
}

.paper-card:hover {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(49, 46, 129, 0.78);
}

.paper-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.paper-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.paper-title h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1rem;
  line-height: 1.24;
}

.paper-title span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.paper-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  color: var(--amber-bright);
  font-size: 0.76rem;
  font-weight: 900;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.paper-meta li {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(30, 27, 75, 0.62);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.paper-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.paper-actions .secondary-button,
.paper-actions .primary-button {
  min-height: 42px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 54px 20px;
  text-align: center;
  border-radius: 18px;
}

.empty-state svg {
  width: 36px;
  height: 36px;
  color: var(--amber-bright);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  color: var(--muted);
}

.bulk-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 28px;
  align-items: center;
  margin-top: 26px;
  padding: 28px;
  border: 1px solid rgba(129, 140, 248, 0.4);
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.34);
}

.bulk-copy p,
.support-copy p,
.bulk-actions p,
.donation-box p,
.modal p,
.fine-print {
  margin: 12px 0 0;
  color: var(--muted);
}

.bulk-actions {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
}

.bulk-meter {
  display: grid;
  gap: 2px;
}

.bulk-meter span,
.bulk-meter small {
  color: var(--muted);
  font-weight: 850;
}

.bulk-meter small.over-limit {
  color: var(--amber-bright);
}

.bulk-meter strong {
  color: #ffffff;
  font-size: 1.55rem;
}

.support-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 30px;
  align-items: center;
  padding: 58px 0;
}

.donation-box {
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 18px;
}

.donation-box strong {
  color: #ffffff;
  font-size: 1.05rem;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 56px);
  border-top: 1px solid rgba(129, 140, 248, 0.24);
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer span:first-child {
  color: #ffffff;
  font-weight: 900;
}

.modal {
  width: min(92vw, 520px);
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
  color: #ffffff;
}

.modal::backdrop {
  background: rgba(8, 7, 28, 0.72);
  backdrop-filter: blur(5px);
}

.modal-shell {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 22px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.full-width {
  width: 100%;
}

.zip-modal {
  gap: 16px;
}

.zip-summary {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(129, 140, 248, 0.36);
  border-radius: 14px;
  background: rgba(30, 27, 75, 0.72);
}

.zip-summary div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.zip-summary span {
  color: var(--muted);
  font-weight: 850;
}

.zip-summary strong {
  text-align: right;
}

.zip-progress {
  display: grid;
  gap: 8px;
}

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.24);
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--amber-bright);
  transition: width 180ms ease;
}

.zip-progress p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border: 1px solid rgba(251, 191, 36, 0.34);
  border-radius: 16px;
  background: rgba(30, 27, 75, 0.96);
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 850;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .nav-optional {
    display: none !important;
  }
}

@media (max-width: 1040px) {
  .hero-inner,
  .bulk-band,
  .support-section {
    grid-template-columns: 1fr;
  }

  .search-panel {
    max-width: 720px;
  }

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

@media (max-width: 760px) {
  :root {
    --header-height: 68px;
  }

  .site-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 14px;
  }

  /* Mobile: collapse the cross-product nav into a hamburger dropdown — same behaviour as the React portal. */
  .nav-toggle { display: inline-flex; }
  .top-nav {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid #3730a3;
  }
  .site-header.nav-open .top-nav { display: flex; }
  .top-nav > a { min-height: 44px; width: 100%; }

  .hero-inner,
  .catalog-section,
  .support-section,
  .bulk-band {
    width: min(100% - 28px, 1120px);
  }

  .hero-inner {
    gap: 24px;
    padding: 54px 0 34px;
  }

  .hero-copy h1 {
    font-size: 2.65rem;
  }

  .hero-copy p {
    font-size: 1rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-panel,
  .bulk-band,
  .donation-box {
    padding: 18px;
  }

  .filter-grid,
  .results-grid,
  .search-steps {
    grid-template-columns: 1fr;
  }

  .search-feedback .secondary-button {
    width: 100%;
  }

  .panel-heading,
  .section-heading,
  .site-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .result-tools {
    justify-content: flex-start;
  }

  .paper-actions {
    grid-template-columns: 1fr;
  }

  .modal-shell {
    padding: 24px 18px 18px;
  }
}
