:root {
  --teal: #0d5c63;
  --teal-dark: #094248;
  --bg: #f4f7f8;
  --text: #1a2b2e;
  --muted: #5a6d70;
  --card-shadow: 0 4px 14px rgba(13, 92, 99, 0.12);
  --radius: 10px;
  --admin-accent: #2563eb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--teal);
}

a:hover {
  color: var(--teal-dark);
}

.site-header {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.site-header > .wrap {
  max-width: none;
  margin: 0;
  padding: 0;
  justify-content: flex-start;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0;
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  text-decoration: none;
  color: inherit;
}

.site-header__brand:hover {
  color: #fff;
}

.site-header__logo {
  height: 96px;
  width: 96px;
  border-radius: 14px;
  background: #fff;
  padding: 6px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

.site-header__titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.site-header h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.site-header p {
  margin: 0.25rem 0 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

.site-header a {
  color: #e0f7fa;
}

.site-header a:hover {
  color: #fff;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* App shell + sidebar (shared by public and admin) */
.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 92px);
}

.sidebar {
  flex: 0 0 260px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 0.5rem;
}

.sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar__item {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  word-break: break-word;
}

.sidebar__item:hover {
  background: #f1f5f9;
  color: var(--teal-dark);
}

.sidebar__item.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-dark);
}

.sidebar__item.is-active:hover {
  background: var(--teal-dark);
  color: #fff;
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid #e2e8f0;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
}

.admin-body .sidebar {
  background: #ffffff;
}

@media (max-width: 820px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    position: static;
    height: auto;
    align-self: stretch;
  }

  .sidebar__title,
  .sidebar__divider {
    display: none;
  }

  .sidebar__list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  .sidebar__item {
    white-space: nowrap;
  }

  .sidebar__footer {
    border-top: none;
    padding-top: 0;
    margin-left: auto;
  }
}

.page-title {
  text-align: center;
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.page-sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 2rem;
}

.curriculum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.curriculum-tile {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  border: 1px solid rgba(13, 92, 99, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.curriculum-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 92, 99, 0.18);
}

.curriculum-tile h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--teal-dark);
}

.section-block {
  margin-bottom: 2.5rem;
}

.section-heading {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  color: var(--teal-dark);
}

.cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  align-items: stretch;
}

.unit-card {
  flex: 1 1 260px;
  max-width: 380px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(13, 92, 99, 0.1);
  display: flex;
  flex-direction: column;
}

.unit-card__head {
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: 1rem 1.1rem;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

.unit-card__body {
  padding: 1rem 1.25rem 1.25rem;
  flex: 1;
}

.unit-card__body ul {
  margin: 0;
  padding-left: 1.2rem;
}

.unit-card__body li {
  margin-bottom: 0.4rem;
}

.unit-card__body li a {
  word-break: break-word;
}

.unit-card__empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 3rem;
}

.section-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  border: 1px solid rgba(13, 92, 99, 0.15);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin: 0 auto 1.5rem;
  max-width: 720px;
  box-shadow: 0 1px 6px rgba(13, 92, 99, 0.08);
}

.section-filter__label {
  font-weight: 600;
  color: var(--teal-dark);
  font-size: 0.95rem;
}

