:root {
  --bg: #f8f4ef;
  --panel: #ffffff;
  --text: #2f251f;
  --muted: #6f6258;
  --line: #ddcec0;
  --brand: #c30000;
  --brand-soft: #f9dddd;
  --accent: #7a6f60;
  --success: #2f7d4f;
  --success-soft: #e3f3e8;
  --danger: #b33632;
  --info: #1d63d6;
  --info-soft: #e4edfc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #fff8f3, var(--bg) 50%);
  min-height: 100vh;
}

h1, h2, h3, p {
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ===== Header ===== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fcf8f3);
  box-shadow: 0 4px 20px rgba(90, 52, 38, 0.08);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.master-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.topbar h1 {
  font-size: 1.5rem;
  color: var(--brand);
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.grade-badge {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ===== Welcome / Standard Select screens ===== */

.screen {
  padding-block: 32px 48px;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 20px;
}

.screen-title {
  font-size: 1.6rem;
  color: var(--brand);
}

.screen-subtitle {
  color: var(--muted);
  margin-bottom: 12px;
}

.back-link {
  align-self: flex-start;
  margin-bottom: 8px;
}

/* ===== Hero ===== */

.hero {
  text-align: center;
  padding: 12px 0 20px;
}

.hero-icon {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 10px;
  animation: hero-float 3s ease-in-out infinite;
}

@keyframes hero-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.hero-title {
  font-size: 2rem;
  color: var(--brand);
  margin-bottom: 8px;
}

.hero-subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ===== How it works ===== */

.how-it-works {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 8px 0 36px;
  padding: 24px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(90, 52, 38, 0.07);
}

.how-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}

.how-step-icon {
  font-size: 2.2rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  border-radius: 50%;
}

.how-step-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
}

.how-arrow {
  font-size: 1.5rem;
  color: var(--line);
  font-weight: 700;
}

/* ===== Grade cards ===== */

.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
  margin-top: 12px;
}

.grade-card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 24px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.grade-card-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.grade-card-cta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.grade-card:not(.locked):hover {
  border-color: var(--brand);
  box-shadow: 0 10px 24px rgba(195, 0, 0, 0.15);
  transform: translateY(-4px);
  cursor: pointer;
}

.grade-card:not(.locked):hover .grade-card-cta {
  opacity: 1;
  transform: translateY(0);
}

.grade-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.grade-card.locked .grade-card-icon {
  filter: grayscale(1);
}

.soon-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
}

.standard-groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 12px;
}

.standard-group-heading {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.standard-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.standard-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
  cursor: pointer;
}

.standard-card:hover {
  border-color: var(--brand);
}

.standard-card-icon {
  font-size: 1.5rem;
}

.standard-card-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.standard-card-title {
  font-weight: 700;
  color: var(--text);
}

/* ===== Story Select screen ===== */

.surprise-btn {
  align-self: flex-start;
  margin-bottom: 18px;
  font-size: 0.95rem;
  padding: 10px 18px;
}

.story-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.story-pick-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.story-pick-card:hover {
  border-color: var(--brand);
  box-shadow: 0 10px 24px rgba(195, 0, 0, 0.15);
  transform: translateY(-4px);
}

.story-pick-genre {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.story-pick-title {
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}

.story-pick-lexile {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

/* ===== Lab screen topbar ===== */

.lab-topbar {
  max-width: 1700px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.standard-badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ===== Layout ===== */

.lab-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px 32px 40px;
  align-items: start;
}

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

.lab-layout.extended .work-panel {
  display: none;
}

/* ===== Story panel ===== */

.story-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
}

.story-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.story-genre {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--info);
  margin-bottom: 4px;
}

.story-title {
  font-size: 1.3rem;
  color: var(--text);
}

.extend-btn {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.extend-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.repeat-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--info-soft);
  border: 1px solid var(--info);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.story-text {
  overflow-y: auto;
  padding-right: 6px;
  font-size: 1.15rem;
  line-height: 1.7;
  flex: 1;
}

.story-text p {
  margin-bottom: 1em;
}

.story-paragraph {
  position: relative;
  padding-left: 28px;
}

.para-num {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: right;
}

.poem-stanza {
  margin-bottom: 1.5em;
  font-style: italic;
}

.paired-text-block {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 2px dashed var(--line);
}

.paired-text-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.paired-text-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--info);
  margin-bottom: 2px;
}

.paired-text-title {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 8px;
}

/* ===== Work panel ===== */

.work-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(90, 52, 38, 0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.work-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}

.work-tab {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  color: var(--muted);
}

.work-tab.active {
  background: var(--panel);
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(90, 52, 38, 0.08);
}

.work-tab.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.work-hint {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ===== Organizer ===== */

.organizer-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 4px;
}

.organizer-title {
  font-size: 1.1rem;
  color: var(--brand);
  margin-bottom: 8px;
}

