
:root {
  --void: #07060f;
  --ink: #f4f0e8;
  --mute: #b7b0c9;
  --line: rgba(255, 236, 210, 0.12);
  --cyan: #5ce1e6;
  --violet: #c084fc;
  --gold: #f5c16c;
  --glass: rgba(16, 14, 28, 0.62);
  --ok: #7dffb3;
  --bad: #ff8a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--void); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, .brand strong { font-family: Georgia, "Times New Roman", serif; font-weight: 700; letter-spacing: -0.02em; }
a { color: var(--cyan); text-decoration: none; }
code { font-size: 0.92em; color: var(--gold); }

.cosmos { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
#fractal-field { width: 100%; height: 100%; display: block; opacity: 0.55; }
.aurora { position: absolute; border-radius: 50%; filter: blur(70px); }
.a1 { width: 46vw; height: 46vw; left: -10vw; top: -12vw; background: radial-gradient(circle, rgba(94,225,230,.35), transparent 70%); animation: drift 18s ease-in-out infinite; }
.a2 { width: 40vw; height: 40vw; right: -8vw; bottom: -14vw; background: radial-gradient(circle, rgba(192,132,252,.32), transparent 70%); animation: drift 22s ease-in-out infinite reverse; }
.orbit { position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; }
.o1 { width: 70vmax; height: 70vmax; left: 50%; top: 48%; translate: -50% -50%; animation: spin 80s linear infinite; }
.o2 { width: 46vmax; height: 46vmax; left: 50%; top: 48%; translate: -50% -50%; animation: spin 50s linear infinite reverse; }
@keyframes drift { 50% { transform: translate(4%, 6%) scale(1.08); } }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.topbar, main, .foot { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px;
  background: rgba(7,6,15,.72);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.mark { width: 48px; height: 48px; color: var(--cyan); display: grid; place-items: center; }
.mark.logo-mark { width: 52px; height: 52px; flex-shrink: 0; }
.mark svg { width: 36px; height: 36px; }
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--cyan) 45%, transparent);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--void) 80%, transparent),
    0 0 18px color-mix(in srgb, var(--cyan) 35%, transparent),
    0 0 28px color-mix(in srgb, var(--violet, #c084fc) 20%, transparent);
  filter: var(--logo-filter, none);
  transition: filter 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 1.02rem; color: var(--ink); }
.brand-text em { font-style: normal; font-size: 0.68rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mute); }
.navbar { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.navbar a {
  pointer-events: auto; position: relative; z-index: 51;
  color: var(--mute); padding: 8px 12px; border-radius: 999px; font-size: 0.88rem; font-weight: 500;
}
.navbar a.on, .navbar a:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.spark {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(245,193,108,.35);
  background: rgba(245,193,108,.08);
  font-variant-numeric: tabular-nums;
}
.spark-icon { color: var(--gold); }
.spark-label { color: var(--mute); font-size: 0.72rem; letter-spacing: .08em; text-transform: uppercase; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 80px; }
.page { animation: rise .5s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.hero { padding: 28px 8px 10px; max-width: 740px; }
.eyebrow { color: var(--cyan); letter-spacing: .2em; text-transform: uppercase; font-size: 0.72rem; margin: 0 0 10px; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; margin: 0 0 16px; }
.lede { color: var(--mute); font-size: 1.08rem; max-width: 58ch; }
.hero-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; font: inherit; color: var(--void);
  background: var(--ink); padding: 11px 18px; border-radius: 999px; font-weight: 600;
}
.btn.glow { background: linear-gradient(135deg, var(--cyan), #9b8cff); box-shadow: 0 0 28px rgba(92,225,230,.25); color: #081018; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:active { transform: translateY(1px); }

.planet-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 36px 0 28px; }
.garden-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.garden-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--mute); font-size: 0.82rem; margin: 10px 0; }
.candidate { padding: 12px; border-radius: 16px; border: 1px solid var(--line); margin: 10px 0; background: rgba(255,255,255,.03); }
.badge { display: inline-block; font-size: 0.68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-left: 8px; }
.node.emergent { border-color: rgba(192,132,252,.35); }
.planet {
  display: flex; flex-direction: column; gap: 8px; padding: 16px;
  border-radius: 22px; border: 1px solid var(--line); background: var(--glass);
  color: var(--ink); min-height: 150px; text-align: left; cursor: pointer;
}
.planet .moon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 1.2rem; }
.planet h3 { margin: 0; font-size: 1.05rem; }
.planet p { margin: 0; color: var(--mute); font-size: 0.82rem; }
.planet:hover { border-color: rgba(92,225,230,.45); transform: translateY(-3px); transition: .2s ease; }

