/* talk2know Design System — Direction C: premium community + education hybrid */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:wght@500;600&display=swap");

:root,
html[data-theme="dark"] {
  /* Semantic tokens — DARK (first-class) */
  --surface-base: #090b10;
  --surface-raised: #0e1219;
  --surface-overlay: #1a2130;
  --surface-selected: rgba(255, 255, 255, 0.075);
  --text-primary: #f4f6fb;
  --text-secondary: #b8c0d0;
  --text-muted: #7a8499;
  --border-subtle: rgba(255, 255, 255, 0.055);
  --border-strong: rgba(255, 255, 255, 0.1);
  --accent: #3d8bfd;
  --focus: #5aa2ff;
  --success: #2dd4a8;
  --warning: #faa81a;
  --danger: #f04747;
  --ai: #8b7cf7;
  --learning: #2dd4a8;
  --premium: #e8b923;
  --trust: #9ec1ff;

  /* Surfaces (map legacy vars → semantic) */
  --tb-rail: var(--surface-base);
  --tb-sidebar: var(--surface-raised);
  --tb-main: #131821;
  --tb-panel: var(--surface-overlay);
  --tb-elevated: #222b3c;
  --tb-input: #1c2433;
  --tb-hover: rgba(255, 255, 255, 0.045);
  --tb-active: var(--surface-selected);
  --tb-border: var(--border-subtle);
  --tb-border-strong: var(--border-strong);

  /* Brand */
  --tb-primary: var(--accent);
  --tb-primary-soft: rgba(61, 139, 253, 0.14);
  --tb-learn: var(--learning);
  --tb-learn-soft: rgba(45, 212, 168, 0.12);
  --tb-ai: var(--ai);
  --tb-ai-deep: #6a5ae0;
  --tb-ai-soft: rgba(139, 124, 247, 0.16);
  --tb-premium: var(--premium);
  --tb-danger: var(--danger);
  --tb-warn: var(--warning);
  --tb-success: var(--success);

  /* Semantic aliases */
  --tibyan-accent: var(--accent);
  --tibyan-ai: var(--ai);
  --tibyan-learning: var(--learning);
  --tibyan-premium: var(--premium);
  --surface-rail: var(--tb-rail);
  --surface-sidebar: var(--tb-sidebar);
  --surface-main: var(--tb-main);
  --surface-elevated: var(--tb-elevated);
  --interactive-hover: var(--tb-hover);
  --interactive-active: var(--tb-active);

  /* Text */
  --tb-text: var(--text-primary);
  --tb-text-secondary: var(--text-secondary);
  --tb-text-muted: var(--text-muted);
  --tb-font: "IBM Plex Sans", "Noto Sans", "Noto Sans Arabic", system-ui, sans-serif;
  --tb-serif: "IBM Plex Serif", Georgia, serif;

  /* Scale */
  --tb-space-1: 4px;
  --tb-space-2: 8px;
  --tb-space-3: 12px;
  --tb-space-4: 16px;
  --tb-space-5: 20px;
  --tb-space-6: 24px;
  --tb-radius-sm: 6px;
  --tb-radius: 8px;
  --tb-radius-lg: 12px;
  --tb-rail-w: 68px;
  --tb-sidebar-w: 260px;
  --tb-context-w: 260px;
  --tb-header-h: 48px;
  --tb-control-h: 36px;
  --tb-avatar-sm: 28px;
  --tb-avatar-md: 36px;
  --tb-avatar-lg: 44px;
  --tb-icon: 18px;
  --tb-ease: 0.14s ease;
  --tb-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  --surface-base: #e8ecf3;
  --surface-raised: #f4f6fa;
  --surface-overlay: #ffffff;
  --surface-selected: rgba(61, 139, 253, 0.12);
  --text-primary: #12151c;
  --text-secondary: #3d4658;
  --text-muted: #6b7385;
  --border-subtle: rgba(18, 21, 28, 0.08);
  --border-strong: rgba(18, 21, 28, 0.16);
  --accent: #2563eb;
  --focus: #1d4ed8;
  --success: #0f9f6e;
  --warning: #c27803;
  --danger: #dc2626;
  --ai: #6d5ce7;
  --learning: #0f9f6e;
  --premium: #b45309;
  --trust: #1d4ed8;

  --tb-rail: var(--surface-base);
  --tb-sidebar: var(--surface-raised);
  --tb-main: #ffffff;
  --tb-panel: #f8fafc;
  --tb-elevated: #ffffff;
  --tb-input: #ffffff;
  --tb-hover: rgba(18, 21, 28, 0.04);
  --tb-active: var(--surface-selected);
  --tb-border: var(--border-subtle);
  --tb-border-strong: var(--border-strong);
  --tb-primary: var(--accent);
  --tb-primary-soft: rgba(37, 99, 235, 0.12);
  --tb-learn: var(--learning);
  --tb-learn-soft: rgba(15, 159, 110, 0.1);
  --tb-ai: var(--ai);
  --tb-ai-deep: #5b4bd6;
  --tb-ai-soft: rgba(109, 92, 231, 0.12);
  --tb-premium: var(--premium);
  --tb-danger: var(--danger);
  --tb-warn: var(--warning);
  --tb-success: var(--success);
  --tb-text: var(--text-primary);
  --tb-text-secondary: var(--text-secondary);
  --tb-text-muted: var(--text-muted);
  --tb-shadow: 0 8px 28px rgba(18, 21, 28, 0.08);
}

html[data-theme="light"] .tb-staging-banner {
  background: #5b21b6;
}