.section-filter__select {
  flex: 1;
  min-width: 180px;
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.section-filter__select:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.section-filter__clear {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Admin */
.admin-body {
  background: #eef2f7;
}

.admin-top {
  background: #1e293b url('logo.png') no-repeat 1rem center;
  background-size: 28px 28px;
  color: #fff;
  padding: 0.75rem 1.25rem 0.75rem 3.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-top a {
  color: #e2e8f0;
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.92rem;
  line-height: 1;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}

.admin-top a:hover,
.admin-top a:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
  outline: none;
}

.admin-top a:active {
  transform: translateY(1px);
}

.admin-top .inline-actions {
  gap: 0.5rem;
}

.admin-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-wrap--wide {
  /* Use much more horizontal space on large screens */
  max-width: min(2000px, 100vw);
  width: 100%;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.admin-wrap--wide .form-row input[type="text"],
.admin-wrap--wide .form-row input[type="url"],
.admin-wrap--wide .form-row input[type="email"],
.admin-wrap--wide .form-row input[type="number"],
.admin-wrap--wide .form-row input[type="password"],
.admin-wrap--wide .form-row select,
.admin-wrap--wide .form-row textarea {
  max-width: none;
  width: 100%;
}

.admin-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
}

.admin-card h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.form-row {
  margin-bottom: 0.85rem;
}

.form-row label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="url"],
.form-row input[type="email"],
.form-row input[type="number"],
.form-row textarea,
.form-row select {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-row textarea {
  max-width: 100%;
  resize: vertical;
  line-height: 1.5;
  min-height: 80px;
}

.form-row select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-row input:hover,
.form-row textarea:hover,
.form-row select:hover {
  border-color: #94a3b8;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 92, 99, 0.18);
}

.form-row input::placeholder,
.form-row textarea::placeholder {
  color: #94a3b8;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--admin-accent);
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  color: #fff;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-ghost {
  background: #e2e8f0;
  color: #334155;
}

.btn-ghost:hover {
  background: #cbd5e1;
  color: #1e293b;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
  font-weight: 600;
  color: #475569;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-admin {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: #f8fafc;
}

.section-admin.collapsible-section {
  padding: 0;
  overflow: hidden;
}

.collapsible-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  background: #e8eef3;
  border-bottom: 1px solid transparent;
}

.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

.collapsible-section[open] > summary {
  border-bottom-color: #cbd5e1;
  background: #f1f5f9;
}

.collapsible-section > summary:focus-visible,
.collapsible-unit > summary:focus-visible,
.collapsible-resources > summary:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: 2px;
}

.collapsible-section__lead {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.collapsible-section__chevron {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid #475569;
  border-bottom: 2px solid #475569;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-top: -0.15rem;
}

.collapsible-section[open] .collapsible-section__chevron {
  transform: rotate(45deg);
  margin-top: 0.1rem;
}

.collapsible-section__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsible-section__badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  background: #fff;
  border: 1px solid #cbd5e1;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.collapsible-section__actions {
  flex-shrink: 0;
}

.collapsible-section__body {
  padding: 1rem;
}

.section-admin h3 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.unit-admin {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.unit-admin.collapsible-unit {
  padding: 0;
  overflow: hidden;
}

.collapsible-unit > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e293b;
  background: #fafafa;
}

.collapsible-unit > summary::-webkit-details-marker {
  display: none;
}

.collapsible-unit[open] > summary {
  border-bottom: 1px solid #e2e8f0;
}

