/* ============================================================
   Growing Brain — style system
   Modern 2026 "calm + liquid-glass" aesthetic.
   Ages 5–11 but NOT childish: refined, confident, explorable.

   Sections:
     1. Tokens (design system)
     2. Base
     3. Glass surface utilities
     4. Layout & nav
     5. Components (cards, buttons, chips, inputs, stages)
     6. Level-specific / interaction styles
   ============================================================ */

/* ---------------- 1. Tokens ---------------- */
:root {
  /* background scaffolding (deep, cool, calm) */
  --bg-0: #151c34;
  --bg-1: #1d2747;
  --bg-2: #263356;

  /* glass surface layers (translucent, frosted) */
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-hover: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.22);

  /* accent — one calm signature hue + functional tones */
  --accent: #8ab4ff;        /* calm periwinkle-blue (signature) */
  --accent-strong: #5b8cff;
  --accent-ink: #0d1526;    /* text on accent */
  --mint: #7fe0c3;          /* correct / success */
  --coral: #ff8f8f;         /* wrong / attention */
  --gold: #ffd28a;          /* winner / found */

  /* text */
  --text: #eef1f8;
  --text-soft: #b7bfd4;
  --text-dim: #8a93ad;

  /* radii + shadows + blur tokens (reproducible glass) */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 20px 60px rgba(0, 0, 0, 0.38);
  --blur-panel: 22px;
  --blur-chip: 14px;

  /* spacing scale */
  --sp-1: 6px;
  --sp-2: 10px;
  --sp-3: 16px;
  --sp-4: 22px;
  --sp-5: 32px;
}

/* ---------------- 2. Base ---------------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "Inter", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 100% at 18% 0%, var(--bg-1) 0%, var(--bg-0) 58%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* re-enable selection only on truly interactive / selectable controls */
button,
select,
.option,
.learn-card,
.predict-card,
.pair-chip,
input,
textarea,
a {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* calm ambient glow blobs behind the glass, so panels have something to frost */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}
body::before {
  top: -14vmax;
  right: -10vmax;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.20), transparent 62%);
}
body::after {
  bottom: -16vmax;
  left: -8vmax;
  background: radial-gradient(circle, rgba(127, 224, 195, 0.13), transparent 62%);
}

/* ---------------- 3. Glass surface utilities ---------------- */
.glass {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* faint top sheen for the liquid-glass look */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%);
  pointer-events: none;
}

/* ---------------- 4. Layout & nav ---------------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 14px clamp(16px, 4vw, 40px);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  background: rgba(13, 15, 28, 0.6);
  border-bottom: 1px solid var(--glass-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(91, 140, 255, 0.35), rgba(127, 224, 195, 0.18));
  border: 1px solid var(--glass-border-strong);
  font-size: 20px;
  box-shadow: var(--shadow-soft);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

nav a {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}

nav a:hover {
  color: var(--text);
  background: var(--glass-hover);
}

nav a.active {
  color: #fff;
  background: var(--glass-strong);
  border-color: var(--glass-border-strong);
}

main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-5) clamp(16px, 4vw, 40px) 80px;
}

/* page heading */
.page-head {
  margin: 8px 0 var(--sp-4);
}
.page-head h2 {
  margin: 0 0 var(--sp-2);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 650;
  letter-spacing: -0.3px;
}
.page-head .kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}
.page-head .kicker::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* Trimmed so the X-Ray and the predict result both fit on a 1280x800 laptop
   without scrolling. Only affects screens with room to spare vertically. */
@media (min-height: 700px) {
  .page-head {
    margin: 4px 0 var(--sp-3);
  }
  .page-head h2 {
    font-size: clamp(24px, 3.4vw, 30px);
    margin-bottom: 6px;
  }
  .page-head .kicker {
    margin-bottom: 6px;
  }
  main > .page-head .hint {
    font-size: 13.5px;
    line-height: 1.5;
  }
  .layout-main > .panel {
    padding: var(--sp-3);
    margin-bottom: var(--sp-3);
  }
  /* A touch shorter so the verdict strip, the predict row and the result all
     land above the fold on a 1280x800 laptop. StoryAI is excluded: its 45-node
     "Next word" column has no vertical slack to give up. */
  @media (min-height: 760px) {
    .canvas-wrap canvas {
      max-height: 320px;
      width: auto;
      max-width: 100%;
      margin: 0 auto;
    }
    body.storyai-page .canvas-wrap canvas {
      max-height: none;
      width: 100%;
    }
  }
}

