:root {
  --bg: #f6f1e8;
  --paper: #fffdf8;
  --ink: #1f2a24;
  --muted: #5f6c63;
  --line: rgba(31, 42, 36, 0.12);
  --accent: #1d6b52;
  --accent-soft: #dbeee3;
  --warm: #e7b46a;
  --shadow: 0 18px 45px rgba(39, 53, 45, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(231, 180, 106, 0.3), transparent 28%),
    linear-gradient(180deg, #f8f3ea 0%, #f2ece2 100%);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.site-version {
  margin-top: 28px;
  font-size: 0.9rem;
  text-align: center;
}

.site-version-link {
  color: var(--muted);
  text-decoration: none;
}

.site-version-link:hover,
.site-version-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.hero {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.95), rgba(243, 236, 222, 0.9)),
    var(--paper);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 4vw, 4.6rem);
  line-height: 0.95;
}

.hero-copy {
  margin: 20px 0 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.levels {
  display: grid;
  gap: 24px;
  margin-top: 28px;
}

.level-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.level-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(219, 238, 227, 0.9), rgba(255, 248, 234, 0.9));
}

.level-header h2 {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
}

.level-header p,
.level-count {
  margin: 0;
  color: var(--muted);
}

.level-count {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.85);
  font-weight: 700;
  white-space: nowrap;
}

.texts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 24px;
}

.text-card {
  position: relative;
}

.text-button {
  display: block;
  min-height: 100%;
  padding: 18px 68px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  text-align: left;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.text-button:hover,
.text-button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(29, 107, 82, 0.45);
  box-shadow: 0 12px 24px rgba(39, 53, 45, 0.08);
  outline: none;
}

.text-button.is-completed {
  border-color: rgba(29, 107, 82, 0.28);
  background: #e3f0e8;
  color: var(--ink);
}

.text-button.is-completed .text-label {
  color: #15533f;
}

.text-bookmark-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.95);
  color: var(--accent);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.text-bookmark-button:hover,
.text-bookmark-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(29, 107, 82, 0.42);
  background: rgba(219, 238, 227, 0.9);
  outline: none;
}

.text-bookmark-button.is-active {
  border-color: rgba(29, 107, 82, 0.46);
  background: rgba(219, 238, 227, 0.95);
}

.text-label {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.text-title {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.text-topic,
.completed-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.text-topic {
  margin-right: 6px;
  background: #f4ead9;
  color: #67491d;
}

.completed-badge {
  background: #c8e5d4;
  color: #124a38;
}

.continue-card,
.library-tools,
.library-state {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.continue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  border-color: rgba(29, 107, 82, 0.24);
  background: linear-gradient(135deg, #dbeee3, #fff8ea);
}

.continue-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.continue-card h2,
.library-tools h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.continue-meta {
  margin: 8px 0 0;
  color: var(--muted);
}

.continue-link,
.next-story-link,
.completion-back-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.continue-link,
.next-story-link {
  background: var(--accent);
  color: #fffdf8;
}

.library-tools {
  padding: 24px 28px;
}

.library-tools-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.library-controls {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(2, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.library-field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.library-field input,
.library-field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 42, 36, 0.24);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

.clear-filters-button,
.level-toggle-button,
.retry-button,
.review-mistakes-button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(29, 107, 82, 0.32);
  border-radius: 12px;
  background: rgba(219, 238, 227, 0.72);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.clear-filters-button:disabled {
  border-color: var(--line);
  background: rgba(222, 224, 221, 0.5);
  color: var(--muted);
  cursor: default;
}

.library-summary {
  margin: 16px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.library-state {
  padding: 22px 24px;
  color: var(--muted);
  text-align: center;
}

.library-state p {
  margin: 0;
}

.library-state .retry-button {
  margin-top: 14px;
}

.level-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.level-visible-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.level-toggle-button {
  background: var(--paper);
}

.story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 20px;
  align-items: start;
}

.back-link {
  display: inline-flex;
  grid-column: 1 / -1;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.story-card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.96), rgba(243, 236, 222, 0.9)),
    var(--paper);
  box-shadow: var(--shadow);
}

.story-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.story-level {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-title {
  margin: 0 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 4vw, 3.7rem);
  line-height: 1.05;
}

.bookmark-button {
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.95);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
}

.bookmark-button:hover,
.bookmark-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(29, 107, 82, 0.42);
  background: rgba(219, 238, 227, 0.8);
  outline: none;
}

