:root {
  --bg: #dce3ec;
  --surface: rgba(249, 251, 254, 0.94);
  --surface-strong: #f6f8fb;
  --text: #1f2f49;
  --muted: #5d6f88;
  --accent: #274f92;
  --accent-soft: #d8e2f1;
  --line: rgba(53, 75, 110, 0.16);
  --shadow: 0 10px 26px rgba(44, 63, 94, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(64, 90, 134, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(151, 167, 191, 0.14), transparent 24%),
    linear-gradient(135deg, #e2e8ef, #eff3f7 56%, #dbe3eb);
}

.page-shell {
  width: min(1800px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  margin-bottom: 24px;
}

.hero-admin,
.hero {
  display: grid;
  gap: 20px;
}

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

.hero-admin {
  grid-template-columns: 1.5fr 0.9fr;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 32px;
}

.hero-card {
  padding: 28px;
  align-self: end;
  background:
    linear-gradient(180deg, rgba(227, 235, 246, 0.95), rgba(240, 245, 251, 0.95));
}

.eyebrow,
.section-label,
.hero-card-label,
.meter-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--muted);
}

.student-eyebrow {
  color: var(--accent);
  font-weight: 800;
}

body:not(.admin-page) .section-label,
.student-step-label {
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.02em;
  font-size: 0.98rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 4vw, 4.2rem);
  line-height: 0.98;
  margin-bottom: 16px;
}

h2 {
  font-family: "Manrope", sans-serif;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

h3 {
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  margin-bottom: 14px;
}

.hero-text,
.scene-note,
.meter-text,
.coach-response,
#output-state,
pre,
li {
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: 1.18fr 0.86fr 0.96fr;
  gap: 18px;
}

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

.admin-page {
  background:
    radial-gradient(circle at top left, rgba(64, 90, 134, 0.35), transparent 32%),
    radial-gradient(circle at bottom right, rgba(151, 167, 191, 0.3), transparent 26%),
    linear-gradient(135deg, #dce3ec, #eef2f6 54%, #d4dde7);
}

.admin-page .hero-copy,
.admin-page .hero-card,
.admin-page .panel {
  border: 1px solid rgba(53, 75, 110, 0.22);
  box-shadow: 0 18px 45px rgba(44, 63, 94, 0.12);
}

.admin-page .hero-copy,
.admin-page .panel {
  background: rgba(248, 251, 255, 0.9);
}

.admin-page .hero-card {
  background: linear-gradient(180deg, rgba(227, 235, 246, 0.95), rgba(240, 245, 251, 0.95));
}

.admin-page .saved-item,
.admin-page .admin-status-card,
.admin-page .admin-guide,
.admin-page .admin-json-preview {
  border-color: rgba(76, 98, 135, 0.18);
  background: rgba(243, 247, 252, 0.94);
}

.panel {
  padding: 22px;
}

.panel-heading,
.coach-heading,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.access-panel {
  margin-bottom: 20px;
}

.access-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

.teacher-strip,
.level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-top: 16px;
  border-radius: 12px;
  border: 1px solid rgba(76, 98, 135, 0.14);
  background: rgba(243, 247, 252, 0.72);
}

.teacher-grid,
.task-status-grid,
.rubric-grid {
  display: grid;
  gap: 14px;
}

.teacher-grid,
.task-status-grid {
  grid-template-columns: repeat(2, 1fr);
}

.rubric-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 14px;
}

.teacher-panel {
  margin: 18px 0 20px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(73, 47, 29, 0.1);
  background: rgba(255, 248, 240, 0.88);
}

.teacher-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.teacher-kill {
  display: flex;
  flex-direction: column;
}

.saved-tasks-card,
.history-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(73, 47, 29, 0.1);
  background: var(--surface-strong);
}

.task-status-card,
.rubric-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(73, 47, 29, 0.1);
  background: var(--surface-strong);
}

.scene-status-card {
  margin-top: 16px;
}

.compact-heading {
  align-items: center;
}

.saved-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.gallery-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.saved-item {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(76, 98, 135, 0.18);
  background: rgba(243, 247, 252, 0.94);
}

.gallery-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(76, 98, 135, 0.18);
  background: rgba(243, 247, 252, 0.94);
}

.gallery-item img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(76, 98, 135, 0.14);
  background: rgba(39, 79, 146, 0.08);
}

.gallery-item-text-only {
  grid-template-columns: 1fr;
}

.saved-item h4,
.saved-item p,
.gallery-item h4,
.gallery-item p {
  margin: 0;
}

.saved-item h4 {
  font-family: "Fraunces", serif;
  font-size: 1rem;
  margin-bottom: 8px;
}

.saved-item p + p {
  margin-top: 6px;
}

.saved-item-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

#admin-new-code-card {
  margin-top: 16px;
  border-color: rgba(39, 79, 146, 0.22);
  background: rgba(255, 249, 214, 0.72);
}