.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.how article { padding: 18px; border-radius: 20px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.how span { color: var(--gold); font-size: 0.78rem; letter-spacing: .16em; }
.how h3 { margin: 8px 0 6px; }
.how p { margin: 0; color: var(--mute); }

.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 2rem; }
.hint { color: var(--mute); max-width: 36ch; }
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(16px);
}
.studio-grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; min-height: 62vh; }
.pane { padding: 16px; overflow: auto; }
.subject { margin: 14px 0 6px; font-size: 0.7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--violet); }
.node {
  width: 100%; text-align: left; margin: 4px 0; padding: 9px 12px;
  border-radius: 14px; border: 1px solid transparent; background: rgba(255,255,255,.03);
  color: var(--ink); cursor: pointer; font: inherit;
}
.node.on { border-color: rgba(92,225,230,.5); background: rgba(92,225,230,.08); }
.lesson-pane { padding: 28px; }
.lesson-pane h2 { text-transform: capitalize; margin: 0 0 10px; }
.obj { color: var(--mute); }
.term { border-left: 3px solid var(--violet); padding: 6px 0 6px 12px; margin: 10px 0; color: var(--mute); }
.q { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 12px 0; background: rgba(255,255,255,.03); }
.q button { margin: 6px 6px 0 0; }
.q .ok { color: var(--ok); border-color: var(--ok); }
.q .bad { color: var(--bad); border-color: var(--bad); }

.composer { display: flex; gap: 10px; padding: 12px; }
.composer input, #chat-form input, input {
  flex: 1; min-width: 0; background: rgba(7,6,15,.55); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 12px 16px; font: inherit;
}
.status { color: var(--gold); min-height: 1.4em; }
.path { padding: 18px; margin: 12px 0; }
.sec { margin: 10px 0; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.03); }
.sec button { margin-top: 8px; }