/* Logical edges for RTL */
html[dir="rtl"] .tb-msg-actions { inset-inline-end: 8px; inset-inline-start: auto; }
html[dir="rtl"] .tb-drawer { inset-inline-end: auto; inset-inline-start: 0; }
html[dir="rtl"] .tb-breadcrumb { flex-direction: row-reverse; }
html[dir="rtl"] .tb-app {
  direction: rtl;
}
html[dir="rtl"] .tb-rail {
  border-inline-end: 1px solid var(--tb-border);
  border-inline-start: none;
}
html[dir="rtl"] .tb-sidebar {
  border-inline-end: 1px solid var(--tb-border);
  border-inline-start: none;
}
html[dir="rtl"] .tb-channel-actions { margin-inline-start: auto; margin-inline-end: 0; }
html[dir="rtl"] .tb-callout {
  border-inline-start: 3px solid var(--tb-accent, #4f8cff);
  border-inline-end: none;
  border-radius: 8px 0 0 8px;
}
html[data-theme="light"] .tb-access-free { background:#e6f7ef; color:#0f6b4a; }
html[data-theme="light"] .tb-access-credits { background:#fff4e0; color:#8a5a00; }
html[data-theme="light"] .tb-access-entitlement,
html[data-theme="light"] .tb-access-locked { background:#fde8e8; color:#a31818; }
html[data-theme="light"] .tb-access-unavailable { background:#ececec; color:#555; }
html[data-theme="light"] .tb-trust-unverified { background:#eceff4; color:#5a6270; }
html[data-theme="light"] .tb-server-header-main:hover { color: var(--text-primary); }
html[data-theme="light"] .tb-topbar,
html[data-theme="light"] .tb-channel-header {
  background: var(--surface-overlay);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}
html[data-theme="light"] .tb-composer,
html[data-theme="light"] .tb-composer-wrap {
  background: var(--surface-raised);
  color: var(--text-primary);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--tb-rail); color: var(--tb-text);
  font-family: var(--tb-font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input, select { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.hidden { display: none !important; }

/* ——— Shell ——— */
.tb-app {
  display: grid;
  grid-template-columns: var(--tb-rail-w) var(--tb-sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}
/* Rail + sidebar + main. No fixed unnecessary right column.
   Density/navigation maturity refs live in Harness UX docs only (not public product branding). */
.tb-app.context-open {
  grid-template-columns: var(--tb-rail-w) var(--tb-sidebar-w) minmax(0, 1fr);
}
body.has-staging-banner .tb-app { margin-top: 28px; height: calc(100% - 28px); }

/* ——— Rail ——— */
.tb-rail {
  background: var(--tb-rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 6px; overflow-y: auto;
  border-right: 1px solid var(--tb-border);
}
.tb-rail-sep {
  width: 28px; height: 2px; background: var(--tb-border-strong);
  margin: 4px 0; border-radius: 1px;
}
.tb-server-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; position: relative; flex-shrink: 0;
  transition: border-radius var(--tb-ease), transform var(--tb-ease), box-shadow var(--tb-ease);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.tb-server-btn span {
  width: 100%; height: 100%; border-radius: inherit;
  display: grid; place-items: center;
  background: inherit;
}
.tb-server-btn:hover { border-radius: 14px; transform: translateY(-1px); }
.tb-server-btn.active {
  border-radius: 14px;
  box-shadow: 0 0 0 2px var(--tb-rail), 0 0 0 4px var(--tb-primary), inset 0 0 0 1px rgba(255,255,255,0.12);
}
.tb-server-btn.active::before,
.tb-server-btn:not(.active)::before {
  content: ""; position: absolute; left: -12px;
  width: 3px; background: #fff; border-radius: 0 3px 3px 0;
  transition: height var(--tb-ease);
}
.tb-server-btn.active::before { height: 36px; top: 4px; }
.tb-server-btn:not(.active)::before { height: 0; top: 50%; transform: translateY(-50%); }
.tb-server-btn:hover:not(.active)::before { height: 18px; }
.tb-server-btn.tb-home {
  background: linear-gradient(145deg, #3d8bfd, #2563c7);
}
.tb-server-btn.tb-add {
  background: transparent; color: var(--tb-learn);
  border: 1.5px dashed rgba(45, 212, 168, 0.4);
  box-shadow: none;
}
.tb-server-btn.tb-add:hover { background: var(--tb-learn-soft); border-style: solid; }
.tb-server-btn[data-hue="0"] { background: linear-gradient(145deg, #3d8bfd, #1e4f9c); }
.tb-server-btn[data-hue="1"] { background: linear-gradient(145deg, #8b7cf7, #4f46a8); }
.tb-server-btn[data-hue="2"] { background: linear-gradient(145deg, #2dd4a8, #0f766e); }
.tb-server-btn[data-hue="3"] { background: linear-gradient(145deg, #f59e0b, #b45309); }

/* ——— Sidebar ——— */
.tb-sidebar {
  background: var(--tb-sidebar);
  display: flex; flex-direction: column; min-width: 0;
  border-right: 1px solid var(--tb-border);
}
.tb-server-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--tb-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.tb-server-header-main {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
}
.tb-server-header-main:hover { color: #fff; }
.tb-trust-line {
  margin-top: 6px; font-size: 11px; color: var(--tb-text-muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.tb-badge-verified { color: var(--tb-learn); font-weight: 700; }
.tb-channel-list { flex: 1; overflow-y: auto; padding: 8px 8px 12px; }
.tb-category { margin-top: 12px; }
.tb-category:first-child { margin-top: 2px; }
.tb-cat-title {
  width: 100%; display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; color: var(--tb-text-muted);
  text-transform: uppercase; padding: 2px 8px 6px; letter-spacing: 0.08em;
}
.tb-cat-title:hover { color: var(--tb-text-secondary); }
.tb-category.collapsed .tb-cat-items { display: none; }
.tb-category.collapsed .tb-cat-title i { transform: rotate(-90deg); }
.tb-channel {
  width: 100%; min-height: 32px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px; border-radius: var(--tb-radius-sm); color: var(--tb-text-muted);
  text-align: left; margin: 1px 0; position: relative;
  transition: background var(--tb-ease), color var(--tb-ease);
}
.tb-channel:hover { background: var(--tb-hover); color: var(--tb-text-secondary); }
.tb-channel.active {
  background: var(--tb-active); color: var(--tb-text); font-weight: 550;
}
.tb-channel.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; border-radius: 2px; background: var(--tb-primary);
}
.tb-channel i { width: var(--tb-icon); height: var(--tb-icon); flex-shrink: 0; opacity: 0.8; }
.tb-channel span:first-of-type {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px;
}
.tb-ch-tag { display: none; }
.tb-unread {
  min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: var(--tb-text); color: var(--tb-rail); font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center;
}
.tb-premium-lock { font-size: 11px; opacity: 0.65; }

.tb-user-panel {
  height: 52px; padding: 0 8px; background: rgba(0,0,0,0.28);
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--tb-border);
}
.tb-user-profile {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: var(--tb-radius-sm); min-width: 0;
}
.tb-user-profile:hover { background: var(--tb-hover); }
.tb-avatar {
  width: var(--tb-avatar-md); height: var(--tb-avatar-md); border-radius: 50%;
  background: linear-gradient(145deg, var(--tb-primary), #1d4ed8);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  position: relative; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.tb-status-dot {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--tb-success); border: 2px solid #0a0d12;
}
.tb-user-meta { min-width: 0; }
.tb-user-name {
  font-size: 12.5px; font-weight: 600; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-user-status { font-size: 11px; color: var(--tb-text-muted); }
.tb-user-controls { display: flex; gap: 2px; }
.tb-icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: var(--tb-radius-sm); color: var(--tb-text-muted);
  transition: background var(--tb-ease), color var(--tb-ease);
}
.tb-icon-btn:hover, .tb-icon-btn.active {
  color: var(--tb-text); background: var(--tb-hover);
}

/* ——— Main ——— */
.tb-main {
  background: var(--tb-main);
  display: grid;
  grid-template-rows: var(--tb-header-h) minmax(0, 1fr) auto;
  min-width: 0;
}
.tb-channel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--tb-border);
  background: rgba(19, 24, 33, 0.92);
  backdrop-filter: blur(8px);
  min-height: var(--tb-header-h);
  z-index: 2;
}
.tb-breadcrumb {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}
.tb-channel-icon { color: var(--tb-text-muted); display: grid; place-items: center; }
.tb-channel-title { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.tb-channel-topic {
  flex: 1; color: var(--tb-text-muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 12px; border-left: 1px solid var(--tb-border); margin-left: 4px;
}
.tb-channel-actions { margin-left: auto; display: flex; gap: 2px; }
.tb-mobile-nav { display: none; }
.tb-content { overflow-y: auto; padding: 12px 18px 8px; min-height: 0; }
.tb-composer-wrap { padding: 8px 16px 18px; }
.tb-composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--tb-input); border-radius: var(--tb-radius-lg);
  padding: 0 10px 0 14px; min-height: 44px;
  border: 1px solid var(--tb-border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
  transition: border-color var(--tb-ease), box-shadow var(--tb-ease);
}
.tb-composer:focus-within {
  border-color: rgba(61, 139, 253, 0.45);
  box-shadow: 0 0 0 3px var(--tb-primary-soft);
}
.tb-composer textarea {
  flex: 1; background: transparent; border: 0; outline: none; resize: none;
  padding: 12px 0; color: var(--tb-text); max-height: 160px; font-size: 14.5px;
}

/* ——— Chat messages ——— */
.tb-scroller { display: flex; flex-direction: column; gap: 0; padding: 4px 0 12px; }
.tb-msg {
  display: flex; gap: 12px; padding: 2px 10px 2px 8px; border-radius: var(--tb-radius-sm);
  position: relative; margin: 0 -4px;
}
.tb-msg:hover { background: var(--tb-hover); }
.tb-msg.group { margin-top: 12px; padding-top: 4px; }
.tb-msg-av {
  width: var(--tb-avatar-lg); height: var(--tb-avatar-lg); border-radius: 50%;
  background: linear-gradient(145deg, #4b86e8, #1e40af);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.tb-msg-av.ai {
  background: linear-gradient(145deg, var(--tb-ai), var(--tb-ai-deep));
}
.tb-msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.tb-msg-head strong { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.tb-msg-head time { font-size: 11px; color: var(--tb-text-muted); font-variant-numeric: tabular-nums; }
.tb-role {
  font-size: 10px; color: var(--tb-learn); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tb-msg p { margin: 0; line-height: 1.5; color: var(--tb-text-secondary); font-size: 14.5px; }
.tb-msg-actions {
  position: absolute; right: 8px; top: -12px;
  display: none; gap: 2px; padding: 2px;
  background: var(--tb-elevated); border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm); box-shadow: var(--tb-shadow);
}
.tb-msg:hover .tb-msg-actions { display: flex; }
.tb-msg-actions button {
  width: 28px; height: 28px; border-radius: 4px; color: var(--tb-text-muted);
  display: grid; place-items: center;
}
.tb-msg-actions button:hover { background: var(--tb-hover); color: var(--tb-text); }
.tb-badge-ai {
  display: inline-flex; align-items: center; height: 16px; padding: 0 5px;
  border-radius: 4px; background: var(--tb-ai-deep); color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
}
.tb-citations {
  margin-top: 8px; padding: 8px 10px;
  background: rgba(139, 124, 247, 0.08);
  border: 1px solid rgba(139, 124, 247, 0.2);
  border-radius: var(--tb-radius-sm); font-size: 12.5px;
}
.tb-citations h4 {
  margin: 0 0 4px; font-size: 10px; color: var(--tb-ai);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tb-citations ul { margin: 0; padding-left: 16px; color: var(--tb-text-secondary); }
.tb-cite-excerpt { display: block; font-size: 11.5px; color: var(--tb-text-muted); margin-top: 2px; }
.tb-ai-disclosure {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--tb-ai-soft); border: 1px solid rgba(139, 124, 247, 0.28);
  border-radius: var(--tb-radius-lg); padding: 12px 14px; margin-bottom: 14px;
  font-size: 13px; color: var(--tb-text-secondary);
}
.tb-ai-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 4px 16px; border-bottom: 1px solid var(--tb-border); margin-bottom: 12px;
}
.tb-ai-hero-av {
  width: 56px; height: 56px; border-radius: 18px;
  background: linear-gradient(145deg, var(--tb-ai), var(--tb-ai-deep));
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 8px 24px rgba(106, 90, 224, 0.35);
}
.tb-ai-hero h2 { margin: 0 0 2px; font-size: 18px; letter-spacing: -0.02em; }
.tb-ai-hero-meta { font-size: 12.5px; color: var(--tb-text-muted); }
.tb-msg-error .tb-msg-head strong { color: var(--tb-danger); }
.tb-no-sources { font-style: italic; margin-top: 6px; }

/* ——— Lesson editorial ——— */
.tb-lesson { max-width: 720px; }
.tb-lesson-kicker {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--tb-text-muted); margin-bottom: 8px;
}
.tb-lesson-kicker .tb-pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 999px; background: var(--tb-learn-soft); color: var(--tb-learn);
  font-size: 11px; font-weight: 650;
}
.tb-lesson h1 {
  margin: 0 0 10px; font-family: var(--tb-serif); font-size: 28px;
  font-weight: 600; letter-spacing: -0.03em; line-height: 1.2;
}
.tb-lesson-meta { font-size: 13px; color: var(--tb-text-muted); margin: 0 0 14px; }
.tb-lesson-meta strong { color: var(--tb-text-secondary); font-weight: 600; }
.tb-lesson-progress {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  font-size: 12px; color: var(--tb-text-muted);
}
.tb-mastery-bar {
  flex: 1; max-width: 180px; height: 4px; background: rgba(255,255,255,0.06);
  border-radius: 2px; overflow: hidden;
}
.tb-mastery-bar span { display: block; height: 100%; background: var(--tb-learn); border-radius: 2px; }
.tb-objectives {
  margin: 0 0 18px; padding: 0 0 0 0;
  border-left: 2px solid var(--tb-learn);
  padding-left: 14px;
}
.tb-objectives h3 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase;
  color: var(--tb-learn); letter-spacing: 0.06em; font-weight: 700;
}
.tb-objectives ul { margin: 0; padding-left: 16px; color: var(--tb-text-secondary); font-size: 13.5px; }
.tb-objectives li { margin: 3px 0; }
.tb-block {
  background: transparent; border-radius: 0; padding: 0;
  margin-bottom: 14px; line-height: 1.65; font-size: 15px;
  color: var(--tb-text-secondary);
}
.tb-block + .tb-block { padding-top: 2px; }
.tb-block-video {
  display: flex; align-items: center; gap: 10px; color: var(--tb-text-muted);
  min-height: 88px; justify-content: center;
  border: 1px dashed var(--tb-border-strong); border-radius: var(--tb-radius);
  background: rgba(255,255,255,0.02);
}
.tb-block-quiz {
  margin-top: 16px; padding: 14px; border-radius: var(--tb-radius);
  background: rgba(255,255,255,0.03); border: 1px solid var(--tb-border);
}
.tb-block-quiz h4 { margin: 0 0 10px; font-size: 14px; }
.tb-block-quiz label { display: block; margin: 6px 0; color: var(--tb-text-secondary); cursor: pointer; }
.tb-lesson-next {
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--tb-border);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.tb-mastery { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--tb-text-muted); }
.tb-mastery-row { margin-bottom: 10px; }
.tb-mastery-row > span:first-child { display: block; font-size: 12.5px; margin-bottom: 4px; }
.tb-progress-card {
  background: transparent; border: 0; border-radius: 0;
  padding: 0 4px 12px; margin: 0 0 8px;
  border-bottom: 1px solid var(--tb-border);
}
.tb-progress-skill { font-weight: 600; margin: 4px 0 8px; font-size: 13px; }
.tb-progress-hint { font-size: 11.5px; margin: 6px 0 0; color: var(--tb-text-muted); }
.tb-progress-delta { color: var(--tb-learn); font-size: 12px; font-weight: 650; }
.tb-result-ok { color: var(--tb-success); font-weight: 600; }

/* ——— Course ——— */
.tb-course h1 { margin: 0 0 14px; font-family: var(--tb-serif); font-size: 24px; }
.tb-module { margin-bottom: 12px; }
.tb-module h3 {
  margin: 0 0 6px; color: var(--tb-text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tb-module ul { list-style: none; margin: 0; padding: 0; }
.tb-module li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--tb-radius-sm); color: var(--tb-text-secondary);
}
.tb-module li:hover { background: var(--tb-hover); }

/* ——— Home ——— */
.tb-home {
  max-width: 880px; margin: 0 auto; padding: 8px 8px 32px;
}
.tb-home-hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; padding-bottom: 16px;
  border-bottom: 1px solid var(--tb-border);
}
.tb-home-hero h1 {
  margin: 0 0 4px; font-size: 22px; letter-spacing: -0.03em; font-weight: 700;
}
.tb-home-grid {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px;
}
@media (max-width: 900px) { .tb-home-grid { grid-template-columns: 1fr; } }
.tb-home-section h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--tb-text-muted);
}
.tb-home-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--tb-radius-sm);
  width: 100%; text-align: left; color: var(--tb-text-secondary);
  transition: background var(--tb-ease);
}
.tb-home-row:hover { background: var(--tb-hover); color: var(--tb-text); }
.tb-home-row .face {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
}
.tb-home-row .meta { font-size: 11.5px; color: var(--tb-text-muted); display: block; }

/* ——— Welcome / empty ——— */
.tb-placeholder, .tb-welcome, .tb-empty {
  text-align: left; padding: 28px 12px; color: var(--tb-text-muted);
  max-width: 420px; margin: 24px auto 0;
}
.tb-empty i { width: 28px; height: 28px; color: var(--tb-text-muted); margin-bottom: 10px; }
.tb-placeholder h2, .tb-welcome h1, .tb-empty h2 {
  color: var(--tb-text); font-size: 18px; margin: 0 0 6px; letter-spacing: -0.02em;
}
.tb-welcome-icon {
  width: 48px; height: 48px; margin: 0 0 12px; background: var(--tb-elevated);
  border-radius: 14px; display: grid; place-items: center;
  border: 1px solid var(--tb-border);
}
.tb-orientation { line-height: 1.55; margin-bottom: 16px; font-size: 13.5px; }
.tb-loading {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  color: var(--tb-text-muted); font-size: 13px;
}
.tb-spinner {
  width: 16px; height: 16px; border: 2px solid var(--tb-panel);
  border-top-color: var(--tb-primary); border-radius: 50%;
  animation: tb-spin 0.7s linear infinite;
}
@keyframes tb-spin { to { transform: rotate(360deg); } }
.tb-skeleton {
  background: linear-gradient(90deg, var(--tb-panel), var(--tb-elevated), var(--tb-panel));
  background-size: 200% 100%; animation: tb-shimmer 1.2s ease infinite;
  border-radius: 6px; height: 12px; margin: 8px 0;
}
@keyframes tb-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ——— Context / members ——— */
.tb-drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.35);
}
.tb-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 92vw);
  z-index: 45; background: var(--tb-sidebar);
  border-left: 1px solid var(--tb-border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
  transform: translateX(0);
  animation: tb-drawer-in 0.16s ease;
}
@keyframes tb-drawer-in { from { transform: translateX(12px); opacity: 0.6; } to { transform: none; opacity: 1; } }
body.has-staging-banner .tb-drawer { top: 28px; }
.tb-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--tb-header-h); padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--tb-border); flex-shrink: 0;
}
.tb-drawer-head strong { font-size: 13px; letter-spacing: -0.01em; }
.tb-drawer-body { overflow-y: auto; padding: 10px 8px 20px; flex: 1; }
.tb-drawer-body h3 {
  font-size: 10px; text-transform: uppercase; color: var(--tb-text-muted);
  margin: 14px 0 4px; letter-spacing: 0.08em; padding: 0 8px; font-weight: 700;
}
.tb-drawer-body h3:first-child { margin-top: 2px; }
.tb-context h3 {
  font-size: 10px; text-transform: uppercase; color: var(--tb-text-muted);
  margin: 14px 0 4px; letter-spacing: 0.08em; padding: 0 8px; font-weight: 700;
}
.tb-context h3:first-child { margin-top: 2px; }
.tb-context-card {
  background: var(--tb-panel); border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius); padding: 10px; margin: 8px;
  font-size: 12.5px; color: var(--tb-text-secondary); line-height: 1.45;
}
.tb-context-card strong { color: var(--tb-text); display: block; margin-bottom: 4px; font-size: 12px; }
.tb-context-card .tb-btn-secondary { width: 100%; margin-top: 8px; }

.tb-popover {
  position: fixed; z-index: 60; min-width: 220px;
  background: var(--tb-elevated); border: 1px solid var(--tb-border-strong);
  border-radius: var(--tb-radius-lg); box-shadow: var(--tb-shadow); padding: 6px;
}
.tb-popover-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--tb-border); margin-bottom: 4px; font-size: 13px; }
.tb-popover-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  border-radius: var(--tb-radius-sm); color: var(--tb-text-secondary); font-size: 13px;
}
.tb-popover-item:hover { background: var(--tb-hover); color: var(--tb-text); }
.tb-popover-item.danger { color: var(--tb-danger); }

.tb-quick-switch {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,0.55); display: grid; place-items: start center; padding-top: 12vh;
}
.tb-quick-card {
  width: min(520px, 92vw); background: var(--tb-elevated);
  border: 1px solid var(--tb-border-strong); border-radius: 14px;
  box-shadow: var(--tb-shadow); overflow: hidden;
}
.tb-quick-card input {
  width: 100%; padding: 14px 16px; background: transparent; outline: none;
  border-bottom: 1px solid var(--tb-border); font-size: 15px; color: var(--tb-text);
}
.tb-quick-results { max-height: 360px; overflow-y: auto; padding: 6px; }
.tb-quick-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--tb-radius); color: var(--tb-text-secondary);
}
.tb-quick-item:hover, .tb-quick-item.active { background: var(--tb-primary-soft); color: var(--tb-text); }
.tb-quick-item .meta { margin-left: auto; font-size: 11px; color: var(--tb-text-muted); }
.tb-quick-hint { margin: 0; padding: 8px 14px 12px; font-size: 11px; color: var(--tb-text-muted); }
.tb-settings-card { max-width: 420px; }
body[data-density="comfortable"] .tb-msg { padding: 8px 12px; }
body[data-density="comfortable"] .tb-channel { padding: 8px 10px; }
body[data-density="compact"] .tb-msg { padding: 2px 10px 2px 8px; }
body[data-density="compact"] .tb-msg.group { margin-top: 8px; }

