:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #eef2ed;
  --ink: #121815;
  --muted: #64716a;
  --line: #d9dfd8;
  --line-strong: #b9c5bd;
  --charcoal: #17201b;
  --green: #236f4d;
  --green-dark: #164a34;
  --teal: #0f766e;
  --blue: #245a88;
  --gold: #b7791f;
  --red: #a64b42;
  --shadow: 0 18px 44px rgba(18, 24, 21, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.hidden,
.view.hidden {
  display: none !important;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(217, 223, 216, 0.8);
  background: rgba(246, 247, 243, 0.92);
  backdrop-filter: blur(14px);
}

.nav-brand,
.site-nav nav,
.nav-actions,
.hero-actions,
.account-actions,
.admin-header-actions {
  display: flex;
  align-items: center;
}

.nav-brand {
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #1f4332;
  border-radius: 7px;
  background: var(--charcoal);
  color: #fff;
  font-weight: 900;
}

.site-nav nav {
  justify-content: center;
  gap: 8px;
}

.site-nav nav button,
.auth-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.site-nav nav button:hover,
.auth-switch button:hover {
  color: var(--ink);
}

.nav-actions,
.hero-actions,
.admin-header-actions {
  gap: 10px;
}

.solid-button,
.ghost-button,
.glass-button,
.actions button,
.pager button,
.image-tabs button,
#closeDetailButton,
.account-actions button,
.admin-editor button {
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 850;
}

.solid-button {
  border: 1px solid var(--green-dark);
  background: var(--green);
  color: #fff;
  padding: 9px 16px;
}

.solid-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 14px;
}

.ghost-button:hover {
  border-color: var(--green);
}

.glass-button {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 9px 16px;
}

.large {
  min-height: 48px;
  padding: 11px 18px;
}

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.light {
  color: #cde9dc;
}

.public-home {
  background: #f7f8f4;
}

.hero-section {
  position: relative;
  display: grid;
  min-height: clamp(520px, calc(100vh - 180px), 620px);
  overflow: hidden;
  place-items: center start;
  background-image: url("/static/hero-question.png");
  background-position: center;
  background-size: cover;
  color: #fff;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 14, 0.62);
  box-shadow: inset 0 -120px 180px rgba(10, 18, 14, 0.25);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0;
}

.hero-content h1 {
  max-width: 780px;
  margin: 14px 0 18px;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.95;
}

.hero-copy {
  max-width: 650px;
  margin: 0;
  color: #ecf5ef;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.42;
}

.hero-actions {
  margin-top: 30px;
}

.hero-proof {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}

.hero-proof span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #f8fbf8;
  font-size: 13px;
  font-weight: 800;
}

.hero-proof strong {
  color: #f1c56f;
  font-size: 20px;
}

.home-band {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 68px 0;
}

.intro-band {
  padding-top: 34px;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 24px;
}

.section-heading h2,
.comparison-copy h2,
.auth-panel h1,
.admin-title h1 {
  margin: 8px 0 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.04;
}

.feature-grid,
.pricing-grid {
  display: grid;
  gap: 14px;
}

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

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

.feature-card,
.price-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(18, 24, 21, 0.04);
}

.feature-card {
  padding: 20px;
}

.feature-icon {
  display: inline-grid;
  min-width: 34px;
  height: 28px;
  margin-bottom: 22px;
  place-items: center;
  border: 1px solid #b7d5cc;
  border-radius: 7px;
  background: #e7f4f0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.feature-card h3,
.price-card h3,
.comparison-copy h2,
.admin-editor h2,
.empty-state h3,
.results-header h3,
.detail-heading h3 {
  margin: 0;
}

.feature-card h3,
.price-card h3 {
  font-size: 19px;
}

.feature-card p,
.price-card p,
.comparison-copy p,
.auth-panel p,
.empty-state p {
  color: var(--muted);
  line-height: 1.5;
}

.price-card {
  padding: 22px;
}

.price-card.featured {
  border-color: #d7b46f;
  background: #fffaf0;
}

.plan-kicker {
  margin: 0 0 12px;
  color: var(--blue) !important;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.price {
  margin: 18px 0 2px !important;
  color: var(--ink) !important;
  font-size: 50px;
  font-weight: 950;
  line-height: 1;
}

.price span {
  margin-right: 3px;
  color: var(--gold);
  font-size: 26px;
}

.plan-meta {
  margin: 0 0 18px !important;
  color: var(--green-dark) !important;
  font-weight: 850;
}

.comparison-band {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.comparison-meter {
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.comparison-meter div:not(.meter-track) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.comparison-meter span {
  color: var(--muted);
}

.comparison-meter strong {
  color: var(--ink);
}

.meter-track {
  position: relative;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7e0;
}

.meter-fill {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: 999px;
  background: var(--green);
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 34px 20px;
  background:
    linear-gradient(rgba(246, 247, 243, 0.92), rgba(246, 247, 243, 0.92)),
    url("/static/hero-question.png") center / cover;
}

.auth-panel {
  display: grid;
  gap: 22px;
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  font-size: 36px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.filter-group {
  display: grid;
  gap: 7px;
}

.auth-form span,
.filter-group label {
  color: #314139;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.auth-form input,
.filter-group input,
.filter-group select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.auth-form input:focus,
.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 111, 77, 0.15);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red) !important;
  font-weight: 800;
}

.auth-switch {
  margin: 0;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.results-header p,
.detail-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.results-header p,
.card-title span,
.meta-line,
.text-sample {
  color: var(--muted);
  font-size: 12px;
}

.account-panel,
.access-panel {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-panel {
  display: grid;
  gap: 10px;
}

.account-role {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.account-panel strong {
  display: block;
  overflow-wrap: anywhere;
}

.account-actions {
  gap: 8px;
}

.account-actions button,
.admin-editor button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
}

.access-panel h2 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
}

.access-list,
.tag-row,
.tag-stack,
.subject-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.access-chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid #cbd8cf;
  border-radius: 999px;
  background: #eef6ef;
  color: #183b29;
  font-size: 12px;
  font-weight: 800;
}

.access-chip.locked {
  border-color: #d6d3ca;
  background: #f1f0eb;
  color: #777166;
}

.filter-grid {
  display: grid;
  gap: 14px;
}

.priority-filters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 2px;
}

.filter-group {
  margin-bottom: 14px;
}

.filter-group select:disabled {
  cursor: not-allowed;
  color: #87948d;
  background: #f3f5f2;
}

.actions {
  padding-top: 8px;
}

.actions button,
.pager button,
.image-tabs button,
#closeDetailButton {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.actions button {
  width: 100%;
}

.actions button:hover,
.pager button:hover,
.image-tabs button:hover,
#closeDetailButton:hover,
.account-actions button:hover,
.admin-editor button:hover {
  border-color: var(--green);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
}

.topbar h2 {
  max-width: 720px;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.14;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 10px;
  min-width: 520px;
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42vw);
  gap: 18px;
  align-items: start;
}

