/* =========================================================
   TrainMyBrain — styles
   A sibling of NeedACheat: dark, minimal, premium, purple accent.
   Only the boot sequence keeps a terminal look (green is fine there).
   ========================================================= */

:root {
  /* design tokens — mirrored from NeedACheat's style.css */
  --bg-primary: #06060f;
  --bg-secondary: #0c0c18;
  --bg-card: #16161f;
  --bg-card-hover: #1e1e2a;
  --border: rgba(255, 255, 255, 0.055);
  --border-hover: rgba(255, 255, 255, 0.11);
  /* matte-glass surfaces + blur (dark) */
  --glass-bg: rgba(10, 10, 20, 0.82);
  --glass-border: rgba(255, 255, 255, 0.055);
  --shadow-card: 0 0 0 0.5px rgba(255,255,255,0.04) inset, 0 24px 64px rgba(0,0,0,0.55);
  --blur-sm: blur(10px);
  --blur: blur(20px);
  --blur-lg: blur(32px);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --text-primary: #f0f0ff;
  --text-secondary: #8888aa;
  --text-muted: #55556a;
  --accent: #7c6dff;
  --accent-hover: #9b8fff;
  --accent-glow: rgba(124, 109, 255, 0.2);
  --success: #4ade80;

  --font-serif: 'Instrument Serif', 'Times New Roman', serif;
  --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* the [hidden] attribute must win over display:flex on screens */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent); color: #fff; }

/* ============ ANIMATIONS ============ */

@keyframes tmb-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tmb-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes tmb-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes tmb-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes tmb-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.45; }
  30%           { transform: translateY(-6px); opacity: 1; }
}
@keyframes tmb-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%       { transform: translateY(-18px) rotate(3deg); }
  66%       { transform: translateY(8px) rotate(-2deg); }
}
@keyframes tmb-float-slow {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-28px) scale(1.04); }
}
@keyframes tmb-gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes tmb-orb-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%       { opacity: 0.85; transform: scale(1.08); }
}
@keyframes tmb-shimmer-text {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes tmb-card-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tmb-border-glow {
  0%, 100% { border-color: rgba(124, 109, 255, 0.3); box-shadow: 0 0 0 rgba(124,109,255,0); }
  50%       { border-color: rgba(124, 109, 255, 0.7); box-shadow: 0 0 24px rgba(124,109,255,0.15); }
}
@keyframes tmb-spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============ APP SHELL + SIDEBAR ============ */

.tmb-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.tmb-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: rgba(8, 8, 16, 0.94);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 0.5px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s var(--ease-out), opacity 0.2s;
  overflow: hidden;
  z-index: 50;
}
.tmb-sidebar.is-collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.tmb-sidebar__toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tmb-sidebar__toggle:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.tmb-sidebar__header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tmb-sidebar__brand {
  font: 600 14px var(--font-mono);
  color: var(--accent);
  padding-left: 75px;
}
.tmb-sidebar__new {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tmb-sidebar__new:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* Mobile-only close (✕) button in the sidebar header — hidden on desktop. */
.tmb-sidebar__close {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

.tmb-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.tmb-session-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  border: 1px solid transparent;
}
.tmb-session-item:hover { background: var(--bg-card); }
.tmb-session-item.is-active {
  background: rgba(124,109,255,0.07);
  border-color: rgba(124,109,255,0.12);
  box-shadow: inset 2px 0 0 rgba(124,109,255,0.85);
}
.tmb-session-item__title {
  font: 500 13px var(--font-sans);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.tmb-session-item.is-active .tmb-session-item__title { color: var(--accent); }
.tmb-session-item__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
}
.tmb-session-item__progress {
  font: 10px var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: 999px;
  padding: 1px 6px;
}
.tmb-session-item.is-active .tmb-session-item__progress {
  background: rgba(124,109,255,0.15);
  color: var(--accent);
}
.tmb-session-item__del {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tmb-session-item:hover .tmb-session-item__del { opacity: 1; }
.tmb-session-item__del:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
}

.tmb-sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.tmb-sidebar__back {
  font: 12px var(--font-sans);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.tmb-sidebar__back:hover { color: var(--text-primary); }

.tmb-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .tmb-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    width: 280px !important;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease-out), opacity 0.2s;
    opacity: 1 !important;
    pointer-events: none;
  }
  .tmb-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    pointer-events: all;
  }
  .tmb-sidebar.is-collapsed {
    width: 280px !important;
    opacity: 1 !important;
  }
}

/* ============ BOOT SEQUENCE (terminal — the one place green lives) ============ */

.tmb-boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease;
}
.tmb-boot.is-gone { opacity: 0; pointer-events: none; }

