/* The brain editor (js/brain/brainui.js). Everything is scoped under .tb-brain.
   TardiGREATS sticker look: cream panels, 3px ink borders, chunky ink shadows,
   Bricolage Grotesque titles, Nunito Sans text. Slot colours: WHEN orange (spark socket),
   WHILE blue (ribbon socket), IF purple (round tab), DO green (square plug). */

.tb-brain, .tbb-thought.is-float {
  --ink: #16223A;
  --cream: #FBF7F0;
  --paper: #FFFDF8;
  --muted: #5B6680;
  --orange: #FF8A3D;
  --blue: #2E8BC9;
  --purple: #8A4FD1;
  --green: #2F9E5B;
  --coral: #F0525F;
  --yellow: #F2C14E;
  --title: 'Bricolage Grotesque', 'Nunito Sans', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text: 'Nunito Sans', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.tb-brain {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  container: tbbrain / inline-size;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--text);
  font-size: 15px;
  line-height: 1.3;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* zero-specificity resets, so every class rule below wins over them */
:where(.tb-brain) *, :where(.tb-brain) *::before, :where(.tb-brain) *::after { box-sizing: border-box; }
:where(.tb-brain button) {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
:where(.tb-brain button):focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.tb-brain .ic { flex: none; display: block; }
.tbb-main { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------------------------------------------------------------- header: mode tabs */

.tbb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 14px 0 10px;
  flex: none;
  min-width: 0;
}
.tbb-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 10px 8px 4px;
  scrollbar-width: none;
}
.tbb-tabs::-webkit-scrollbar { display: none; }
.tbb-tab {
  --mode: var(--blue);
  --mode-ink: #fff;
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 4px 14px 4px 5px;
  border: 3px solid var(--ink) !important;
  border-radius: 18px;
  background: var(--paper) !important;
  box-shadow: inset 7px 0 0 var(--mode), 0 3px 0 var(--ink);
  font: 800 15px/1 var(--title) !important;
  color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tbb-tab.is-active {
  background: var(--mode) !important;
  color: var(--mode-ink);
  box-shadow: 0 5px 0 var(--ink);
  transform: translateY(-2px);
}
.tbb-tab-face { display: grid; place-items: center; margin-left: 6px; }
.tbb-tab.is-active .tbb-tab-face { margin-left: 0; }
.tbb-tab-name { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.tbb-tab-start {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); border: 2px solid var(--ink);
}
.tbb-tab-edit {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255, 253, 248, .92); color: var(--ink); border: 2px solid var(--ink);
}
.tbb-tab-live {
  display: none;
  position: absolute; top: -9px; right: -7px;
  width: 24px; height: 24px; border-radius: 50%;
  place-items: center;
  background: var(--orange); color: var(--ink); border: 2.5px solid var(--ink);
  animation: tbb-throb 1s ease-in-out infinite;
}
.tbb-tab.is-live .tbb-tab-live { display: grid; }
.tbb-tab-add {
  border-style: dashed !important;
  box-shadow: none;
  color: var(--muted);
  padding: 4px 14px 4px 10px;
}
.tbb-ideas {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 14px 0 10px;
  border: 3px solid var(--ink) !important;
  border-radius: 999px;
  background: var(--yellow) !important;
  box-shadow: 0 3px 0 var(--ink);
  font: 800 15px/1 var(--title) !important;
}
.tbb-ideas:active, .tbb-tab:active, .tbb-tool:active, .tbb-chip:active, .tbb-tile:active, .tbb-new:active, .tbb-pick:active, .tbb-choice:active, .tbb-btn:active, .tbb-add:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
.tbb-higher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px 6px 22px;
  color: var(--muted);
  font: 700 13px/1.2 var(--text);
}

/* ---------------------------------------------------------------- the card list */

