:root {
  --primary: #163b65;
  --secondary: #007f73;
  --ink: #172333;
  --muted: #5d6876;
  --surface: #ffffff;
  --surface-alt: #f3f6f9;
  --border: #d8e0e8;
  --danger: #a11d2e;
  --warning: #7a4b00;
  --success: #17663b;
  --focus: #ffbf47;
  --shadow: 0 12px 34px rgba(20, 39, 62, 0.08);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface-alt);
  line-height: 1.55;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 90% 0, rgba(0, 127, 115, 0.08), transparent 28rem),
    var(--surface-alt);
}

a {
  color: #075b87;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--primary);
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: #111;
  color: #fff;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  min-height: 76px;
  padding: 0.65rem max(1.25rem, calc((100vw - 1200px) / 2));
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand span {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 1.02rem;
}

.brand small {
  color: var(--muted);
}

.site-header nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header nav a,
.link-button {
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.1rem;
  cursor: pointer;
}

.site-header nav a:hover,
.link-button:hover {
  color: var(--secondary);
}

.danger-link {
  color: var(--danger);
}

.site-header .nav-login {
  background: var(--primary);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
}

.site-header .nav-login:hover {
  color: #fff;
  background: #0e2d50;
}

.menu-button {
  display: none;
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
}

.container {
  width: min(1200px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
  flex: 1;
}

.site-footer {
  padding: 2rem max(1.25rem, calc((100vw - 1200px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  background: #10283f;
  color: #fff;
}

.site-footer a {
  color: #fff;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  align-items: center;
  gap: 4rem;
  padding: 3rem 0;
}

.hero h1 {
  max-width: 780px;
  margin: 0 0 1.25rem;
  font-size: clamp(2.6rem, 6vw, 5.2rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
  color: var(--primary);
}

.lead {
  max-width: 650px;
  font-size: 1.3rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero-panel {
  padding: 1rem;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--primary), #0f2740);
  box-shadow: 0 28px 60px rgba(15, 39, 64, 0.24);
  color: #fff;
}

.hero-panel div {
  padding: 1.3rem;
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.hero-panel div:last-child {
  border-bottom: 0;
}

.hero-panel strong {
  color: #9ee5dc;
}

.feature-grid,
.card-grid,
.stats-grid,
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.full-width {
  grid-column: 1 / -1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin-top: 0;
}

.card.compact {
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.action-card {
  color: var(--ink);
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--secondary);
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-heading h1,
.prose h1 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
  border: 1px solid var(--primary);
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  padding: 0.58rem 1rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: #eef4fa;
  color: var(--primary);
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: #0e2d50;
  color: #fff;
}

.button-danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover {
  color: #fff;
  background: #7c1321;
}

.button-small {
  min-height: 2rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.inline-form {
  display: inline;
}

.auth-shell {
  width: min(900px, 100%);
  margin: 3rem auto;
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 3rem;
  align-items: center;
}

.auth-copy h1,
.narrow h1 {
  margin-top: 0;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  line-height: 1.06;
  color: var(--primary);
}

.narrow {
  width: min(720px, 100%);
  margin: 1rem auto;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wide-form {
  width: min(960px, 100%);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label,
.filter-bar label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.filter-bar input,
.filter-bar select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aebbc8;
  border-radius: 8px;
}

.field select[multiple] {
  min-height: 8rem;
}

.field textarea {
  min-height: 9rem;
  resize: vertical;
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--danger);
}

.errors {
  color: var(--danger);
  margin: 0;
  padding-left: 1.2rem;
}

.help,
.muted,
.empty {
  color: var(--muted);
}

.help {
  margin: 0;
  font-size: 0.9rem;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.8rem;
}

.check-field input {
  width: 1.2rem;
  height: 1.2rem;
}

.actions {
  margin-top: 0.5rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.notifications {
  margin-bottom: 1.5rem;
}

.notice {
  margin: 0.75rem 0;
  padding: 1rem 1.15rem;
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  background: #eaf2fa;
}

.notice-error {
  border-color: var(--danger);
  background: #fff0f2;
}

.notice-warning {
  border-color: #b36b00;
  background: #fff6df;
}

.notice-success {
  border-color: var(--success);
  background: #e8f7ee;
}

.notice-info {
  border-color: #146b95;
}

.two-columns,
.management-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.management-layout {
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.7fr);
  align-items: start;
  margin-top: 2rem;
}

.management-layout aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 2rem;
}

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

.stat strong {
  display: block;
  color: var(--primary);
  font-size: 2rem;
}

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

.stat.warning strong {
  color: var(--warning);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #eaf0f5;
  color: #1e3a55;
}

tbody tr:hover {
  background: #f7fafc;
}

.badge {
  display: inline-block;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  background: #e8eef4;
  color: #28465f;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge-success {
  background: #dff3e7;
  color: #155a34;
}

.badge-muted {
  background: #eceff2;
  color: #555f69;
}

.badge-warning {
  background: #fff0c2;
  color: #744600;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.chapter-card {
  margin-bottom: 1rem;
}

.chapter-heading,
.lesson-row,
.resource-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.lesson-row {
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}

.nested-row {
  margin: -0.4rem 0 0.6rem 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.lesson-list {
  padding-left: 1.3rem;
}

.lesson-list li {
  margin: 0.5rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.resource-list {
  list-style: none;
  padding: 0;
}

.resource-list li {
  padding: 1rem;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.resource-list span {
  display: block;
  color: var(--muted);
}

.prose {
  max-width: 78ch;
}

.prose :first-child {
  margin-top: 0;
}

.prose :last-child {
  margin-bottom: 0;
}

.prose pre,
.prose code,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  color: #eef5fb;
  background: #12283d;
  border-radius: 8px;
}

.question-card {
  margin-bottom: 1rem;
}

.correct-option {
  color: var(--success);
  font-weight: 700;
}

.answer-option {
  display: flex;
  align-items: start;
  gap: 0.7rem;
  padding: 0.7rem;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.answer-option:hover {
  background: #f4f8fb;
}

.answer-option input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
}

.result-panel,
.error-page {
  width: min(680px, 100%);
  margin: 3rem auto;
  text-align: center;
}

.score {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--primary);
}

.score strong {
  font-size: 6rem;
  line-height: 1;
}

.score span {
  font-size: 2rem;
}

progress {
  width: min(420px, 100%);
  height: 1rem;
  accent-color: var(--secondary);
}

.error-code {
  margin: 0;
  color: var(--secondary);
  font-size: 5rem;
  font-weight: 900;
}

.secret-box,
.code-list {
  padding: 1rem;
  background: #172333;
  color: #fff;
  border-radius: 10px;
}

.secret-box code {
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.code-list {
  columns: 2;
  list-style: none;
}

.code-list li {
  padding: 0.4rem;
}

.break-all {
  overflow-wrap: anywhere;
}

.definition-list {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.65rem 1rem;
}

.definition-list dt {
  font-weight: 800;
}

.definition-list dd {
  margin: 0;
}

.danger-zone {
  margin-top: 2rem;
  border-color: #d89ba3;
}

.pagination {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
}

.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: 980px) {
  .menu-button {
    display: block;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .site-header nav {
    display: none;
    width: 100%;
    margin: 0;
    padding: 0.75rem 0;
    flex-direction: column;
    align-items: stretch;
  }

  .site-header nav.is-open {
    display: flex;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-panel {
    max-width: 680px;
  }

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

  .management-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .container {
    width: min(100% - 1.4rem, 1200px);
    padding-top: 2rem;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    display: none;
  }

  .hero {
    min-height: auto;
    padding-top: 1rem;
  }

  .feature-grid,
  .card-grid,
  .action-grid,
  .stats-grid,
  .two-columns,
  .auth-shell,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .page-heading,
  .chapter-heading,
  .lesson-row,
  .resource-list li,
  .site-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading {
    display: flex;
  }

  .site-footer {
    display: flex;
  }

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

  .definition-list dd {
    margin-bottom: 0.5rem;
  }

  .code-list {
    columns: 1;
  }
}

@media print {
  .site-header,
  .site-footer,
  .button,
  button,
  .notifications {
    display: none !important;
  }

  body,
  .card {
    background: #fff;
    box-shadow: none;
  }

  .container {
    width: 100%;
    padding: 0;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