.tmb-boot__window {
  width: min(620px, 90vw);
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.tmb-boot__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: #1a1a1a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.tmb-boot__dot { width: 11px; height: 11px; border-radius: 50%; }
.tmb-boot__dot:nth-child(1) { background: #ff5f56; }
.tmb-boot__dot:nth-child(2) { background: #ffbd2e; }
.tmb-boot__dot:nth-child(3) { background: #27c93f; }
.tmb-boot__name {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #6b6b76;
}
.tmb-boot__lines {
  margin: 0;
  padding: 22px 20px;
  min-height: 190px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.85;
  color: #00ff41;
  white-space: pre-wrap;
}
.tmb-boot__cursor {
  display: inline-block;
  width: 8px;
  background: #00ff41;
  animation: tmb-blink 1s steps(2) infinite;
}
.tmb-boot__skip {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #6b6b76;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s;
}
.tmb-boot__skip:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* ============ SHARED BUTTONS ============ */

.tmb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out),
              border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.tmb-btn--solid {
  background: var(--accent);
  color: #fff;
  overflow: hidden;
}
.tmb-btn--solid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, 0.32) 50%, transparent 68%);
  transform: translateX(-130%);
  transition: transform 0.65s var(--ease-out);
}
.tmb-btn--solid:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.tmb-btn--solid:hover::after { transform: translateX(130%); }
.tmb-btn--ghost {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.tmb-btn--ghost:hover {
  border-color: var(--accent);
  background: rgba(124, 109, 255, 0.06);
}
.tmb-btn--lg { font-size: 15px; padding: 14px 32px; border-radius: var(--radius-lg); }
.tmb-btn--sm { font-size: 13px; padding: 8px 16px; }
.tmb-btn--block { width: 100%; }

/* ============ LANDING ============ */

.tmb-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 32px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.tmb-nav__brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  transition: text-shadow 0.3s;
}
.tmb-nav__brand:hover {
  text-shadow: 0 0 20px rgba(124,109,255,0.5);
}
.tmb-nav__prompt {
  animation: tmb-shimmer-text 3s linear infinite;
  background: linear-gradient(90deg, #7c6dff 0%, #c084fc 50%, #7c6dff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tmb-nav__links {
  display: flex;
  gap: 26px;
  margin-left: auto;
}
.tmb-nav__links a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.tmb-nav__links a:hover { color: var(--text-primary); }

.tmb-hero {
  max-width: 880px;
  margin: 0 auto;
  padding: 96px 32px 72px;
  text-align: center;
  position: relative;
  overflow: visible;
  background: transparent;
}
/* Orb 1 — large purple glow top-left */
.tmb-hero::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,109,255,0.18) 0%, transparent 70%);
  top: -120px; left: -160px;
  z-index: 0;
  animation: tmb-float-slow 9s ease-in-out infinite;
  pointer-events: none;
}
/* Orb 2 — smaller blue-pink glow right */
.tmb-hero::after {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,179,255,0.13) 0%, rgba(200,109,255,0.08) 50%, transparent 70%);
  top: 40px; right: -100px;
  z-index: 0;
  animation: tmb-float 12s ease-in-out infinite 3s;
  pointer-events: none;
}
.tmb-hero__badge,
.tmb-hero__title,
.tmb-hero__sub,
.tmb-hero__cta,
.tmb-hero__feat { position: relative; z-index: 1; }
.tmb-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  border: 1px solid rgba(124, 109, 255, 0.25);
  background: rgba(124, 109, 255, 0.08);
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 28px;
  animation: tmb-fade-up 0.6s var(--ease-out) both;
}
.tmb-blink {
  color: var(--accent);
  animation: tmb-pulse 2s ease-in-out infinite;
}
.tmb-hero__title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.8rem, 6vw, 4rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  color: var(--text-primary);
  animation: tmb-fade-up 0.6s var(--ease-out) 0.05s both;
}
.tmb-glow {
  background: linear-gradient(135deg, #7c6dff 0%, #a78bfa 30%, #60a5fa 60%, #c084fc 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: tmb-gradient-shift 5s ease infinite;
}
.tmb-hero__sub {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 52ch;
  margin: 0 auto 32px;
  animation: tmb-fade-up 0.6s var(--ease-out) 0.1s both;
}
.tmb-hero__sub b { color: var(--text-primary); font-weight: 600; }
.tmb-hero__cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 56px;
  animation: tmb-fade-up 0.6s var(--ease-out) 0.15s both;
}
.tmb-hero__feat {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
  max-width: 680px;
  margin: 0 auto;
  animation: tmb-fade-up 0.6s var(--ease-out) 0.2s both;
}
.tmb-feat {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(22,22,35,1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
  cursor: default;
}
.tmb-feat:hover {
  transform: translateY(-4px);
  border-color: rgba(124,109,255,0.4);
  box-shadow: 0 12px 32px rgba(124,109,255,0.12);
}
.tmb-feat b { color: var(--text-primary); font-weight: 600; }
.tmb-feat__k {
  color: var(--accent);
  font-weight: 700;
  opacity: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-right: 6px;
}

.tmb-section {
  max-width: 1040px;
  margin: 0 auto;
  padding: 64px 32px;
}
.tmb-section__title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0 0 32px;
}
.tmb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.tmb-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s, background 0.25s;
  animation: tmb-fade-up 0.5s var(--ease-out) both;
}
.tmb-tile:hover {
  transform: translateY(-6px);
  border-color: rgba(124,109,255,0.35);
  background: rgba(124,109,255,0.05);
  box-shadow: 0 16px 40px rgba(124,109,255,0.1);
}
.tmb-tile__icon {
  font-size: 28px;
  margin-bottom: 12px;
  display: block;
  transition: transform 0.3s var(--ease-out);
}
.tmb-tile:hover .tmb-tile__icon { transform: scale(1.15) rotate(-3deg); }
.tmb-tile h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.tmb-tile p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0;
}

/* PRICING */
.tmb-pricing {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 760px;
}
.tmb-price {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s, border-color 0.25s;
}
.tmb-price:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(124,109,255,0.12);
  border-color: rgba(124,109,255,0.4);
}
.tmb-price--pro {
  border: 1px solid rgba(124, 109, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(124, 109, 255, 0.1), 0 20px 60px rgba(124, 109, 255, 0.12);
  animation: tmb-border-glow 3s ease-in-out infinite;
}
.tmb-price__tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.tmb-price__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.tmb-price__amount {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 3.5rem;
  line-height: 1;
  color: var(--text-primary);
  margin-bottom: 22px;
}
.tmb-price__amount span {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 14px;
  color: var(--text-muted);
}
.tmb-price__list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}
.tmb-price__list li {
  position: relative;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  padding-left: 22px;
}
.tmb-price__list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.tmb-footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 32px 64px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.tmb-footer a { color: var(--accent); text-decoration: none; }
.tmb-footer a:hover { text-decoration: underline; }

