:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

a {
  color: inherit;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #d8dde5;
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 42px);
}

.nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.nav a:not(.brand) {
  color: #3e4a58;
  font-weight: 650;
  text-decoration: none;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.page {
  margin: 0 auto;
  max-width: 1160px;
  padding: 28px clamp(16px, 4vw, 42px);
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.panel,
.auth-panel {
  background: #ffffff;
  border: 1px solid #d8dde5;
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 18px;
}

.auth-panel {
  margin: 60px auto;
  max-width: 420px;
}

.auth-panel.wide {
  max-width: 720px;
}

h1,
h2,
h3 {
  margin: 0 0 14px;
}

label {
  display: block;
  font-weight: 650;
  margin: 12px 0 6px;
}

textarea,
input,
select {
  border: 1px solid #b9c2cf;
  border-radius: 6px;
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

button {
  background: #126d6a;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  margin-top: 12px;
  padding: 10px 14px;
}

.speech-control {
  align-items: center;
  display: flex;
  gap: 6px;
  margin: 0;
}

.speech-control select {
  padding: 6px 8px;
  width: auto;
}

.speak-button {
  background: #eef2f6;
  color: #17202a;
  margin: 8px 0 0;
  padding: 6px 10px;
}

.speak-button.large {
  font-size: 18px;
  margin-bottom: 12px;
  min-width: 180px;
  text-align: center;
}

.button-link {
  background: #126d6a;
  border-radius: 6px;
  color: #ffffff;
  display: inline-block;
  font-weight: 700;
  margin-top: 12px;
  padding: 10px 14px;
  text-decoration: none;
}

.button-link.secondary {
  background: #eef2f6;
  color: #24313f;
}

.danger-button {
  background: #a92d2d;
}

.muted,
small {
  color: #596574;
}

.messages {
  margin-bottom: 18px;
}

.message {
  border-radius: 6px;
  margin: 0 0 8px;
  padding: 10px 12px;
}

.message.success {
  background: #e6f4ef;
  color: #145b43;
}

.message.error {
  background: #fdeaea;
  color: #8a1f1f;
}

.ai-overlay {
  align-items: center;
  background: rgba(23, 32, 42, 0.54);
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 40;
}

.ai-overlay div {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
  max-width: 360px;
  padding: 22px;
  text-align: center;
}

.ai-overlay strong,
.ai-overlay span {
  display: block;
}

.ai-overlay strong {
  font-size: 22px;
  margin-bottom: 8px;
}

.htmx-indicator {
  display: none;
}

.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
  display: flex;
}

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

.entry-card,
.question {
  border: 1px solid #d8dde5;
  border-radius: 8px;
  padding: 14px;
}

.entry-card strong {
  font-size: 28px;
}

.entry-card span {
  color: #126d6a;
  display: block;
}

.entry-meta,
.notes {
  color: #596574;
  font-size: 14px;
  margin: 6px 0;
}

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

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

.stats p {
  background: #eef2f6;
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

.stats strong,
.stats span {
  display: block;
}

.stats strong {
  font-size: 28px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.actions.compact {
  margin: 0;
}

.review-row span {
  color: #126d6a;
}

.components {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.components span {
  background: #eef2f6;
  border-radius: 999px;
  color: #2e3a47;
  padding: 4px 8px;
}

.check-list {
  border: 1px solid #d8dde5;
  border-radius: 8px;
  margin-top: 12px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
}

.check-list.tall {
  max-height: 520px;
}

.check-list label {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 22px 70px 1fr;
  margin: 0;
  padding: 8px;
}

.check-list.tall label {
  grid-template-columns: 22px 1fr;
}

.check-list input {
  width: auto;
}

.option-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.option-list label {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 18px 1fr;
  margin: 0;
}

.option-list input {
  width: auto;
}

.category-choice-list {
  border: 1px solid #d8dde5;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  padding: 10px;
}

.category-choice-list label {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 0;
}

.category-choice-list input {
  width: auto;
}

.review-setup {
  border: 1px solid #d8dde5;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  margin-bottom: 18px;
  padding: 14px;
}

.review-setup label {
  margin: 0;
}

.review-setup button {
  align-self: end;
}

.search-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 200px) minmax(150px, 200px) auto;
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry-row {
  align-items: start;
  border: 1px solid #d8dde5;
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px;
}

.selectable-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
}

.entry-select {
  margin: 6px 0 0;
}

.entry-select input {
  width: auto;
}

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

.bulk-actions label {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 0;
}

.bulk-actions input {
  width: auto;
}

.bulk-actions button {
  margin-top: 0;
}

.entry-row strong {
  font-size: 26px;
}

.entry-row span {
  color: #126d6a;
  display: block;
}

.category-badge {
  background: #eef2f6;
  border-radius: 999px;
  color: #3e4a58;
  display: inline-block;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  margin-top: 8px;
  padding: 4px 8px;
}

.row-actions {
  display: flex;
  gap: 10px;
}

.row-actions a {
  font-weight: 700;
  text-decoration: none;
}

.danger {
  color: #a92d2d;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

.pagination a {
  background: #eef2f6;
  border-radius: 6px;
  color: #24313f;
  font-weight: 700;
  padding: 8px 12px;
  text-decoration: none;
}

.admin-grid {
  align-items: start;
}

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

.account-row {
  align-items: center;
  border: 1px solid #d8dde5;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

.account-tools {
  display: grid;
  gap: 10px;
  min-width: min(360px, 100%);
}

.account-tools form {
  border: 1px solid #d8dde5;
  border-radius: 8px;
  padding: 12px;
}

.account-tools button {
  margin-top: 8px;
}

.account-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal {
  align-items: center;
  background: rgba(23, 32, 42, 0.54);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 50;
}

.modal:target,
.modal.is-open {
  display: flex;
}

.modal-panel {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
  max-height: min(760px, 92vh);
  max-width: 720px;
  overflow: auto;
  padding: 20px;
  width: min(720px, 100%);
}

.modal-close {
  color: #596574;
  font-weight: 700;
  text-decoration: none;
}

.table a {
  border-top: 1px solid #d8dde5;
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  text-decoration: none;
}

.test-row {
  align-items: center;
  border-top: 1px solid #d8dde5;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
}

.test-row > a:first-child {
  border-top: 0;
}

.test-row .button-link {
  margin-top: 0;
  white-space: nowrap;
}

.questions {
  display: grid;
  gap: 12px;
}

.question h2 {
  font-size: 32px;
}

.choice-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.choice-grid button {
  background: #eef2f6;
  color: #17202a;
  margin-top: 0;
  min-height: 48px;
  text-align: left;
}

.choice-grid button span {
  display: block;
}

.choice-audio {
  color: #126d6a;
  font-weight: 800;
}

.choice-grid button:hover {
  background: #dfe8ee;
}

.question-nav {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 14px;
}

.question.correct {
  border-color: #2f8f68;
  background: #edf8f3;
}

.question.wrong {
  border-color: #d66b6b;
  background: #fff0f0;
}

@media (max-width: 720px) {
  .topbar,
  .section-heading,
  .entry-row,
  .bulk-actions,
  .account-row {
    align-items: stretch;
    flex-direction: column;
  }

  .selectable-row {
    grid-template-columns: 1fr;
  }

  .nav {
    align-items: start;
    flex-wrap: wrap;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .review-setup {
    grid-template-columns: 1fr;
  }
}