/* ---------------- 5. Components ---------------- */

/* cards (landing) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.brain-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  text-align: left;
  padding: var(--sp-4);
  text-decoration: none;
  color: var(--text);
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.2s, background 0.2s;
}
.brain-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 45%);
  pointer-events: none;
}
.brain-card:hover {
  transform: translateY(-4px);
  border-color: var(--glass-border-strong);
  background: var(--glass-strong);
}

.brain-card .emoji {
  font-size: 40px;
  line-height: 1;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  margin-bottom: var(--sp-1);
}

.brain-card .name {
  font-size: 21px;
  font-weight: 650;
  color: #fff;
}

.brain-card .params {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.brain-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
}

/* panels */
.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  backdrop-filter: blur(var(--blur-panel)) saturate(1.4);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%);
  pointer-events: none;
}

.panel.center {
  text-align: center;
}

.panel h2 {
  margin: 0 0 var(--sp-3);
  font-size: 18px;
  font-weight: 650;
  color: #fff;
  letter-spacing: -0.2px;
}

h2 {
  color: #fff;
}

/* buttons */
button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 22px;
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  background: var(--accent-strong);
  color: #fff;
  transition: transform 0.15s, filter 0.15s, background 0.18s, border-color 0.18s;
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.28);
}
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
button:active {
  transform: translateY(0);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

button.secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border-strong);
  box-shadow: none;
  color: var(--text);
}
button.secondary:hover {
  background: var(--glass-hover);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  box-shadow: none;
  color: var(--text-soft);
}
button.ghost:hover {
  color: var(--text);
  border-color: var(--glass-border-strong);
  background: var(--glass-hover);
}

/* canvas */
canvas {
  width: 100%;
  display: block;
  background: rgba(8, 10, 20, 0.5);
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-border);
}

.canvas-wrap {
  max-width: 760px;
  margin: 0 auto;
}

/* two-column layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-4);
  align-items: start;
}
.layout-side {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.layout-side .panel {
  padding: var(--sp-3);
}

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

/* rows */
.row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  margin: var(--sp-3) 0;
}

.big-emoji {
  font-size: 40px;
  min-height: 56px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
}

.big-emoji.empty {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* chips / option cells */
.option-grid {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.option-grid.centered {
  justify-content: center;
}

.predict-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.predict-head h2 {
  margin: 0;
}
.predict-head .hint {
  margin: 0;
  color: var(--text-dim);
}

#knownPairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
#knownPairs .option {
  justify-content: center;
  font-size: 20px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
}

/* AttentionAI "Stories it knows" — skinny pills in 2 columns */
#knownStories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}
#knownStories .option {
  justify-content: center;
  font-size: 15px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  white-space: normal;
  text-align: center;
  line-height: 1.2;
}

/* AttentionAI child-added stories — smaller chips in the 2-col grid */
#addedStories .option {
  font-size: 15px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  justify-content: center;
}

.center-heading {
  text-align: center;
}

.panel-center-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.learn-more-wrap {
  display: flex;
  justify-content: center;
  margin: var(--sp-4) 0 0;
}

.layout-main .learn-more-wrap {
  margin: var(--sp-4) 0 0;
  text-align: center;
}

.learn-more-wrap .modal-open {
  background: transparent;
  border: 1px solid var(--glass-border-strong);
  color: var(--accent);
  box-shadow: none;
}
.learn-more-wrap .modal-open:hover {
  background: var(--glass-hover);
  color: var(--text);
}