#admin-new-code-value {
  margin-top: 4px;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.admin-task-card {
  padding: 18px;
}

.admin-task-grid {
  display: grid;
  grid-template-columns: 150px 160px;
  gap: 14px;
}

.admin-image-preview {
  margin-top: 14px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(76, 98, 135, 0.18);
  background: rgba(233, 240, 249, 0.85);
  min-height: 180px;
  display: grid;
  place-items: center;
}

.admin-image-preview img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.admin-image-preview-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

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

.task-status-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.scene-status-reset {
  display: flex;
  align-items: end;
}

.scene-status-reset .ghost-button {
  width: 100%;
}

.saved-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.history-note {
  margin: 14px 0 0;
  color: var(--muted);
}

.admin-status-card,
.admin-guide {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(73, 47, 29, 0.1);
  background: var(--surface-strong);
}

.admin-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  grid-column: 1 / -1;
}

.admin-access-panel {
  grid-column: 1 / -1;
}

.admin-code-controls {
  grid-template-columns: minmax(0, 1fr) 180px;
}

.admin-code-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.admin-submission-card {
  align-items: start;
}

.admin-submission-card img {
  width: 140px;
  height: 140px;
}

.admin-summary-grid {
  margin-top: 18px;
}

.admin-summary-grid .saved-item {
  min-height: 104px;
}

.admin-summary-grid .input-label {
  margin-top: 0;
}

.admin-guide p {
  margin: 0;
}

.admin-guide p + p {
  margin-top: 10px;
}

.admin-json-preview {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(73, 47, 29, 0.1);
  background: rgba(255, 250, 244, 0.75);
  max-height: 420px;
  overflow: auto;
}

.task-status-text {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.gallery-kind {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(216, 226, 241, 0.95);
  color: #274f92;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.disabled-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(39, 79, 146, 0.12);
  border: 1px solid rgba(39, 79, 146, 0.18);
  color: #274f92;
  font-weight: 700;
}

.small-value {
  font-size: 1.3rem;
}

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

.scene-frame,
.generated-image-frame {
  overflow: hidden;
  border-radius: 12px;
  margin-top: 18px;
  min-height: 320px;
  background: linear-gradient(135deg, rgba(39, 79, 146, 0.08), rgba(255, 255, 255, 0.6));
  border: 1px solid rgba(76, 98, 135, 0.14);
}

.scene-panel .scene-frame {
  min-height: clamp(380px, 44vw, 620px);
}

.output-panel .generated-image-frame {
  min-height: 340px;
}

.scene-frame img,
.generated-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-note {
  margin: 14px 2px 0;
  color: var(--text);
  font-weight: 600;
}

.primary-feedback-block {
  margin-top: 10px;
}

.revision-nudge {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(39, 79, 146, 0.09);
  border: 1px solid rgba(39, 79, 146, 0.16);
  color: #234573;
  font-weight: 800;
}

.input-label {
  display: inline-block;
  margin: 18px 0 10px;
  font-weight: 700;
}

.english-only-note {
  margin: 10px 2px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(39, 79, 146, 0.08);
  border: 1px solid rgba(39, 79, 146, 0.14);
  color: #274f92;
  font-size: 0.92rem;
  font-weight: 700;
}

.english-only-note-main,
.english-only-note-detail {
  margin: 0;
}

.english-only-note-main {
  font-weight: 800;
}

.english-only-details {
  margin-top: 6px;
}

.english-only-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: inherit;
  list-style: none;
}

.english-only-details summary::-webkit-details-marker {
  display: none;
}

.english-only-details summary::after {
  content: " +";
}

.english-only-details[open] summary::after {
  content: " -";
}

.english-only-note-detail {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
}

.english-only-note.english-only-warning {
  background: rgba(186, 72, 39, 0.1);
  border-color: rgba(186, 72, 39, 0.22);
  color: #8d3b1f;
  font-weight: 700;
}

textarea {
  width: 100%;
  border: 1px solid rgba(74, 99, 143, 0.24);
  background: rgba(250, 252, 255, 0.98);
  color: var(--text);
  border-radius: 12px;
  padding: 16px 18px;
  font: inherit;
  resize: vertical;
  min-height: 180px;
}

.studio-panel textarea::placeholder {
  color: #6c7e97;
}

.text-input,
.select-input,
.file-input {
  width: 100%;
  border: 1px solid rgba(74, 99, 143, 0.24);
  background: rgba(250, 252, 255, 0.98);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
}