.lab-wrap { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.guides { display: flex; flex-direction: column; gap: 10px; }
.guide {
  text-align: left; padding: 14px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--glass); color: var(--ink); cursor: pointer; font: inherit;
}
.guide.on { border-color: rgba(92,225,230,.5); }
.guide span { display: block; color: var(--mute); font-size: 0.8rem; }
.orb { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-bottom: 6px; }
.orb.cyan { background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.orb.gold { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.orb.violet { background: var(--violet); box-shadow: 0 0 12px var(--violet); }
.chat-shell { padding: 16px; display: flex; flex-direction: column; min-height: 58vh; }
.chat { flex: 1; overflow: auto; padding-right: 6px; }
.bubble { margin: 10px 0; padding: 12px 14px; border-radius: 16px 16px 16px 4px; max-width: 82%; white-space: pre-wrap; }
.bubble.user { margin-left: auto; border-radius: 16px 16px 4px 16px; background: linear-gradient(135deg, rgba(92,225,230,.2), rgba(192,132,252,.2)); }
.bubble.assistant { background: rgba(255,255,255,.05); border: 1px solid var(--line); }
#chat-form { display: flex; gap: 8px; margin-top: 12px; }

.quest { padding: 24px; min-height: 280px; }
.credits { padding: 20px; color: var(--mute); }
.code { padding: 18px; overflow: auto; font-size: 0.82rem; color: #d7c9ff; }

.foot {
  display: flex; justify-content: center; gap: 12px; align-items: center;
  padding: 18px; color: var(--mute); font-size: 0.78rem; letter-spacing: .04em;
}
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .navbar { margin-left: 0; width: 100%; }
  .planet-row, .how, .studio-grid, .lab-wrap, .garden-grid { grid-template-columns: 1fr; }
  .hero-actions, .composer, #chat-form { flex-direction: column; }
}

.einstein-dock { position: fixed; right: 22px; bottom: 22px; z-index: 8; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.einstein-fab {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(245,193,108,.45);
  background: radial-gradient(circle at 30% 30%, #f5c16c, #7a4a12);
  color: #1a1208; cursor: pointer; display: grid; place-items: center; position: relative;
  box-shadow: 0 0 24px rgba(245,193,108,.35);
}
.einstein-face { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 1.35rem; }
.einstein-live {
  position: absolute; bottom: -6px; right: -6px; font-size: 0.58rem; letter-spacing: .08em;
  background: #07060f; color: var(--gold); border: 1px solid rgba(245,193,108,.4);
  border-radius: 999px; padding: 2px 6px;
}
.einstein-panel { width: min(380px, calc(100vw - 32px)); height: min(520px, 70vh); padding: 14px; display: none !important; flex-direction: column; }
.einstein-panel.is-open { display: flex !important; }
.einstein-panel[hidden] { display: none !important; }
.page[hidden] { display: none !important; }

.einstein-panel header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.einstein-panel header em { color: var(--mute); font-style: normal; font-size: 0.75rem; margin-right: auto; }
.einstein-panel .chat { flex: 1; }
.einstein-panel form { display: flex; gap: 8px; margin-top: 8px; }


/* ---- Gamified practice ---- */
.game-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}
.game-card h3 { margin: 0 0 0.5rem; font-family: Georgia, "Times New Roman", serif; }
.game-card .row-controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0;
  align-items: center;
}
.game-card select, .game-card input[type="number"] {
  background: rgba(10, 16, 32, 0.7);
  border: 1px solid rgba(120, 180, 255, 0.25);
  color: inherit;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}
.cards-stage { margin-top: 1rem; min-height: 8rem; }
.flip-card {
  perspective: 900px;
  max-width: 420px;
  margin: 0 auto;
  cursor: pointer;
}
.flip-inner {
  position: relative;
  transition: transform 0.55s;
  transform-style: preserve-3d;
  min-height: 160px;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  padding: 1.25rem;
  border-radius: 14px;
  display: flex; flex-direction: column; justify-content: center;
}
.flip-back { transform: rotateY(180deg); }
.arcade-hud {
  display: flex; gap: 1.25rem; margin: 0.75rem 0;
  font-variant-numeric: tabular-nums;
}
.arcade-q .arcade-choice {
  display: block; width: 100%; text-align: left; margin: 0.35rem 0;
}
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.memory-cell {
  min-height: 72px;
  cursor: pointer;
  font-size: 0.85rem;
}
.memory-cell.revealed {
  border-color: rgba(245, 193, 108, 0.55);
}


/* Emergent tags & garden evolution */
.badge {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
  border: 1px solid rgba(245, 193, 108, 0.45);
  color: var(--gold, #f5c16c);
  background: rgba(245, 193, 108, 0.12);
}
.badge.emergent {
  border-color: rgba(167, 139, 250, 0.55);
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.18);
}
.node.emergent {
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35);
}
.profile-evo { margin: 0.75rem 0; }
.evo-card h4 { margin: 0 0 0.4rem; font-family: Georgia, "Times New Roman", serif; }
.evo-card ul { margin: 0.4rem 0 0; padding-left: 1.1rem; color: var(--mute, #9aa4b2); }
.garden-grid textarea {
  width: 100%;
  background: rgba(10, 16, 32, 0.7);
  border: 1px solid rgba(120, 180, 255, 0.25);
  color: inherit;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  resize: vertical;
}
.candidate .badge { margin-left: 0.25rem; }


/* Flip cards — fixed height so back is visible */
.flip-card {
  perspective: 1000px;
  max-width: 440px;
  margin: 0 auto;
  cursor: pointer;
  min-height: 200px;
}
.flip-inner {
  position: relative;
  width: 100%;
  min-height: 200px;
  transition: transform 0.55s;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 1.25rem;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 200px;
  box-sizing: border-box;
}
.flip-back { transform: rotateY(180deg); }
.flip-back .answer-label {
  color: var(--gold, #f5c16c);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
}

/* Art studio */
.art-studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .art-studio-grid { grid-template-columns: 1fr; }
}
#icon-canvas {
  width: 100%;
  max-width: 320px;
  height: 320px;
  border-radius: 16px;
  background: rgba(8, 12, 24, 0.85);
  border: 1px solid rgba(120, 180, 255, 0.25);
  display: block;
}
.icon-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
  max-height: 360px;
  overflow: auto;
}
.icon-tile {
  border: 1px solid rgba(120, 180, 255, 0.2);
  border-radius: 10px;
  padding: 0.35rem;
  text-align: center;
  cursor: pointer;
  background: rgba(10, 16, 32, 0.6);
  font-size: 0.65rem;
  color: var(--mute);
}
.icon-tile img, .icon-tile svg {
  width: 48px;
  height: 48px;
  display: block;
  margin: 0 auto 0.25rem;
}
.icon-tile.emergent {
  border-color: rgba(167, 139, 250, 0.55);
}
.node-icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  margin-right: 0.25em;
}