/* modal (advanced "Learn more" popups) */
body.modal-is-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(8, 10, 20, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: relative;
  width: min(680px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #232e52, #161e3a);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-lift), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal .modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  color: var(--text);
}
.modal .modal-close:hover {
  background: var(--glass-hover);
}

.modal h2 {
  margin: 0 0 var(--sp-3);
  font-size: 20px;
  color: #fff;
  padding-right: 40px;
}

.modal-body {
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.7;
}
.modal-body p {
  margin: 0 0 var(--sp-3);
}
.modal-body b {
  color: var(--text);
}
.modal-body em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 26px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  user-select: none;
  transition: background 0.16s, border-color 0.16s, transform 0.1s;
}
.option:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border-strong);
  transform: translateY(-1px);
}
.option.selected {
  border-color: var(--accent);
  background: rgba(138, 180, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(138, 180, 255, 0.35) inset;
}

/* smaller emoji options (AttentionAI build + predict palettes) */
.option-sm {
  font-size: 20px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
}

/* SmallAI Predict — compact emoji so the whole palette fits in one row */
#inputOptions .option {
  font-size: 24px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
}

.emotion-options .option {
  font-size: 22px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  line-height: 1;
}

/* compact added-pairs grid: 2 columns, small chips so the Teach box stays short */
.pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}
/* visual divider between the Learn/Reset controls and the added-pairs list */
.teach-sep {
  height: 1px;
  background: var(--glass-border-strong);
  margin: var(--sp-2) 0 var(--sp-3);
}
.pair-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 18px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  user-select: none;
}
.pair-rm {
  cursor: pointer;
  color: #ff9a9a;
  margin-left: 6px;
}

/* learn checkboxes */
.learn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}

.learn-card {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  user-select: none;
  transition: background 0.16s, border-color 0.16s;
}
.learn-card:hover {
  background: var(--glass-hover);
}
.learn-card.checked {
  border-color: var(--accent);
  background: rgba(138, 180, 255, 0.14);
}

.learn-card .box {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: transparent;
  flex-shrink: 0;
}
.learn-card.checked .box {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.learn-card .item-emoji {
  font-size: 24px;
}
.learn-card .learn-label {
  font-size: 15px;
  font-weight: 600;
}

.learn-card .learn-pair {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  font-size: 26px;
  color: var(--text-soft);
  line-height: 1;
}
.learn-card .pair-emoji {
  font-size: 24px;
}

/* in the smiley's pill the arrow sits beside the label, select holds the right edge */
.learn-card:has(.emotion-select) .learn-pair {
  margin: 0 6px 0 0;
}

.learn-card .emotion-select {
  margin-left: auto;
  font-size: 14px;
  padding: 5px 10px;
  min-height: 0;
  cursor: pointer;
}

/* predict grid */
.predict-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
}

.predict-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border-radius: var(--r-md);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s, background 0.16s, border-color 0.16s;
}
.predict-card:hover {
  transform: translateY(-2px);
  background: rgba(138, 180, 255, 0.12);
  border-color: var(--accent);
}

.predict-card .item-emoji {
  font-size: 32px;
}
.predict-card .predict-label {
  font-size: 13px;
  color: var(--text-soft);
}

/* TinyAI Predict — smaller emoji buttons */
#predictOptions .predict-card {
  padding: 8px 6px;
  gap: 2px;
}
#predictOptions .predict-card .item-emoji {
  font-size: 20px;
}
#predictOptions .predict-card .predict-label {
  font-size: 12px;
}

/* confidence bar */
.confidence {
  font-size: 15px;
  margin-top: var(--sp-2);
}
.confidence b {
  color: var(--text);
}
.confidence .bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--glass-border);
}
.confidence .fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--mint));
  transition: width 0.4s ease;
}

/* result / feedback */
.result {
  font-size: 19px;
  font-weight: 600;
  margin-top: var(--sp-3);
  min-height: 26px;
  color: #fff;
}
.result.correct {
  color: var(--mint);
}
.result.wrong {
  color: var(--coral);
}

.hint {
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.6;
}
.hint b {
  color: var(--text);
  font-weight: 600;
}

.hint-sm {
  font-size: 12.5px;
}

#message {
  font-size: 14.5px;
  color: var(--text-soft);
  min-height: 22px;
  margin-top: var(--sp-2);
}

/* An empty #message is just reserved blank space — the guess/remembered verdict
   lives in the X-Ray strip now, so collapse it until something is written. */
#message:empty {
  min-height: 0;
  margin-top: 0;
}

/* Verdict line ("I remembered" / "I guessed") shown above the X-Ray canvas, so
   it stays readable whether the box is closed or the inside is revealed. */