.tb-member {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: var(--tb-radius-sm);
}
.tb-member:hover { background: var(--tb-hover); }
.tb-av, .tb-member-av {
  width: 28px; height: 28px; border-radius: 50%; background: #3b82f6;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; position: relative; flex-shrink: 0;
}
.tb-av.ai { background: linear-gradient(145deg, var(--tb-ai), var(--tb-ai-deep)); }
.tb-online {
  position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--tb-success); border: 2px solid var(--tb-sidebar);
}
.tb-member-name { flex: 1; font-size: 13px; }
.tb-member {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: var(--tb-radius-sm); font-size: 13px;
}
.tb-member:hover { background: var(--tb-hover); }
.tb-member .tb-av {
  width: var(--tb-avatar-sm); height: var(--tb-avatar-sm); border-radius: 50%;
  background: var(--tb-elevated); display: grid; place-items: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.tb-member .tb-av.ai {
  background: linear-gradient(145deg, var(--tb-ai), var(--tb-ai-deep));
  border-radius: 9px;
}
.tb-member .tb-av .tb-online {
  position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--tb-success); border: 2px solid var(--tb-sidebar);
}
.tb-member-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.tb-member .tb-muted { margin-left: auto; font-size: 10px; color: var(--tb-text-muted); }
.tb-muted { color: var(--tb-text-muted); font-size: 12.5px; }
.tb-context-card {
  background: transparent; border-radius: 0; padding: 6px 8px 12px; margin: 0 0 4px;
  font-size: 12.5px; color: var(--tb-text-secondary);
  border-bottom: 1px solid var(--tb-border);
}
.tb-context-card strong { color: var(--tb-text); display: block; margin-bottom: 4px; font-size: 12px; }
.tb-context-card .tb-btn-secondary { width: 100%; margin-top: 8px; }