/* ============ SETUP ============ */

.tmb-setup {
  flex: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  animation: tmb-border-glow 4s ease-in-out infinite;
}
.tmb-setup__box {
  width: min(560px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  animation: tmb-fade-up 0.45s var(--ease-out) both;
}
.tmb-setup__head {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.6rem;
  color: var(--text-primary);
  padding-bottom: 20px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
}
.tmb-setup__head .tmb-nav__prompt { font-family: var(--font-sans); font-style: normal; }
.tmb-setup__step { margin-bottom: 24px; }
.tmb-setup__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.tmb-subjects {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tmb-subject {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out),
              box-shadow 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.tmb-subject__icon { font-size: 28px; line-height: 1; }
.tmb-subject__label { font-size: 13px; font-weight: 500; }
.tmb-subject:hover { transform: translateY(-3px) scale(1.02); }
.tmb-subject.is-active {
  border-color: var(--accent);
  background: rgba(124, 109, 255, 0.08);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 109, 255, 0.1);
}
/* Subject-specific colors */
.tmb-subject[data-subject="Mathematics"]:hover,
.tmb-subject[data-subject="Mathematics"].is-active {
  border-color: #60a5fa; background: rgba(96,165,250,0.1); box-shadow: 0 0 24px rgba(96,165,250,0.15);
}
.tmb-subject[data-subject="Mathematics"]:hover .tmb-subject__label,
.tmb-subject[data-subject="Mathematics"].is-active .tmb-subject__label { color: #60a5fa; }
.tmb-subject[data-subject="Physics"]:hover,
.tmb-subject[data-subject="Physics"].is-active {
  border-color: #fb923c; background: rgba(251,146,60,0.1); box-shadow: 0 0 24px rgba(251,146,60,0.15);
}
.tmb-subject[data-subject="Physics"]:hover .tmb-subject__label,
.tmb-subject[data-subject="Physics"].is-active .tmb-subject__label { color: #fb923c; }
.tmb-subject[data-subject="Chemistry"]:hover,
.tmb-subject[data-subject="Chemistry"].is-active {
  border-color: #4ade80; background: rgba(74,222,128,0.1); box-shadow: 0 0 24px rgba(74,222,128,0.15);
}
.tmb-subject[data-subject="Chemistry"]:hover .tmb-subject__label,
.tmb-subject[data-subject="Chemistry"].is-active .tmb-subject__label { color: #4ade80; }
.tmb-subject[data-subject="Biology"]:hover,
.tmb-subject[data-subject="Biology"].is-active {
  border-color: #f472b6; background: rgba(244,114,182,0.1); box-shadow: 0 0 24px rgba(244,114,182,0.15);
}
.tmb-subject[data-subject="Biology"]:hover .tmb-subject__label,
.tmb-subject[data-subject="Biology"].is-active .tmb-subject__label { color: #f472b6; }
.tmb-subject[data-subject="History"]:hover,
.tmb-subject[data-subject="History"].is-active {
  border-color: #fbbf24; background: rgba(251,191,36,0.1); box-shadow: 0 0 24px rgba(251,191,36,0.15);
}
.tmb-subject[data-subject="History"]:hover .tmb-subject__label,
.tmb-subject[data-subject="History"].is-active .tmb-subject__label { color: #fbbf24; }
.tmb-subject[data-subject="Other"]:hover,
.tmb-subject[data-subject="Other"].is-active {
  border-color: #c084fc; background: rgba(192,132,252,0.1); box-shadow: 0 0 24px rgba(192,132,252,0.15);
}
.tmb-subject[data-subject="Other"]:hover .tmb-subject__label,
.tmb-subject[data-subject="Other"].is-active .tmb-subject__label { color: #c084fc; }
.tmb-setup__input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tmb-setup__input::placeholder { color: var(--text-muted); }
.tmb-setup__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 109, 255, 0.12);
}
.tmb-levels { display: flex; gap: 10px; }
.tmb-level {
  flex: 1;
  padding: 11px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease-out);
}
.tmb-level:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.tmb-level.is-active {
  border-color: var(--accent);
  background: rgba(124, 109, 255, 0.08);
  color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 109, 255, 0.1);
}
.tmb-setup__err {
  margin-top: 16px;
  font-size: 13px;
  color: #ff8f8f;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.28);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
}
.tmb-setup__back {
  margin-top: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 0;
  transition: color 0.15s;
}
.tmb-setup__back:hover { color: var(--text-primary); }

/* ============ SESSION ============ */

.tmb-session {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100vh;
}
.tmb-shead {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  flex-shrink: 0;
  padding: 0 18px;
  background: rgba(6, 6, 15, 0.92);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border-bottom: 0.5px solid var(--glass-border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
}
.tmb-shead__brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.tmb-shead__topic {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 38vw;
}
.tmb-shead__progress {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}
.tmb-shead__bar {
  width: 90px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.tmb-shead__bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s var(--ease-out);
}
.tmb-shead__progress + .tmb-btn { margin-left: 10px; }
.tmb-shead__progress[hidden] + .tmb-btn { margin-left: auto; }

.tmb-split {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---- CHAT ---- */
.tmb-chat {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-primary);
  border-right: 0.5px solid var(--glass-border);
  position: relative;
}
/* subtle purple glow at the top of the chat */
.tmb-chat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 80px;
  background: radial-gradient(ellipse at 50% -10%, rgba(124,109,255,0.07), transparent);
  pointer-events: none;
  z-index: 0;
}
.tmb-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tmb-msg {
  max-width: 88%;
  font-size: 14px;
  line-height: 1.65;
  animation: tmb-fade-up 0.3s var(--ease-out);
}
.tmb-msg--ai {
  align-self: flex-start;
  background: rgba(16, 16, 28, 0.88);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 0.5px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px 14px 14px 3px;
  padding: 12px 16px;
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
.tmb-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(124,109,255,0.22), rgba(124,109,255,0.1));
  border: 0.5px solid rgba(124, 109, 255, 0.18);
  border-radius: 14px 14px 3px 14px;
  padding: 12px 16px;
  color: var(--text-primary);
}
.tmb-msg--err {
  align-self: stretch;
  max-width: 100%;
  background: rgba(255, 107, 107, 0.09);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff9b9b;
  border-radius: var(--radius);
  padding: 11px 14px;
}
.tmb-msg__step {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.tmb-msg p { margin: 0 0 8px; }
.tmb-msg p:last-child { margin-bottom: 0; }
.tmb-msg ul, .tmb-msg ol { margin: 6px 0; padding-left: 20px; }
.tmb-msg li { margin: 3px 0; }
.tmb-msg strong { color: var(--text-primary); font-weight: 600; }
.tmb-msg code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(124, 109, 255, 0.12);
  color: var(--accent-hover);
  padding: 1px 5px;
  border-radius: 5px;
}

/* typing indicator */
.tmb-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
}
.tmb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: tmb-bounce 1.3s infinite ease-in-out;
}
.tmb-typing span:nth-child(2) { animation-delay: 0.18s; }
.tmb-typing span:nth-child(3) { animation-delay: 0.36s; }