.bookmark-button.is-active {
  border-color: rgba(29, 107, 82, 0.46);
  background: rgba(219, 238, 227, 0.92);
}

.bookmark-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.story-note {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.75;
}

.story-content {
  display: grid;
  gap: 16px;
}

.word-count-note {
  margin: 4px 0 0;
  color: var(--accent);
  font-weight: 800;
}

.questions-card {
  position: sticky;
  top: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.questions-title {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
}

.questions-list {
  display: grid;
}

.questions-footer {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.questions-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.question-item {
  display: grid;
  gap: 12px;
  min-inline-size: 0;
  margin: 0;
  padding: 20px 0;
  border: 0;
  border-bottom: 2px dotted rgba(31, 42, 36, 0.22);
}

.question-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.question-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  font-weight: 800;
}

.question-legend {
  display: grid;
  width: 100%;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0;
}

.question-prompt {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.45;
}

.question-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.answer-option {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: start;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  cursor: pointer;
  line-height: 1.4;
  transform-origin: center;
  transition:
    transform 0.14s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.answer-option:not(.is-locked):hover {
  transform: translateY(-2px);
  border-color: rgba(29, 107, 82, 0.34);
  box-shadow: 0 8px 18px rgba(31, 42, 36, 0.08);
}

.answer-option:not(.is-locked):active {
  transform: translateY(0) scale(0.975);
}

.answer-option input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.answer-option.is-locked,
.answer-option.is-locked input {
  cursor: not-allowed;
}

.answer-marker {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.answer-option span:last-child {
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.answer-option.is-correct {
  border-color: rgba(29, 107, 82, 0.55);
  background: rgba(219, 238, 227, 0.8);
}

.answer-option.is-wrong {
  border-color: rgba(164, 67, 52, 0.45);
  background: rgba(255, 236, 229, 0.75);
}

.answer-option.is-correct-answer {
  border-color: rgba(29, 107, 82, 0.52);
  box-shadow: inset 0 0 0 1px rgba(29, 107, 82, 0.3);
}

.answer-option.is-answering-correct {
  animation: answer-success 0.46s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.answer-option.is-answering-wrong {
  animation: answer-error 0.38s ease;
}

.answer-option.is-revealing-correct-answer {
  animation: answer-correct-hint 0.58s ease;
}

.answer-option.is-answering-correct .answer-marker {
  animation: answer-marker-success 0.46s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.answer-option.is-answering-wrong .answer-marker {
  animation: answer-marker-error 0.38s ease;
}

.answer-feedback {
  min-height: 1.5em;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.5;
}

.answer-feedback.is-correct {
  color: #15533f;
}

.answer-feedback.is-wrong {
  color: #873729;
}

.answer-feedback.is-revealing {
  animation: answer-feedback-in 0.28s ease-out;
}

.completion-actions {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(29, 107, 82, 0.2);
  border-radius: 16px;
  background: rgba(219, 238, 227, 0.46);
}

.completion-actions:not([hidden]) {
  animation: completion-actions-in 0.36s ease-out;
}

.completion-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.review-mistakes-button {
  width: 100%;
  background: var(--paper);
}

.completion-back-link {
  border: 1px solid rgba(31, 42, 36, 0.2);
  color: var(--ink);
}

.restart-button {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(29, 107, 82, 0.22);
  border-radius: 14px;
  background: rgba(219, 238, 227, 0.72);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.restart-button:hover,
.restart-button:focus-visible {
  border-color: rgba(29, 107, 82, 0.45);
  background: rgba(219, 238, 227, 0.95);
  outline: none;
}

.review-mistakes-button,
.restart-button,
.next-story-link,
.completion-back-link {
  transition:
    transform 0.14s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}

.review-mistakes-button:active,
.restart-button:active,
.next-story-link:active,
.completion-back-link:active {
  transform: translateY(1px) scale(0.98);
}

@keyframes answer-success {
  0% {
    transform: scale(0.975);
  }
  55% {
    transform: scale(1.025);
    box-shadow: 0 0 0 5px rgba(29, 107, 82, 0.13);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes answer-error {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes answer-correct-hint {
  0% {
    box-shadow: inset 0 0 0 1px rgba(29, 107, 82, 0.3);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(29, 107, 82, 0.3),
      0 0 0 5px rgba(29, 107, 82, 0.12);
  }
  100% {
    box-shadow: inset 0 0 0 1px rgba(29, 107, 82, 0.3);
  }
}

@keyframes answer-marker-success {
  0% {
    transform: scale(0.75) rotate(-8deg);
  }
  65% {
    transform: scale(1.15) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes answer-marker-error {
  0%,
  100% {
    transform: rotate(0);
  }
  35% {
    transform: rotate(-10deg);
  }
  70% {
    transform: rotate(8deg);
  }
}

@keyframes answer-feedback-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes completion-actions-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1100px) {
  .story-layout {
    grid-template-columns: 1fr;
  }

  .questions-card {
    position: static;
  }
}

@media (max-width: 900px) {
  .texts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-options {
    grid-template-columns: 1fr;
  }

  .library-controls {
    grid-template-columns: 1fr 1fr;
  }

  .library-search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .hero,
  .level-header,
  .texts-grid,
  .story-card,
  .questions-card {
    padding-left: 18px;
    padding-right: 18px;
  }

  .level-header {
    flex-direction: column;
    align-items: start;
  }

  .level-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .continue-card,
  .library-tools-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .continue-link,
  .clear-filters-button {
    width: 100%;
  }

  .library-tools {
    padding: 20px 18px;
  }

  .library-controls {
    grid-template-columns: 1fr;
  }

  .library-search-field {
    grid-column: auto;
  }

  .texts-grid {
    grid-template-columns: 1fr;
  }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.admin-page { background: radial-gradient(circle at 15% 10%, rgba(231, 180, 106, 0.22), transparent 30%), linear-gradient(145deg, #f8f3ea, #eef2eb); }
.admin-page [hidden] { display: none !important; }
.admin-shell { min-height: 100vh; }
.admin-login { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.admin-login-form { display: grid; gap: 12px; width: min(100%, 360px); }
.admin-login-field input { width: 100%; padding: 16px 18px; border: 1px solid rgba(31, 42, 36, 0.16); border-radius: 14px; background: rgba(255, 253, 248, 0.94); color: var(--ink); font: inherit; font-size: 1rem; box-shadow: 0 8px 24px rgba(39, 53, 45, 0.06); }
.admin-login-field input:focus, .admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus { border-color: var(--accent); outline: 3px solid rgba(29, 107, 82, 0.12); }
.admin-primary-button, .admin-logout-button { border: 0; border-radius: 12px; font: inherit; font-weight: 800; cursor: pointer; }
.admin-primary-button { padding: 13px 18px; background: var(--accent); color: #fff; }
.admin-primary-button:hover, .admin-primary-button:focus-visible { background: #15533f; outline: none; }
.admin-secondary-button { padding: 12px 16px; border: 1px solid rgba(29, 107, 82, 0.28); border-radius: 12px; background: rgba(255, 253, 248, 0.95); color: var(--accent); font: inherit; font-weight: 800; cursor: pointer; }
.admin-secondary-button:hover, .admin-secondary-button:focus-visible { border-color: rgba(29, 107, 82, 0.48); background: rgba(219, 238, 227, 0.68); outline: none; }
.admin-login-form .admin-primary-button { width: 100%; margin-top: 2px; }
.admin-status { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 0.9rem; }
.admin-login-form .admin-status { text-align: center; }
.admin-status.is-error { color: #9c3d2d; }
.admin-status.is-success { color: var(--accent); }
.admin-panel { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 32px 0 56px; }
.admin-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.admin-topbar h1, .admin-editor-heading h2, .admin-sidebar-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; }
.admin-topbar h1 { font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1; }
.admin-kicker { margin: 0 0 7px; color: var(--accent); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.admin-logout-button { position: fixed; z-index: 10; top: 22px; right: 24px; padding: 10px 15px; border: 1px solid rgba(31, 42, 36, 0.14); background: rgba(255, 253, 248, 0.92); color: var(--ink); box-shadow: 0 8px 24px rgba(39, 53, 45, 0.1); backdrop-filter: blur(12px); }
.admin-logout-button:hover, .admin-logout-button:focus-visible { border-color: rgba(156, 61, 45, 0.35); color: #9c3d2d; outline: none; }
.admin-workspace { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.admin-sidebar-column { position: sticky; top: 22px; display: grid; gap: 12px; min-width: 0; }
.admin-add-story-button { width: 100%; padding: 15px 18px; border: 1px solid rgba(29, 107, 82, 0.28); border-radius: 16px; background: var(--accent); color: #fff; font: inherit; font-weight: 800; text-align: left; cursor: pointer; box-shadow: 0 12px 28px rgba(29, 107, 82, 0.18); }
.admin-add-story-button:hover, .admin-add-story-button:focus-visible { background: #15533f; outline: none; }
.admin-sidebar, .admin-editor-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 253, 248, 0.9); box-shadow: var(--shadow); }
.admin-sidebar { max-height: calc(100vh - 110px); overflow: hidden; }
.admin-sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.admin-sidebar-heading h2 { font-size: 1.25rem; }
.admin-sidebar-heading span { color: var(--muted); font-size: 0.85rem; }
.admin-text-list { display: grid; gap: 6px; max-height: calc(100vh - 112px); padding: 10px; overflow-y: auto; }
.admin-text-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 11px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; font: inherit; font-size: 0.92rem; cursor: pointer; }
.admin-text-row:hover { background: rgba(219, 238, 227, 0.42); }
.admin-text-row.is-active { border-color: rgba(29, 107, 82, 0.28); background: rgba(219, 238, 227, 0.72); }
.admin-pill { flex: 0 0 auto; width: 8px; height: 8px; overflow: hidden; border-radius: 50%; color: transparent; font-size: 0; }
.admin-pill.is-enabled { background: var(--accent); }
.admin-pill.is-disabled { background: #c46c58; }
.admin-editor-card { padding: 26px; }
.admin-form { display: grid; gap: 16px; }
.admin-form label { display: grid; gap: 7px; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.admin-form input, .admin-form textarea, .admin-form select { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; font-weight: 400; }
.admin-form input[readonly] { background: #f1eee7; color: var(--muted); }
.admin-form textarea { min-height: 260px; resize: vertical; line-height: 1.65; }
.admin-editor-heading, .admin-form-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.admin-editor-heading h2 { font-size: 1.75rem; }
.admin-meta-fields { display: grid; grid-template-columns: 90px 90px; gap: 10px; }
.admin-questions-panel { display: grid; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(248, 243, 234, 0.65); }
.admin-questions-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.admin-questions-header h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.4rem; color: var(--ink); }
.admin-questions-copy { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.admin-questions-list { display: grid; gap: 14px; }
.admin-question-card { display: grid; gap: 14px; padding: 16px; border: 1px solid rgba(31, 42, 36, 0.12); border-radius: 16px; background: rgba(255, 253, 248, 0.96); }
.admin-question-card label textarea { min-height: 110px; }
.admin-question-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-question-card-header h4 { margin: 0; font-size: 1rem; color: var(--ink); }
.admin-question-remove { padding: 8px 12px; border: 1px solid rgba(156, 61, 45, 0.2); border-radius: 10px; background: rgba(255, 248, 246, 0.92); color: #9c3d2d; font: inherit; font-weight: 700; cursor: pointer; }
.admin-question-remove:hover, .admin-question-remove:focus-visible { border-color: rgba(156, 61, 45, 0.4); outline: none; }
.admin-question-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-toggles { display: flex; flex-wrap: wrap; gap: 16px; }
.admin-checkbox { display: flex !important; grid-template-columns: none; align-items: center; gap: 8px !important; color: var(--ink) !important; font-size: 0.9rem !important; }
.admin-checkbox input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
@media (max-width: 820px) { .admin-panel { width: min(100% - 24px, 1440px); padding-top: 24px; } .admin-workspace { grid-template-columns: 1fr; } .admin-sidebar-column { position: static; } .admin-sidebar { max-height: 340px; } .admin-text-list { max-height: 270px; } .admin-editor-heading, .admin-form-footer, .admin-questions-header { align-items: stretch; flex-direction: column; } .admin-meta-fields { grid-template-columns: 1fr 1fr; } .admin-question-grid { grid-template-columns: 1fr; } .admin-form-footer .admin-primary-button, .admin-questions-header .admin-secondary-button { width: 100%; } }
@media (max-width: 520px) { .admin-login { padding: 18px; } .admin-topbar { padding-right: 78px; } .admin-logout-button { top: 14px; right: 12px; } .admin-editor-card { padding: 18px; } }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid #1d6b52 !important;
  outline-offset: 3px;
}

.answer-option:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 107, 82, 0.18);
}

.clear-filters-button:not(:disabled):hover,
.level-toggle-button:hover,
.retry-button:hover,
.review-mistakes-button:hover,
.completion-back-link:hover {
  border-color: rgba(29, 107, 82, 0.52);
  background: #dbeee3;
}

.continue-link:hover,
.next-story-link:hover {
  background: #15533f;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Admin publishing workflow */
.admin-user-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-primary-button:disabled,
.admin-secondary-button:disabled,
.admin-danger-button:disabled,
.admin-question-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.admin-list-filters {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-list-filters input,
.admin-list-filters select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.admin-filter-row {
  display: grid;
  grid-template-columns: 0.85fr 1.35fr;
  gap: 8px;
}

.admin-text-list {
  max-height: calc(100vh - 294px);
}

.admin-text-row-copy {
  display: grid;
  min-width: 0;
}

.admin-text-row-copy strong {
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-text-row-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-pill,
.admin-story-status {
  width: auto;
  height: auto;
  overflow: visible;
  padding: 4px 7px;
  border-radius: 999px;
  color: #405047;
  background: #ece8df;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.admin-pill.is-published,
.admin-story-status.is-published {
  color: #15533f;
  background: #dbeee3;
}

.admin-pill.is-draft,
.admin-story-status.is-draft {
  color: #76551a;
  background: #f6e9c8;
}

.admin-pill.is-published_with_draft,
.admin-story-status.is-published_with_draft {
  color: #24516b;
  background: #dcebf3;
}

.admin-pill.is-unpublished,
.admin-story-status.is-unpublished {
  color: #843728;
  background: #f5ded8;
}

.admin-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.admin-editor-attribution {
  min-height: 1.35em;
  margin-top: -8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-form label small {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 400;
}

.admin-editor-card[aria-busy="true"] {
  cursor: progress;
}

.admin-question-card {
  display: block;
  padding: 0;
  overflow: clip;
}

.admin-question-card.has-error {
  border-color: rgba(156, 61, 45, 0.48);
}

.admin-question-card summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style-position: inside;
}

.admin-question-card summary::marker {
  color: var(--accent);
}

.admin-question-number {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-question-summary-prompt {
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-question-card-body {
  display: grid;
  gap: 14px;
  padding: 2px 16px 16px;
}

.admin-question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.admin-question-actions button,
.admin-text-action,
.admin-undo-bar button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.admin-question-actions .admin-question-remove {
  margin-left: auto;
  color: #9c3d2d;
}

.admin-question-error {
  min-height: 1.2em;
  margin: 0;
  color: #9c3d2d;
  font-size: 0.82rem;
  font-weight: 700;
}

.admin-undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #25362d;
  color: #fff;
  font-size: 0.86rem;
}

.admin-undo-bar button {
  border-color: rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
}

.admin-history-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.78);
}

.admin-history-heading,
.admin-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-history-heading h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
}

.admin-history-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-history-list {
  display: grid;
  gap: 8px;
}

.admin-history-row {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.admin-history-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.admin-history-row strong,
.admin-history-row span,
.admin-history-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-history-row span,
.admin-history-row small {
  color: var(--muted);
  font-size: 0.76rem;
}

.admin-empty-state {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.admin-empty-state.is-error {
  color: #9c3d2d;
}

.admin-save-bar {
  position: sticky;
  z-index: 5;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid rgba(31, 42, 36, 0.16);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 12px 34px rgba(39, 53, 45, 0.16);
  backdrop-filter: blur(14px);
}

.admin-save-state {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.admin-save-state.is-dirty {
  color: #9c5e1d;
  font-weight: 800;
}

.admin-save-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-danger-button {
  padding: 12px 16px;
  border: 1px solid rgba(156, 61, 45, 0.28);
  border-radius: 12px;
  background: rgba(255, 248, 246, 0.96);
  color: #9c3d2d;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-preview-dialog {
  width: min(760px, calc(100% - 30px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(31, 42, 36, 0.28);
}

.admin-preview-dialog::backdrop {
  background: rgba(22, 31, 26, 0.58);
  backdrop-filter: blur(4px);
}

.admin-preview-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
}

.admin-preview-toolbar h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.admin-preview-story,
.admin-preview-quiz {
  padding: 8px 28px 24px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.8;
}

.admin-preview-quiz {
  padding-top: 0;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .admin-text-list { max-height: 250px; }
  .admin-save-bar { align-items: stretch; flex-direction: column; }
  .admin-save-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-save-actions button { width: 100%; }
}

@media (max-width: 520px) {
  .admin-filter-row,
  .admin-save-actions { grid-template-columns: 1fr; }
  .admin-question-actions .admin-question-remove { margin-left: 0; }
  .admin-history-row { align-items: flex-start; }
  .admin-preview-toolbar { align-items: stretch; flex-direction: column; }
}