.xray-status {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--text-soft);
  min-height: 22px;
  margin-top: var(--sp-2);
}
.xray-status.good {
  color: var(--mint);
}
.xray-status.guess {
  color: var(--gold);
}

/* Palette chips that can't follow the words already built (StoryAI) */
.option.invalid {
  opacity: 0.28;
  pointer-events: none;
}

/* selects */
select {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
}
select:focus {
  outline: none;
  border-color: var(--accent);
}

/* big emoji pickers in the Teach box — easier for kids to tap */
#newIn,
#newOut {
  flex: 1 1 0;
  min-width: 0;
  font-size: 26px;
  padding: 10px 8px;
  min-height: 60px;
  text-align: center;
}
.pair-arrow {
  font-size: 22px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.teach-row {
  flex-wrap: nowrap;
}

label {
  color: var(--text-soft);
  font-size: 14.5px;
}

/* ---------------- 6. Level / interaction ---------------- */

/* subtle learning pulse — guides attention, not decorative */
.learn-anim {
  animation: pulse 0.8s 2;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138, 180, 255, 0.5); }
  50% { box-shadow: 0 0 0 14px rgba(138, 180, 255, 0); }
}

/* "how it works" callout — transparent-ML framing */
.callout {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.10), rgba(127, 224, 195, 0.06));
  border: 1px solid var(--glass-border-strong);
}
.callout .callout-ico {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  font-size: 17px;
}
.callout .callout-body h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
}
.callout .callout-body p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
}

/* x-ray label tag above canvases */
.viz-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: var(--sp-2) 0 var(--sp-2);
}
.viz-label .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.16);
}
/* dot turns mint when the X-Ray is revealed (canvas-wrap gains .xray-on) */
.viz-label:has(+ .canvas-wrap.xray-on) .dot {
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(127, 224, 195, 0.18);
}

/* ---------------- X-Ray reveal / hide-inside ---------------- */
.canvas-wrap {
  position: relative;
  border-radius: var(--r-sm);
  transition: box-shadow 0.5s ease;
  cursor: pointer;
}
.canvas-wrap.xray-on {
  box-shadow: 0 0 0 1px rgba(138, 180, 255, 0.25), 0 0 28px rgba(138, 180, 255, 0.18);
  cursor: default;
}

/* small circular ✕ button inside the dark canvas area to turn X-Ray off
   (hidden by default, shown only while in X-Ray mode) */
.xray-off-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  border-radius: 50%;
  background: rgba(8, 10, 20, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.xray-off-btn:hover {
  background: rgba(8, 10, 20, 0.85);
  border-color: var(--accent);
  color: #fff;
}

.xray-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: var(--sp-2) 0 0;
}
.xray-hint b {
  color: var(--accent);
  font-weight: 600;
}

/* StoryAI "Build your story" panel — story starters are primary, individual
   words are an advanced, collapsible section. */
details.advanced-words {
  margin-top: var(--sp-3);
  border-top: 1px solid var(--glass-border);
  padding-top: var(--sp-3);
}

/* "Add your own words" now lives in the narrow side column, so it needs its
   chip sizing tuned for that width rather than a full-width panel. */
.layout-side .advanced-words {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}
.layout-side #palette .option {
  padding: 5px 9px;
  font-size: 17px;
}

details.advanced-words summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, rgba(138, 180, 255, 0.22), rgba(127, 224, 195, 0.20));
  border: 1px solid rgba(138, 180, 255, 0.55);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(138, 180, 255, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
details.advanced-words summary::-webkit-details-marker {
  display: none;
}
details.advanced-words summary:hover {
  background: linear-gradient(135deg, rgba(138, 180, 255, 0.34), rgba(127, 224, 195, 0.30));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px rgba(138, 180, 255, 0.45);
  transform: translateY(-1px);
}
details.advanced-words summary .toggle-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--mint);
}
details.advanced-words[open] summary .toggle-hint {
  color: var(--mint);
}
details.advanced-words[open] summary {
  border-color: var(--mint);
  background: linear-gradient(135deg, rgba(127, 224, 195, 0.28), rgba(138, 180, 255, 0.22));
  box-shadow: none;
}
details.advanced-words .hint {
  margin: var(--sp-2) 0;
}
details.advanced-words #palette {
  margin-bottom: var(--sp-2);
}