.collapsible-unit__lead {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.collapsible-unit__chevron {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.collapsible-unit[open] .collapsible-unit__chevron {
  transform: rotate(45deg);
}

.collapsible-unit__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsible-unit__actions {
  flex-shrink: 0;
}

.collapsible-unit__body {
  padding: 0.85rem 1rem 1rem;
}

.unit-resources.collapsible-resources {
  margin-top: 0.5rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.collapsible-resources > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #334155;
}

.collapsible-resources > summary::-webkit-details-marker {
  display: none;
}

.collapsible-resources[open] > summary {
  border-bottom: 1px dashed #cbd5e1;
  background: #f1f5f9;
}

.collapsible-resources__chevron {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.collapsible-resources[open] .collapsible-resources__chevron {
  transform: rotate(45deg);
}

.collapsible-resources__badge {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 1.35rem;
  text-align: center;
  background: #e2e8f0;
  color: #475569;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.collapsible-resources__hint {
  font-weight: 400;
  font-size: 0.8rem;
}

.collapsible-resources__body {
  padding: 0.75rem;
  background: #fff;
}

.unit-admin h4 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}

.resource-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.65rem;
}

.resource-row form.resource-update {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
  gap: 0.5rem;
  align-items: flex-end;
  min-width: min(100%, 280px);
}

.resource-row form.resource-update .form-row {
  flex: 1 1 140px;
  margin-bottom: 0;
}

.resource-row form.resource-update .form-row.wide {
  flex: 2 1 220px;
}

.resource-table {
  margin-bottom: 0.85rem;
  table-layout: fixed;
  width: 100%;
}

.resource-table th,
.resource-table td {
  vertical-align: middle;
  word-break: break-word;
}

.resource-table th:first-child,
.resource-table td:first-child {
  width: 22%;
}

.resource-table__url {
  max-width: 0;
}

.resource-table__url a,
.resource-table__url span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-table__actions {
  width: 240px;
  min-width: 240px;
  white-space: nowrap;
  text-align: right;
}

.resource-table__actions .inline-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.resource-edit-row > td {
  background: #f8fafc;
}

.resource-edit-form {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.65rem 0.85rem;
  align-items: end;
  padding: 0.5rem 0;
}

.resource-edit-form .form-row {
  margin-bottom: 0;
}

.resource-edit-form .inline-actions {
  grid-column: 1 / -1;
}

@media (max-width: 720px) {
  .resource-edit-form {
    grid-template-columns: 1fr;
  }
}

.resource-add-area {
  margin-top: 0.5rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #e2e8f0;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.login-box {
  max-width: 400px;
  margin: 3rem auto;
}

.login-box .admin-card h2 {
  margin-bottom: 0.5rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.card-form {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.85rem;
}

.card-form .form-row:last-of-type {
  margin-bottom: 0.85rem;
}

.detail-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 0.35rem 1rem;
}

.detail-list > div {
  display: contents;
}

.detail-list dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
  align-self: center;
}

.detail-list dd {
  margin: 0;
  font-size: 0.95rem;
  word-break: break-word;
}

.detail-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88rem;
}

/* Sidebar divider for Library section */
.sidebar__divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0.85rem 0;
}

/* Unit card tags for flashcards/quizzes */
.unit-card__tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  background: #e0f2f1;
  color: var(--teal-dark);
}
.unit-card__quiz .unit-card__tag {
  background: #fef3c7;
  color: #92400e;
}
.unit-card__flashcard .unit-card__tag {
  background: #ddd6fe;
  color: #5b21b6;
}

/* Flashcard study page */
.flashcard-page {
  max-width: min(1200px, 96vw);
  margin: 0 auto;
}
.flashcard-stage {
  position: relative;
  height: clamp(440px, 70vh, 720px);
  margin: 1.5rem 0;
  perspective: 1600px;
}
.flashcard {
  position: absolute;
  inset: 0;
  display: none;
  cursor: pointer;
}
.flashcard.is-active {
  display: block;
}
.flashcard__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}
.flashcard.is-flipped .flashcard__inner {
  transform: rotateY(180deg);
}
.flashcard__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  font-size: 1.6rem;
  line-height: 1.4;
  text-align: center;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(13, 92, 99, 0.18);
  backface-visibility: hidden;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}
.flashcard__face--back {
  transform: rotateY(180deg);
  background: #f0fdfa;
  color: var(--teal-dark);
}
.flashcard__img {
  max-width: 100%;
  max-height: 70%;
  object-fit: contain;
  border-radius: 10px;
  background: #f8fafc;
}
.flashcard__text {
  max-width: 100%;
  word-break: break-word;
}
.flashcard-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}
.flashcard-counter {
  min-width: 60px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}