.mini-lesson {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.mini-lesson ul {
  margin: 4px 0 4px;
  padding-left: 18px;
}

.organizer-instructions {
  font-size: 0.95rem;
  line-height: 1.5;
}

.organizer-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fffefc;
  margin-bottom: 14px;
}

.organizer-group-label {
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 10px;
}

.organizer-fields-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.organizer-fields-row .organizer-field {
  flex: 1 1 200px;
  min-width: 0;
}

.organizer-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.organizer-field {
  border: none;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.organizer-field label {
  display: block;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 4px;
  line-height: 1.3;
}

.organizer-fields-row .organizer-field label {
  /* Reserves space for up to 3 wrapped lines so that when two fields sit
     side by side with labels of different lengths (e.g. "Who is the
     narrator?" next to "What is the narrator's point of view in this
     literary text?"), their answer boxes still start at the same height
     instead of staggering based on label length. */
  min-height: 3.9em;
}

.organizer-field .field-prompt {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.organizer-field textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  overflow: hidden;
}

.organizer-field.incomplete textarea {
  border-color: var(--danger);
  background: #fdf1f0;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.85rem;
}

.choice-row-label {
  color: var(--muted);
  font-weight: 600;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.organizer-feedback {
  font-weight: 700;
  min-height: 1.2em;
}

.organizer-feedback.success {
  color: var(--success);
}

.organizer-feedback.error {
  color: var(--danger);
}

/* ===== Buttons ===== */

.primary {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  color: #fff;
  background: var(--info);
}

.primary.success {
  background: var(--success);
}

.primary:hover {
  filter: brightness(1.05);
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--accent);
  font-weight: 600;
}

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

.ghost.small {
  font-size: 0.85rem;
  padding: 6px 10px;
}

/* ===== Questions ===== */

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.question-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fffefc;
}

.question-standard {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.question-prompt {
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.5;
}

.question-instructions {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 8px;
}

.option-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.option-row:hover {
  background: var(--bg);
}

.option-row input {
  margin-top: 4px;
}

.option-row label {
  flex: 1;
  cursor: pointer;
  line-height: 1.4;
}

.option-row.answer-correct {
  background: var(--success-soft);
  border-color: var(--success);
}

.option-row.answer-correct label::after {
  content: " \2713 correct answer";
  color: var(--success);
  font-weight: 700;
}

.option-row.answer-incorrect {
  background: #fdf1f0;
  border-color: var(--danger);
}

.option-row.answer-incorrect label::after {
  content: " \2717 your answer";
  color: var(--danger);
  font-weight: 700;
}

.option-row input:disabled,
.grid-question-table input:disabled {
  cursor: not-allowed;
}

.grid-question-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 0.9rem;
}

.grid-question-table th,
.grid-question-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
}

.grid-question-table th {
  background: var(--bg);
  font-weight: 700;
  color: var(--text);
}

.grid-question-table td.answer-correct {
  background: var(--success-soft);
  outline: 2px solid var(--success);
  outline-offset: -2px;
}

.grid-question-table td.answer-incorrect {
  background: #fdf1f0;
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

.grid-row-label {
  text-align: left !important;
  font-weight: 600;
}

.hot-text-passage {
  line-height: 2.1;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 6px;
}

.hot-text-segment {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 1px;
}

.hot-text-segment:hover {
  background: var(--bg);
}

.hot-text-segment.selected {
  background: #dbe7fb;
  outline: 2px solid #3b6fd6;
  outline-offset: -1px;
}

.hot-text-passage.locked .hot-text-segment {
  cursor: not-allowed;
}

.hot-text-segment.answer-correct {
  background: var(--success-soft);
  outline: 2px solid var(--success);
  outline-offset: -1px;
}

.hot-text-segment.answer-correct::after {
  content: " \2713";
  color: var(--success);
  font-weight: 700;
}

.hot-text-segment.answer-incorrect {
  background: #fdf1f0;
  outline: 2px solid var(--danger);
  outline-offset: -1px;
}

.hot-text-segment.answer-incorrect::after {
  content: " \2717";
  color: var(--danger);
  font-weight: 700;
}

.question-block.correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.question-block.incorrect {
  border-color: var(--danger);
  background: #fdf1f0;
}

.question-result-note {
  margin-top: 10px;
  font-weight: 700;
  font-size: 0.9rem;
}

.question-result-note.correct {
  color: var(--success);
}

.question-result-note.incorrect {
  color: var(--danger);
}

.results-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--info-soft);
  text-align: center;
}

.results-box h3 {
  font-size: 1.4rem;
  color: var(--info);
  margin-bottom: 4px;
}

/* ===== Footer ===== */

.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--brand);
}

/* ===== Responsive ===== */

@media (max-width: 900px) {
  .lab-layout {
    grid-template-columns: 1fr;
  }

  .story-panel {
    position: static;
    max-height: none;
  }

  .story-text {
    max-height: 340px;
  }
}
