:root {
  color-scheme: light;
  font-family: 'SF Pro Text', 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
  --bg: #f5f7fc;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --text: #0f172a;
  --muted: #3f4c66;
  --border: rgba(15, 23, 42, 0.12);
  --accent: #0f766e;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-strong: #0b5d54;
  --danger: #b91c1c;
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.16);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #050a15;
  --panel: rgba(15, 23, 42, 0.62);
  --panel-solid: #0d162b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.22);
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-strong: #5eead4;
  --danger: #fca5a5;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

/* The HTML `hidden` attribute must beat any later CSS that sets display. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 10% 5%, #e4f2ff 0%, #f6f8ff 28%, #f8fafc 65%, #f1f5f9 100%);
  transition: background 0.3s ease, color 0.2s ease;
}

:root[data-theme='dark'] body {
  background: radial-gradient(circle at 15% -5%, #0b1628 0%, #070b18 45%, #03060d 100%);
}

.aurora {
  position: fixed;
  inset: -25% auto auto -20%;
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.45), transparent 65%);
  filter: blur(28px);
  pointer-events: none;
}

:root[data-theme='dark'] .aurora {
  background: radial-gradient(circle, rgba(45, 212, 191, 0.3), transparent 65%);
}

.shell {
  max-width: 1100px;
  margin: 32px auto;
  padding: 22px;
  display: grid;
  gap: 16px;
}

.glass {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.48));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

:root[data-theme='dark'] .glass {
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.86), rgba(15, 23, 42, 0.55));
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px;
}

.hero h1 {
  margin: 8px 0;
  font-size: clamp(1.45rem, 2.3vw, 2.2rem);
}

.hero .kicker {
  margin: 0;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.73rem;
}

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

button,
.ghost {
  border-radius: 12px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.95);
  color: white;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

:root[data-theme='dark'] button {
  background: rgba(226, 232, 240, 0.92);
  color: #0f172a;
}

button:hover,
.ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.18);
}

.ghost {
  background: rgba(15, 23, 42, 0.09);
  color: var(--text);
}

:root[data-theme='dark'] .ghost {
  background: rgba(226, 232, 240, 0.08);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.3);
}

.ghost.icon {
  min-width: 40px;
  padding: 10px 12px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button[data-loading='true']::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  margin-left: 8px;
  animation: spin 0.75s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  padding: 16px;
}

.login-gate {
  padding: 12px 0;
}

.stack,
.stack-inline {
  display: grid;
  gap: 10px;
}

.stack-inline {
  grid-template-columns: 1fr 1fr auto auto;
}

input,
select {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.85);
  color: inherit;
  font: inherit;
}

.field {
  display: grid;
  gap: 4px;
}

.field > span {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field > input {
  width: 100%;
}

:root[data-theme='dark'] input,
:root[data-theme='dark'] select {
  background: rgba(15, 23, 42, 0.72);
}

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

.module-stack {
  display: grid;
  gap: 14px;
}

.module {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  background: var(--panel);
  animation: rise 0.45s ease;
}

.module.locked {
  opacity: 0.74;
  background: rgba(15, 23, 42, 0.04);
}

:root[data-theme='dark'] .module.locked {
  background: rgba(148, 163, 184, 0.05);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.module h3 {
  margin: 0 0 8px 0;
}

.module .meta {
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 0.93rem;
}

.phase-stack {
  display: grid;
  gap: 14px;
}

.phase {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.86);
  display: grid;
  gap: 12px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

:root[data-theme='dark'] .phase {
  background: rgba(15, 23, 42, 0.6);
}

.phase.locked {
  opacity: 0.7;
  background: rgba(15, 23, 42, 0.05);
  gap: 6px;
  padding: 14px 18px;
}

:root[data-theme='dark'] .phase.locked {
  background: rgba(148, 163, 184, 0.05);
}

.phase.active {
  border-color: rgba(45, 212, 191, 0.45);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.18), 0 14px 32px rgba(13, 148, 136, 0.12);
}

.phase.completed {
  border-color: rgba(15, 118, 110, 0.45);
  background: linear-gradient(160deg, rgba(204, 251, 241, 0.85), rgba(255, 255, 255, 0.9));
}

:root[data-theme='dark'] .phase.completed {
  background: linear-gradient(160deg, rgba(19, 78, 74, 0.5), rgba(15, 23, 42, 0.6));
  border-color: rgba(94, 234, 212, 0.4);
}

.phase-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.phase-header h4 {
  margin: 0;
  font-size: 1.05rem;
}

.phase-marker {
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.phase.locked .phase-marker {
  color: var(--muted);
  background: transparent;
}

.phase-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.phase-body {
  display: grid;
  gap: 10px;
  line-height: 1.6;
}

.phase-body p {
  margin: 0;
}

.phase-body h5 {
  margin: 6px 0 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.examples {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.code {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'SF Mono', 'Menlo', ui-monospace, monospace;
  font-size: 0.86rem;
  overflow-x: auto;
  white-space: pre;
}

:root[data-theme='dark'] .code {
  background: #020617;
}

.phase-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.resources {
  display: grid;
  gap: 8px;
}

.resource-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

:root[data-theme='dark'] .resource-item {
  background: rgba(15, 23, 42, 0.5);
}

.resource-item:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.resource-item .left {
  display: grid;
  gap: 4px;
}

.small {
  font-size: 0.84rem;
  color: var(--muted);
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

.meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme='dark'] .meter {
  background: rgba(15, 23, 42, 0.72);
}

.meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #06b6d4, #0d9488);
  transition: width 0.4s ease;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.84rem;
}

:root[data-theme='dark'] .chip {
  background: rgba(15, 23, 42, 0.55);
}

.chip-locked {
  color: var(--muted);
}

.quiz-form {
  margin-top: 4px;
}

.quiz-question {
  margin: 0;
  border-left: 3px solid var(--accent);
  padding: 12px 12px 12px 14px;
}

.quiz-options {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quiz-option:hover {
  background: var(--accent-soft);
  border-color: rgba(45, 212, 191, 0.4);
}

.quiz-option input {
  width: auto;
  height: auto;
  margin: 0;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hidden {
  display: none;
}

.student-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(140px, 2fr) auto minmax(160px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
}

:root[data-theme='dark'] .student-row {
  background: rgba(15, 23, 42, 0.55);
}

.student-row .id {
  font-weight: 600;
}

.student-row button {
  font-size: 0.88rem;
  padding: 8px 12px;
}

.admin-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.admin-toolbar input[type='search'] {
  flex: 1;
  min-width: 220px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
  font-size: 0.88rem;
}

.pager button {
  padding: 6px 12px;
  font-size: 0.88rem;
}

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

.credential-notice {
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(160deg, rgba(254, 243, 199, 0.92), rgba(255, 255, 255, 0.85));
  display: grid;
  gap: 10px;
}

:root[data-theme='dark'] .credential-notice {
  background: linear-gradient(160deg, rgba(120, 53, 15, 0.45), rgba(15, 23, 42, 0.7));
  border-color: rgba(252, 211, 77, 0.4);
}

.credential-notice h3 {
  margin: 0;
  font-size: 1rem;
}

.credential-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.credential-row code {
  flex: 1;
  min-width: 240px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  font-family: 'SF Mono', 'Menlo', ui-monospace, monospace;
  font-size: 0.96rem;
  letter-spacing: 0.04em;
  user-select: all;
  word-break: break-all;
}

:root[data-theme='dark'] .credential-row code {
  background: rgba(15, 23, 42, 0.78);
}

.progress-row {
  display: grid;
  grid-template-columns: 2fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
}

:root[data-theme='dark'] .progress-row {
  background: rgba(15, 23, 42, 0.55);
}

@media (max-width: 860px) {
  .stack-inline {
    grid-template-columns: 1fr;
  }
  .hero {
    padding-bottom: 4px;
  }
  .student-row,
  .progress-row {
    grid-template-columns: 1fr;
  }
  .credential-row code {
    min-width: 100%;
  }
}