/* ——— Buttons ——— */
.tb-btn-primary {
  margin-top: 0; padding: 0 14px; height: var(--tb-control-h);
  background: var(--tb-primary); color: #fff;
  border-radius: var(--tb-radius); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: filter var(--tb-ease), transform var(--tb-ease);
}
.tb-btn-primary:hover { filter: brightness(1.08); }
.tb-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.tb-btn-secondary {
  padding: 0 12px; height: 32px; border-radius: var(--tb-radius);
  background: var(--tb-elevated); color: var(--tb-text); font-weight: 500;
  font-size: 12.5px; margin-top: 0;
  border: 1px solid var(--tb-border);
  display: inline-flex; align-items: center; justify-content: center;
}
.tb-btn-secondary:hover { background: var(--tb-hover); }
.tb-btn-ghost {
  padding: 0 12px; height: var(--tb-control-h); border-radius: var(--tb-radius);
  color: var(--tb-text-muted); border: 1px solid var(--tb-border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.tb-btn-ghost:hover { color: var(--tb-text); border-color: var(--tb-border-strong); }

/* ——— Upsell / overlays ——— */
.tb-upsell {
  max-width: 400px; margin: 40px auto; text-align: left; padding: 22px;
  background: var(--tb-elevated); border-radius: var(--tb-radius-lg);
  border: 1px solid rgba(232,185,35,0.28);
}
.tb-upsell-icon { font-size: 28px; margin-bottom: 8px; }
.tb-upsell h2 { margin: 0 0 8px; font-size: 18px; }
.tb-upsell-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.tb-upsell-why, .tb-upsell-note { line-height: 1.5; color: var(--tb-text-secondary); font-size: 13px; }

.tb-login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(ellipse at 25% 15%, rgba(61,139,253,0.18), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139,124,247,0.12), transparent 45%),
    #090b10;
  display: flex; align-items: center; justify-content: center;
}
.tb-login-card {
  background: rgba(26, 33, 48, 0.92); padding: 32px 28px; border-radius: 16px;
  width: min(380px, 92vw); display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--tb-shadow); border: 1px solid var(--tb-border);
  backdrop-filter: blur(12px);
}
.tb-login-card h1 {
  margin: 0; font-size: 26px; letter-spacing: -0.04em; text-align: center; font-weight: 700;
  background: linear-gradient(135deg, #fff 35%, var(--tb-primary));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tb-login-card > .tb-muted { text-align: center; margin: 0; }
.tb-login-card label {
  display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 650;
  color: var(--tb-text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.tb-login-card input, .tb-login-card textarea, .tb-login-card select {
  padding: 10px 12px; border-radius: var(--tb-radius); border: 1px solid var(--tb-border);
  background: var(--tb-input); color: var(--tb-text); text-transform: none;
  letter-spacing: 0; font-weight: 400; font-size: 14.5px; height: 40px;
}
.tb-login-card input:focus { outline: 2px solid rgba(61,139,253,0.4); outline-offset: 0; }
.tb-login-error { color: var(--tb-danger); font-size: 13px; text-align: center; }
.tb-boot-shell {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--tb-rail); color: var(--tb-text-muted); z-index: 90;
}
.tb-boot-shell::before {
  content: "T"; width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff;
  background: linear-gradient(145deg, #3d8bfd, #2563c7);
  box-shadow: 0 8px 28px rgba(61,139,253,0.35);
}
.tb-boot-shell p { margin: 0; font-size: 13px; }

/* —— Public landing (Discord-inspired composition; talk2know brand) —— */
.tb-landing {
  position: fixed; inset: 0; z-index: 95;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  color: var(--tb-text);
  background:
    radial-gradient(ellipse 80% 60% at 70% 40%, rgba(61, 139, 253, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 15% 80%, rgba(139, 124, 247, 0.16), transparent 50%),
    linear-gradient(180deg, #0b0e14 0%, #090b10 45%, #0a1020 100%);
}
.tb-landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px clamp(20px, 5vw, 56px);
}
.tb-landing-brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; font-weight: 700; font-size: 18px;
  letter-spacing: -0.03em;
}
.tb-landing-mark {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, #3d8bfd, #2563c7);
  box-shadow: 0 8px 24px rgba(61, 139, 253, 0.35);
  text-transform: lowercase;
}
.tb-landing-hero {
  position: relative; z-index: 2;
  max-width: 720px;
  padding: clamp(24px, 8vh, 80px) clamp(20px, 5vw, 56px) 48px;
  animation: tb-landing-in 0.7s ease both;
}
.tb-landing-title {
  margin: 0 0 18px;
  font-family: var(--tb-serif);
  font-size: clamp(42px, 7vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 600;
}
.tb-landing-lead {
  margin: 0 0 28px;
  max-width: 34rem;
  font-size: clamp(16px, 2.2vw, 20px);
  line-height: 1.45;
  color: var(--tb-text-secondary);
}
.tb-landing-cta {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 32px;
  border-radius: 999px;
  font-family: var(--tb-font);
  font-size: 16px; font-weight: 700;
  color: #0b1020;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.tb-landing-cta:hover {
  transform: translateY(-2px);
  background: #f2f6ff;
  box-shadow: 0 16px 40px rgba(61, 139, 253, 0.28);
}
.tb-landing-cta:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.tb-landing-visual {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  display: grid; place-items: center end;
  padding: 8% 4% 6% 40%;
}
.tb-landing-orb {
  position: absolute; border-radius: 50%; filter: blur(40px); opacity: 0.55;
  animation: tb-landing-float 8s ease-in-out infinite alternate;
}
.tb-landing-orb-a {
  width: min(48vw, 420px); height: min(48vw, 420px);
  right: 8%; top: 18%;
  background: rgba(61, 139, 253, 0.45);
}
.tb-landing-orb-b {
  width: min(36vw, 280px); height: min(36vw, 280px);
  right: 28%; bottom: 12%;
  background: rgba(139, 124, 247, 0.4);
  animation-delay: -2s;
}
.tb-landing-panel {
  position: relative;
  width: min(52vw, 520px);
  height: min(58vh, 420px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(14, 18, 25, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template-columns: 52px 120px 1fr;
  overflow: hidden;
  animation: tb-landing-in 0.9s 0.12s ease both;
}
.tb-landing-rail {
  background: #07090e;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}
.tb-landing-side {
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(14, 18, 25, 0.9);
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}
.tb-landing-side span {
  height: 10px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}
.tb-landing-side span:nth-child(2) { width: 78%; background: rgba(61, 139, 253, 0.35); }
.tb-landing-side span:nth-child(3) { width: 62%; }
.tb-landing-main {
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.tb-landing-chip {
  width: 88px; height: 14px; border-radius: 99px;
  background: linear-gradient(90deg, rgba(61, 139, 253, 0.55), rgba(139, 124, 247, 0.4));
}
.tb-landing-line {
  height: 10px; border-radius: 6px; width: 88%;
  background: rgba(255, 255, 255, 0.08);
}
.tb-landing-line.short { width: 54%; }
.tb-landing-bubble {
  margin-top: auto;
  height: 72px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(61, 139, 253, 0.22), rgba(45, 212, 168, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.08);
}
@keyframes tb-landing-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes tb-landing-float {
  from { transform: translateY(0); }
  to { transform: translateY(-18px); }
}
@media (max-width: 860px) {
  .tb-landing-visual { padding: 0; align-items: end; justify-items: center; opacity: 0.35; }
  .tb-landing-panel { width: min(88vw, 420px); height: 240px; margin-bottom: 12px; }
  .tb-landing-hero { padding-bottom: 28vh; }
}
@media (max-width: 520px) {
  .tb-landing-title { font-size: 40px; }
  .tb-landing-side { display: none; }
  .tb-landing-panel { grid-template-columns: 44px 1fr; }
}

.tb-toast-region {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--tb-elevated); padding: 10px 16px; border-radius: var(--tb-radius);
  box-shadow: var(--tb-shadow); z-index: 200; opacity: 0;
  transition: transform 0.2s, opacity 0.2s; pointer-events: none;
  border: 1px solid var(--tb-border); font-size: 13px;
}
.tb-toast-region.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.tb-staging-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 300;
  background: #4c3ab0; color: #fff; text-align: center; padding: 5px 12px; font-size: 11.5px;
  letter-spacing: 0.01em;
}
.tb-checkout-methods { display: flex; gap: 8px; flex-wrap: wrap; }
.tb-creator-economy { margin: 8px 0; font-size: 13px; }

button:focus-visible, .tb-channel:focus-visible, textarea:focus-visible, .tb-server-btn:focus-visible {
  outline: 2px solid var(--tb-primary); outline-offset: 2px;
}

/* ——— Teacher studio ——— */
.tb-teacher-body {
  min-height: 100%; overflow: auto;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(61,139,253,0.12), transparent 40%),
    var(--tb-rail);
}
.tb-teacher-chrome {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; border-bottom: 1px solid var(--tb-border);
  background: rgba(9, 11, 16, 0.9); position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
}
.tb-teacher-brand {
  font-weight: 750; font-size: 16px; color: var(--tb-text); text-decoration: none;
  letter-spacing: -0.03em;
}
.tb-teacher-chrome .tb-btn-ghost { margin-left: auto; height: 32px; font-size: 12.5px; }
.tb-teacher-app {
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: 0; max-width: 1100px; margin: 0 auto; min-height: calc(100vh - 52px);
}
.tb-teacher-nav {
  padding: 20px 12px; border-right: 1px solid var(--tb-border);
  position: sticky; top: 52px; height: calc(100vh - 52px);
}
.tb-teacher-nav button {
  width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--tb-radius-sm);
  color: var(--tb-text-muted); font-size: 13px; margin-bottom: 2px;
}
.tb-teacher-nav button.active, .tb-teacher-nav button:hover {
  background: var(--tb-hover); color: var(--tb-text);
}
.tb-teacher-main { padding: 24px 28px 48px; }
.tb-teacher-header { margin-bottom: 18px; }
.tb-teacher-header h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.tb-teacher-step {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--tb-sidebar); padding: 20px; border-radius: var(--tb-radius-lg);
  border: 1px solid var(--tb-border);
}
.tb-teacher-step + .tb-teacher-step { margin-top: 14px; }
.tb-teacher-step label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--tb-text-muted); }
.tb-teacher-step input, .tb-teacher-step textarea, .tb-teacher-step select {
  padding: 9px 11px; border-radius: var(--tb-radius); border: 1px solid var(--tb-border);
  background: var(--tb-input); color: var(--tb-text); font-size: 14px;
}
.tb-teacher-progress { font-size: 12px; color: var(--tb-text-muted); margin-top: 6px; }
.tb-interview { border: 1px solid var(--tb-border); border-radius: var(--tb-radius); padding: 12px; }
.tb-test-result {
  background: var(--tb-panel); padding: 12px; border-radius: var(--tb-radius);
  font-size: 12px; overflow: auto; max-height: 240px; border: 1px solid var(--tb-border);
}

/* ——— Direction C polish pass ——— */
.tb-server-header {
  background:
    linear-gradient(135deg, rgba(61,139,253,0.14), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
}
.tb-channel.active {
  background: linear-gradient(90deg, rgba(61,139,253,0.18), rgba(255,255,255,0.05));
  font-weight: 600;
}
.tb-msg { padding: 7px 12px 7px 8px; }
.tb-msg.group { margin-top: 6px; padding-top: 8px; }
.tb-msg-head strong { font-weight: 700; color: var(--tb-text); }
.tb-msg p { color: #d7dde9; }
.tb-composer {
  min-height: 48px; border-radius: 14px; background: #1a2232;
  border-color: rgba(255,255,255,0.09);
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}
.tb-member { padding: 6px 8px; }
.tb-content { padding: 6px 10px 8px; }

/* ——— Responsive ——— */
@media (max-width: 900px) {
  .tb-channel-topic { display: none; }
}
/* Legacy ≤640 rules removed — unified mobile shell is in the 860px block below. */

/* ——— Visual Quality Closure ——— */
.tb-server-btn.tb-mark {
  padding: 0; overflow: hidden; background: transparent; box-shadow: none;
}
.tb-server-btn.tb-mark .tb-server-mark,
.tb-server-btn.tb-mark .tb-tibyan-mark {
  width: 44px; height: 44px; display: block; border-radius: 50%;
  transition: border-radius var(--tb-ease);
  overflow: hidden;
}
.tb-server-btn.tb-mark:hover .tb-server-mark,
.tb-server-btn.tb-mark:hover .tb-tibyan-mark,
.tb-server-btn.tb-mark.active .tb-server-mark,
.tb-server-btn.tb-mark.active .tb-tibyan-mark { border-radius: 14px; }
.tb-server-mark svg, .tb-tibyan-mark svg { width: 100%; height: 100%; display: block; }
.tb-server-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0; overflow: hidden; }
.tb-msg-gutter { width: var(--tb-avatar-lg); flex-shrink: 0; }
.tb-msg-body { flex: 1; min-width: 0; }
.tb-date-sep {
  display: flex; align-items: center; gap: 12px; margin: 14px 8px 10px;
  color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.tb-date-sep::before, .tb-date-sep::after {
  content: ""; flex: 1; height: 1px; background: var(--tb-border-strong);
}
.tb-composer-attach {
  width: 36px; height: 40px; color: var(--text-muted); display: grid; place-items: center; flex-shrink: 0;
}
.tb-composer-attach:hover { color: var(--text-primary); }
.tb-composer-send { color: var(--tibyan-accent) !important; }

.tb-home-greet {
  margin: 0 0 4px; font-size: 13px; color: var(--tibyan-accent); font-weight: 600; letter-spacing: 0.02em;
}
.tb-home-hero-actions { display: flex; gap: 10px; align-items: center; }
.tb-home-block { margin-bottom: 22px; }
.tb-home-block h3 {
  margin: 0 0 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700;
}
.tb-continue-list { display: flex; flex-direction: column; gap: 10px; }
.tb-continue-card {
  display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--tb-radius-lg);
  background: linear-gradient(135deg, rgba(61,139,253,0.1), rgba(255,255,255,0.02));
  border: 1px solid var(--tb-border-strong);
  transition: border-color var(--tb-ease), background var(--tb-ease);
}
.tb-continue-card:hover {
  border-color: rgba(61,139,253,0.35);
  background: linear-gradient(135deg, rgba(61,139,253,0.16), rgba(255,255,255,0.03));
}
.tb-continue-top { display: flex; align-items: center; gap: 12px; }
.tb-continue-top strong { display: block; font-size: 16px; letter-spacing: -0.02em; }
.tb-continue-top .meta { font-size: 12px; color: var(--text-muted); }
.tb-continue-bar {
  height: 6px; border-radius: 99px; background: rgba(255,255,255,0.06); overflow: hidden;
}
.tb-continue-bar span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--tibyan-learning), var(--tibyan-accent));
}
.tb-continue-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary);
}
.tb-pill-mini {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--tibyan-learning); background: var(--tb-learn-soft); padding: 3px 8px; border-radius: 99px;
}
.tb-home-split {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 24px;
}
@media (max-width: 900px) { .tb-home-split { grid-template-columns: 1fr; } }
.tb-activity-list { display: flex; flex-direction: column; gap: 6px; }
.tb-activity-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px;
  border-radius: var(--tb-radius-sm);
}
.tb-activity-row:hover { background: var(--interactive-hover); }
.tb-activity-row strong { display: block; font-size: 13px; }
.tb-activity-row .meta { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.tb-ai-dot {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px;
  background: linear-gradient(145deg, var(--tibyan-ai), var(--tb-ai-deep));
  box-shadow: 0 0 0 2px rgba(139,124,247,0.25);
}
.tb-space-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tb-space-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 999px;
  background: var(--surface-elevated); border: 1px solid var(--tb-border);
  color: var(--text-secondary); font-size: 12.5px;
}
.tb-space-chip:hover { border-color: rgba(61,139,253,0.4); color: var(--text-primary); }
.tb-space-chip .tb-server-mark { width: 28px; height: 28px; border-radius: 9px; }
.tb-home-row .face.ai-face {
  background: linear-gradient(145deg, var(--tibyan-ai), var(--tb-ai-deep));
  box-shadow: 0 0 0 2px rgba(139,124,247,0.28);
}