/* Admin: side-by-side front/back edit form */
.card-edit-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 720px) {
  .card-edit-sides { grid-template-columns: 1fr; }
}
.card-edit-side {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0;
  background: #f8fafc;
}
.card-edit-side legend {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 0.35rem;
}
.card-image-current {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.card-image-current img {
  max-width: 140px;
  max-height: 100px;
  object-fit: contain;
  background: #f1f5f9;
  border-radius: 4px;
}
.card-image-current__remove {
  font-size: 0.85rem;
  color: var(--muted);
}
.card-thumb {
  display: inline-block;
  margin-bottom: 0.35rem;
}
.card-thumb img {
  max-width: 120px;
  max-height: 90px;
  object-fit: contain;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
}

/* Sidebar unread badge */
.sidebar__badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.sidebar__item.is-active .sidebar__badge {
  background: #fff;
  color: var(--teal-dark);
}

/* Public contact page */
.contact-page {
  max-width: min(1100px, 96%);
  margin: 0 auto;
}
.contact-page .page-title {
  margin-bottom: 0.35rem;
}
.contact-page .page-sub {
  max-width: 720px;
  margin: 0 auto 1.5rem;
}

.contact-form {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 2rem 2.25rem;
  box-shadow: 0 10px 32px rgba(13, 92, 99, 0.08);
}
.contact-form .form-row {
  margin-bottom: 1.1rem;
}
.contact-form .form-row label {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: #1e293b;
}
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
  max-width: none;
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}
.contact-form textarea {
  min-height: 240px;
  line-height: 1.6;
  font-size: 1rem;
  resize: vertical;
}
.contact-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
}
@media (max-width: 720px) {
  .contact-form__grid { grid-template-columns: 1fr; }
  .contact-form { padding: 1.25rem; }
}
.contact-form .inline-actions {
  margin-top: 0.5rem;
  gap: 0.75rem;
}
.contact-form .inline-actions .btn {
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
}
.contact-form .muted {
  font-weight: 400;
}

/* Admin: messages page */
.message-card .message-card__head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.message-card__from {
  font-weight: 600;
  font-size: 1.05rem;
}
.message-card__email {
  font-size: 0.9rem;
  margin-top: 0.15rem;
}
.message-card__meta {
  text-align: right;
}
.message-card__time {
  font-size: 0.85rem;
}
.message-card__body {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Public sidebar contact link visual tweak */
.sidebar__item[href*="contact.php"]::before {
  content: "✉ ";
  margin-right: 0.25rem;
}

/* Admin quiz editor */
.quiz-question {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem 0;
}
.quiz-question__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.quiz-question__num {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 0.5rem;
}
.quiz-question__text {
  font-size: 1.05rem;
  margin: 0.4rem 0 0.75rem;
}
.quiz-question__text--pre {
  white-space: pre-wrap;
  tab-size: 4;
  -moz-tab-size: 4;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.quiz-question__image {
  margin: 0.4rem 0 0.6rem;
}
.quiz-question__image img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  display: block;
  background: #f8fafc;
}
.quiz-question__editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  tab-size: 4;
  -moz-tab-size: 4;
  white-space: pre;
  overflow-x: auto;
}
.quiz-option-table {
  margin-top: 0.5rem;
}
.quiz-correct-toggle {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}
.quiz-correct-toggle.is-correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
  font-weight: 600;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

/* Public quiz */
.quiz-page {
  max-width: 820px;
  margin: 0 auto;
}
.quiz-page__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.quiz-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.6rem;
  font-weight: 700;
  background: #fff;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--card-shadow);
}
.quiz-timer.is-warning {
  color: #b91c1c;
  border-color: #fca5a5;
  background: #fef2f2;
}
.quiz-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.5rem 0;
  z-index: 5;
}
.quiz-nav__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.quiz-nav__pill.is-answered {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.quiz-question.public {
  scroll-margin-top: 80px;
}
.quiz-options {
  list-style: none;
  margin: 0.25rem 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.quiz-option:hover {
  border-color: var(--teal);
  background: #f0fdfa;
}
.quiz-option input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}
.quiz-question__nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.quiz-submit-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.05);
  margin-top: 1.5rem;
}

