:root {
  --brand-purple: #7000FF;
  --brand-pink: #FF00FF;
  --brand-magenta: #C00FD1;
  --brand-teal: #00D2FF;
  --brand-blue: #00D2FF; 
  --brand-dark-base: #0a0214;
  --brand-dark-surface: #140d20;
  --brand-dark-elevated: #1e1630;
  --text-white: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.65);
  
  --glass: rgba(30, 22, 48, 0.6);
  --border: rgba(255, 255, 255, 0.1);
  --done: #00e676;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--brand-dark-base);
  color: var(--text-white);
  line-height: 1.55;
  overflow: hidden; /* Canvas handles everything */
}

* { box-sizing: border-box; }

.bg-glow {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(circle at 20% 30%, rgba(112, 0, 255, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(0, 210, 255, 0.1) 0%, transparent 60%);
  background-color: var(--brand-dark-base);
  z-index: -2;
}

#nursery-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: crosshair;
}

header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 40px;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through except on buttons */
}

.logo-mark {
  font-weight: 700;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.logo-mark .badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--brand-purple);
  color: white;
}

.tools {
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: auto;
}

.btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.92rem;
  background: var(--brand-dark-surface);
  transition: all 0.2s;
  font-weight: 500;
}
.btn:hover {
  border-color: var(--brand-teal);
  background: rgba(0, 210, 255, 0.1);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn[disabled]:hover {
  border-color: var(--border);
  background: var(--brand-dark-surface);
}
.btn.primary {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: white;
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--brand-magenta);
  border-color: var(--brand-magenta);
}

.status {
  font-family: 'Nova Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Modal Overlays */
#question-overlay, #forcing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 2, 20, 0.7);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.6s ease-in-out, backdrop-filter 0.6s ease-in-out;
}
#question-overlay.hidden, #forcing-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0px);
}
#forcing-overlay.hidden .card {
  transform: translateY(100vh) scale(0.9);
  opacity: 0;
}

.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 650px;
  display: grid;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 0 32px rgba(112, 0, 255, 0.05);
  backdrop-filter: blur(16px);
  position: relative;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.hidden .card { transform: translateY(20px); }

.close-btn {
  position: absolute;
  top: 16px; right: 20px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.close-btn:hover { color: white; }

.card h3 { font-size: 1.4rem; font-weight: 600; margin: 0; }
.known {
  border-left: 3px solid var(--border);
  padding-left: 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}
.known b {
  font-family: 'Nova Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  all: unset; cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  font-size: 0.85rem; background: var(--brand-dark-elevated);
  transition: all 0.2s;
}
.chip:hover { border-color: var(--brand-teal); background: rgba(0,210,255,0.1); }

textarea {
  width: 100%; min-height: 120px; resize: vertical;
  font-family: inherit; font-size: 1rem;
  color: white; background: rgba(0,0,0,0.3);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; transition: border-color 0.2s;
}
textarea:focus { outline: none; border-color: var(--brand-purple); }

.tooltip {
  position: absolute;
  background: var(--brand-dark-elevated);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.15s;
}
.tooltip.hidden { opacity: 0; }

/* Focus: the buttons use `all: unset`, which removes the browser ring, so draw our own. */
.btn:focus-visible, .chip:focus-visible, .close-btn:focus-visible,
.q-index-item:focus-visible, #slide-title:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand-teal);
  outline-offset: 2px;
}
#slide-title:focus-visible { outline-offset: 6px; border-radius: 4px; }

.chip[aria-pressed="true"] {
  border-color: var(--brand-teal);
  background: rgba(0, 210, 255, 0.18);
}

#slide-container { max-width: 600px; margin: 15vh auto; text-align: center; }
#slide-desc { color: var(--text-muted); margin: 0 0 4px; }
#slide-content { display: grid; gap: 12px; }
.card-actions { text-align: right; }
.slide-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Question index */
#q-index {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 15;
  width: min(320px, calc(100vw - 48px));
  max-height: 45vh;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
#q-index[hidden] { display: none; }
#q-index h2 {
  margin: 0 0 8px;
  font-family: 'Nova Mono', monospace;
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--text-muted);
}
#q-index ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.q-index-item {
  all: unset;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  cursor: pointer;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--brand-dark-elevated);
  font-size: 0.88rem;
}
.q-index-item:hover { border-color: var(--brand-teal); }
.q-index-item .q-state {
  flex: none;
  font-family: 'Nova Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Small screens */
@media (max-width: 640px) {
  header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .logo-mark { font-size: 1.4rem; }
  .card { padding: 20px; }
  #slide-container { margin: 6vh 12px; }
  #q-index { left: 12px; right: 12px; bottom: 12px; width: auto; max-height: 38vh; }
}

/* Respect the reduced-motion setting: no transitions, no slide drop */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #forcing-overlay.hidden .card { transform: none; }
}

/* The three exits: each is a valid answer */
.exits { display: flex; flex-wrap: wrap; gap: 8px; }
.btn[aria-pressed="true"] { border-color: var(--brand-teal); background: rgba(0, 210, 255, 0.18); }
#q-open-count { font-weight: 400; text-transform: none; }
#build-note { margin: 0 0 8px; font-size: 0.85rem; color: var(--text-muted); }

#delete-btn { margin-top: 10px; }
#delete-btn[hidden], #signin-link[hidden] { display: none; }

.hint { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.hint[hidden] { display: none; }