.tb-citations {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--tb-radius);
  background: rgba(139,124,247,0.08); border: 1px solid rgba(139,124,247,0.2);
}
.tb-citations h4 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--tibyan-ai); font-weight: 700;
}
.tb-citations ul { margin: 0; padding: 0; list-style: none; }
.tb-citations li { margin-bottom: 6px; font-size: 12.5px; color: var(--text-secondary); }
.tb-cite-excerpt { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.tb-msg-av.ai {
  box-shadow: 0 0 0 2px rgba(139,124,247,0.35), 0 0 12px rgba(139,124,247,0.2);
}

/* Studio creator workspace */
.tb-studio-login {
  max-width: 420px; margin: 48px auto; padding: 0 16px;
}
.tb-studio-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  height: calc(100vh - 48px);
  background: var(--surface-main);
}
.tb-studio-tree {
  background: var(--surface-sidebar); border-right: 1px solid var(--tb-border);
  padding: 12px 8px; overflow-y: auto;
}
.tb-studio-tree-head, .tb-studio-props-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 700; padding: 6px 10px 10px;
}
.tb-tree-node {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: var(--tb-radius-sm);
  color: var(--text-secondary); font-size: 13px; text-align: left;
}
.tb-tree-node:hover { background: var(--interactive-hover); color: var(--text-primary); }
.tb-tree-node.active {
  background: linear-gradient(90deg, rgba(61,139,253,0.2), rgba(255,255,255,0.04));
  color: var(--text-primary); font-weight: 600;
}
.tb-tree-node.nest { padding-left: 22px; }
.tb-tree-node.nest2 { padding-left: 34px; font-size: 12.5px; }
.tb-tree-node.nest3 { padding-left: 46px; font-size: 12.5px; }
.tb-tree-node i { width: 16px; height: 16px; opacity: 0.85; }
.tb-studio-canvas {
  padding: 18px 24px 40px; overflow-y: auto; background:
    radial-gradient(ellipse at top, rgba(61,139,253,0.06), transparent 50%),
    var(--surface-main);
}
.tb-studio-canvas-bar { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--tb-border); }
.tb-studio-canvas-bar h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.03em; }
.tb-studio-props {
  background: var(--surface-sidebar); border-left: 1px solid var(--tb-border);
  padding: 12px 10px; overflow-y: auto;
}
.tb-prop-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px; margin-bottom: 8px; border-radius: var(--tb-radius);
  background: var(--surface-elevated); border: 1px solid var(--tb-border);
}
.tb-prop-card strong { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.tb-prop-card span { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.tb-canvas-lesson { display: flex; flex-direction: column; gap: 10px; }
.tb-teacher-body { overflow: auto; background: var(--surface-rail); }
.tb-teacher-chrome { height: 48px; }
.tb-teacher-brand { display: inline-flex; align-items: center; gap: 8px; }
.tb-tibyan-mark-inline::before {
  content: "T"; display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(145deg, #3d8bfd, #2563c7);
}
.tb-studio-shell .tb-teacher-step {
  background: rgba(14,18,25,0.72); border: 1px solid var(--tb-border-strong);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.tb-studio-shell .tb-teacher-progress { padding: 12px 10px; font-size: 11px; }

.tb-home-progress-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 900px) { .tb-home-progress-row { grid-template-columns: 1fr; } }
.tb-home-progress-chip {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border-radius: var(--tb-radius-lg);
  background: var(--surface-elevated); border: 1px solid var(--tb-border);
}
.tb-home-progress-chip strong { display: block; font-size: 13.5px; }
.tb-home-progress-chip .meta { font-size: 12px; color: var(--text-muted); display: block; margin: 2px 0 8px; }
.tb-home { max-width: 960px; }
.tb-home-split { gap: 18px; }
.tb-activity-list { max-height: none; }
.tb-msg { padding: 3px 10px 3px 8px; }
.tb-msg.group { margin-top: 10px; padding-top: 6px; }
.tb-scroller { padding-bottom: 4px; }
.tb-checkpoint {
  margin: 16px 0; padding: 14px 16px; border-radius: var(--tb-radius-lg);
  border: 1px solid rgba(45,212,168,0.25); background: var(--tb-learn-soft);
}
.tb-checkpoint h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tibyan-learning); }
.tb-lesson-resource {
  display: flex; flex-direction: column; gap: 4px;
  margin: 14px 0; padding: 12px 14px; border-radius: var(--tb-radius);
  background: var(--surface-elevated); border: 1px solid var(--tb-border);
}
.tb-live-canvas {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: min(70vh, 720px);
}
.tb-live-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tb-live-canvas-toolbar .tb-btn-primary { margin-inline-start: auto; }
.tb-lesson-canvas-host {
  background: var(--surface-overlay, var(--tb-main));
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-lg, 12px);
  padding: 20px 22px 28px;
  box-shadow: var(--tb-shadow);
}
.tb-canvas-editable {
  outline: 1px dashed transparent;
  border-radius: 6px;
  transition: outline-color 0.14s ease, background 0.14s ease;
}
.tb-canvas-editable:hover,
.tb-canvas-editable:focus {
  outline-color: var(--accent, var(--tb-primary));
  background: var(--surface-selected, var(--tb-active));
}
.tb-prop-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  background: var(--surface-elevated, var(--tb-elevated));
  font-size: 12px;
  color: var(--text-muted);
}
.tb-prop-field input {
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  padding: 4px 0;
}
.tb-studio-hidden-fields { display: none !important; }
html[data-theme="light"] .tb-lesson-canvas-host {
  background: #fff;
  border-color: var(--border-strong);
}
.tb-canvas-lesson textarea#lesson-content { min-height: 180px; font-family: var(--tb-serif); line-height: 1.55; }