.einstein-panel { pointer-events: auto; z-index: 9; }
.einstein-panel header button { pointer-events: auto; cursor: pointer; flex-shrink: 0; }
.einstein-dock { z-index: 20; }


/* Collapsible constellation subjects */
.subject-block { margin-bottom: 0.35rem; }
.subject-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 8px;
}
.subject-toggle:hover { background: rgba(120, 180, 255, 0.08); }
.subject-toggle .chev {
  display: inline-block;
  width: 1em;
  transition: transform 0.2s;
  color: var(--cyan, #5ce1e6);
}
.subject-block.collapsed .chev { transform: rotate(-90deg); }
.subject-block.collapsed .subject-nodes { display: none; }
.subject-nodes { display: flex; flex-direction: column; gap: 0.25rem; padding-left: 0.35rem; }

/* Studio debug surface collapsed by default */
.sdk-debug details { margin-top: 1rem; }
.sdk-debug summary { cursor: pointer; color: var(--mute); font-size: 0.85rem; }


/* Study Pulse + Curiosity Compass */
.study-pulse {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; color: var(--mute);
  max-width: 220px; margin-right: 0.5rem;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan, #5ce1e6);
  box-shadow: 0 0 10px rgba(92, 225, 230, 0.7);
  animation: pulseGlow 2.4s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}
.compass {
  margin: 1.5rem 0 0.5rem; padding: 1.1rem 1.25rem;
}
.compass-head h3 { margin: 0.2rem 0 0.35rem; font-family: Georgia, "Times New Roman", serif; }
.compass-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}
.compass-card {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(120, 180, 255, 0.2);
  background: rgba(10, 16, 32, 0.55);
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.compass-card:hover {
  border-color: rgba(92, 225, 230, 0.45);
  box-shadow: 0 0 18px rgba(92, 225, 230, 0.12);
}
.compass-card .kind {
  font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold, #f5c16c);
}
.compass-card strong { display: block; margin: 0.25rem 0; }
.compass-card .reason { font-size: 0.82rem; color: var(--mute); }

.studio-controls .field { display:flex; flex-direction:column; gap:0.35rem; margin-bottom:0.75rem; }
.studio-controls textarea, .studio-controls input, .studio-controls select {
  background: rgba(8,12,28,0.7); border:1px solid rgba(120,180,255,0.25);
  border-radius:10px; color:inherit; padding:0.55rem 0.7rem; font:inherit;
}
.studio-controls textarea { resize: vertical; min-height: 4.5rem; }
.studio-actions { display:flex; flex-wrap:wrap; gap:0.5rem; margin:0.5rem 0; }
.studio-stage { display:flex; flex-direction:column; align-items:center; gap:0.75rem; }
#icon-canvas {
  width: min(320px, 100%); height: auto; border-radius: 16px;
  background: #070b16; box-shadow: 0 0 40px rgba(92,225,230,0.12);
}
.art-meta { text-align:center; max-width: 28rem; }
.icon-gallery {
  display:grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap:0.5rem; width:100%; margin-top:0.5rem;
}
.icon-tile {
  display:flex; flex-direction:column; align-items:center; gap:0.25rem;
  font-size:0.65rem; padding:0.35rem; border-radius:10px;
  border:1px solid rgba(120,180,255,0.15); background:rgba(8,12,28,0.5);
  color:inherit; cursor:pointer;
}
.icon-tile img { border-radius:8px; width:48px; height:48px; object-fit:cover; }
.icon-tile.emergent { border-color: rgba(245,193,108,0.45); }