/* suggestion pills */
.tmb-chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px;
}
.tmb-chat__suggest:empty { display: none; }
.tmb-chat__suggest + .tmb-chat__input { margin-top: 10px; }
.tmb-suggest {
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  color: var(--accent);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  letter-spacing: -0.01em;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.tmb-suggest:hover {
  background: rgba(124, 109, 255, 0.1);
  border-color: rgba(124, 109, 255, 0.2);
  transform: translateY(-1px);
}
.tmb-suggest:disabled { opacity: 0.4; pointer-events: none; }

/* chat input */
.tmb-chat__input {
  display: flex;
  flex-direction: column;
  padding: 8px 16px 14px;
  border-top: 1px solid var(--border);
}
.tmb-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
}
.tmb-chat__chips:empty { display: none; }
.tmb-chat__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.tmb-chat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(124, 109, 255, 0.1);
  border: 1px solid rgba(124, 109, 255, 0.3);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-sans);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tmb-chat-chip > span { overflow: hidden; text-overflow: ellipsis; }
.tmb-chat-chip__remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.tmb-chat-chip__remove:hover { color: var(--accent); }
.tmb-attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.tmb-attach-btn:hover { color: var(--accent); background: rgba(124, 109, 255, 0.08); }
.tmb-img-seen {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
#tmbInput {
  flex: 1;
  resize: none;
  max-height: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.15s;
}
#tmbInput::placeholder { color: var(--text-muted); }
#tmbInput:focus { border-color: rgba(124, 109, 255, 0.4); }
.tmb-chat__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s, color 0.15s;
}
.tmb-chat__send:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.tmb-chat__send:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* completion banner */
.tmb-done {
  align-self: stretch;
  max-width: 100%;
  text-align: center;
  background: rgba(124, 109, 255, 0.08);
  border: 1px solid rgba(124, 109, 255, 0.3);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--accent-hover);
  font-weight: 600;
  animation: tmb-fade-up 0.3s var(--ease-out);
}

/* ============ BOARD — infinite pan/zoom canvas ============ */

.tmb-board {
  flex: 1;
  min-width: 0;
  display: flex;
  background-color: var(--bg-primary);
  background-image: radial-gradient(ellipse at 50% 30%, rgba(124,109,255,0.05) 0%, transparent 60%);
}
.tmb-board__viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;          /* pan / pinch handled in JS */
  cursor: grab;
}
.tmb-board__viewport.is-panning { cursor: grabbing; }

.tmb-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 6000px;
  transform-origin: 0 0;
}

/* paper styles */
.tmb-canvas--graph {
  background-color: #f7f6f1;
  background-image:
    repeating-linear-gradient(rgba(124, 109, 255, 0.1) 0 1px, transparent 1px 100%),
    repeating-linear-gradient(90deg, rgba(124, 109, 255, 0.1) 0 1px, transparent 1px 100%);
  background-size: 28px 28px;
}
.tmb-canvas--lined {
  background-color: #f7f6f1;
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 27px, rgba(124, 109, 255, 0.15) 27px 28px);
}
.tmb-canvas--light {
  background-color: #fefefe;
}
.tmb-canvas--dark {
  background-color: #1a1a2e;
  background-image:
    repeating-linear-gradient(rgba(124, 109, 255, 0.07) 0 1px, transparent 1px 100%),
    repeating-linear-gradient(90deg, rgba(124, 109, 255, 0.07) 0 1px, transparent 1px 100%);
  background-size: 28px 28px;
}

/* empty state — pinned to viewport centre */
.tmb-board__empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}
.tmb-board__empty-icon { font-size: 2.6rem; margin-bottom: 12px; opacity: 0.5; }
.tmb-board__empty p { font-size: 14px; line-height: 1.6; margin: 0; }

/* toolbar — bottom-right */
.tmb-board__toolbar {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.tmb-tb-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.tmb-tb-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.tmb-tb-btn.is-active {
  background: rgba(124, 109, 255, 0.15);
  color: var(--accent);
}
.tmb-tb-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
}