/* Quiz results */
.quiz-result-summary {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.25rem;
  box-shadow: var(--card-shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.quiz-result-summary__score {
  font-size: 1.8rem;
}
.quiz-result-summary__pct {
  font-size: 1.1rem;
  color: var(--muted);
  margin-left: 0.5rem;
}
.quiz-result.is-correct {
  border-left: 4px solid #16a34a;
}
.quiz-result.is-partial {
  border-left: 4px solid #ca8a04;
}
.quiz-result.is-wrong {
  border-left: 4px solid #dc2626;
}
.quiz-option-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.quiz-option-result.is-correct {
  background: #dcfce7;
  border-color: #86efac;
}
.quiz-option-result.is-missed {
  background: #fef9c3;
  border-color: #fde68a;
}
.quiz-option-result.is-wrong {
  background: #fee2e2;
  border-color: #fca5a5;
}
.quiz-option-result__marker {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}


/* ===== Food for thought (blogs) ===== */
.blogs-page {
  max-width: min(1280px, 100%);
  margin: 0 auto;
}
.blog-list {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}
.blog-tile {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(13, 92, 99, 0.06);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.blog-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(13, 92, 99, 0.1);
}
.blog-tile--with-image {
  grid-template-columns: 260px 1fr;
}
@media (max-width: 720px) {
  .blog-tile--with-image {
    grid-template-columns: 1fr;
  }
}
.blog-tile__media {
  display: block;
  height: 100%;
  min-height: 180px;
  overflow: hidden;
  background: #f1f5f9;
}
.blog-tile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.blog-tile__body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.blog-tile__title {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.3;
}
.blog-tile__title a {
  color: var(--text);
  text-decoration: none;
}
.blog-tile__title a:hover {
  color: var(--primary);
  text-decoration: underline;
}
.blog-tile__meta {
  color: var(--muted);
  font-size: 0.85rem;
}
.blog-tile__excerpt {
  margin: 0.25rem 0 0.5rem;
  color: #334155;
  line-height: 1.55;
}
.blog-tile__actions {
  margin-top: 0.25rem;
}

/* Single blog post */
.blog-single {
  max-width: min(1280px, 100%);
  margin: 0 auto;
}
.blog-single__top {
  margin-bottom: 0.75rem;
}
.blog-single__article {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(13, 92, 99, 0.08);
  padding: 2.25rem 2.75rem;
}
.blog-single__title {
  margin: 0 0 0.4rem;
  font-size: 1.9rem;
  line-height: 1.25;
}
.blog-single__meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}
.blog-single__content {
  line-height: 1.7;
  color: #1f2937;
  font-size: 1.05rem;
}
.blog-single__content > * + * {
  margin-top: 0.8rem;
}
.blog-single__content h1,
.blog-single__content h2,
.blog-single__content h3,
.blog-single__content h4 {
  line-height: 1.3;
  margin-top: 1.4rem;
}
.blog-single__content h2 { font-size: 1.5rem; }
.blog-single__content h3 { font-size: 1.25rem; }
.blog-single__content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 0.5rem auto;
}
.blog-single__content iframe {
  max-width: 100%;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: 10px;
  display: block;
  margin: 0.75rem auto;
}
.blog-single__content audio {
  width: 100%;
  margin: 0.5rem 0;
}
.blog-single__content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
}
.blog-single__content table th,
.blog-single__content table td {
  border: 1px solid #cbd5e1;
  padding: 0.5rem 0.7rem;
  text-align: left;
}
.blog-single__content table th {
  background: #f8fafc;
  font-weight: 600;
}
.blog-single__content blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.5rem 1rem;
  color: #475569;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
}
.blog-single__content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
}
.blog-single__content code {
  background: #f1f5f9;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.95em;
}
.blog-single__content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.blog-single__content ul,
.blog-single__content ol {
  padding-left: 1.5rem;
}

/* Page heading shared */
.page-heading {
  margin-bottom: 1rem;
}
.page-heading h2 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
}