.auth-strip { display:flex; align-items:center; gap:0.5rem; margin-right:0.35rem; }
.auth-modal {
  position: fixed; right: 1.25rem; top: 4.5rem; z-index: 40;
  width: min(360px, calc(100vw - 2rem)); padding: 1rem;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.auth-modal[hidden] { display: none !important; }
.auth-modal header { display:flex; justify-content:space-between; align-items:center; }
.auth-modal label { font-size: 0.8rem; color: var(--mute); display:flex; flex-direction:column; gap:0.2rem; }
.auth-modal input {
  background: rgba(8,12,28,0.85); border: 1px solid rgba(120,180,255,0.25);
  border-radius: 8px; color: inherit; padding: 0.45rem 0.6rem; font: inherit;
}


/* Theme presets */
:root, [data-theme="cosmos"] {
  --bg: #070b16;
  --cyan: #5ce1e6;
  --gold: #f5c16c;
  --text: #e8eefc;
  --mute: #9aa8c7;
}
[data-theme="nebula"] {
  --bg: #120814;
  --cyan: #ff8fab;
  --gold: #c084fc;
  --text: #fce8f4;
  --mute: #c4a0b8;
}
[data-theme="aurora"] {
  --bg: #061410;
  --cyan: #7dffb3;
  --gold: #5ce1e6;
  --text: #e8fff4;
  --mute: #8bbba0;
}
[data-theme="solar"] {
  --bg: #120e06;
  --cyan: #f5c16c;
  --gold: #ff8fab;
  --text: #fff6e8;
  --mute: #c4b08a;
}
[data-theme="obsidian"] {
  --bg: #050508;
  --cyan: #c0c8d8;
  --gold: #9b8cff;
  --text: #f0f2f8;
  --mute: #888ea0;
}
[data-theme="ocean"] {
  --bg: #060b14;
  --cyan: #4aa3ff;
  --gold: #5ce1e6;
  --text: #e8f2ff;
  --mute: #7a94b8;
}
body { background: var(--bg, #070b16); color: var(--text, #e8eefc); }
.announce-bar {
  text-align: center; padding: 0.45rem 1rem; font-size: 0.85rem;
  background: rgba(92, 225, 230, 0.12); border-bottom: 1px solid rgba(120,180,255,0.2);
  color: var(--text);
}
.sky-stage { padding: 0.75rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
#sky-canvas {
  width: min(960px, 100%); height: auto; border-radius: 16px;
  background: #050814; cursor: crosshair;
  box-shadow: 0 0 40px rgba(92, 225, 230, 0.1);
}


/* Constellation learn layout — tree left, lesson right */
.learn-wrap {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 16px;
  align-items: start;
  min-height: 58vh;
}
.learn-wrap #tree {
  max-height: min(70vh, 720px);
  overflow: auto;
  padding: 12px;
}
.learn-wrap .lesson-pane {
  min-height: 320px;
}
.learn-sort {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  font-size: 0.82rem;
}
.learn-sort select {
  width: auto;
  min-width: 11rem;
  margin: 0;
  background: rgba(8,12,28,0.75);
  border: 1px solid rgba(120,180,255,0.25);
  border-radius: 8px;
  color: inherit;
  padding: 0.4rem 0.55rem;
  font: inherit;
}
.sky-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}
.sky-controls select {
  width: auto;
  min-width: 12rem;
  margin: 0.25rem 0 0;
  background: rgba(8,12,28,0.75);
  border: 1px solid rgba(120,180,255,0.25);
  border-radius: 8px;
  color: inherit;
  padding: 0.4rem 0.55rem;
}
@media (max-width: 840px) {
  .learn-wrap {
    grid-template-columns: 1fr;
  }
  .learn-wrap #tree {
    max-height: 280px;
  }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .learn-sort { align-items: flex-start; }
}