.file-input {
  padding: 10px 12px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: #ffe56c;
  background: linear-gradient(135deg, #1d3d73, #274f92);
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
  box-shadow: 0 10px 18px rgba(29, 61, 115, 0.24);
}

.submit-attempt-button {
  min-height: 76px;
  min-width: min(100%, 360px);
  padding: 18px 28px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 16px 26px rgba(29, 61, 115, 0.28);
  border-radius: 14px;
}

.submit-action-row {
  justify-content: flex-start;
  margin-top: 18px;
}

.admin-page .secondary-button,
.admin-page .ghost-button {
  color: #1f355d;
  background: rgba(241, 246, 252, 0.96);
  border: 1px solid rgba(74, 99, 143, 0.24);
  box-shadow: none;
}

.admin-page textarea,
.admin-page .text-input,
.admin-page .select-input,
.admin-page .file-input {
  border-color: rgba(74, 99, 143, 0.24);
  background: rgba(250, 252, 255, 0.98);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.secondary-button,
.ghost-button {
  color: var(--text);
  background: rgba(241, 246, 252, 0.96);
  box-shadow: none;
  border: 1px solid rgba(74, 99, 143, 0.24);
}

.ghost-button {
  padding: 10px 14px;
}

.meter-grid,
.feedback-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.meter-grid {
  grid-template-columns: repeat(2, 1fr);
}

.feedback-grid {
  grid-template-columns: repeat(2, 1fr);
}

.meter-card,
.feedback-card,
.coach-card,
.prompt-card {
  background: var(--surface-strong);
  border: 1px solid rgba(76, 98, 135, 0.18);
  border-radius: 12px;
  padding: 16px;
}

.meter-value {
  font-size: 1.8rem;
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
}

.feedback-list {
  margin: 0;
  padding-left: 18px;
}

.feedback-list li::marker {
  color: var(--accent);
}

.coach-card,
.prompt-card {
  margin-top: 18px;
}

.output-coach-card {
  margin-top: 18px;
}

.compact-meter-grid,
.compact-feedback-grid {
  margin-top: 16px;
}

.single-meter-grid {
  grid-template-columns: 1fr;
}

.coach-subgrid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(73, 47, 29, 0.1);
}

.coach-details {
  margin-top: 16px;
  border-top: 1px solid rgba(73, 47, 29, 0.1);
  padding-top: 14px;
}

.coach-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
  list-style: none;
}

.coach-details summary::-webkit-details-marker {
  display: none;
}

.coach-details summary::after {
  content: " +";
}

.coach-details[open] summary::after {
  content: " -";
}

.coach-details-content {
  margin-top: 14px;
}

.alert-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #274f92;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
}

.output-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: rgba(243, 247, 252, 0.94);
  border: 1px dashed rgba(76, 98, 135, 0.22);
  border-radius: 12px;
  margin-top: 18px;
  padding: 24px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  color: #294063;
}

.hidden {
  display: none;
}

@keyframes guidedPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(39, 79, 146, 0.26), 0 0 0 0 rgba(255, 229, 108, 0.12);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(39, 79, 146, 0), 0 0 0 20px rgba(255, 229, 108, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(39, 79, 146, 0), 0 0 0 0 rgba(255, 229, 108, 0);
  }
}

.guided-focus {
  position: relative;
  border-color: rgba(39, 79, 146, 0.5) !important;
  box-shadow:
    0 0 0 4px rgba(255, 229, 108, 0.22),
    0 18px 30px rgba(39, 79, 146, 0.18);
  animation: guidedPulse 2.2s ease-out infinite;
}

textarea.guided-focus,
.level-row.guided-focus,
#next-step.guided-focus {
  background: rgba(255, 251, 226, 0.78);
}

#next-step.guided-focus {
  padding: 10px 12px;
  border-radius: 10px;
}

.coach-card.guided-focus {
  background: rgba(255, 250, 220, 0.92);
}

@media (min-width: 1400px) {
  .workspace {
    grid-template-columns: 1.28fr 0.82fr 1.02fr;
    gap: 20px;
  }

  .scene-panel .scene-frame {
    min-height: 540px;
  }

  .output-panel .generated-image-frame {
    min-height: 380px;
  }
}

.submit-attempt-button.guided-focus {
  box-shadow:
    0 0 0 4px rgba(255, 229, 108, 0.2),
    0 18px 30px rgba(29, 61, 115, 0.32);
}

@media (max-width: 1100px) {
  .workspace,
  .hero-admin,
  .admin-workspace,
  .admin-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 14px;
  }

  .hero-copy,
  .hero-card,
  .panel {
    padding: 18px;
  }

  .meter-grid,
  .feedback-grid,
  .coach-subgrid,
  .teacher-grid,
  .task-status-grid,
  .rubric-grid,
  .admin-code-sections,
  .admin-code-controls {
    grid-template-columns: 1fr;
  }

  .scene-status-reset {
    align-items: stretch;
  }

  .panel-heading,
  .coach-heading,
  .action-row,
  .teacher-strip,
  .level-row,
  .teacher-actions,
  .saved-item-actions,
  .history-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-status-actions {
    justify-content: flex-start;
  }

  .gallery-item {
    grid-template-columns: 1fr;
  }

  .gallery-item img {
    width: 100%;
    height: 200px;
  }

  button {
    width: 100%;
  }

  .submit-attempt-button {
    min-width: 100%;
  }
}