/* ---- board card ---- */
.tmb-card {
  position: absolute;
  width: 360px;
  background: #ffffff;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: tmb-fade-up 0.34s cubic-bezier(0.34, 1.2, 0.64, 1);
  transition: border-left-color 0.3s, transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
/* hover levitation (not while dragging) */
.tmb-card:hover:not(.is-dragging) {
  transform: translateY(-3px);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.tmb-card__actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
.tmb-card:hover .tmb-card__actions { opacity: 1; }
.tmb-card__action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(124, 109, 255, 0.3);
  background: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.tmb-card__action-btn:hover {
  background: rgba(124, 109, 255, 0.1);
  border-color: var(--accent);
}
.tmb-chat--drop-active {
  background: rgba(124, 109, 255, 0.04);
  outline: 2px dashed rgba(124, 109, 255, 0.4);
  outline-offset: -4px;
}
.tmb-card.is-dragging { box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5); }
.tmb-card__badge {
  position: absolute;
  top: -10px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
}
.tmb-card__head {
  padding: 22px 22px 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.tmb-card__head:active { cursor: grabbing; }
.tmb-card__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tmb-card__visuals {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 22px 22px;
}

/* ---- visual blocks (light card) ---- */
.tmb-vis {
  background: #f3f3f8;
  border: 1px solid rgba(20, 24, 40, 0.07);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
}
.tmb-vis--formula {
  text-align: center;
  font-size: 1.15rem;
  color: #1a1a2e;
}
/* ── given_data_box ── textbook-style "Дано / Найти" block */
.tmb-vis--given-box {
  background: linear-gradient(180deg, #fafbff 0%, #f3f4ff 100%);
  border: 1px solid rgba(124, 109, 255, 0.25);
  border-left: 4px solid #7c6dff;
  border-radius: 10px;
  padding: 14px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: #1a1a2e;
  box-shadow: 0 1px 3px rgba(124, 109, 255, 0.06);
}
.tmb-given__head {
  font-weight: 700;
  color: #7c6dff;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.tmb-given__list {
  list-style: none;
  padding: 0;
  margin: 0 0 6px 0;
}
.tmb-given__item {
  padding: 3px 0 3px 16px;
  position: relative;
  line-height: 1.55;
}
.tmb-given__item::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.75em;
  width: 5px;
  height: 5px;
  background: #7c6dff;
  border-radius: 50%;
}
.tmb-given__item--find {
  color: #c0392b;
  font-weight: 600;
}
.tmb-given__item--find::before {
  background: #e74c3c;
}
.tmb-given__latex { display: inline-block; }
.tmb-given__sep {
  border-top: 1px dashed rgba(124, 109, 255, 0.35);
  margin: 8px 0;
}
/* ── physics_scene ── semantic physics diagrams in SVG */
.tmb-vis--physics {
  padding: 4px;
  background: #ffffff;
  border-radius: 8px;
}
.tmb-vis--physics svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
.tmb-vis--graph { position: relative; padding: 6px; background: #ffffff; }
.tmb-graph-expand-btn {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(124,109,255,0.3);
  border-radius: 6px;
  width: 26px; height: 26px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #7c6dff;
  transition: background 0.15s;
}
.tmb-graph-expand-btn:hover { background: rgba(124,109,255,0.12); }
.tmb-vis--diagram { text-align: center; background: #ffffff; }
.tmb-vis--diagram svg { max-width: 100%; height: auto; }
/* ── new visual templates ── */
.tmb-vis--table-wrap { background: #ffffff; padding: 10px; overflow-x: auto; }
.tmb-tbl { border-collapse: collapse; width: 100%; font-size: 13px; font-family: var(--font-sans); }
.tmb-tbl th { background: rgba(124,109,255,0.12); color: #1a1a2e; font-weight: 600; padding: 7px 10px; text-align: left; border-bottom: 2px solid rgba(124,109,255,0.25); }
.tmb-tbl td { padding: 6px 10px; color: #374151; border-bottom: 1px solid rgba(0,0,0,0.06); }
.tmb-tbl__row--hi td { background: rgba(124,109,255,0.08); color: #1a1a2e; font-weight: 500; }
.tmb-tbl__col--hi { background: rgba(124,109,255,0.08); color: #1a1a2e; font-weight: 500; }
.tmb-pf-step { background: #fafaff; }
.tmb-vis__plot { width: 100%; height: 300px; }
.tmb-vis--molecule { background: #ffffff; text-align: center; padding: 16px; }
.tmb-vis__mol { display: flex; justify-content: center; }
.tmb-mol-svg { max-width: 300px; max-height: 250px; width: 100%; height: auto; }
.tmb-vis__mol-name { margin-top: 10px; font-size: 13px; color: var(--text-muted); font-family: var(--font-sans); }
.tmb-mol-fallback { text-align: center; font-family: var(--font-mono); color: #33384a; padding: 12px; }
.tmb-mol-formula { font-size: 1.4rem; font-weight: 600; color: #1a1a2e; margin-bottom: 8px; }
.tmb-mol-fallback code { display: inline-block; background: rgba(124,109,255,0.12); color: #5a4bd4; padding: 4px 8px; border-radius: 5px; font-size: 13px; }
.tmb-mol-note { margin-top: 8px; font-size: 12px; color: #6b7280; font-family: var(--font-sans); }

/* steps_formula */
.tmb-steps { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tmb-step-row {
  width: 100%;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.tmb-step-row.is-shown { opacity: 1; transform: translateY(0); }
.tmb-step-row__formula { font-size: 1.1rem; color: #1a1a2e; }
.tmb-step-row__note { font-size: 12px; color: #6b6b80; margin-top: 3px; }
.tmb-step-arrow {
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
}
.tmb-step-arrow.is-shown { opacity: 1; }

/* ---- board cards on the dark paper ---- */
.tmb-canvas--dark .tmb-card { background: #1e1e2e; }
.tmb-canvas--dark .tmb-card__title { color: var(--text-secondary); }
.tmb-canvas--dark .tmb-vis {
  background: var(--bg-card);
  border-color: var(--border);
}
.tmb-canvas--dark .tmb-vis--formula,
.tmb-canvas--dark .tmb-step-row__formula { color: var(--text-primary); }
.tmb-canvas--dark .tmb-step-row__note { color: var(--text-muted); }
.tmb-canvas--dark .tmb-vis__mol-name { color: var(--accent-hover); }
.tmb-canvas--dark .tmb-mol-fallback { color: var(--text-secondary); }

/* ============ SETUP — progress dots ============ */

.tmb-setup__dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}
.tmb-sdot {
  width: 28px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.3s var(--ease-out), transform 0.2s;
}
.tmb-sdot.is-cur  { background: rgba(124, 109, 255, 0.4); }
.tmb-sdot.is-done { background: var(--accent); transform: scaleX(1.08); }

/* ============ SETUP — step reveal animation ============ */

@keyframes tmb-step-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tmb-step-reveal { animation: tmb-step-in 0.3s var(--ease-out) both; }

/* ============ SETUP — option cards (knowledge / style) ============ */

.tmb-opts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tmb-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 14px 13px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
}
.tmb-opt:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.tmb-opt.is-active {
  border-color: var(--accent);
  background: rgba(124, 109, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(124, 109, 255, 0.1);
}
.tmb-opt__icon { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.tmb-opt__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.tmb-opt.is-active .tmb-opt__title { color: var(--accent); }
.tmb-opt__desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0;
}
.tmb-opt-optional {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.55;
}

/* ============ SETUP — context textarea + pills ============ */

.tmb-setup__textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
  display: block;
}
.tmb-ctx-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.tmb-pill {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 5px 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tmb-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124, 109, 255, 0.06);
}

/* ============ PLANNING screen ============ */

.tmb-planning {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tmb-planning__inner {
  text-align: center;
  animation: tmb-fade-up 0.4s var(--ease-out) both;
}
.tmb-planning__brain {
  font-size: 58px;
  display: block;
  margin-bottom: 22px;
  animation: tmb-pulse 1.4s ease-in-out infinite;
}
.tmb-planning__title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.tmb-planning__sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* ============ SESSION header — style badge + end confirm ============ */

.tmb-shead__style {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(124,109,255,0.12);
  border: 0.5px solid rgba(124,109,255,0.24);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tmb-shead__style--friend {
  background: rgba(124, 109, 255, 0.15);
  color: var(--accent);
  border-color: rgba(124, 109, 255, 0.3);
}
.tmb-shead__style--strict {
  background: rgba(100, 100, 150, 0.15);
  color: var(--text-secondary);
  border-color: rgba(150, 150, 200, 0.2);
}
.tmb-end-confirm {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ============ CHAT — AI sender name ============ */

.tmb-msg__name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 3px;
}

/* ============ CHAT — lesson plan card ============ */

.tmb-lesson-plan {
  background: var(--bg-card);
  border: 1px solid rgba(124, 109, 255, 0.25);
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 13px;
  animation: tmb-fade-up 0.3s var(--ease-out);
}
.tmb-lesson-plan__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  gap: 8px;
}
.tmb-lesson-plan__toggle {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.tmb-lesson-plan__body { margin-top: 10px; }
.tmb-lesson-plan__body ol {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.75;
  font-size: 12px;
}
.tmb-lesson-plan.is-collapsed .tmb-lesson-plan__body { display: none; }

/* ============ SESSION COMPLETE overlay ============ */

.tmb-session { position: relative; }

/* ============ LESSON STEPS — live step-by-step lesson ============ */

.tmb-vis--lesson {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.tmb-ls-step {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  padding: 10px 0 4px;
  border-top: 1px solid rgba(124, 109, 255, 0.12);
}
.tmb-ls-step:first-child { border-top: none; }
.tmb-ls-step.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tmb-ls-visuals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tmb-ls-explanation {
  font: 13px/1.6 Inter, sans-serif;
  color: #1a1a2e;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
}
.tmb-ls-explanation.is-visible { opacity: 1; }
.tmb-canvas--dark .tmb-ls-explanation { color: var(--text-primary); }

.tmb-ls-continue-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 10px 0 4px;
  padding: 5px 14px;
  background: transparent;
  border: 1.5px solid rgba(124, 109, 255, 0.5);
  border-radius: 20px;
  color: #7c6dff;
  font: 600 12px Inter, sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tmb-ls-continue-btn:hover {
  background: rgba(124, 109, 255, 0.08);
  border-color: #7c6dff;
}

.tmb-ls-done {
  font: 500 12px Inter, sans-serif;
  color: #4ade80;
  margin: 8px 0 4px;
}

/* ============ CARD MINI-CHAT ============ */

.tmb-card-chat {
  border-top: 1px solid rgba(124, 109, 255, 0.15);
  margin-top: 10px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tmb-card-chat__log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.tmb-card-chat__msg {
  font: 12px/1.5 Inter, sans-serif;
  padding: 4px 8px;
  border-radius: 8px;
  max-width: 100%;
  word-wrap: break-word;
}
.tmb-card-chat__msg--user {
  background: rgba(124, 109, 255, 0.12);
  color: #1a1a2e;
  align-self: flex-end;
  text-align: right;
}
.tmb-canvas--dark .tmb-card-chat__msg--user { color: var(--text-primary); }
.tmb-card-chat__msg--ai {
  background: rgba(0, 0, 0, 0.04);
  color: #4b4b5f;
  align-self: flex-start;
}
.tmb-canvas--dark .tmb-card-chat__msg--ai {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}
.tmb-card-chat__msg--typing {
  opacity: 0.6;
  font-style: italic;
}

.tmb-card-chat__input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.tmb-card-chat__input {
  flex: 1;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(124, 109, 255, 0.25);
  border-radius: 10px;
  color: #1a1a2e;
  font: 12px/1.4 Inter, sans-serif;
  padding: 6px 10px;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  max-height: 80px;
}
.tmb-canvas--dark .tmb-card-chat__input {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.tmb-card-chat__input:focus { border-color: rgba(124, 109, 255, 0.6); }
.tmb-card-chat__input:disabled { opacity: 0.4; }

.tmb-card-chat__send {
  width: 30px;
  height: 30px;
  background: #7c6dff;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.tmb-card-chat__send:disabled { opacity: 0.35; cursor: default; }

/* Ensure molecule visual always fills container width */
.tmb-vis--molecule {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.tmb-ls-visuals .tmb-vis {
  width: 100%;
  min-width: 0;
}

/* ============ QUIZ ============ */

.tmb-vis--quiz {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
}
.tmb-canvas--dark .tmb-vis--quiz { background: var(--bg-card); }

.tmb-quiz-header {
  font: 700 11px/1 Inter, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7c6dff;
  opacity: 0.8;
}

.tmb-quiz-question {
  font: 500 14px/1.6 Inter, sans-serif;
  color: #1a1a2e;
}
.tmb-canvas--dark .tmb-quiz-question { color: var(--text-primary); }
.tmb-quiz-question p { margin: 0; }

.tmb-quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tmb-quiz-option {
  padding: 8px 12px;
  background: rgba(124,109,255,0.04);
  border: 1.5px solid rgba(124,109,255,0.25);
  border-radius: 10px;
  color: #1a1a2e;
  font: 13px/1.4 Inter, sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.tmb-canvas--dark .tmb-quiz-option {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}
.tmb-quiz-option:hover { border-color: #7c6dff; background: rgba(124,109,255,0.08); }
.tmb-quiz-option.is-selected { border-color: #7c6dff; background: rgba(124,109,255,0.12); }
.tmb-quiz-option.is-correct  { border-color: #4ade80; background: rgba(74,222,128,0.12); }
.tmb-quiz-option.is-wrong    { border-color: #f87171; background: rgba(248,113,113,0.12); }
.tmb-quiz-option:disabled { cursor: default; }

.tmb-quiz-input {
  width: 100%;
  background: rgba(124,109,255,0.04);
  border: 1px solid rgba(124,109,255,0.3);
  border-radius: 10px;
  color: #1a1a2e;
  font: 13px/1.4 Inter, sans-serif;
  padding: 8px 12px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.tmb-canvas--dark .tmb-quiz-input {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}
.tmb-quiz-input:focus { border-color: #7c6dff; }
.tmb-quiz-input:disabled { opacity: 0.5; }

.tmb-quiz-fill-template {
  font: 14px/1.8 'JetBrains Mono', monospace;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.tmb-canvas--dark .tmb-quiz-fill-template { color: var(--text-primary); }
.tmb-quiz-fill-input {
  min-width: 80px;
  background: rgba(124,109,255,0.1);
  border: 1px dashed #7c6dff;
  border-radius: 6px;
  color: #1a1a2e;
  font: 13px 'JetBrains Mono', monospace;
  padding: 2px 8px;
  outline: none;
}
.tmb-canvas--dark .tmb-quiz-fill-input { color: var(--text-primary); }
.tmb-quiz-fill-input:disabled { opacity: 0.5; }

.tmb-quiz-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tmb-quiz-hint-btn {
  background: none;
  border: 1px solid rgba(124,109,255,0.35);
  border-radius: 20px;
  color: var(--text-muted);
  font: 12px Inter, sans-serif;
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.tmb-quiz-hint-btn:hover { border-color: #7c6dff; color: #7c6dff; }
.tmb-quiz-hint-btn:disabled { opacity: 0.5; cursor: default; }

.tmb-quiz-check-btn {
  background: #7c6dff;
  border: none;
  border-radius: 20px;
  color: #fff;
  font: 600 12px Inter, sans-serif;
  padding: 6px 16px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.tmb-quiz-check-btn:hover:not(:disabled) { background: var(--accent-hover); }
.tmb-quiz-check-btn:disabled { opacity: 0.35; cursor: default; }

.tmb-quiz-hint-text {
  font: italic 12px/1.5 Inter, sans-serif;
  color: var(--text-muted);
  opacity: 0.85;
  padding: 4px 0;
}

.tmb-quiz-feedback {
  border-top: 1px solid rgba(124,109,255,0.15);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tmb-quiz-result {
  font: 700 13px Inter, sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tmb-quiz-result--correct { color: #4ade80; }
.tmb-quiz-result--wrong   { color: #f87171; }

.tmb-quiz-ai-reply {
  font: 12px/1.6 Inter, sans-serif;
  color: #4b4b5f;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  padding: 6px 10px;
}
.tmb-canvas--dark .tmb-quiz-ai-reply {
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
}

/* ============ SCROLL REVEAL ============ */
.tmb-reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.tmb-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}
.tmb-reveal:nth-child(2) { transition-delay: 0.1s; }
.tmb-reveal:nth-child(3) { transition-delay: 0.2s; }
.tmb-reveal:nth-child(4) { transition-delay: 0.3s; }
.tmb-reveal:nth-child(5) { transition-delay: 0.4s; }
.tmb-reveal:nth-child(6) { transition-delay: 0.5s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .tmb-grid { grid-template-columns: 1fr; }
  .tmb-pricing { grid-template-columns: 1fr; }
  .tmb-hero__feat { grid-template-columns: 1fr; }
  .tmb-nav__links { display: none; }
  .tmb-subjects { grid-template-columns: repeat(2, 1fr); }
  .tmb-opts { grid-template-columns: 1fr; }
  .tmb-setup__box { padding: 28px 22px; }

  .tmb-split { flex-direction: column-reverse; }
  .tmb-chat {
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border);
    height: 48vh;
  }
  .tmb-board { height: 52vh; }
  .tmb-shead__topic { max-width: 28vw; }
  .tmb-card { width: 300px; }
}

/* ============ shared upgrade modal buttons (showUpgradeModal) ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ============ scrollbars ============ */
.tmb-chat__log::-webkit-scrollbar { width: 8px; }
.tmb-chat__log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}
.tmb-chat__log::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); }

/* ============ MOBILE-LITE MODE (≤768px) ============
   Chat-only layout: the infinite board/canvas is hidden and cards flow below
   the chat as a vertical scrollable list. Declared LAST so these rules win over
   the generic @media (max-width: 860px) block above at ≤768px widths.
   Desktop (>768px) is completely unaffected. */
@media (max-width: 768px) {
  /* ---- no horizontal scroll on mobile (BUG 4) ---- */
  html, body { overflow-x: hidden; max-width: 100vw; }
  .tmb-landing { overflow-x: hidden; }
  /* The hero's decorative glow orbs (::before left:-160px, ::after right:-100px)
     bleed past the viewport — clip them to the hero so they can't add ~100px of
     horizontal overflow. */
  .tmb-hero { overflow: hidden; }
  .tmb-hero__cta, .tmb-hero__feat { flex-wrap: wrap; max-width: 100%; }
  .tmb-hero, .tmb-section, .tmb-grid, .tmb-pricing, .tmb-subjects { max-width: 100%; }

  /* ---- sessions drawer: dimmer overlay + close button (BUG 2) ---- */
  .tmb-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;   /* below the sidebar drawer (z 200), above content */
  }
  .tmb-sidebar-overlay.active { display: block; }
  .tmb-sidebar__close { display: flex; }

  /* ---- desktop-only banner ---- */
  .tmb-mobile-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 44px;
    z-index: 9000;
    background: #7c6dff;
    color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 42px;        /* room for the ✕ on the right */
    transition: opacity 0.3s ease;
  }
  .tmb-mobile-banner__text {
    text-align: center;
    font-size: 12px;
    line-height: 1.2;
    min-width: 0;                       /* allow the flex item to shrink + wrap */
    max-width: calc(100vw - 84px);      /* force wrap within the padded banner */
    white-space: normal;
    overflow-wrap: break-word;
    max-height: 36px;
    overflow: hidden;
  }
  .tmb-mobile-banner__close {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 9px;
  }
  /* Push the active screen below the fixed banner (border-box keeps 100vh). */
  body.tmb-banner-on .tmb-landing,
  body.tmb-banner-on .tmb-setup,
  body.tmb-banner-on .tmb-planning,
  body.tmb-banner-on .tmb-session { padding-top: 44px; }
  /* Keep the sidebar toggle + drawer (incl. its ✕ header) below the banner. */
  body.tmb-banner-on .tmb-sidebar__toggle { top: 52px; }
  body.tmb-banner-on .tmb-sidebar { top: 44px; }

  /* ---- hide the board / canvas entirely ---- */
  .tmb-board,
  .tmb-board__viewport,
  #tmbViewport,
  .tmb-board__toolbar,
  #tmbBoardToolbar { display: none !important; }

  /* ---- single full-width column ---- */
  .tmb-split { flex-direction: column; }

  .tmb-chat {
    width: 100%;
    height: auto;
    flex: 1;
    min-height: 0;
    border-right: none;
    border-top: none;
  }
  /* The chat log is the single scroll area: messages AND inline cards together,
     filling all height between the header and the input bar. */
  .tmb-chat__log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- cards live inline inside the chat log (flow layout) ---- */
  .tmb-chat__log .tmb-card {
    position: static;
    width: calc(100% - 24px);
    margin: 4px 12px 8px 12px;
    cursor: default;
    box-sizing: border-box;
    left: auto; top: auto;
    /* box-shadow inherited from .tmb-card keeps visual separation */
  }
  .tmb-chat__log .tmb-card__head { cursor: default; }
  /* No hover on touch — keep pin/quiz actions always visible. */
  .tmb-chat__log .tmb-card__actions { opacity: 1; }

  /* ---- input stays at the bottom, full width ---- */
  .tmb-chat__input { flex-shrink: 0; width: 100%; }

  /* ============ compact UI (~1.4× tighter feel) ============
     Sizes / padding / line-height only — no colours, shadows, borders, logic. */
  .tmb-msg {
    font-size: 13.5px;
    padding: 10px 12px;
    border-radius: 12px;
  }
  .tmb-msg__name { font-size: 11px; }      /* AI label */

  .tmb-card__head {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 32px;
  }
  .tmb-card__visuals { padding: 8px 10px; } /* card body */

  .tmb-ls-explanation {                      /* lesson_steps explanation text */
    font-size: 13px;
    line-height: 1.45;
  }

  .tmb-suggest {                             /* suggestion buttons */
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 16px;
  }

  #tmbInput {                                /* chat input */
    font-size: 14px;
    padding: 10px 12px;
  }

  .tmb-shead {                               /* session header */
    padding: 6px 10px;
    gap: 6px;
  }
  .tmb-shead .tmb-lang-btn,                  /* mode / lang buttons in header */
  .tmb-shead .tmb-btn,
  .tmb-shead__style {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* ============ CHAT MODE toggle (session header) ============ */
.tmb-chatmode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tmb-chatmode-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tmb-chatmode-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
/* Mobile: icon only */
@media (max-width: 768px) {
  .tmb-chatmode-btn span.label { display: none; }
}

/* ============ toast ============ */
.tmb-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 10000;
  max-width: 86vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: 500 13px/1.3 Inter, system-ui, sans-serif;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.tmb-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