.results-panel,
.inspector {
  min-width: 0;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.results-header h3,
.detail-heading h3 {
  font-size: 18px;
}

.results-header p {
  margin-top: 4px;
}

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

.pager button {
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
}

.pager button:disabled {
  opacity: 0.45;
}

#pageLabel {
  min-width: 70px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.result-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  text-align: left;
}

.result-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 111, 77, 0.14);
}

.result-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.thumb {
  position: relative;
  height: 164px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f7f3;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-title strong {
  font-size: 15px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag.secondary {
  border-color: #e5d6ac;
  background: #f8f4e8;
  color: #6f4718;
}

.tag.needs-review {
  border-color: #efc6bd;
  background: #fff1ee;
  color: #8a3a2d;
}

.text-sample {
  display: -webkit-box;
  min-height: 48px;
  overflow: hidden;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.inspector {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state {
  display: grid;
  min-height: 520px;
  place-items: center;
  padding: 38px;
  text-align: center;
}

.empty-state.compact {
  min-height: 220px;
  padding: 24px;
}

.empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--green-dark);
  font-size: 28px;
}

.empty-state p {
  max-width: 330px;
  margin-top: 8px;
}

.detail-panel {
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr) auto auto;
  max-height: calc(100vh - 48px);
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

#closeDetailButton {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
}

.image-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.image-tabs button {
  min-height: 34px;
}

.image-tabs button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.image-tabs button:disabled {
  opacity: 0.48;
}

.image-frame {
  min-height: 300px;
  overflow: auto;
  padding: 12px;
  background: #ecefeb;
}

.image-frame img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

.markscheme-frame {
  display: block;
  width: 100%;
  height: min(66vh, 760px);
  min-height: 500px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

.detail-section {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.detail-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
}

.detail-text {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  color: #33443b;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.loading,
.no-results {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.admin-shell {
  min-height: 100vh;
  background: var(--bg);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.admin-content {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.admin-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.admin-users,
.admin-editor {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-users {
  overflow: auto;
}

.admin-users table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.admin-users th,
.admin-users td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-users th {
  color: #3a4941;
  font-size: 12px;
  text-transform: uppercase;
}

.user-row {
  cursor: pointer;
}

.user-row.active,
.user-row:hover {
  background: #f2f6f2;
}

.user-main {
  display: grid;
  gap: 4px;
}

.user-main strong {
  overflow-wrap: anywhere;
}

.user-main span,
.admin-muted {
  color: var(--muted);
  font-size: 12px;
}

.admin-editor {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.editor-heading {
  display: grid;
  gap: 6px;
}

.editor-heading strong {
  overflow-wrap: anywhere;
}

.editor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-line,
.subject-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.subject-checkboxes {
  display: grid;
}

.subject-check {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid #b9d2c4;
  border-radius: var(--radius);
  background: #f1fbf5;
  color: #123522;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.error {
  border-color: #ecc2bb;
  background: #fff1ee;
  color: #81352c;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .content-grid,
  .admin-grid,
  .comparison-band {
    grid-template-columns: 1fr;
  }

  .inspector,
  .admin-editor {
    position: static;
    max-height: none;
  }

  .detail-panel {
    max-height: none;
  }

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

@media (max-width: 820px) {
  .site-nav {
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding: 12px 16px;
  }

  .site-nav nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow: auto;
  }

  .nav-actions {
    justify-content: flex-end;
  }

  .hero-section {
    min-height: min(540px, calc(100vh - 180px));
  }

  .hero-content {
    width: min(100% - 32px, 720px);
    padding: 58px 0;
  }

  .home-band {
    width: min(100% - 32px, 720px);
    padding: 48px 0;
  }

  .feature-grid,
  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .admin-title,
  .admin-header {
    display: grid;
  }

  .topbar h2 {
    font-size: 23px;
  }

  .stats,
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .markscheme-frame {
    height: 62vh;
    min-height: 420px;
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .nav-actions,
  .admin-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .solid-button,
  .ghost-button,
  .glass-button {
    width: 100%;
  }

  .hero-actions .solid-button,
  .hero-actions .glass-button {
    width: auto;
  }

  .stats,
  .filter-grid,
  .priority-filters {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px;
  }
}