.tbb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 6px 12px 92px 4px;
  overscroll-behavior: contain;
}
.tbb-cards { position: relative; padding-left: 20px; }
.tbb-lines {
  position: absolute;
  left: 0; top: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.tbb-lines .ln { fill: none; stroke: var(--ink); stroke-opacity: .55; stroke-width: 2.5; stroke-dasharray: 4 5; stroke-linecap: round; }
.tbb-lines .dot { fill: var(--orange); stroke: var(--ink); stroke-width: 2; }

.tbb-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: stretch;
  margin: 0 0 18px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .22s cubic-bezier(.3, 1.3, .5, 1), box-shadow .2s ease, opacity .2s ease, filter .2s ease;
}
.tbb-card[data-kind="while"] { background: linear-gradient(90deg, #EEF6FC, var(--paper) 40%); }
.tbb-card.is-off { opacity: .6; }
.tbb-card.is-selected { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px rgba(46, 139, 201, .3); }
.tbb-card.is-new { animation: tbb-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.tbb-card.is-leaving { transform: scale(.9) translateX(30px); opacity: 0; }
.tbb-card.is-dragging {
  z-index: 10;
  transition: none;
  box-shadow: 0 14px 0 rgba(22, 34, 58, .25), 0 4px 0 var(--ink);
}
.tb-brain.is-sorting .tbb-card:not(.is-dragging) { transition: transform .2s ease; }

.tbb-grip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 14px 0 10px 6px;
  min-height: 44px;
  color: var(--muted);
  touch-action: none;
  cursor: grab;
}
.tbb-grip.is-static { cursor: default; }
.tbb-card.is-dragging .tbb-grip { cursor: grabbing; }
.tbb-badge {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  font: 800 17px/1 var(--title);
  box-shadow: 0 2px 0 rgba(22, 34, 58, .35);
}
.tbb-body { min-width: 0; padding: 18px 0 6px 2px; }
.tbb-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 20px 24px;
  padding: 2px 12px 2px 10px;
}

/* ---------------------------------------------------------------- slots */

.tbb-slot, .tbb-add, .tbb-kind { --slot: var(--orange); --slot-soft: #FFE6D3; --slot-deep: #B4520F; }
.tbb-while { --slot: var(--blue); --slot-soft: #D7EAF7; --slot-deep: #1A5E8C; }
.tbb-if { --slot: var(--purple); --slot-soft: #EADDF8; --slot-deep: #5E2E9C; }
.tbb-do { --slot: var(--green); --slot-soft: #D6EFDF; --slot-deep: #1D6B3C; }
.tbb-add-if { --slot: var(--purple); --slot-soft: #EADDF8; --slot-deep: #5E2E9C; }
.tbb-add-do { --slot: var(--green); --slot-soft: #D6EFDF; --slot-deep: #1D6B3C; }

.tbb-slot {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 112px;
  max-width: 100%;
  padding: 13px 8px 8px;
  background: var(--slot);
  border: 3px solid var(--ink);
  border-radius: 18px;
  filter: drop-shadow(0 3px 0 var(--ink));
}
/* DO slots share the line with their WHEN and wrap their chips inside, so cards stay short */
.tbb-slot.tbb-do { flex: 1 1 0%; min-width: min(100%, 220px); }
.tbb-slot.tbb-while {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .16) 0 10px, rgba(255, 255, 255, 0) 10px 20px),
    var(--slot);
}
.tbb-socket {
  position: absolute;
  top: 50%;
  z-index: 0;
  margin-top: calc(var(--sh) / -2);
  overflow: visible;
  pointer-events: none;
}
.tbb-socket.is-right { right: calc(var(--sw) * -1); }
.tbb-socket.is-left { left: calc(var(--sw) * -1); }
.tbb-socket .fill { fill: var(--slot); }
.tbb-socket .line { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.tbb-word {
  position: absolute;
  top: -13px;
  left: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: 800 11.5px/1 var(--title);
  letter-spacing: .08em;
}
.tbb-word .ic { color: var(--slot-deep); }
.tbb-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  min-height: 48px;
  padding: 5px 12px 5px 6px;
  background: var(--paper) !important;
  border: 2.5px solid var(--ink) !important;
  border-radius: 14px;
  box-shadow: 0 2px 0 var(--ink);
  font: 800 16px/1.1 var(--title) !important;
  text-align: left;
}
.tbb-tile-ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--slot-soft);
  color: var(--slot-deep);
}
.tbb-tile-label { min-width: 0; overflow-wrap: anywhere; }
.tbb-slot.is-empty { background: var(--slot-soft); border-style: dashed; filter: none; }
.tbb-slot.is-empty .tbb-socket .fill { fill: var(--slot-soft); }
.tbb-tile.is-empty { border-style: dashed !important; box-shadow: none; color: var(--slot-deep); animation: tbb-breathe 1.8s ease-in-out infinite; }
.tbb-tile.is-empty .tbb-tile-ic { background: var(--slot); color: #fff; }

.tbb-chips { display: contents; }
.tbb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px 0 8px;
  border: 2.5px solid var(--ink) !important;
  border-radius: 999px;
  background: var(--paper) !important;
  box-shadow: 0 2px 0 var(--ink);
  font: 750 14px/1 var(--text) !important;
  white-space: nowrap;
}
.tbb-chip.is-missing { background: var(--yellow) !important; animation: tbb-breathe 1.6s ease-in-out infinite; }
.tbb-not { color: var(--muted); }
.tbb-not.is-on { background: var(--ink) !important; color: var(--cream); }
.tbb-swatch {
  display: inline-block;
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
}
.tbb-swatch.is-big { width: 30px; height: 30px; }
.tbb-face .scr { fill: var(--ink); stroke: none; }
.tbb-face { color: #A8F0FF; flex: none; }
.tbb-face .f { fill: currentColor; }

.tbb-note {
  flex-basis: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 10px;
  background: rgba(255, 253, 248, .94);
  color: var(--ink);
  font: 700 12.5px/1.15 var(--text);
}
.tbb-note.is-start { background: #FFF6D9; box-shadow: inset 0 0 0 2px rgba(22, 34, 58, .18); }
.tbb-note.is-have { background: #D6EFDF; color: #1D6B3C; }
.tbb-slot.is-locked { background: repeating-linear-gradient(135deg, #D9D3C8 0 8px, #E8E2D8 8px 16px); }
.tbb-slot.is-locked .tbb-socket .fill { fill: #DED8CD; }
.tbb-slot.is-locked .tbb-tile { color: var(--muted); }
.tbb-slot.is-locked .tbb-tile-ic { background: #E9E4DA; color: var(--muted); }
.tbb-slot.is-grey { opacity: .62; filter: grayscale(.6) drop-shadow(0 3px 0 var(--ink)); }
.tbb-slot.is-over { border-style: dashed; }
/* "When I start" in a mode the robot does not start in: it can never fire there */
.tbb-slot.is-off-mode { border-style: dashed; background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .28) 0 8px, rgba(255, 255, 255, 0) 8px 16px), var(--slot); }
.tbb-slot.is-off-mode .tbb-tile { color: var(--muted); }
.tbb-slot.is-off-mode .tbb-tile-ic { background: #E9E4DA; color: var(--muted); }

.tbb-add {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: 2px;
  min-width: 50px;
  min-height: 56px;
  padding: 4px 6px;
  border: 3px dashed var(--ink) !important;
  border-radius: 16px;
  background: var(--slot-soft) !important;
  color: var(--slot-deep);
  font: 800 11.5px/1 var(--title) !important;
  letter-spacing: .06em;
}
.tbb-add .tbb-socket .fill { fill: var(--slot-soft); }
.tbb-add .tbb-socket .line { stroke-dasharray: 3 3; }

/* the "Why didn't it...?" marks: an hourglass on the WHEN slot it waits for, a no-sign on the IF that said no */
.tbb-mark {
  display: none;
  position: absolute;
  top: -12px; right: -10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  place-items: center;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  z-index: 2;
}
.tbb-mark .ic { display: none; }
[data-why="wait"] > .tbb-mark, [data-why="no"] > .tbb-mark { display: grid; }
[data-why="wait"] > .tbb-mark .m-wait { display: block; color: var(--blue); }
[data-why="no"] > .tbb-mark { background: var(--coral); }
[data-why="no"] > .tbb-mark .m-no { display: block; color: #fff; }
.tbb-slot[data-why="no"] { outline: 3px dashed var(--coral); outline-offset: 3px; }

/* ---------------------------------------------------------------- card foot + tools */

.tbb-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 10px 10px 2px 6px;
}
.tbb-sentence {
  flex: 1 1 180px;
  margin: 0;
  color: #34405A;
  font: 650 15px/1.35 var(--text);
  -webkit-user-select: text;
  user-select: text;
}
.tbb-speak {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2.5px solid var(--ink) !important;
  background: var(--paper) !important;
  color: var(--ink);
}
.tbb-card.is-speaking .tbb-speak { background: var(--yellow) !important; animation: tbb-throb .8s ease-in-out infinite; }
.tbb-stills { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tbb-stills:empty { display: none; }
.tbb-still {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 11px 0 8px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #D7EAF7;
  font: 800 13px/1 var(--title);
}
.tbb-still .ic { animation: tbb-roll 2.4s linear infinite; }
.tbb-still.is-out { background: #FCE3E5; color: #9C1F2B; }
.tbb-still.is-out .ic { animation: none; }
.tbb-tools {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.tbb-tool {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 3px solid var(--ink) !important;
  box-shadow: 0 3px 0 var(--ink);
  background: var(--paper) !important;
}
.tbb-play { background: var(--green) !important; color: #fff; }
.tbb-play .ic { transform: translateX(1px); }
.tbb-trash { color: var(--ink); }

/* ---------------------------------------------------------------- new card + empty */

.tbb-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: calc(100% - 20px);
  margin: 4px 0 0 20px;
  min-height: 64px;
  border: 3px dashed var(--ink) !important;
  border-radius: 22px;
  background: #FFF1E5 !important;
  font: 800 18px/1 var(--title) !important;
}
.tbb-new.is-big { width: 100%; margin: 18px 0 0; min-height: 72px; font-size: 20px !important; }
.tbb-new-ic {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--orange);
  border: 3px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}
.tbb-empty {
  margin: 6px 0 0;
  padding: 22px 20px 20px;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
}
.tbb-empty.is-small { padding: 14px; box-shadow: none; border-style: dashed; color: var(--muted); font-weight: 700; }
.tbb-empty.is-small p { margin: 0; }
.tbb-empty-art {
  display: inline-grid;
  place-items: center;
  width: 84px; height: 84px;
  border-radius: 28px;
  background: var(--orange);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  animation: tbb-bob 2.6s ease-in-out infinite;
}
.tbb-empty-title { margin: 14px 0 4px; font: 800 24px/1.1 var(--title); }
.tbb-empty-text { margin: 0 0 14px; color: var(--muted); font-weight: 650; }
.tbb-idea-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.tbb-idea-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 96px;
  padding: 10px 8px;
  border: 3px solid var(--ink) !important;
  border-radius: 18px;
  background: var(--cream) !important;
  box-shadow: 0 3px 0 var(--ink);
  font: 800 15px/1.1 var(--title) !important;
}
.tbb-idea-ic {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 16px;
  background: #FFE6D3;
  color: #B4520F;
  border: 2.5px solid var(--ink);
}

/* ---------------------------------------------------------------- live states */

.tbb-status {
  position: absolute;
  top: -14px;
  right: 18px;
  z-index: 4;
  pointer-events: none;
}
.tbb-badge-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 11px 0 8px;
  border-radius: 999px;
  border: 2.5px solid var(--ink);
  background: var(--paper);
  font: 800 13px/1 var(--title);
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}
.tbb-badge-live.is-fired { background: var(--orange); animation: tbb-pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.tbb-badge-live.is-true { background: #EADDF8; }
.tbb-badge-live.is-lost { background: #E3DED5; color: #3E475C; }
.tbb-badge-live.is-dizzy { background: var(--coral); color: #fff; }
.tbb-badge-live.is-dizzy .ic { animation: tbb-roll .8s linear infinite; }
.tbb-badge-live.is-listening { width: 30px; padding: 0; justify-content: center; color: var(--muted); }

.tb-brain.is-live .tbb-card[data-state="listening"] { animation: tbb-listen 2s ease-in-out infinite; }
.tb-brain.is-live .tbb-card[data-state="idle"] { opacity: .72; }
.tb-brain.is-live .tbb-card[data-state="true"] { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px rgba(138, 79, 209, .35); }
.tb-brain.is-live .tbb-card[data-state="fired"] {
  box-shadow: 0 4px 0 var(--ink), 0 0 0 5px #FFB06B, 0 0 26px 8px rgba(255, 138, 61, .5);
  transform: scale(1.012);
}
.tb-brain.is-live .tbb-card[data-state="fired"] .tbb-slot.tbb-when,
.tb-brain.is-live .tbb-card[data-state="fired"] .tbb-mini-slot.tbb-when { animation: tbb-zap .5s ease-out; }
.tb-brain.is-live .tbb-card[data-state="lost"] { opacity: .5; filter: saturate(.35); }
.tbb-card.is-flash { animation: tbb-flash .6s ease-out; }
.tbb-card.is-dizzy { animation: tbb-wobble .5s ease-in-out infinite; outline: 3px dashed var(--coral); outline-offset: 4px; }
.tbb-slot.is-running, .tbb-mini-slot.is-running {
  filter: drop-shadow(0 3px 0 var(--ink)) drop-shadow(0 0 8px rgba(47, 158, 91, .95));
  animation: tbb-throb .7s ease-in-out infinite;
}

.tbb-burst { position: absolute; left: 24px; top: 20px; width: 0; height: 0; pointer-events: none; z-index: 6; }
.tbb-burst i {
  position: absolute;
  left: -9px; top: -9px;
  color: var(--yellow);
  filter: drop-shadow(0 0 2px var(--ink));
  animation: tbb-spark .75s cubic-bezier(.2, .8, .3, 1) forwards;
  transform: rotate(var(--a)) translateY(0) scale(.4);
}
.tbb-burst i:nth-child(2n) { color: #fff; }

/* the thought bubble with the firing card's sentence */
.tbb-thought {
  position: absolute;
  left: 50%;
  top: 74px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(92%, 460px);
  padding: 8px 16px 8px 8px;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  font: 750 15px/1.3 var(--text);
  transform: translate(-50%, -8px) scale(.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.tbb-thought::before, .tbb-thought::after {
  content: '';
  position: absolute;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}
.tbb-thought::before { width: 18px; height: 18px; left: 26px; bottom: -16px; }
.tbb-thought::after { width: 10px; height: 10px; left: 16px; bottom: -28px; }
.tbb-thought.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.tbb-thought.is-pop.is-on { animation: tbb-thought-pop .4s cubic-bezier(.3, 1.6, .5, 1); }
.tbb-thought-ic {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding: 4px 8px 4px 5px;
  border-radius: 999px;
  background: var(--orange);
  border: 2.5px solid var(--ink);
  font: 800 15px/1 var(--title);
}
/* In the compact strip (Try it) the bubble lives OUTSIDE the panel (brainui.js puts it next to the
   mount element and places it), under the panel with its dots going up, or beside it with its
   dots pointing at the firing card. So it never hides a card. */
.tbb-thought.is-float {
  box-sizing: border-box;
  left: 0;
  top: 0;
  z-index: 1;
  max-width: 400px;
  color: var(--ink);
  font-size: 14.5px;
  transform: translateY(-6px) scale(.94);
  transform-origin: 30px 0;
}
.tbb-thought.is-float * { box-sizing: border-box; }
.tbb-thought.is-float .ic { flex: none; display: block; }
.tbb-thought.is-float.is-on { transform: none; }
.tbb-thought.is-float.is-pop.is-on { animation: tbb-float-pop .4s cubic-bezier(.3, 1.6, .5, 1); }
.tbb-thought.is-float.is-below::before { left: 30px; top: -16px; bottom: auto; }
.tbb-thought.is-float.is-below::after { left: 22px; top: -28px; bottom: auto; }
.tbb-thought.is-float.is-beside { transform-origin: 0 var(--tail-y, 50%); transform: translateX(-6px) scale(.94); }
.tbb-thought.is-float.is-beside.is-on { transform: none; }
.tbb-thought.is-float.is-beside::before { left: -17px; bottom: auto; top: calc(var(--tail-y, 50%) - 9px); }
.tbb-thought.is-float.is-beside::after { left: -30px; bottom: auto; top: calc(var(--tail-y, 50%) - 5px); }
.tbb-thought.is-float.is-calm, .tbb-thought.is-float.is-calm.is-on { animation: none; transition: none; }

/* ---------------------------------------------------------------- overlays: picker, chooser, sheets */

.tbb-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.tbb-layer > * { pointer-events: auto; }
.tbb-layer > .tbb-thought { pointer-events: none; }
.tbb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(22, 34, 58, .32);
  animation: tbb-fade .18s ease-out;
}
.tbb-sheet {
  --slot: var(--orange); --slot-soft: #FFE6D3; --slot-deep: #B4520F;
  display: flex;
  flex-direction: column;
  width: min(580px, 100%);
  max-height: 100%;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--cream);
  box-shadow: 0 6px 0 var(--ink);
  overflow: hidden;
  animation: tbb-sheet-in .28s cubic-bezier(.3, 1.4, .5, 1);
}
.tbb-sheet.tbb-while { --slot: var(--blue); --slot-soft: #D7EAF7; --slot-deep: #1A5E8C; }
.tbb-sheet.tbb-if { --slot: var(--purple); --slot-soft: #EADDF8; --slot-deep: #5E2E9C; }
.tbb-sheet.tbb-do { --slot: var(--green); --slot-soft: #D6EFDF; --slot-deep: #1D6B3C; }
.tbb-sheet.tbb-mode-sheet { --slot: var(--blue); --slot-soft: #D7EAF7; --slot-deep: #1A5E8C; }
.tbb-sheet.tbb-ideas-sheet { --slot: var(--yellow); --slot-soft: #FCEFC8; --slot-deep: #7A5A07; }
.tbb-sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 10px 10px 10px 14px;
  background: var(--slot);
  border-bottom: 3px solid var(--ink);
}
.tbb-sheet-head h3 { flex: 1; margin: 0; font: 800 21px/1.15 var(--title); color: var(--ink); }
.tbb-sheet-ic {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 14px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  color: var(--slot-deep);
}
.tbb-x, .tbb-round {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid var(--ink) !important;
  background: var(--paper) !important;
  box-shadow: 0 3px 0 var(--ink);
}
.tbb-round:disabled { opacity: .35; box-shadow: none; cursor: default; }
.tbb-sheet-body { padding: 14px; overflow-y: auto; min-height: 0; }
.tbb-sheet-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 2px 14px 14px;
}
.tbb-sheet-text { margin: 0 0 12px; color: var(--muted); font-weight: 650; }

.tbb-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 14px; }
.tbb-kind {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 64px;
  padding: 8px 18px 8px 12px;
  border: 3px solid var(--ink) !important;
  border-radius: 16px;
  background: var(--slot-soft) !important;
  text-align: left;
}
.tbb-kind .tbb-socket .fill { fill: var(--slot-soft); }
.tbb-kind.is-on { background: var(--slot) !important; box-shadow: 0 3px 0 var(--ink); }
.tbb-kind.is-on .tbb-socket .fill { fill: var(--slot); }
.tbb-kind-word { display: inline-flex; align-items: center; gap: 6px; font: 800 17px/1 var(--title); letter-spacing: .06em; }
.tbb-kind-hint { font: 700 13px/1.2 var(--text); }
.tbb-kind.is-on .tbb-kind-word, .tbb-kind.is-on .tbb-kind-hint { color: var(--ink); }

.tbb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tbb-pick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100px;
  padding: 8px 6px;
  border: 3px solid var(--ink) !important;
  border-radius: 20px;
  background: var(--paper) !important;
  box-shadow: 0 3px 0 var(--ink);
  text-align: center;
}
.tbb-pick-ic {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  border-radius: 18px;
  background: var(--slot-soft);
  color: var(--slot-deep);
  border: 2.5px solid var(--ink);
}
.tbb-pick:not(.is-locked):not(.is-grey) .tbb-pick-ic { animation: tbb-bob 2.8s ease-in-out infinite; }
.tbb-pick:nth-child(2n) .tbb-pick-ic { animation-delay: -.7s; }
.tbb-pick:nth-child(3n) .tbb-pick-ic { animation-delay: -1.4s; }
.tbb-pick-label { font: 800 15px/1.1 var(--title); overflow-wrap: anywhere; }
.tbb-pick-note { display: inline-flex; align-items: center; gap: 4px; font: 700 11.5px/1.15 var(--text); color: var(--muted); }
.tbb-pick.is-current { background: var(--slot-soft) !important; }
.tbb-pick-check {
  position: absolute;
  right: -8px; top: -8px;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--slot);
  color: var(--ink);
  border: 2px solid var(--ink);
}
.tbb-pick.is-locked { background: #ECE7DE !important; box-shadow: none; border-style: dashed !important; }
.tbb-pick.is-locked .tbb-pick-ic { background: #DED8CD; color: var(--muted); }
.tbb-pick.is-locked .tbb-pick-label { color: var(--muted); }
.tbb-pick.is-grey { opacity: .55; box-shadow: none; }
.tbb-pick-note.is-far { color: #7A5A07; }
.tbb-pick.is-nope, .tbb-choice.is-nope { animation: tbb-nope .4s ease; }

.tbb-pager { display: flex; align-items: center; justify-content: center; gap: 16px; width: 100%; }
.tbb-dots { display: inline-flex; gap: 8px; }
.tbb-dots i { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper); }
.tbb-dots i.is-on { background: var(--slot); }
.tbb-takeoff, .tbb-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px 0 12px;
  border: 3px solid var(--ink) !important;
  border-radius: 999px;
  background: var(--paper) !important;
  box-shadow: 0 3px 0 var(--ink);
  font: 800 15px/1 var(--title) !important;
}
.tbb-btn.is-orange { background: var(--orange) !important; }
.tbb-btn.is-coral { background: var(--coral) !important; color: #fff; }

.tbb-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.tbb-choice {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 0 18px 0 12px;
  border: 3px solid var(--ink) !important;
  border-radius: 18px;
  background: var(--paper) !important;
  box-shadow: 0 3px 0 var(--ink);
  font: 800 17px/1 var(--title) !important;
}
.tbb-choice.is-on { background: var(--slot-soft) !important; outline: 3px solid var(--slot); outline-offset: 2px; }
.tbb-choice.is-grey { opacity: .45; box-shadow: none; }
.tbb-choice-mode { background: var(--mode) !important; color: var(--mode-ink); }
.tbb-choice-mode.is-on { background: var(--mode) !important; outline-color: var(--ink); }
.tbb-choice-new { border-style: dashed !important; box-shadow: none; }
.tbb-preview { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 0; padding: 10px 12px; border-radius: 16px; background: var(--paper); border: 2px dashed rgba(22, 34, 58, .35); color: var(--ink); }

.tbb-label { margin: 6px 0 8px; font: 800 14px/1 var(--title); letter-spacing: .04em; color: var(--muted); }
.tbb-label:not(:first-child) { margin-top: 16px; }
.tbb-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.tbb-preset {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 14px 0 6px;
  border: 3px solid var(--ink) !important;
  border-radius: 16px;
  background: var(--paper) !important;
  box-shadow: inset 6px 0 0 var(--mode), 0 2px 0 var(--ink);
  font: 800 15px/1 var(--title) !important;
}
.tbb-preset-ic { display: grid; place-items: center; width: 32px; height: 32px; margin-left: 6px; border-radius: 10px; background: var(--mode); color: var(--mode-ink); }
.tbb-preset.is-on { background: var(--mode) !important; color: var(--mode-ink); box-shadow: 0 3px 0 var(--ink); }
.tbb-preset.is-on .tbb-preset-ic { background: rgba(255, 253, 248, .92); color: var(--ink); }
.tbb-own { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.tbb-own label { flex: 1; display: flex; flex-direction: column; gap: 6px; font: 800 13px/1 var(--title); color: var(--muted); }
.tbb-own input {
  min-height: 48px;
  padding: 0 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font: 700 17px/1 var(--text);
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}
.tbb-swatches, .tbb-faces { display: flex; flex-wrap: wrap; gap: 10px; }
.tbb-swatch-btn {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid var(--ink) !important;
  background: var(--sw) !important;
  color: var(--sw-ink);
  box-shadow: 0 3px 0 var(--ink);
}
.tbb-swatch-btn.is-on { outline: 3px solid var(--ink); outline-offset: 3px; }
.tbb-face-btn {
  display: grid;
  place-items: center;
  width: 60px; height: 56px;
  border-radius: 16px;
  border: 3px solid var(--ink) !important;
  background: var(--paper) !important;
  box-shadow: 0 3px 0 var(--ink);
}
.tbb-face-btn.is-on { background: var(--slot-soft) !important; outline: 3px solid var(--slot); outline-offset: 2px; }
.tbb-start-note { display: inline-flex; align-items: center; gap: 8px; font: 800 14px/1.2 var(--title); }

.tbb-ideas-list { display: flex; flex-direction: column; gap: 10px; }
.tbb-idea {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--ink);
}
.tbb-idea .tbb-idea-ic { width: 52px; height: 52px; }
.tbb-idea-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.tbb-idea-text b { font: 800 17px/1.1 var(--title); }
.tbb-idea-text > span { color: var(--muted); font-weight: 650; }
.tbb-idea-btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.tbb-idea-text .tbb-note { flex-basis: auto; margin-top: 3px; }
.tbb-idea.is-far .tbb-note.is-lock { background: #FCEFC8; }
.tbb-idea.is-far .tbb-idea-ic, .tbb-idea.is-have .tbb-idea-ic { background: #ECE7DE; color: var(--muted); }
.tbb-idea.is-have { box-shadow: none; background: var(--cream); }

/* hint bubble and undo bar */
.tbb-hint {
  position: absolute;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  padding: 10px 14px 10px 10px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--yellow);
  box-shadow: 0 4px 0 var(--ink);
  font: 750 14px/1.25 var(--text);
  transform: translate(-50%, -100%) scale(.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.tbb-hint.is-on { opacity: 1; transform: translate(-50%, -100%) scale(1); }
.tbb-undo {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: var(--ink);
  color: var(--cream);
  box-shadow: 0 4px 0 rgba(22, 34, 58, .3);
  font: 800 15px/1 var(--title);
  transform: translate(-50%, 140%);
  transition: transform .3s cubic-bezier(.3, 1.4, .5, 1);
}
.tbb-undo > span { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tbb-undo.is-on { transform: translate(-50%, 0); }
.tbb-undo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  background: var(--yellow) !important;
  color: var(--ink) !important;
  border: 2.5px solid var(--cream) !important;
  font: 800 15px/1 var(--title) !important;
}

/* ---------------------------------------------------------------- compact strip (Try it screen) */

.tb-brain.is-compact { background: transparent; font-size: 14px; }
.tb-brain.is-compact .tbb-head { padding: 6px 8px 0; }
.tb-brain.is-compact .tbb-tab { min-height: 40px; font-size: 13px !important; }
.tb-brain.is-compact .tbb-list { padding: 8px 8px 8px 0; }
.tb-brain.is-compact .tbb-cards { padding-left: 12px; }
.tbb-card.tbb-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 7px 10px 7px 7px;
  border-radius: 18px;
}
.tbb-mini .tbb-badge { width: 28px; height: 28px; font-size: 14px; }
.tbb-mini-slots { display: inline-flex; gap: 4px; flex: none; }
.tbb-mini-slot {
  --slot: var(--orange);
  position: relative;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 11px;
  border: 2.5px solid var(--ink);
  background: var(--slot);
  color: var(--ink);
}
.tbb-mini-slot.tbb-while { --slot: var(--blue); color: #fff; }
.tbb-mini-slot.tbb-if { --slot: var(--purple); color: #fff; border-radius: 50%; }
.tbb-mini-slot.tbb-do { --slot: var(--green); color: #fff; }
.tbb-mini-slot.is-locked { background: #DED8CD; color: var(--muted); }
.tbb-mini-slot.is-grey { background: repeating-linear-gradient(135deg, #D9D3C8 0 6px, #E8E2D8 6px 12px); color: var(--muted); }
.tbb-mini-slot .tbb-mark { width: 20px; height: 20px; top: -8px; right: -8px; border-width: 2px; }
.tbb-mini .tbb-sentence { flex: 1 1 140px; font-size: 13.5px; }
/* the live badge's corner: the first line of the sentence stops short of it, so no word hides */
.tbb-mini .tbb-sentence::before { content: ''; float: right; width: 30px; height: 1.2em; }
.tbb-mini .tbb-status { top: -11px; right: 8px; }
.tbb-badge-live.is-mini {
  justify-content: center;
  gap: 2px;
  width: auto;
  min-width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0 4px;
}
.tbb-badge-live.is-mini b { font: 800 13px/1 var(--title); padding-right: 2px; }
.tbb-mini .tbb-badge-live.is-listening { width: 28px; height: 28px; min-height: 0; }
.tb-brain.is-compact .tbb-list { padding-top: 14px; }

/* ---------------------------------------------------------------- narrow panels */

@container tbbrain (max-width: 520px) {
  .tbb-card { grid-template-columns: 44px minmax(0, 1fr); }
  .tbb-tab { padding-right: 10px; gap: 6px; }
  .tbb-tab:not(.is-active) .tbb-tab-name > span { display: none; }
  .tbb-tab-add { padding: 4px 10px; }
  .tbb-tab-add > span { display: none; }
  .tbb-ideas span { display: none; }
  .tbb-ideas { padding: 0 10px; }
  .tbb-strip { gap: 18px 22px; padding: 2px 8px 2px 6px; }
  .tbb-slot { padding: 12px 6px 6px; }
  .tbb-tile { font-size: 15px !important; padding-right: 10px; }
  .tbb-tile-ic { width: 32px; height: 32px; }
  .tbb-chip { padding: 0 10px 0 7px; font-size: 13.5px !important; }
  .tbb-sentence { font-size: 14px; }
  .tbb-pick { min-height: 96px; }
}
.tb-brain .tbb-list::-webkit-scrollbar { width: 10px; }
.tb-brain .tbb-list::-webkit-scrollbar-thumb { background: rgba(22, 34, 58, .25); border-radius: 10px; border: 3px solid var(--cream); }

/* ---------------------------------------------------------------- motion */

@keyframes tbb-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes tbb-thought-pop { 0% { transform: translate(-50%, 6px) scale(.7); } 70% { transform: translate(-50%, -2px) scale(1.04); } 100% { transform: translate(-50%, 0) scale(1); } }
@keyframes tbb-float-pop { 0% { transform: scale(.7); } 70% { transform: scale(1.04); } 100% { transform: none; } }
@keyframes tbb-sheet-in { 0% { transform: translateY(30px) scale(.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes tbb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tbb-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes tbb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes tbb-throb { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes tbb-roll { to { transform: rotate(360deg); } }
@keyframes tbb-listen { 0%, 100% { box-shadow: 0 4px 0 var(--ink), 0 0 0 0 rgba(255, 138, 61, 0); } 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px rgba(255, 138, 61, .28); } }
@keyframes tbb-flash { 0% { box-shadow: 0 4px 0 var(--ink), 0 0 0 0 rgba(255, 176, 107, .9); } 100% { box-shadow: 0 4px 0 var(--ink), 0 0 0 16px rgba(255, 176, 107, 0); } }
@keyframes tbb-zap { 0% { transform: scale(1); } 30% { transform: scale(1.06) rotate(-1deg); } 100% { transform: scale(1); } }
@keyframes tbb-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }
@keyframes tbb-nope { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes tbb-spark {
  0% { transform: rotate(var(--a)) translateY(0) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-brain *, .tb-brain *::before, .tb-brain *::after,
  .tbb-thought.is-float, .tbb-thought.is-float * { animation: none !important; transition: none !important; }
}
.tb-brain.is-calm *, .tb-brain.is-calm *::before, .tb-brain.is-calm *::after { animation: none !important; transition: none !important; }