/* —— Reconciliation surfaces —— */
.tb-access-badge { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:999px; margin-left:6px; }
.tb-access-free { background:#14352a; color:#7ddea8; }
.tb-access-credits { background:#3a2a10; color:#f0c674; }
.tb-access-entitlement,.tb-access-locked { background:#3a1a1a; color:#f0a0a0; }
.tb-access-unavailable { background:#2a2a2a; color:#999; }
.tb-trust-badge { display:inline-block; font-size:11px; padding:2px 8px; border-radius:6px; background:#1e2a44; color:#9ec1ff; margin-left:6px; }
.tb-trust-unverified { background:#2a2a2a; color:#888; }
.tb-trust-open { background:none; border:0; color:inherit; cursor:pointer; text-decoration:underline; font:inherit; padding:0; }
.tb-course-head,.tb-surface-head { margin-bottom:16px; }
.tb-course-lesson { display:flex; gap:8px; align-items:center; width:100%; background:transparent; border:0; color:inherit; padding:8px 4px; cursor:pointer; text-align:left; }
.tb-course-lesson:hover { background:var(--surface-elevated); border-radius:6px; }
.tb-skill-map { display:grid; gap:12px; }
.tb-skill-card { padding:12px 14px; border:1px solid var(--tb-border); border-radius:var(--tb-radius); background:var(--surface-elevated); }
.tb-skill-card header { display:flex; justify-content:space-between; margin-bottom:8px; }
.tb-assessment { max-width:640px; padding:8px 4px 32px; }
.tb-choices { display:grid; gap:8px; margin:16px 0; }
.tb-choice { display:flex; gap:10px; padding:10px 12px; border:1px solid var(--tb-border); border-radius:8px; cursor:pointer; }
.tb-choice:hover { border-color:#4f8cff; }
.tb-assessment-actions,.tb-course-actions { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0; }
.tb-asm-progress { font-size:12px; color:var(--tb-muted); margin-bottom:8px; }
.tb-knowledge-row { display:flex; justify-content:space-between; gap:12px; padding:12px 0; border-bottom:1px solid var(--tb-border); }
.tb-knowledge-upload { display:grid; gap:8px; margin-bottom:20px; max-width:520px; }
.tb-knowledge-upload input,.tb-knowledge-upload textarea,.tb-create-server input,.tb-create-server textarea,.tb-create-server select { width:100%; }
.tb-create-server,.tb-credits-surface,.tb-profile-surface,.tb-server-mgmt,.tb-progress-surface { padding:8px 4px 40px; max-width:720px; }
.tb-credit-list,.tb-mgmt-members,.tb-resp-list { list-style:none; padding:0; margin:0; }
.tb-credit-list li,.tb-mgmt-members li { display:flex; justify-content:space-between; gap:12px; padding:8px 0; border-bottom:1px solid var(--tb-border); }
.tb-resp-list dt { font-size:11px; color:var(--tb-muted); margin-top:10px; }
.tb-resp-list dd { margin:2px 0 0; }
.tb-skeleton .tb-skel-line { height:10px; background:linear-gradient(90deg,#222,#333,#222); border-radius:4px; margin:10px 0; animation:tbPulse 1.2s infinite; }
.tb-skeleton .tb-skel-line.short { width:40%; }
@keyframes tbPulse { 0%,100%{opacity:.55} 50%{opacity:1} }
.tb-empty,.tb-error-panel { padding:24px 8px; max-width:420px; }
.tb-ctx-menu { position:fixed; z-index:80; min-width:160px; background:var(--surface-elevated); border:1px solid var(--tb-border); border-radius:8px; box-shadow:0 12px 40px rgba(0,0,0,.45); padding:6px; }
.tb-ctx-menu button { display:block; width:100%; text-align:left; background:none; border:0; color:inherit; padding:8px 10px; border-radius:6px; cursor:pointer; font:inherit; }
.tb-ctx-menu button:hover { background:rgba(255,255,255,.06); }
.tb-badge-ai.mini { font-size:9px; margin-left:2px; }
.tb-callout { padding:12px 14px; border-left:3px solid #4f8cff; background:rgba(79,140,255,.08); margin:12px 0; border-radius:0 8px 8px 0; }
.tb-soft-pre { white-space:pre-wrap; font-size:12px; opacity:.85; }
.tb-live-preview { margin-top:16px; padding:16px; border:1px dashed var(--tb-border); border-radius:var(--tb-radius); background:rgba(0,0,0,.2); }
.tb-live-preview h3 { margin:0 0 8px; font-size:13px; color:var(--tb-muted); }

/* Mobile: single-column usable shell */
@media (max-width: 860px) {
  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .tb-app {
    grid-template-columns: 1fr !important;
    height: 100dvh !important;
    overflow: hidden;
  }
  .tb-rail, .tb-sidebar {
    position: fixed;
    z-index: 80;
    top: 0;
    bottom: 0;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--tb-sidebar);
    pointer-events: none;
  }
  .tb-rail {
    left: 0;
    width: 72px;
    background: var(--tb-rail);
    border-right: 1px solid var(--tb-border);
  }
  .tb-sidebar {
    left: 72px;
    width: min(300px, calc(100vw - 72px));
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45);
  }
  body.tb-nav-open .tb-rail,
  body.tb-nav-open .tb-sidebar {
    transform: none;
    pointer-events: auto;
  }
  html[dir="rtl"] .tb-rail,
  html[dir="rtl"] .tb-sidebar {
    left: auto;
    right: 0;
    transform: translateX(110%);
  }
  html[dir="rtl"] .tb-sidebar { right: 72px; }
  html[dir="rtl"] body.tb-nav-open .tb-rail,
  html[dir="rtl"] body.tb-nav-open .tb-sidebar { transform: none; }
  .tb-drawer-backdrop.tb-nav-backdrop,
  #nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 75;
    background: rgba(2, 6, 23, 0.5);
  }
  body.tb-nav-open .tb-companion-fab { visibility: hidden; pointer-events: none; }
  .tb-main {
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .tb-channel-header {
    flex-shrink: 0;
    gap: 6px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    min-height: 52px;
    position: sticky;
    top: 0;
  }
  .tb-channel-header .tb-channel-actions {
    gap: 0;
    flex-shrink: 0;
  }
  .tb-channel-icon { display: none; }
  .tb-mobile-nav {
    display: inline-flex !important;
    flex-shrink: 0;
    margin-right: 2px;
    background: var(--tb-hover);
  }
  .tb-channel-title {
    font-size: 16px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #btn-members,
  #btn-context,
  #btn-feedback {
    display: none !important;
  }
  .tb-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px calc(88px + env(safe-area-inset-bottom));
  }
  .tb-composer-wrap {
    flex-shrink: 0;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    background: var(--tb-main);
    border-top: 1px solid var(--tb-border);
  }
  .tb-composer textarea { min-height: 44px; font-size: 16px; }
  .tb-icon-btn, .tb-mobile-nav, .tb-composer-send {
    min-width: 44px;
    min-height: 44px;
  }
  .tb-welcome,
  .tb-placeholder,
  .tb-empty {
    max-width: none;
    margin: 8px 0 0;
    padding: 12px 4px 24px;
    text-align: left;
  }
  .tb-welcome h1 {
    font-size: 22px;
    line-height: 1.25;
  }
  .tb-welcome .tb-btn-primary,
  .tb-welcome .tb-btn-ghost,
  .tb-home-hero-actions .tb-btn-primary,
  .tb-home-hero-actions .tb-btn-secondary,
  .tb-home-hero-actions .tb-btn-ghost {
    width: 100%;
    min-height: 48px;
    margin-top: 8px;
    justify-content: center;
  }
  .tb-home {
    max-width: none;
    padding: 4px 0 24px;
  }
  .tb-home-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .tb-home-hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .tb-home-row {
    min-height: 52px;
    padding: 12px 10px;
  }
  .tb-create-server,
  .tb-credits-surface,
  .tb-profile-surface {
    max-width: none;
    padding: 4px 0 32px;
  }
  .tb-create-server .tb-btn-primary,
  .tb-create-server .tb-btn-secondary {
    width: 100%;
    min-height: 48px;
  }
  .tb-companion-fab {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 60;
  }
  .tb-voice-orb {
    bottom: max(100px, calc(18vh + env(safe-area-inset-bottom)));
  }
  .tb-drawer {
    width: min(100vw, 100%);
    z-index: 70;
  }
  .tb-teacher-app { grid-template-columns: 1fr; }
  .tb-teacher-nav { display: none; }
  .tb-studio-shell { grid-template-columns: 1fr; }
  .tb-studio-tree, .tb-studio-props { display: none; }
}
.tb-knowledge-upload label, .tb-create-server label { display:grid; gap:4px; font-size:12px; color:var(--tb-muted); }
.tb-knowledge-upload input, .tb-knowledge-upload textarea,
.tb-create-server input, .tb-create-server textarea, .tb-create-server select {
  background: var(--surface-elevated); border:1px solid var(--tb-border); border-radius:8px;
  color:inherit; padding:10px 12px; font:inherit;
}
.tb-studio-embed { position:fixed; inset:0; z-index:90; display:flex; flex-direction:column; background:#0b0c0f; }
.tb-studio-embed.hidden { display:none; }
.tb-studio-embed-bar { display:flex; justify-content:space-between; align-items:center; padding:10px 16px; border-bottom:1px solid var(--tb-border); }
.tb-studio-embed iframe { flex:1; border:0; width:100%; background:#0b0c0f; }
body.tb-studio-embed-page .tb-teacher-chrome { display:none !important; }

/* AMD-001 closure — light chrome parity */
html[data-theme="light"] .tb-channel-header,
html[data-theme="light"] .tb-server-header {
  background: var(--surface-overlay);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
html[data-theme="light"] .tb-composer {
  background: var(--tb-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
html[data-theme="light"] .tb-composer textarea {
  color: var(--text-primary);
  background: transparent;
}
html[data-theme="light"] .tb-msg,
html[data-theme="light"] .tb-content {
  color: var(--text-primary);
}
html[data-theme="light"] .tb-login-card,
html[data-theme="light"] .tb-settings-card {
  background: var(--surface-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
html[data-theme="light"] body,
html[data-theme="light"] .tb-app {
  background: var(--surface-base);
  color: var(--text-primary);
}
html[data-theme="light"] .tb-teacher-body,
html[data-theme="light"] .tb-studio-shell,
html[data-theme="light"] .tb-studio-canvas {
  background: var(--surface-raised);
  color: var(--text-primary);
}
html[dir="rtl"] .tb-crumb-sep { display: inline-block; transform: scaleX(-1); }
html[dir="rtl"] .tb-composer-send i,
html[dir="rtl"] [data-lucide="chevron-right"] { transform: scaleX(-1); }

/* Closure-23 — interactive visibility + mobile + source drawer */
.tb-citations li { cursor: pointer; border-radius: 8px; padding: 6px 8px; }
.tb-citations li:hover, .tb-citations li:focus-visible {
  outline: 2px solid var(--tb-accent, #6E61AC); outline-offset: 1px;
  background: var(--surface-elevated, rgba(110,97,172,0.08));
}
.tb-soft-hr { border: 0; border-top: 1px solid var(--tb-border); margin: 24px 0; }
.tb-join-server { display: grid; gap: 10px; }
html[data-theme="light"] .tb-btn-ghost,
html[data-theme="light"] .tb-btn-secondary {
  color: var(--text-primary); border-color: var(--border-strong); background: var(--surface-elevated);
}
html[data-theme="light"] .tb-btn-ghost:hover,
html[data-theme="light"] .tb-btn-secondary:hover { background: var(--surface-overlay); }
html[data-theme="light"] .tb-muted { color: var(--text-secondary, #5c6570); }
html[data-theme="light"] .tb-pill,
html[data-theme="light"] .tb-pill-mini {
  background: rgba(110,97,172,0.12); color: #4a4080; border: 1px solid rgba(110,97,172,0.25);
}
html[data-theme="light"] .tb-mastery-bar { background: rgba(0,0,0,0.08); }
html[data-theme="light"] input, html[data-theme="light"] textarea, html[data-theme="light"] select {
  color: var(--text-primary); background: var(--surface-elevated); border-color: var(--border-strong);
}
html[data-theme="dark"] .tb-btn-ghost,
html[data-theme="dark"] .tb-btn-secondary {
  color: var(--text-primary); border-color: var(--border-subtle);
}
.tb-choice, .tb-block-quiz label { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 8px; }
.tb-choice:hover, .tb-block-quiz label:hover { background: var(--surface-elevated); }
@media (max-width: 860px) {
  .tb-continue-card, .tb-space-chip { min-width: 0; }
}

/* Auth + onboarding */
.tb-social-auth { display: grid; gap: 8px; margin: 12px 0; }
.tb-btn-social {
  width: 100%; border: 1px solid var(--tb-border, #334); background: var(--tb-elev, #111827);
  color: var(--tb-fg, #f8fafc); border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.tb-btn-social:disabled { opacity: 0.45; cursor: not-allowed; }
.tb-auth-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--tb-muted, #94a3b8); font-size: 12px; }
.tb-auth-divider::before, .tb-auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--tb-border, #334); }
.tb-onboarding-card { max-width: 420px; }
.tb-onboard-progress { font-size: 12px; color: var(--tb-muted, #94a3b8); margin-bottom: 8px; }
.tb-onboard-choice { width: 100%; margin: 6px 0; text-align: start; }
.tb-onboard-path-item {
  margin: 8px 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--tb-border, #334155); background: rgba(148,163,184,0.08);
}
.tb-onboard-path-item small { display: block; margin-top: 4px; }
.tb-home-path {
  margin: 12px 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(14,165,233,0.35); background: rgba(14,165,233,0.08);
}
.tb-home-path h3 { margin: 0 0 6px; font-size: 14px; }
.tb-home-path p { margin: 0; font-size: 13px; opacity: 0.9; }

/* ——— Official talk2know Agent (companion drawer; not permanent right column) ——— */
.tb-companion-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 10px 14px;
  background: #0f172a; color: #f8fafc; cursor: pointer;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
}
.tb-companion-fab-mark { color: #38bdf8; font-weight: 700; }
.tb-companion-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.35); z-index: 125;
}
.tb-companion-backdrop-passive {
  pointer-events: none !important; background: transparent;
}
.tb-companion-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100vw);
  z-index: 130; background: var(--tb-panel, #111827); color: var(--tb-text, #e5e7eb);
  display: flex; flex-direction: column; border-left: 1px solid var(--tb-border, #334155);
}
.tb-companion-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--tb-border, #334155); gap: 8px;
  flex-shrink: 0;
}
.tb-companion-head-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-companion-chat-title {
  display: block; font-size: 11px; color: var(--tb-muted, #94a3b8);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-companion-body {
  flex: 1; min-height: 0; display: flex; overflow: hidden;
}
.tb-companion-chat-list {
  width: min(200px, 42vw); flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--tb-border, #334155);
  padding: 8px; display: flex; flex-direction: column; gap: 4px;
  background: rgba(2, 6, 23, 0.35);
}
.tb-companion-chat-list.hidden { display: none !important; }
.tb-companion-chat-item {
  text-align: start; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; color: inherit; background: transparent; cursor: pointer;
  border: 1px solid transparent;
}
.tb-companion-chat-item:hover, .tb-companion-chat-item.is-active {
  background: rgba(14, 165, 233, 0.12); border-color: rgba(14, 165, 233, 0.35);
}
.tb-companion-chat-item small { display: block; opacity: 0.65; margin-top: 2px; font-size: 10px; }
.tb-companion-thread {
  flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0;
}
.tb-companion-badge {
  display: inline-block; margin-inline-start: 8px; font-size: 10px; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 999px; background: #0ea5e9; color: #082f49; font-weight: 700;
}
.tb-companion-messages { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
@media (max-width: 860px) {
  .tb-companion-drawer { width: 100vw; }
  .tb-companion-chat-list {
    position: absolute; inset: 52px 0 0 0; width: 100%; z-index: 2;
    background: var(--tb-panel, #111827);
  }
  .tb-companion-body { position: relative; }
}
.tb-companion-msg { padding: 10px 12px; border-radius: 12px; background: rgba(148, 163, 184, 0.12); }
.tb-companion-msg-assistant { border: 1px solid rgba(14, 165, 233, 0.35); }
.tb-companion-msg header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.tb-companion-compose {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 12px;
  border-top: 1px solid var(--tb-border, #334155);
}
.tb-companion-compose textarea {
  width: 100%; resize: none; border-radius: 10px; border: 1px solid var(--tb-border, #334155);
  background: transparent; color: inherit; padding: 8px;
}
.tb-companion-nav { margin-top: 8px; }
.tb-companion-listen { margin-top: 8px; margin-inline-start: 8px; font-size: 12px; padding: 4px 10px; }
.tb-companion-head-actions { display: flex; align-items: center; gap: 4px; }
.tb-companion-voice-state {
  display: inline-block; margin-inline-start: 8px; font-size: 10px; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 6px; background: rgba(56, 189, 248, 0.15); color: #7dd3fc;
}
.tb-companion-voice-hint { padding: 0 16px 8px; font-size: 12px; }
#companion-voice-btn.is-active { color: #f87171; box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.35); }
#companion-voice-mode.is-on { color: #38bdf8; }
.tb-companion-fab.is-listening { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.45); }
.tb-companion-fab.is-speaking { box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.45); }
.tb-companion-fab.is-processing { opacity: 0.92; }

/* Voice orb — ChatGPT-like vibrating circle */
.tb-voice-orb {
  position: fixed;
  left: 50%;
  bottom: max(96px, calc(18vh + env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  z-index: 140;
  width: 120px;
  height: 120px;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.tb-voice-orb.hidden { display: none !important; }
.tb-voice-orb-core {
  width: calc(52px + var(--voice-level, 0) * 28px);
  height: calc(52px + var(--voice-level, 0) * 28px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7dd3fc, #0ea5e9 45%, #0369a1 100%);
  box-shadow:
    0 0 calc(12px + var(--voice-level, 0) * 28px) rgba(14, 165, 233, 0.55),
    0 8px 28px rgba(2, 6, 23, 0.35);
  transition: width 0.08s linear, height 0.08s linear;
  animation: tb-orb-breathe 1.8s ease-in-out infinite;
}
.tb-voice-orb.is-user .tb-voice-orb-core {
  background: radial-gradient(circle at 35% 30%, #fda4af, #f43f5e 48%, #be123c 100%);
  box-shadow:
    0 0 calc(12px + var(--voice-level, 0) * 28px) rgba(244, 63, 94, 0.5),
    0 8px 28px rgba(2, 6, 23, 0.35);
}
.tb-voice-orb.is-wait .tb-voice-orb-core {
  background: radial-gradient(circle at 35% 30%, #c4b5fd, #8b5cf6 50%, #5b21b6 100%);
  animation: tb-orb-spin-soft 1.2s linear infinite;
}
.tb-voice-orb-ring {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.35);
  transform: scale(calc(0.85 + var(--voice-level, 0) * 0.55));
  opacity: calc(0.25 + var(--voice-level, 0) * 0.6);
  transition: transform 0.08s linear, opacity 0.08s linear;
}
.tb-voice-orb.is-user .tb-voice-orb-ring { border-color: rgba(244, 63, 94, 0.4); }
.tb-voice-orb-ring.r2 { inset: 8%; animation: tb-orb-ring 1.6s ease-out infinite; }
.tb-voice-orb-ring.r3 { inset: 0; animation: tb-orb-ring 1.6s ease-out infinite 0.35s; }
@keyframes tb-orb-breathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
@keyframes tb-orb-ring {
  0% { transform: scale(0.7); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes tb-orb-spin-soft {
  0% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(20deg) brightness(1.15); }
  100% { filter: hue-rotate(0deg) brightness(1); }
}
@media (max-width: 720px) {
  .tb-voice-orb {
    bottom: max(120px, calc(22vh + env(safe-area-inset-bottom)));
    width: 108px;
    height: 108px;
  }
}
@media (max-width: 720px) {
  .tb-companion-drawer {
    width: 100vw;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tb-companion-fab {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    min-height: 48px;
    padding: 12px 16px;
  }
  .tb-companion-compose {
    grid-template-columns: 44px 1fr 72px;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .tb-companion-compose textarea { font-size: 16px; min-height: 44px; }
  #companion-send { min-height: 44px; }
  .tb-login-card, .tb-settings-card, .tb-onboarding-card {
    width: min(100%, calc(100vw - 24px));
    margin: 16px auto;
    padding: 18px 16px;
  }
  #login-overlay, #onboarding-overlay {
    padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
    align-items: flex-start;
    overflow: auto;
  }
}
html[dir="rtl"] .tb-companion-drawer { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--tb-border, #334155); }
html[dir="rtl"] .tb-companion-fab { right: auto; left: 20px; }

/* Only block app while auth/onboarding overlays are visible (sibling ~ matched forever otherwise). */
#login-overlay:not(.hidden) ~ .tb-app,
#onboarding-overlay:not(.hidden) ~ .tb-app {
  pointer-events: none;
}

.tb-onboard-agent {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: rgba(14,165,233,0.12); border: 1px solid rgba(14,165,233,0.35); color: inherit;
}
.tb-onboarding-card { max-width: 440px; width: min(440px, 94vw); }
.tb-onboard-summary { text-align: start; font-size: 13px; margin: 8px 0; }
.tb-onboard-summary li { margin: 4px 0; }