.grade-pill {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(120,180,255,0.25);
  color: var(--cyan, #5ce1e6);
  margin-left: 0.35rem;
  font-weight: 500;
}
.subject-toggle { display: flex; align-items: center; gap: 0.35rem; width: 100%; }

.instruct-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}
.instruct-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  font-size: 0.82rem;
}
.instruct-grid input,
.instruct-grid select,
.instruct-grid textarea {
  background: rgba(8,12,28,0.85);
  border: 1px solid rgba(120,180,255,0.25);
  border-radius: 8px;
  color: inherit;
  padding: 0.5rem 0.65rem;
  font: inherit;
}
.inst-preview {
  max-height: min(60vh, 640px);
  overflow: auto;
  line-height: 1.45;
  font-size: 0.92rem;
}
.inst-preview h4 { margin: 1rem 0 0.35rem; font-family: Georgia, "Times New Roman", serif; }
.inst-preview ul { margin: 0.25rem 0 0.5rem 1.1rem; }
.sky-stage { position: relative; }
#sky-canvas {
  width: min(1100px, 100%);
  height: auto;
  border-radius: 16px;
  background: #050814;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 0 48px rgba(92, 225, 230, 0.12);
}
#sky-canvas:active { cursor: grabbing; }
@media (max-width: 840px) {
  .instruct-grid { grid-template-columns: 1fr; }
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}
.profile-hero { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.6rem;
  background: radial-gradient(circle at 30% 30%, rgba(92,225,230,0.35), rgba(12,16,32,0.9));
  border: 1px solid rgba(92,225,230,0.35);
  box-shadow: 0 0 20px rgba(92,225,230,0.2);
}
.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1rem;
}
.profile-stats div {
  padding: 0.65rem 0.75rem; border-radius: 10px;
  border: 1px solid rgba(120,180,255,0.14); background: rgba(0,0,0,0.2);
}
.profile-stats strong { display: block; font-size: 1.2rem; }
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}
.badge-card {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(120,180,255,0.2);
  background: rgba(8,12,28,0.65);
  text-align: center;
  min-height: 110px;
}
.badge-card .ico { font-size: 1.6rem; display: block; margin-bottom: 0.35rem; }
.badge-card strong { display: block; font-size: 0.88rem; margin-bottom: 0.25rem; }
.badge-card p { margin: 0; font-size: 0.72rem; color: var(--mute, #9aa8c7); line-height: 1.3; }
.badge-grid.locked .badge-card { opacity: 0.45; filter: grayscale(0.4); }
@media (max-width: 840px) {
  .profile-grid { grid-template-columns: 1fr; }
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.cert-card {
  position: relative;
  padding: 1rem 0.9rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(245, 193, 108, 0.35);
  background:
    linear-gradient(145deg, rgba(245, 193, 108, 0.12), rgba(12, 16, 36, 0.92)),
    rgba(8, 12, 28, 0.85);
  box-shadow: 0 0 24px rgba(245, 193, 108, 0.08);
  text-align: center;
  min-height: 140px;
}
.cert-card .seal {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}
.cert-card strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}
.cert-card .meta {
  font-size: 0.72rem;
  color: var(--mute, #9aa8c7);
  line-height: 1.35;
}
.cert-card .code {
  margin-top: 0.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(245, 193, 108, 0.9);
}
.cert-card.dim { opacity: 0.55; border-style: dashed; }

.mastery-pill {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  border: 1px solid rgba(120,180,255,0.25);
}
.mastery-pill.visited { color: #9aa8c7; }
.mastery-pill.practiced { color: #5ce1e6; border-color: rgba(92,225,230,0.4); }
.mastery-pill.certified { color: #f5c16c; border-color: rgba(245,193,108,0.5); }
.onboard-steps { padding-left: 1.1rem; line-height: 1.6; font-size: 0.88rem; }
.onboard-steps li.on { color: #5ce1e6; }
#adaptation-banner {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(92,225,230,0.25);
  background: rgba(92,225,230,0.08);
}
.node.mastery-certified { box-shadow: inset 0 0 0 1px rgba(245,193,108,0.35); }
.node.mastery-practiced { box-shadow: inset 0 0 0 1px rgba(92,225,230,0.25); }
