:root {
  --bg: #ffffff;
  --text: #11141d;
  --line: #dfe3ea;
  --line-strong: #0f1115;
  --user: #141923;
  --bot: #f3f5f9;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.logo-defs { position: absolute; }

.intro-gate {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(74, 35, 183, 0.35), transparent 55%),
    radial-gradient(circle at 50% 75%, rgba(122, 76, 246, 0.45), transparent 45%),
    #07071a;
  display: grid;
  place-items: center;
  color: #f8f7ff;
}
.intro-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(32px);
  opacity: .6;
  animation: floatOrb 7s ease-in-out infinite alternate;
}
.orb-a { width: 280px; height: 280px; background: rgba(104, 63, 243, 0.6); top: 7%; left: 10%; }
.orb-b { width: 360px; height: 360px; background: rgba(71, 123, 255, 0.45); right: 8%; top: 14%; animation-delay: .8s; }
.orb-c { width: 300px; height: 300px; background: rgba(180, 103, 255, 0.45); left: 35%; bottom: -50px; animation-delay: 1.6s; }
@keyframes floatOrb { from { transform: translateY(0) scale(1); } to { transform: translateY(-16px) scale(1.06); } }

.intro-card {
  position: relative;
  z-index: 2;
  width: min(760px, 92vw);
  text-align: center;
  padding: 40px 24px 34px;
  border-radius: 26px;
  border: 1px solid rgba(199, 180, 255, 0.35);
  background: linear-gradient(180deg, rgba(20, 19, 56, 0.78), rgba(10, 10, 34, 0.86));
  box-shadow: 0 30px 80px rgba(58, 39, 139, 0.45);
}
.intro-fish { width: min(300px, 62vw); height: auto; color: #f7f5ff; margin: 0 auto 8px; }
.intro-card h1 { margin: 0; font-size: clamp(2.7rem, 8vw, 5rem); letter-spacing: -0.04em; font-weight: 700; }
.intro-kicker { margin: 8px 0 8px; font-weight: 700; color: #d9ccff; }
.intro-copy { margin: 0 auto 20px; max-width: 620px; line-height: 1.55; color: #efeaff; }
.intro-lightbar {
  margin: 0 auto 22px;
  width: min(620px, 84%);
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(92, 74, 255, 0), #9f8cff, #5f9dff, rgba(92, 74, 255, 0));
  box-shadow: 0 0 26px rgba(140, 111, 255, 0.95), 0 0 44px rgba(95, 157, 255, 0.55);
  animation: pulseBeam 1.8s ease-in-out infinite alternate;
}
@keyframes pulseBeam { from { transform: scaleX(.94); opacity: .82; } to { transform: scaleX(1); opacity: 1; } }

.enter-app-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #6f3aff, #5f83ff);
  box-shadow: 0 14px 32px rgba(102, 74, 252, 0.45);
  cursor: pointer;
}
.enter-app-btn:hover { filter: brightness(1.06); }

.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}
.topbar,
.chat-area,
.thinking-toolbar,
.input-shell,
.model-menu,
.plus-menu {
  position: relative;
  z-index: 5;
}
.app > .topbar {
  z-index: 30;
}
.left-tools { position: relative; width: fit-content; }
.model-chip-wrap { display: flex; align-items: center; gap: 8px; }
.model-badge {
  font-size: .88rem;
  font-weight: 700;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
}
.icon-btn { border: none; background: transparent; padding: 0; cursor: pointer; }
.fish-logo { display: block; color: #0e1117; shape-rendering: geometricPrecision; }
.fish-logo.small { width: 64px; height: auto; }
.brand { justify-self: center; font-size: 1.95rem; font-weight: 650; letter-spacing: -0.03em; }
.right-tools {
  justify-self: end;
  display: flex;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}
.right-tools > * { flex-shrink: 1; }
.memory-btn,
.clear-btn {
  border: 1.7px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
}
.ui-inline-icon {
  width: 1.02rem;
  height: 1.02rem;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -0.16em;
}
.model-menu {
  position: absolute;
  top: 56px;
  left: 0;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(16,22,34,.14);
  padding: 6px;
  z-index: 20;
}
.model-option {
  width: 100%;
  border: 1px solid transparent;
  background: #f4f7fb;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  font-size: .95rem;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
}
.model-option.active { border-color: #11151d; }
.thinking-mode-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.thinking-mode-picker {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #faf8ff);
  color: #5b21b6;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(109, 40, 217, .09);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.thinking-mode-picker:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(109, 40, 217, .16);
}
.thinking-mode-picker.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #6d28d9, #9333ea);
}
.thinking-mode-picker:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.thinking-mode-icon {
  width: 16px;
  min-width: 16px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}
.thinking-mode-picker .css-gear-icon {
  --gear-hole: #fff;
  transform: scale(.68);
}
.thinking-mode-chevron {
  margin-left: 1px;
  font-size: .9rem;
  line-height: .8;
  transition: transform .18s ease;
}
.thinking-mode-picker[aria-expanded="true"] .thinking-mode-chevron { transform: rotate(180deg); }
.thinking-mode-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 218px;
  padding: 7px;
  border: 1px solid rgba(196, 181, 253, .8);
  border-radius: 15px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 44px rgba(76, 29, 149, .2);
  backdrop-filter: blur(16px);
  z-index: 35;
}
.thinking-mode-option {
  width: 100%;
  display: grid;
  grid-template-columns: 27px 1fr;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #312e81;
  text-align: left;
  cursor: pointer;
}
.thinking-mode-option:hover { background: #f5f3ff; }
.thinking-mode-option.active {
  border-color: #c4b5fd;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
}
.thinking-mode-option > span:last-child { display: grid; gap: 2px; }
.thinking-mode-option strong { font-size: .86rem; }
.thinking-mode-option small { color: #6b7280; font-size: .7rem; }
.thinking-mode-option-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 1rem;
}
.thinking-mode-option .css-gear-icon {
  --gear-core: #6d28d9;
  --gear-hole: #fff;
  transform: scale(.72);
}


.memory-toast {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #f5f3ff;
  background: linear-gradient(90deg, #6d28d9, #7c3aed, #a855f7);
  box-shadow:
    0 0 0 1px rgba(196, 181, 253, 0.7),
    0 0 26px rgba(168, 85, 247, 0.75),
    0 0 46px rgba(124, 58, 237, 0.45);
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .01em;
  animation: memoryGlow 1.2s ease-in-out infinite alternate;
}
.balos-notice {
  position: fixed;
  inset: 0;
  z-index: 340;
  display: grid;
  place-items: start center;
  padding-top: 92px;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);
}
.balos-notice.hidden { display: none !important; }
.balos-notice-card {
  width: min(420px, calc(100vw - 28px));
  padding: 18px 18px 16px;
  border-radius: 22px;
  border: 1px solid rgba(167, 139, 250, 0.55);
  background: linear-gradient(180deg, rgba(18, 18, 40, 0.96), rgba(34, 20, 68, 0.96));
  color: #f5f3ff;
  box-shadow: 0 24px 70px rgba(76, 29, 149, 0.4), 0 0 0 1px rgba(196, 181, 253, 0.18) inset;
  animation: balosNoticeFloat .45s ease;
}
.balos-notice-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.balos-notice-card strong {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 6px;
}
.balos-notice-card p {
  margin: 0 0 14px;
  line-height: 1.55;
  color: #ddd6fe;
}
.balos-notice-card button {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(90deg, #7c3aed, #8b5cf6, #6366f1);
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.36);
  cursor: pointer;
}
@keyframes balosNoticeFloat {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.agent-intro-notice {
  position: fixed;
  inset: 0;
  z-index: 360;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, .58);
  backdrop-filter: blur(12px);
}
.agent-intro-notice.hidden { display: none !important; }
.agent-intro-card {
  width: min(620px, calc(100vw - 28px));
  border-radius: 20px;
  border: 1px solid rgba(125, 211, 252, .42);
  background: linear-gradient(145deg, rgba(15, 23, 42, .98), rgba(17, 24, 39, .98));
  color: #f8fafc;
  box-shadow: 0 32px 90px rgba(2, 6, 23, .52);
  overflow: hidden;
  animation: agentIntroIn .42s ease;
}
.agent-thumb {
  height: 190px;
  position: relative;
  background:
    linear-gradient(130deg, rgba(20, 184, 166, .24), transparent 38%),
    linear-gradient(230deg, rgba(124, 58, 237, .26), transparent 42%),
    #08111f;
  display: grid;
  place-items: center;
}
.agent-thumb-browser {
  width: min(420px, 78%);
  height: 128px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .32);
  background: rgba(15, 23, 42, .82);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
  position: relative;
  overflow: hidden;
}
.agent-thumb-browser > span {
  position: absolute;
  top: 13px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
}
.agent-thumb-browser > span:nth-child(1) { left: 14px; background: #fb7185; }
.agent-thumb-browser > span:nth-child(2) { left: 30px; background: #facc15; }
.agent-thumb-browser > span:nth-child(3) { left: 46px; background: #34d399; }
.agent-thumb-url {
  position: absolute;
  left: 72px;
  right: 18px;
  top: 10px;
  height: 16px;
  border-radius: 999px;
  background: rgba(226, 232, 240, .12);
}
.agent-thumb-url::after {
  content: "https://";
  position: absolute;
  left: 12px;
  top: 2px;
  font-size: .58rem;
  color: rgba(226, 232, 240, .62);
}
.agent-thumb-scan {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 48px;
  bottom: 18px;
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(20, 184, 166, .28) 0 18%, transparent 18% 24%, rgba(59, 130, 246, .22) 24% 55%, transparent 55% 62%, rgba(168, 85, 247, .2) 62% 100%),
    repeating-linear-gradient(180deg, rgba(248, 250, 252, .18), rgba(248, 250, 252, .18) 2px, transparent 2px, transparent 13px);
}
.agent-thumb-scan::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(125, 211, 252, .5), transparent);
  animation: agentScanThumb 1.8s ease-in-out infinite;
}
.agent-thumb-mark {
  position: absolute;
  right: 74px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #ccfbf1;
  background: rgba(15, 23, 42, .88);
  border: 1px solid rgba(94, 234, 212, .38);
  font-weight: 900;
  box-shadow: 0 18px 44px rgba(20, 184, 166, .22);
}
.agent-intro-copy {
  padding: 20px 22px 8px;
}
.agent-intro-copy span {
  color: #5eead4;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.agent-intro-copy strong {
  display: block;
  margin-top: 7px;
  font-size: 1.35rem;
}
.agent-intro-copy p {
  margin: 8px 0 0;
  color: #cbd5e1;
  line-height: 1.58;
}
.agent-intro-actions {
  display: flex;
  gap: 10px;
  padding: 14px 22px 22px;
}
.agent-intro-actions button {
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}
#agentTryNowBtn {
  color: #022c22;
  background: linear-gradient(90deg, #5eead4, #93c5fd);
  border-color: transparent;
}
#agentLaterBtn {
  color: #e2e8f0;
  background: rgba(15, 23, 42, .72);
}
@keyframes agentIntroIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes agentScanThumb {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.agent-virtual-desktop {
  position: fixed;
  inset: 86px 18px 96px;
  z-index: 280;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.agent-virtual-desktop.hidden { display: none !important; }
.agent-desktop-window {
  width: min(860px, 96vw);
  height: min(520px, calc(100vh - 170px));
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, .36);
  background: #08111f;
  box-shadow: 0 34px 90px rgba(2, 6, 23, .4);
  pointer-events: auto;
}
.agent-window-bar {
  height: 48px;
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: linear-gradient(180deg, #111827, #0f172a);
  border-bottom: 1px solid rgba(148, 163, 184, .18);
}
.agent-window-dots {
  display: flex;
  gap: 6px;
}
.agent-window-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fb7185;
}
.agent-window-dots span:nth-child(2) { background: #facc15; }
.agent-window-dots span:nth-child(3) { background: #34d399; }
.agent-address-bar {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(248, 250, 252, .08);
  color: #cbd5e1;
  font-size: .82rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.agent-browser-body {
  position: relative;
  height: calc(100% - 86px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(236, 253, 245, .96), rgba(240, 249, 255, .96)),
    #f8fafc;
}
.agent-search-stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 38%, rgba(20, 184, 166, .18), transparent 34%),
    linear-gradient(180deg, #f8fafc, #e0f2fe);
  transition: opacity .55s ease, transform .55s ease;
}
.agent-virtual-desktop[data-live="1"] .agent-search-stage {
  opacity: 0;
  transform: translateY(-18px) scale(.98);
  pointer-events: none;
}
.agent-search-logo {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #0f766e;
  background: #ffffff;
  border: 1px solid rgba(20, 184, 166, .34);
  font-weight: 900;
  box-shadow: 0 18px 44px rgba(20, 184, 166, .2);
}
.agent-search-title {
  display: grid;
  place-items: center;
  gap: 3px;
  color: #0f172a;
  text-align: center;
}
.agent-search-title strong {
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  letter-spacing: -.04em;
}
.agent-search-title span {
  color: #0f766e;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.agent-search-box {
  width: min(520px, 78%);
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-radius: 999px;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid rgba(14, 165, 233, .42);
  box-shadow: 0 18px 45px rgba(14, 165, 233, .16);
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.agent-search-hint {
  color: #0f766e;
  font-weight: 900;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.agent-live-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
  opacity: 0;
  transform: scale(.985);
  transition: opacity .55s ease, transform .55s ease;
}
.agent-live-frame.visible {
  opacity: .72;
  transform: scale(1);
}
.agent-page-skeleton {
  position: absolute;
  inset: 28px;
  z-index: 2;
  animation: agentPageScroll 7.2s ease-in-out infinite;
  transition: opacity .45s ease;
}
.agent-virtual-desktop[data-live="1"] .agent-page-skeleton {
  opacity: .62;
}
.agent-page-hero {
  height: 96px;
  border-radius: 16px;
  background: linear-gradient(100deg, #0f766e, #2563eb);
  margin-bottom: 22px;
}
.agent-page-lines {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}
.agent-page-lines span {
  height: 12px;
  border-radius: 999px;
  background: #cbd5e1;
}
.agent-page-lines span:nth-child(1) { width: 72%; }
.agent-page-lines span:nth-child(2) { width: 90%; }
.agent-page-lines span:nth-child(3) { width: 64%; }
.agent-page-lines span:nth-child(4) { width: 82%; }
.agent-page-lines span:nth-child(5) { width: 52%; }
.agent-page-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.agent-page-grid span {
  height: 98px;
  border-radius: 14px;
  background: rgba(14, 165, 233, .16);
  border: 1px solid rgba(14, 165, 233, .22);
}
.agent-scan-beam {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.agent-scan-beam.run {
  opacity: 1;
}
.agent-scan-beam::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -18%;
  height: 18%;
  background: linear-gradient(180deg, transparent, rgba(20, 184, 166, .32), transparent);
  animation: agentBeamMove 1.9s ease-in-out infinite;
}
.agent-cursor {
  position: absolute;
  left: 22%;
  top: 18%;
  width: 18px;
  height: 24px;
  z-index: 4;
  filter: drop-shadow(0 8px 10px rgba(2, 6, 23, .28));
  transition: left 1.1s ease, top 1.1s ease, transform .5s ease;
}
.agent-cursor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #0f172a;
  clip-path: polygon(0 0, 0 100%, 36% 74%, 56% 100%, 78% 89%, 58% 62%, 100% 62%);
}
.agent-cursor::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 0;
  height: 0;
  border-radius: 999px;
  background: rgba(20, 184, 166, .35);
}
.agent-cursor.pulse::after {
  animation: agentCursorPulse .7s ease-out;
}
.agent-virtual-desktop[data-phase="boot"] .agent-cursor { left: 18%; top: 22%; }
.agent-virtual-desktop[data-phase="newtab"] .agent-cursor { left: 32%; top: 12%; }
.agent-virtual-desktop[data-phase="search"] .agent-cursor { left: 50%; top: 47%; transform: scale(.96); }
.agent-virtual-desktop[data-phase="address"] .agent-cursor { left: 43%; top: 8%; transform: scale(.92); }
.agent-virtual-desktop[data-phase="enter"] .agent-cursor { left: 72%; top: 9%; }
.agent-virtual-desktop[data-phase="clickHero"] .agent-cursor { left: 50%; top: 28%; transform: scale(1); }
.agent-virtual-desktop[data-phase="clickText"] .agent-cursor { left: 34%; top: 52%; }
.agent-virtual-desktop[data-phase="scroll"] .agent-cursor { left: 82%; top: 64%; transform: rotate(8deg); }
.agent-virtual-desktop[data-phase="cards"] .agent-cursor { left: 58%; top: 74%; transform: rotate(-4deg); }
.agent-virtual-desktop[data-phase="done"] .agent-cursor { left: 88%; top: 18%; transform: scale(.96); }
.agent-desktop-status {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: #ccfbf1;
  background: #0f172a;
  border-top: 1px solid rgba(148, 163, 184, .18);
  font-weight: 800;
}
@keyframes agentBeamMove {
  from { transform: translateY(0); }
  to { transform: translateY(720%); }
}
@keyframes agentPageScroll {
  0%, 22% { transform: translateY(0); }
  38%, 58% { transform: translateY(-64px); }
  76%, 100% { transform: translateY(-126px); }
}
@keyframes agentCursorPulse {
  0% { width: 0; height: 0; opacity: .85; transform: translate(-50%, -50%); }
  100% { width: 52px; height: 52px; opacity: 0; transform: translate(-50%, -50%); }
}

@media (max-width: 700px) {
  .agent-virtual-desktop {
    inset: 78px 8px 92px;
  }
  .agent-desktop-window {
    height: min(500px, calc(100vh - 160px));
  }
  .agent-intro-actions {
    flex-direction: column;
  }
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f5d0fe;
  box-shadow: 0 0 12px rgba(245, 208, 254, 0.95);
}
@keyframes memoryGlow {
  from { box-shadow: 0 0 0 1px rgba(196, 181, 253, 0.65), 0 0 20px rgba(168, 85, 247, 0.65), 0 0 36px rgba(124, 58, 237, 0.4); }
  to { box-shadow: 0 0 0 1px rgba(216, 180, 254, 0.85), 0 0 30px rgba(192, 132, 252, 0.9), 0 0 56px rgba(147, 51, 234, 0.55); }
}

.memory-panel {
  position: fixed;
  top: 82px;
  right: 16px;
  width: min(340px, 92vw);
  max-height: 62vh;
  overflow: auto;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 12px;
}
.memory-panel h3 { margin: 2px 0 8px; }
.memory-hint { margin: 0 0 10px; color: #475569; font-size: .9rem; }
#memoryList { margin: 0 0 10px; padding-left: 18px; }
#memoryList li { margin-bottom: 6px; }
#clearMemory {
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
}

.chat-area { flex: 1; overflow-y: auto; padding: 16px 18px; }
.splash {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-bottom: 8vh;
  transform: translateY(-22px);
}
.fish-logo.big { width: min(520px, 76vw); height: auto; }
.splash h1 { margin: 6px 0 0; font-size: clamp(2.5rem, 7vw, 5.2rem); font-weight: 650; letter-spacing: -0.04em; }
.splash-prompt {
  margin: 12px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  color: #c026d3;
  text-shadow: 0 0 10px rgba(217, 70, 239, .65), 0 0 20px rgba(168, 85, 247, .45);
  animation: neonPromptFlow 2.2s linear infinite;
  background: linear-gradient(90deg, #d946ef, #a855f7, #c026d3, #d946ef);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@keyframes neonPromptFlow {
  from { background-position: 0% 50%; filter: drop-shadow(0 0 5px rgba(192,38,211,.55)); }
  to { background-position: 220% 50%; filter: drop-shadow(0 0 10px rgba(217,70,239,.75)); }
}
.chat-log { display: flex; flex-direction: column; gap: 10px; max-width: 980px; margin: 0 auto; width: 100%; }
.msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: min(72%, 820px);
  white-space: pre-wrap;
  line-height: 1.45;
}
.msg.user { margin-left: auto; background: var(--user); color: #fff; }
.msg.bot { margin-right: auto; background: var(--bot); }

.input-shell {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
#userInput {
  width: 100%;
  border: 1.8px solid var(--line-strong);
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 1rem;
}
#userInput:focus { outline: none; box-shadow: 0 0 0 3px rgba(17,21,29,.08); }
.thinking-image-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  border: 1px solid #d8b4fe;
  border-radius: 12px;
  padding: 8px;
  background: #faf5ff;
}
.thinking-image-preview img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #c4b5fd;
}
.thinking-image-meta {
  display: grid;
  gap: 2px;
}
.thinking-image-meta strong { font-size: .86rem; color: #5b21b6; }
.thinking-image-meta span { font-size: .78rem; color: #6b7280; }
.thinking-image-preview button {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #c4b5fd;
  background: #fff;
  color: #6d28d9;
  cursor: pointer;
}
.input-shell button[type="submit"] {
  width: 48px;
  height: 48px;
  border: 1.8px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  color: #131821;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.input-shell button svg { width: 21px; height: 21px; }
.thinking-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 12px;
  position: relative;
}
.thinking-toggle-btn {
  border: 1px solid #c4b5fd;
  background: #fff;
  color: #6d28d9;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}
.css-gear-icon {
  --gear-core: currentColor;
  --gear-hole: #fff;
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gear-core);
  box-shadow:
    0 -9.5px 0 -5px var(--gear-core),
    0 9.5px 0 -5px var(--gear-core),
    9.5px 0 0 -5px var(--gear-core),
    -9.5px 0 0 -5px var(--gear-core),
    6.8px 6.8px 0 -5px var(--gear-core),
    -6.8px 6.8px 0 -5px var(--gear-core),
    6.8px -6.8px 0 -5px var(--gear-core),
    -6.8px -6.8px 0 -5px var(--gear-core);
}
.css-gear-icon::before {
  content: "";
  position: absolute;
  inset: 3.5px;
  border-radius: 50%;
  background: var(--gear-hole);
}
.css-gear-icon::after {
  content: "";
  position: absolute;
  inset: 6.5px;
  border-radius: 50%;
  background: var(--gear-core);
}
.thinking-button-gear {
  --gear-hole: #fff;
  transform: scale(.78);
}
.thinking-toggle-btn.active .thinking-button-gear {
  --gear-hole: #7c3aed;
}
.thinking-toggle-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(109, 40, 217, .12);
}
.thinking-toggle-btn.active {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(109, 40, 217, .28);
}
.thinking-toggle-btn.locked,
.thinking-toggle-btn:disabled {
  opacity: .58;
  cursor: not-allowed;
  box-shadow: none;
}
.thinking-quota-text {
  font-size: .88rem;
  color: #6b7280;
}
.thinking-promo-bubble {
  position: absolute;
  left: 12px;
  bottom: calc(100% + 8px);
  width: min(420px, calc(100vw - 32px));
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  border-radius: 14px;
  padding: 10px 36px 10px 12px;
  box-shadow: 0 14px 30px rgba(124, 58, 237, .32);
  border: 1px solid rgba(255,255,255,.25);
}
.thinking-promo-bubble::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 100%;
  border: 8px solid transparent;
  border-top-color: #9333ea;
}
.thinking-promo-bubble p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.35;
  font-weight: 600;
}
.thinking-promo-bubble button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: #6d28d9;
  cursor: pointer;
  font-weight: 800;
}
.thinking-limit-banner {
  margin: 0 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(192, 132, 252, .45);
  background: linear-gradient(135deg, rgba(248, 250, 252, .98), rgba(250, 245, 255, .96));
  box-shadow: 0 16px 38px rgba(109, 40, 217, .12);
}
.thinking-limit-copy strong {
  display: block;
  color: #4c1d95;
  margin-bottom: 4px;
}
.thinking-limit-copy p {
  margin: 0;
  color: #6b7280;
  font-size: .92rem;
}
.thinking-limit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.thinking-unlock-btn,
.thinking-upgrade-btn {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}
.thinking-unlock-btn {
  border: 1px solid #d8b4fe;
  background: #fff;
  color: #6d28d9;
}
.thinking-upgrade-btn {
  border: 1px solid transparent;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  box-shadow: 0 14px 30px rgba(124, 58, 237, .25);
}

.plus-area { position: relative; }
.plus-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1.8px solid #6d28d9;
  background: #f4efff; font-size: 1.45rem; font-weight: 700; cursor: pointer; color: #5b21b6;
}
.plus-menu {
  position: absolute; bottom: 52px; left: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; min-width: 220px; box-shadow: 0 10px 25px rgba(16,22,34,.14);
  z-index: 35;
}
.image-mode-label { font-size: .92rem; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.agent-mode-btn {
  width: 100%;
  border: 1px solid rgba(20, 184, 166, .42);
  border-radius: 12px;
  padding: 9px 10px;
  background: linear-gradient(135deg, #ecfeff, #f8fafc);
  color: #0f172a;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.agent-mode-btn.active {
  border-color: #14b8a6;
  box-shadow: 0 12px 26px rgba(20, 184, 166, .18);
}
.agent-mode-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #0f766e;
  background: #ffffff;
  border: 1px solid rgba(20, 184, 166, .38);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.8);
}
.agent-core {
  font-size: .8rem;
  font-weight: 900;
  line-height: 1;
}
.agent-orbit {
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  border: 1px dashed rgba(14, 165, 233, .75);
  animation: agentOrbit 2.2s linear infinite;
}
@keyframes agentOrbit { to { transform: rotate(360deg); } }

.model-option-2 {
  border-color: #d1d5db;
  color: #1f2937;
  background: #ffffff;
  animation: none;
}


.balle-mode-label {
  position: relative;
  overflow: hidden;
  border: 1px solid #f0abfc;
  border-radius: 12px;
  padding: 8px 10px;
  background: linear-gradient(125deg, rgba(250,245,255,.98), rgba(243,232,255,.92), rgba(254,242,242,.95));
  box-shadow: 0 10px 25px rgba(168,85,247,.18);
}
.balle-mode-label::after {
  content: "";
  position: absolute;
  inset: -40% -20%;
  background: radial-gradient(circle at 20% 30%, rgba(34,197,94,.30) 0 8%, transparent 9%),
              radial-gradient(circle at 75% 30%, rgba(250,204,21,.34) 0 7%, transparent 8%),
              radial-gradient(circle at 32% 72%, rgba(239,68,68,.28) 0 7%, transparent 8%),
              radial-gradient(circle at 84% 72%, rgba(168,85,247,.34) 0 8%, transparent 9%);
  animation: balleBubbleDrift 7s linear infinite;
  pointer-events: none;
}


.balle-generate-btn {
  border: none;
  min-width: 232px;
  height: 48px;
  border-radius: 14px;
  font-weight: 900;
  color: #fff;
  letter-spacing: .01em;
  cursor: pointer;
  background: linear-gradient(120deg, #22c55e, #facc15, #a855f7, #ef4444, #22c55e);
  background-size: 300% 100%;
  animation: balleBtnGlow 2.8s linear infinite;
  box-shadow: 0 10px 30px rgba(168,85,247,.28), 0 0 0 1px rgba(255,255,255,.35) inset;
}
.balle-generate-btn:disabled { opacity: .65; cursor: not-allowed; }

@keyframes balleBtnGlow {
  0% { background-position: 0% 50%; filter: saturate(1); }
  50% { filter: saturate(1.2); }
  100% { background-position: 220% 50%; filter: saturate(1); }
}

.balle-result-wrap {
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #c4b5fd;
  position: relative;
  background: #f8fafc;
}
.balle-result-wrap img {
  width: 100%;
  display: block;
  max-height: min(56vh, 440px);
  object-fit: cover;
}
.balle-banner {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .92rem;
  color: #fff;
  background: rgba(15, 23, 42, .45);
  border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(3px);
}

@media (max-width: 700px) {
  .balle-generate-btn { min-width: 0; width: 100%; }
}



@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
  position: fixed; top: 82px; right: 16px; width: min(480px, 94vw); max-height: 72vh; overflow: auto;
  z-index: 55; background: #f8fbff; border: 1px solid #93c5fd; border-radius: 14px;
  box-shadow: 0 16px 36px rgba(30, 64, 175, .16); padding: 12px;
}
.math-studio-panel h3 { margin: 0 0 8px; color: #1e40af; }
.math-studio-panel p { margin: 0 0 10px; font-size: .9rem; color: #334155; }
.math-studio-input {
  min-height: 110px; border: 1.5px solid #93c5fd; border-radius: 10px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff;
  white-space: pre-wrap;
}
.math-studio-output { margin-top: 10px; display: grid; gap: 8px; }
.math-result {
  background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; border-radius: 10px; padding: 8px 10px;
  font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}


.account-icon-btn {
  width: 40px;
  min-width: 40px;
  flex: 0 0 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.account-panel {
  position: fixed;
  top: 82px;
  right: 16px;
  width: min(360px, 94vw);
  max-height: 74vh;
  overflow: auto;
  z-index: 56;
  background: #f8fbff;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(30, 64, 175, .15);
  padding: 12px;
}
.account-panel h3 { margin: 0 0 10px; color: #1e3a8a; }
.account-row { display: grid; gap: 6px; margin-bottom: 10px; }
.account-row label { font-size: .86rem; color: #334155; font-weight: 700; }
.account-row input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: .92rem;
}
.account-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbeafe;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}
.account-preview img {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  object-fit: cover;
  background: #eef2ff;
}
.account-panel button {
  width: 100%;
  border: 1px solid #bfdbfe;
  background: linear-gradient(180deg, #ffffff, #eff6ff);
  color: #1e3a8a;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}
.account-panel button:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  box-shadow: 0 8px 16px rgba(37, 99, 235, .12);
}
#saveAccount {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #e0f2fe, #bfdbfe);
}
#persistBrowserAccount {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4, #bbf7d0);
  color: #14532d;
}
#logoutAccount {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb, #fde68a);
  color: #713f12;
}
#deleteAccount {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff1f2, #fecdd3);
  color: #881337;
}
.account-settings { margin-top: 10px; }
.account-settings summary { cursor: pointer; font-weight: 700; color: #1e40af; }
.account-settings p { font-size: .86rem; color: #334155; }

.profanity-lock {
  position: fixed; inset: 0; z-index: 400; display: grid; place-content: center; text-align: center;
  gap: 10px; background: rgba(20, 0, 0, .7); backdrop-filter: blur(3px); color: #fff;
}
.profanity-lock h3 { margin: 0; color: #fecaca; font-size: 1.4rem; }
.profanity-lock input {
  width: min(260px, 80vw); margin: 0 auto; padding: 10px 12px; border-radius: 10px; border: 1px solid #ef4444;
}
.profanity-lock button {
  border: none; border-radius: 10px; padding: 10px 14px; background: #ef4444; color: #fff; font-weight: 700; cursor: pointer;
}

.app.math-mode .fish-logo,
.app.math-mode .brand { color: #1d4ed8; }
.app.math-mode .model-badge { border-color: #1d4ed8; color: #1d4ed8; }
.app.math-mode .memory-btn,
.app.math-mode .clear-btn,
.app.math-mode .plus-btn { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }

.hidden { display: none !important; pointer-events: none !important; }

.thinking-bubble {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  box-shadow: 0 14px 34px rgba(99, 102, 241, 0.12);
}
.thinking-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #1e293b;
}
.thinking-head span {
  font-size: 1.08rem;
  letter-spacing: .01em;
}
.think-fish { width: 40px; height: auto; }
.thinking-head-deep { gap: 14px; }
.thinking-status-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 38px;
}
.think-fish-stage {
  position: relative;
  width: 72px;
  min-width: 72px;
  height: 38px;
}
.think-fish-static {
  position: absolute;
  left: 0;
  top: 2px;
  width: 48px;
}
.think-gear-bubble {
  position: absolute;
  left: 30px;
  top: -4px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  border: 1px solid rgba(129, 140, 248, 0.45);
  box-shadow: 0 10px 24px rgba(91, 33, 182, 0.16);
  animation: thinkGearLaunch 1.7s ease-in-out infinite;
}
.think-gear-bubble::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(129, 140, 248, 0.18);
}
.thinking-cog-icon {
  --gear-core: #5b21b6;
  --gear-hole: #f7f7ff;
  animation: spinCogSmall 1.7s linear infinite;
}
.spin-fast { animation: spinFishFast 1s linear infinite; }
@keyframes spinFishFast { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes thinkGearLaunch {
  0% { transform: translate(0, 7px) scale(.82); opacity: 0; }
  16% { transform: translate(6px, 0) scale(1); opacity: 1; }
  58% { transform: translate(22px, -1px) scale(1); opacity: 1; }
  100% { transform: translate(34px, -6px) scale(.88); opacity: 0; }
}
@keyframes spinCog {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes spinCogSmall {
  from { transform: scale(.72) rotate(0deg); }
  to { transform: scale(.72) rotate(360deg); }
}
.thinking-answer { margin-top: 8px; white-space: pre-wrap; }
.thinking-live-note {
  margin-top: 8px;
  color: rgba(109, 40, 217, .72);
  font-size: 1rem;
  line-height: 1.72;
  min-height: 3.5em;
}
.thinking-live-sources,
.thinking-detail-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.thinking-source-chip {
  border: 1px solid rgba(167, 139, 250, .45);
  background: rgba(255, 255, 255, .92);
  color: #6d28d9;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
}
.thinking-details {
  margin-top: 14px;
  border-top: 1px dashed rgba(167, 139, 250, .55);
  padding-top: 10px;
}
.thinking-details summary {
  cursor: pointer;
  color: #6d28d9;
  font-weight: 800;
}
.thinking-details ol {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #475569;
}
.thinking-details li + li { margin-top: 8px; }
.thinking-details p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: .96rem;
  line-height: 1.68;
}

@media (max-width: 700px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 8px 10px;
  }
  .brand { font-size: 1.2rem; justify-self: center; }
  .model-chip-wrap { gap: 4px; }
  .fish-logo.small { width: 46px; }
  .model-badge { padding: 3px 7px; font-size: .72rem; }
  .thinking-mode-picker { min-height: 27px; padding: 4px 7px; gap: 5px; font-size: .7rem; }
  .thinking-mode-chevron { display: none; }
  .thinking-mode-menu { width: 205px; }
  .right-tools { gap: 4px; }
  .memory-btn, .clear-btn { padding: 6px 7px; font-size: .72rem; }
  #clearChat { max-width: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #memoryToggle { max-width: 62px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thinking-toolbar,
  .thinking-limit-banner,
  .thinking-limit-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .thinking-limit-actions > * { width: 100%; }
  .account-icon-btn { width: 34px; min-width: 34px; height: 34px; }
  .account-panel {
    width: 96vw;
    right: 2vw;
    top: 76px;
    max-height: 78vh;
  }
  .memory-toast { width: calc(100vw - 20px); max-width: 420px; text-align: center; justify-content: center; }
  .msg { max-width: 90%; }
}


.plus-area { position: relative; }
.plus-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1.8px solid #6d28d9;
  background: #f4efff; font-size: 1.45rem; font-weight: 700; cursor: pointer; color: #5b21b6;
}
.plus-menu {
  position: absolute; bottom: 52px; left: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; min-width: 220px; box-shadow: 0 10px 25px rgba(16,22,34,.14);
  z-index: 35;
}
.image-mode-label { font-size: .92rem; font-weight: 600; display: flex; gap: 8px; align-items: center; }



@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
  position: fixed; top: 82px; right: 16px; width: min(480px, 94vw); max-height: 72vh; overflow: auto;
  z-index: 55; background: #f8fbff; border: 1px solid #93c5fd; border-radius: 14px;
  box-shadow: 0 16px 36px rgba(30, 64, 175, .16); padding: 12px;
}
.math-studio-panel h3 { margin: 0 0 8px; color: #1e40af; }
.math-studio-panel p { margin: 0 0 10px; font-size: .9rem; color: #334155; }
.math-studio-input {
  min-height: 110px; border: 1.5px solid #93c5fd; border-radius: 10px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff;
  white-space: pre-wrap;
}
.math-studio-output { margin-top: 10px; display: grid; gap: 8px; }
.math-result {
  background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; border-radius: 10px; padding: 8px 10px;
  font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}


.profanity-lock {
  position: fixed; inset: 0; z-index: 400; display: grid; place-content: center; text-align: center;
  gap: 10px; background: rgba(20, 0, 0, .7); backdrop-filter: blur(3px); color: #fff;
}
.profanity-lock h3 { margin: 0; color: #fecaca; font-size: 1.4rem; }
.profanity-lock input {
  width: min(260px, 80vw); margin: 0 auto; padding: 10px 12px; border-radius: 10px; border: 1px solid #ef4444;
}
.profanity-lock button {
  border: none; border-radius: 10px; padding: 10px 14px; background: #ef4444; color: #fff; font-weight: 700; cursor: pointer;
}

.app.math-mode .fish-logo,
.app.math-mode .brand { color: #1d4ed8; }
.app.math-mode .model-badge { border-color: #1d4ed8; color: #1d4ed8; }
.app.math-mode .memory-btn,
.app.math-mode .clear-btn,
.app.math-mode .plus-btn { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }

.hidden { display: none !important; pointer-events: none !important; }
.enter-transition.hidden { display: none !important; }
.enter-transition {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 44%, rgba(125, 94, 250, 0.26), rgba(10, 10, 31, 0.9) 58%), #07071a;
}
.transition-blur {
  position: absolute;
  inset: -40px;
  backdrop-filter: blur(6px);
  background: radial-gradient(circle at 50% 60%, rgba(114, 83, 246, 0.26), transparent 52%);
  animation: transitionFog 1.8s ease-out forwards;
}
@keyframes transitionFog {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0px); }
}
.transition-logo-wrap {
  position: relative;
  text-align: center;
  color: #f7f5ff;
  opacity: 0;
  transform: translateY(14px) scale(.96);
  animation: logoReveal 2.4s ease-out .35s forwards;
}
@keyframes logoReveal {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.transition-fish { width: min(320px, 68vw); height: auto; color: #ffffff; margin: 0 auto 10px; }
.transition-logo-wrap h2 {
  margin: 0;
  font-size: clamp(2.8rem, 9vw, 6.2rem);
  letter-spacing: -0.04em;
  text-shadow: 0 0 18px rgba(188, 171, 255, 0.7), 0 0 40px rgba(122, 103, 255, 0.45);
}
.transition-drop {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f3edff, #a68cff 70%);
  box-shadow: 0 0 16px rgba(173, 143, 255, 0.95);
  transform: translateX(-50%);
  animation: dropFall 2.9s ease-in .65s forwards;
}
@keyframes dropFall {
  0% { opacity: 0; transform: translate(-50%, -28px) scale(.7); }
  16% { opacity: 1; }
  72% { opacity: 1; transform: translate(-50%, 170px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 210px) scale(.45); }
}
.transition-vapor {
  position: absolute;
  left: 50%;
  top: 170px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(205, 187, 255, .88), rgba(170, 138, 255, .35), transparent 70%);
  transform: translateX(-50%) scale(.3);
  filter: blur(1px);
  opacity: 0;
  animation: vaporRise 3.2s ease-out 1.65s forwards;
}
@keyframes vaporRise {
  0% { opacity: 0; transform: translateX(-50%) translateY(0) scale(.25); filter: blur(0px); }
  22% { opacity: .95; transform: translateX(-50%) translateY(-6px) scale(1.7); filter: blur(2px); }
  58% { opacity: .6; transform: translateX(-50%) translateY(-32px) scale(2.6); filter: blur(5px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-64px) scale(3.4); filter: blur(7px); }
}
.transition-beam {
  margin: 16px auto 0;
  width: min(640px, 84vw);
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(102, 74, 255, 0), #a58bff, #6fa8ff, rgba(102, 74, 255, 0));
  box-shadow: 0 0 20px rgba(161, 132, 255, 0.95), 0 0 46px rgba(95, 157, 255, 0.55);
  animation: beamFlash 2.6s ease-out 1.4s forwards;
  opacity: 0;
}
@keyframes beamFlash {
  0% { opacity: 0; transform: scaleX(.72); }
  45% { opacity: 1; transform: scaleX(1.03); }
  100% { opacity: .95; transform: scaleX(1); }
}

/* math-mode refresh */
.math-mode-label {
  padding: 8px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  font-size: 1.02rem;
  font-weight: 800;
}
.math-mode-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dbeafe, #bfdbfe);
  border: 1px solid #93c5fd;
}



@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
  width: min(52vw, 760px);
  height: calc(100vh - 102px);
  max-height: none;
  overflow: hidden;
  background: linear-gradient(180deg, #f8fdff, #eef8ff);
  border: 1px solid #a5d8ff;
  box-shadow: 0 16px 38px rgba(56, 189, 248, .28), inset 0 0 0 1px rgba(147, 197, 253, .3);
}
.math-studio-panel p { font-size: .95rem; }
.math-studio-input {
  height: calc(100% - 86px);
  min-height: 260px;
  padding: 16px;
  font-size: 1.04rem;
  line-height: 1.75;
  color: #0f172a;
  border: 1.8px solid #7dd3fc;
  background:
    repeating-linear-gradient(180deg, rgba(59,130,246,0.06), rgba(59,130,246,0.06) 1px, transparent 1px, transparent 30px),
    #ffffff;
  caret-color: #2563eb;
}
.math-studio-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(56, 189, 248, .28); }
.math-studio-input .calc-answer,
.math-studio-input { color: #0f172a; }

.math-mode-flash {
  position: fixed;
  inset: 0;
  z-index: 330;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(125, 211, 252, .3), rgba(14, 116, 255, .06) 45%, transparent 70%);
  animation: mathFlashFade 1.05s ease-out forwards;
}
.math-flash-ring {
  width: min(58vw, 520px);
  height: min(58vw, 520px);
  border-radius: 50%;
  border: 2px solid rgba(125, 211, 252, .95);
  box-shadow: 0 0 36px rgba(56, 189, 248, .95), 0 0 86px rgba(59, 130, 246, .62);
  animation: mathRingPulse 1.05s ease-out forwards;
}
.math-flash-text {
  position: absolute;
  color: #e0f2fe;
  font-size: clamp(1.3rem, 4vw, 2.6rem);
  font-weight: 800;
  text-shadow: 0 0 18px rgba(56, 189, 248, .95);
}
@keyframes mathRingPulse {
  from { transform: scale(.6); opacity: 0; }
  30% { opacity: 1; }
  to { transform: scale(1.28); opacity: 0; }
}
@keyframes mathFlashFade {
  from { opacity: 0; }
  12% { opacity: 1; }
  to { opacity: 0; }
}

.math-tutor-overlay {
  position: fixed;
  inset: 0;
  z-index: 340;
}
.math-tutor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .68);
}
.math-tutor-bubble {
  position: absolute;
  top: 88px;
  right: 20px;
  width: min(330px, 88vw);
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 14px 34px rgba(14, 116, 144, .26);
}
.math-tutor-bubble button {
  border: 1px solid #38bdf8;
  background: #e0f2fe;
  color: #0c4a6e;
  border-radius: 10px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}
.math-spotlight {
  position: relative;
  z-index: 360;
  box-shadow: 0 0 0 4px rgba(186, 230, 253, .8), 0 0 22px rgba(56, 189, 248, .95);
  animation: tutorBlink .9s ease-in-out infinite alternate;
}
@keyframes tutorBlink {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

.app.math-mode {
  background: radial-gradient(circle at 50% 0%, #e0f2fe 0%, #f0f9ff 35%, #f8fdff 100%);
}
.app.math-mode .fish-logo,
.app.math-mode .brand { color: #0284c7; }
.app.math-mode .model-badge {
  border-color: #38bdf8;
  color: #0369a1;
  background: #ecfeff;
  box-shadow: 0 0 14px rgba(56, 189, 248, .35);
}
.app.math-mode .memory-btn,
.app.math-mode .clear-btn,
.app.math-mode .plus-btn,
.app.math-mode .input-shell button[type="submit"] {
  border-color: #38bdf8;
  color: #0c4a6e;
  background: linear-gradient(180deg, #f0f9ff, #dbeafe);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, .7), 0 0 14px rgba(56, 189, 248, .42);
}

@media (max-width: 900px) {
  

@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
    width: min(90vw, 640px);
    height: min(58vh, 560px);
  }
  .math-studio-input { height: calc(100% - 102px); }
  .math-tutor-bubble { right: 12px; top: 132px; }
}

/* geometry lab */
.geometry-lab {
  border: 1px solid #bae6fd;
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, #f0f9ff, #ecfeff);
  margin-bottom: 12px;
}
.geometry-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.geo-btn {
  border: 1px solid #7dd3fc;
  border-radius: 999px;
  background: #fff;
  color: #075985;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}
.geo-btn.active {
  background: linear-gradient(90deg, #dbeafe, #bae6fd);
  box-shadow: 0 0 14px rgba(56, 189, 248, .35);
}
.geometry-card { display: grid; gap: 10px; }
.geometry-sketch {
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 10px;
}
.geo-title { font-weight: 800; color: #0c4a6e; margin-bottom: 8px; }
.geo-edge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
}
.geo-edge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .78rem;
  color: #155e75;
}
.geo-edge input, #geoGoalInput {
  border: 1.5px solid #7dd3fc;
  border-radius: 10px;
  padding: 7px 8px;
  font-weight: 700;
}
.geo-center-box { margin-top: 8px; }
#geoGoalInput { width: 100%; text-transform: lowercase; }
.geo-corners { margin-top: 6px; font-size: .8rem; color: #0369a1; font-weight: 700; }
.geometry-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#solveGeometryBtn {
  border: 1.5px solid #38bdf8;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  color: #0c4a6e;
  background: linear-gradient(180deg, #e0f2fe, #bfdbfe);
  box-shadow: 0 0 14px rgba(14, 165, 233, .33);
  cursor: pointer;
}
.geometry-warn {
  color: #b91c1c;
  font-size: .85rem;
  font-weight: 700;
}

.thinking-bubble.thinking-math {
  border: 1px solid #7dd3fc;
  background: linear-gradient(90deg, #e0f2fe, #dbeafe, #e0f2fe);
  background-size: 220% 100%;
  animation: mathAnalyzeGlow 1.2s linear infinite;
}
.thinking-bubble.thinking-math .thinking-head {
  color: #0369a1;
  font-weight: 800;
}
@keyframes mathAnalyzeGlow {
  0% { background-position: 0% 0%; }
  100% { background-position: 220% 0%; }
}

@media (max-width: 900px) {
  .geometry-toolbar { max-height: 104px; overflow: auto; }
  .geo-edge-grid { grid-template-columns: 1fr; }
}



@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel { overflow: auto; }
.math-studio-input {
  height: 260px;
  min-height: 220px;
}
@media (max-width: 900px) {
  .math-studio-input { height: 180px; min-height: 150px; }
}

/* notebook geometry redesign */
.geometry-sketch {
  background: transparent;
  border: none;
  padding: 0;
}
.geo-notebook {
  position: relative;
  min-height: 360px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background:
    repeating-linear-gradient(180deg, rgba(59,130,246,0.08), rgba(59,130,246,0.08) 1px, transparent 1px, transparent 34px),
    #ffffff;
  box-shadow: inset 0 0 0 1px rgba(186, 230, 253, .45), 0 8px 18px rgba(14, 165, 233, .12);
}

.rational-notebook {
  display: grid;
  place-items: center;
}
.rational-zone {
  margin-top: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.rational-box {
  width: 92px;
  display: grid;
  gap: 4px;
  justify-items: center;
}
.rational-box input {
  width: 74px;
  border: 1.4px solid #7dd3fc;
  border-radius: 8px;
  padding: 5px 6px;
  text-align: center;
  font-weight: 700;
}
.rat-line {
  width: 76px;
  height: 2px;
  background: #0284c7;
}
.rat-op {
  border: 1.5px solid #38bdf8;
  background: #f0f9ff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 900;
  color: #0c4a6e;
}
.rational-btn {
  background: linear-gradient(135deg, #eef2ff, #e0f2fe);
}
.geo-shape-svg {
  position: relative;
  width: 230px;
  height: 230px;
  transform: translateY(-4%);
  fill: rgba(59,130,246,.10);
  stroke: #0284c7;
  stroke-width: 3;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, .35));
}
.geo-side-input {
  position: absolute;
  display: grid;
  gap: 3px;
  width: 74px;
  font-size: .72rem;
  color: #155e75;
  font-weight: 700;
}
.geo-side-input input {
  border: 1.4px solid #7dd3fc;
  border-radius: 9px;
  padding: 5px 6px;
  font-weight: 700;
  background: rgba(255,255,255,.96);
}
.geo-widget-wrap .pos-top { left: 50%; top: -12px; transform: translateX(-50%); }
.geo-widget-wrap .pos-bottom { left: 50%; bottom: -10px; transform: translateX(-50%); }
.geo-widget-wrap .pos-left { left: -10px; top: 50%; transform: translateY(-50%); }
.geo-widget-wrap .pos-right { right: -10px; top: 50%; transform: translateY(-50%); }
.geo-widget-wrap .pos-upper-left { left: 0; top: 44px; }
.geo-widget-wrap .pos-upper-right { right: 0; top: 44px; }
.geo-widget-wrap .pos-lower-left { left: 0; bottom: 44px; }
.geo-widget-wrap .pos-lower-right { right: 0; bottom: 44px; }

.geo-goal-input {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  border: 1.6px solid #38bdf8;
  border-radius: 10px;
  padding: 7px 9px;
  text-align: center;
  font-weight: 800;
  text-transform: lowercase;
  color: #0c4a6e;
  background: #f0f9ff;
}
.geo-result-pad {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  color: #0369a1;
  font-weight: 800;
  background: rgba(224, 242, 254, .92);
  border: 1px solid #7dd3fc;
  border-radius: 10px;
  padding: 5px 10px;
}
.geo-notebook.geo-hit {
  animation: geoHit 700ms ease-out;
}
@keyframes geoHit {
  0% { box-shadow: inset 0 0 0 1px rgba(186, 230, 253, .45), 0 0 0 rgba(14,165,233,0); }
  40% { box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .8), 0 0 28px rgba(14,165,233,.65); }
  100% { box-shadow: inset 0 0 0 1px rgba(186, 230, 253, .45), 0 8px 18px rgba(14,165,233,.12); }
}


.unified-notebook {
  overflow: hidden;
}
.notebook-typing {
  position: absolute;
  inset: 12px;
  border: none;
  outline: none;
  background: transparent;
  color: #0f172a;
  font-size: 1rem;
  line-height: 1.9;
  z-index: 1;
  min-height: 260px;
  white-space: pre-wrap;
}
.geo-widget-wrap {
  position: absolute;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  z-index: 2;
}
.geo-widget-wrap.dragging { cursor: grabbing; }
.geo-delete-btn {
  position: absolute;
  right: -4px;
  top: -22px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #ef4444;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 900;
  cursor: pointer;
  display: none;
  z-index: 6;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.22);
}
.geo-widget-wrap.selected .geo-delete-btn { display: inline-grid; place-items: center; }
.geo-widget-wrap .geo-side-input,
.geo-widget-wrap .geo-goal-input,
.geo-widget-wrap .rational-zone {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.geo-widget-wrap.selected .geo-side-input,
.geo-widget-wrap.selected .geo-goal-input,
.geo-widget-wrap.selected .rational-zone {
  opacity: 1;
  pointer-events: auto;
}
.geometry-widget .geo-shape-svg { pointer-events: none; }
.rational-widget {
  width: auto;
  height: auto;
}
.rational-widget .rational-zone {
  margin-top: 0;
  background: rgba(255,255,255,.92);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 8px;
}
.math-tutor-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.math-tutor-finale {
  position: fixed;
  inset: 0;
  z-index: 380;
  display: grid;
  place-items: center;
}
.math-tutor-finale-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .78);
}
.math-tutor-finale-card {
  position: relative;
  text-align: center;
  color: #e0f2fe;
  animation: tutorFinalePop 1.6s ease-out forwards;
}
.finale-fish {
  width: min(280px, 70vw);
  color: #f0f9ff;
  margin: 0 auto 8px;
  filter: drop-shadow(0 0 24px rgba(56, 189, 248, .8));
}
.math-tutor-finale-card h3 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  color: #7dd3fc;
  text-shadow: 0 0 20px rgba(56, 189, 248, .9);
}
@keyframes tutorFinalePop {
  0% { opacity: 0; transform: scale(.88); }
  18% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

@media (max-width: 900px) {
  .geo-notebook { min-height: 300px; }
   .geo-shape-svg { width: 190px; height: 190px; }
  .geo-widget-wrap { width: 214px; height: 214px; }
  .geo-side-input { width: 64px; font-size: .68rem; }
  .geo-goal-input { width: 110px; }
  .rational-zone { margin-top: 54px; gap: 8px; }
  .rational-box { width: 76px; }
  .rational-box input, .rat-line { width: 62px; }
  .geo-result-pad { bottom: 44px; font-size: .82rem; }
}

.math-tutor-finale.hidden { display: none !important; }


.warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 390;
  display: grid;
  place-items: center;
  background: rgba(12, 10, 22, .62);
  backdrop-filter: blur(3px);
}
.warning-card {
  width: min(760px, 92vw);
  text-align: center;
  border-radius: 22px;
  border: 2px solid #f59e0b;
  background: linear-gradient(180deg, #fff7ed, #ffedd5);
  box-shadow: 0 0 40px rgba(245, 158, 11, .45);
  padding: 26px 20px;
}
.warning-card h3 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  color: #b45309;
}
.warning-card p {
  margin: 0;
  font-size: clamp(1.05rem, 2.8vw, 1.6rem);
  font-weight: 800;
  color: #9a3412;
}

.safety-survey {
  border: 1px solid #93c5fd;
  background: linear-gradient(180deg, #eff6ff, #f0f9ff);
}
.survey-title { font-weight: 800; color: #1e3a8a; margin-bottom: 8px; }
.survey-start-btn {
  border: 1.5px solid #3b82f6;
  border-radius: 10px;
  background: #dbeafe;
  color: #1e40af;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}
.survey-panel {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  color: #1f2937;
}
.survey-panel label { display: flex; gap: 8px; align-items: center; }
.survey-note {
  margin-top: 6px;
  color: #1d4ed8;
  font-weight: 700;
}

.warning-overlay.hidden { display: none !important; }


.safety-survey-modal {
  position: fixed;
  inset: 0;
  z-index: 395;
  display: grid;
  place-items: center;
}
.safety-survey-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, .74);
  backdrop-filter: blur(4px);
}
.safety-survey-card {
  position: relative;
  width: min(640px, 92vw);
  border-radius: 18px;
  border: 1px solid #93c5fd;
  background: linear-gradient(180deg, #f8fbff, #eaf4ff);
  box-shadow: 0 20px 44px rgba(30, 64, 175, .28);
  padding: 18px;
}
.safety-survey-card h3 { margin: 0 0 8px; color: #1e40af; }
.safety-survey-card p { margin: 0 0 12px; color: #334155; }
.safety-survey-options { display: grid; gap: 8px; }
.safety-survey-options button {
  border: 1.5px solid #60a5fa;
  border-radius: 11px;
  background: #fff;
  color: #1e3a8a;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}
.safety-survey-options button:hover { background: #eff6ff; }
.close-safety-survey {
  margin-top: 10px;
  border: 1px solid #94a3b8;
  background: #fff;
  border-radius: 9px;
  padding: 8px 11px;
  font-weight: 700;
  cursor: pointer;
}
.safety-survey-modal.hidden { display: none !important; }

.web-mode-label {
  padding: 8px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2ff, #e0e7ff);
  border: 1px solid #a5b4fc;
  font-size: .98rem;
  font-weight: 800;
}

.input-web-wrap {
  position: relative;
  width: 100%;
}
.web-input-badge {
  position: absolute;
  top: -22px;
  left: 10px;
  font-size: .72rem;
  font-weight: 800;
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  padding: 2px 8px;
}
#userInput.web-search-input {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
  background: linear-gradient(180deg, #ffffff, #faf5ff);
}

.thinking-bubble.web-thinking,
.thinking-bubble.thinking-web {
  background: #ffffff;
  border: 1px solid #d8b4fe;
}
.thinking-bubble.thinking-web .thinking-head,
.thinking-bubble.web-thinking .thinking-head {
  color: #111;
  font-weight: 800;
  background: linear-gradient(120deg, #111 0%, #111 40%, #9333ea 50%, #111 60%, #111 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: webShimmer 2s linear infinite;
}
@keyframes webShimmer { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.web-results {
  background: #fff;
  border: 1px solid #c4b5fd;
}
.web-results-head {
  font-weight: 900;
  color: #6d28d9;
  margin-bottom: 4px;
}
.web-query { color: #475569; font-size: .9rem; margin-bottom: 8px; }
.web-top3 { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.web-top3 li a { color: #4c1d95; font-weight: 800; text-decoration: none; }
.web-top3 li p { margin: 2px 0 0; color: #334155; font-size: .9rem; }
.web-results details { margin-top: 8px; }
.web-results summary { cursor: pointer; color: #6d28d9; font-weight: 700; }

/* mobile math studio size fix */
@media (max-width: 900px) {
  

@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
    width: 96vw;
    height: 78vh;
    right: 2vw;
    top: 78px;
  }
  .math-studio-input {
    height: 260px;
    min-height: 220px;
    font-size: 1rem;
  }
}

@media (max-width: 560px) {
  #clearChat { display: none; }
  

@keyframes balleBubbleDrift { from { transform: translateX(-4%); } to { transform: translateX(6%); } }

.balle-model-badge {
  color: #4c1d95 !important;
  border-color: #d946ef !important;
  background: linear-gradient(120deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.14), rgba(168,85,247,.2));
  background-size: 240% 100%;
  animation: balleBadgeGlow 2.5s linear infinite;
  box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset, 0 0 16px rgba(217,70,239,.28);
}
@keyframes balleBadgeGlow { from { background-position: 0% 50%; } to { background-position: 220% 50%; } }

.app.balle-bg-active::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 8% 20%, rgba(34,197,94,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 26% 58%, rgba(250,204,21,.2) 0 6%, transparent 7%),
              radial-gradient(circle at 52% 22%, rgba(239,68,68,.18) 0 7%, transparent 8%),
              radial-gradient(circle at 77% 62%, rgba(168,85,247,.22) 0 7%, transparent 8%),
              radial-gradient(circle at 88% 18%, rgba(250,204,21,.14) 0 5%, transparent 6%);
  animation: balleBackdropFloat 8s ease-in-out infinite alternate;
  z-index: 0;
}
.app.balle-bg-active #chatArea,
.app.balle-bg-active .input-shell,
.app.balle-bg-active .topbar { position: relative; z-index: 1; }
@keyframes balleBackdropFloat { from { transform: translateY(0); } to { transform: translateY(-10px); } }

.balle-stage-wrap { margin-top: 10px; }
.balle-stage-title { font-weight: 800; color: #6d28d9; margin-bottom: 8px; }
.balle-stage-canvas {
  height: min(44vh, 320px);
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5), 0 12px 28px rgba(15,23,42,.14);
}
.balle-stage-canvas::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.16), rgba(250,204,21,.16), rgba(239,68,68,.16), rgba(168,85,247,.2), rgba(34,197,94,.16));
  animation: balleSweep 4.6s linear infinite;
}
@keyframes balleSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.balle-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  animation: orbFloat 4.8s ease-in-out infinite;
  box-shadow: 0 0 24px currentColor;
}
.balle-orb.orb-green { width: 110px; height: 110px; left: 8%; top: 18%; color: rgba(34,197,94,.65); background: rgba(34,197,94,.38); }
.balle-orb.orb-yellow { width: 90px; height: 90px; right: 14%; top: 16%; color: rgba(250,204,21,.7); background: rgba(250,204,21,.4); animation-delay: .5s; }
.balle-orb.orb-red { width: 120px; height: 120px; left: 22%; bottom: 10%; color: rgba(239,68,68,.64); background: rgba(239,68,68,.36); animation-delay: 1.1s; }
.balle-orb.orb-purple { width: 100px; height: 100px; right: 26%; bottom: 8%; color: rgba(168,85,247,.72); background: rgba(168,85,247,.42); animation-delay: 1.6s; }
@keyframes orbFloat {
  0%,100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-14px) scale(1.08); }
}
.balle-core-fish {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px rgba(255,255,255,.75));
}

.math-studio-panel {
    width: 98vw;
    right: 1vw;
    height: 80vh;
  }
  .math-studio-input {
    height: 230px;
    min-height: 200px;
  }
}

/* plus menu compact + glowing clickable mode options */
.plus-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 1.15rem;
  border: 1.4px solid #7c3aed;
  background: radial-gradient(circle at 28% 24%, #faf5ff 0%, #ede9fe 48%, #ddd6fe 100%);
  color: #5b21b6;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, .35), 0 0 14px rgba(124, 58, 237, .25);
  transition: transform .14s ease, box-shadow .2s ease, filter .2s ease;
}
.plus-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, .45), 0 0 20px rgba(124, 58, 237, .35), 0 0 28px rgba(59, 130, 246, .18);
}
.plus-btn:active { transform: translateY(0) scale(.98); }

.plus-menu {
  min-width: 188px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid #ddd6fe;
  background: linear-gradient(180deg, #ffffff, #faf7ff);
}

.image-mode-label {
  position: relative;
  gap: 6px;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.image-mode-label:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, .22), 0 0 18px rgba(124, 58, 237, .16);
  filter: brightness(1.03);
}

.image-mode-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #6d28d9;
  cursor: pointer;
}
.image-mode-label .mode-icon { font-size: .9rem; line-height: 1; }
.image-mode-label .mode-spark {
  font-size: .78rem;
  line-height: 1;
  text-shadow: 0 0 8px rgba(147, 51, 234, .45), 0 0 14px rgba(59, 130, 246, .25);
}

.math-mode-label,
.web-mode-label {
  padding: 6px 8px;
  border-radius: 10px;
  font-size: .78rem;
}
.baluk-engine-btn {
  width: 100%;
  border: 1px solid #99f6e4;
  background: linear-gradient(90deg, #ecfeff, #dcfce7);
  color: #134e4a;
  justify-content: flex-start;
  text-align: left;
  font: inherit;
}
.baluk-engine-btn:hover {
  box-shadow: 0 0 0 1px rgba(20, 184, 166, .22), 0 0 18px rgba(16, 185, 129, .16);
}
.baluk-engine-pill {
  background: linear-gradient(90deg, #ccfbf1, #dcfce7);
  border-color: #5eead4;
  color: #115e59;
}
.math-mode-pill {
  padding: 3px 8px;
  font-size: .76rem;
  border-radius: 999px;
}

@media (max-width: 700px) {
  .plus-btn {
    width: 34px;
    height: 34px;
    font-size: 1.02rem;
  }
  .plus-menu {
    min-width: 174px;
    padding: 7px;
  }
  .image-mode-label {
    padding: 5px 7px;
    font-size: .74rem;
  }
  .math-mode-pill {
    font-size: .7rem;
    padding: 2px 7px;
  }
}

.bmw-video-card {
  max-width: min(420px, 92vw);
  padding: 10px;
  border: 1px solid #c7d2fe;
  background: linear-gradient(180deg, #ffffff, #eef2ff);
}
.bmw-video-card iframe {
  width: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 8px 18px rgba(30, 58, 138, .22);
}

/* drawer + premium purchase UI */
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(360px, 92vw);
  z-index: 410;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-right: 1px solid #dbeafe;
  border-radius: 0;
  padding: 14px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .18);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.side-drawer.hidden {
  display: none !important;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-head h3,
.drawer-tools-section h4,
.memory-panel h3,
.account-panel h3,
.math-studio-panel h3,
.account-settings summary,
#persistBrowserAccount {
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-head h3 { margin: 0; color: #1e3a8a; font-size: 1rem; }
.drawer-head button { border: none; background: #eff6ff; border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.drawer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #0f172a;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 6px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}
.menu-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 18px;
  position: relative;
  color: #334155;
}
.icon-user::before,
.icon-user::after {
  content: "";
  position: absolute;
  border: 1.7px solid currentColor;
}
.icon-user::before {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  top: 2px;
}
.icon-user::after {
  width: 10px;
  height: 6px;
  border-top-left-radius: 999px;
  border-top-right-radius: 999px;
  border-bottom: none;
  bottom: 2px;
}
.icon-newchat {
  border: 1.5px solid #0f172a;
  border-radius: 4px;
  position: relative;
}
.icon-newchat::before,
.icon-newchat::after {
  content: "";
  position: absolute;
  background: #0f172a;
}
.icon-newchat::before { width: 9px; height: 1.5px; }
.icon-newchat::after { width: 1.5px; height: 9px; }
.icon-bg {
  border-radius: 50%;
  border: 1.6px solid #0f172a;
  box-shadow: inset 0 0 0 3px rgba(59,130,246,.18);
}
.icon-plus {
  border-radius: 50%;
  border: 1.6px solid #7c3aed;
  color: #7c3aed;
  font-size: 12px;
  font-weight: 900;
}
.icon-plus::before { content: "+"; line-height: 1; }
.icon-screatch {
  font-size: 15px;
  color: #7c3aed;
}
.drawer-chat-section {
  flex: 1;
  min-height: 220px;
  overflow: auto;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.chat-list { display: grid; gap: 6px; }
.chat-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  background: #f8fafc;
}
.chat-list-item.active { border-color: #93c5fd; background: #eff6ff; }
.chat-open-btn {
  flex: 1;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-open-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-menu-wrap { position: relative; }
.chat-item-menu-btn {
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 1.05rem;
}
.chat-item-menu {
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 4;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15,23,42,.16);
  padding: 6px;
  display: grid;
  gap: 4px;
}
.chat-item-menu button {
  border: none;
  border-radius: 8px;
  background: #f8fafc;
  text-align: left;
  padding: 6px 8px;
  cursor: pointer;
  font-weight: 600;
}
.drawer-tools-section {
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.drawer-btn-soon {
  opacity: .72;
  cursor: not-allowed;
  justify-content: space-between;
}
.drawer-btn-soon small {
  color: #7c3aed;
  font-size: .72rem;
  font-weight: 800;
}
.drawer-btn-soon:disabled {
  filter: saturate(.9);
}
.drawer-tools-section h4 {
  margin: 0 0 8px;
  color: #1e3a8a;
  font-size: .9rem;
}
.premium-glow {
  border-color: #a78bfa;
  background: linear-gradient(90deg, #faf5ff, #eef2ff);
  box-shadow: 0 0 0 1px rgba(167,139,250,.35), 0 0 20px rgba(124,58,237,.24);
  animation: premiumPulse 1.5s ease-in-out infinite alternate;
}
@keyframes premiumPulse { from { filter: brightness(1); } to { filter: brightness(1.08); } }
.premium-owned { color: #065f46; font-weight: 800; margin: 4px 2px 0; }
.premium-pending { color: #92400e; font-weight: 700; margin: 4px 2px 0; }

.premium-expiry { color: #334155; font-weight: 700; margin: 2px 2px 0; font-size: 12px; }

body.premium-active .chat-area,
body.premium-active .input-shell,
body.premium-active .topbar {
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.10);
}

body.premium-active .model-badge,
body.premium-active .memory-btn,
body.premium-active .plus-btn,
body.premium-active .clear-btn {
  border-width: 1.5px;
}

.premium-modal {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
}
.premium-backdrop { position: absolute; inset: 0; background: rgba(12, 14, 24, .62); backdrop-filter: blur(2px); }
.premium-card {
  position: relative;
  width: min(520px, 92vw);
  background: linear-gradient(180deg, #ffffff, #f5f3ff);
  border: 1px solid #c4b5fd;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 20px 44px rgba(76, 29, 149, .26);
}
.premium-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.premium-title-row h3 { margin: 0; color: #5b21b6; }
.premium-title-row button { border: none; background: #ede9fe; border-radius: 8px; cursor: pointer; padding: 4px 8px; }
.premium-card ul { margin: 10px 0; padding-left: 18px; display: grid; gap: 6px; color: #334155; }
.premium-card ul li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.premium-feature-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
  color: #6d28d9;
}
.premium-actions { display: flex; gap: 10px; }
.premium-buy-btn,
.premium-confirm-btn {
  flex: 1;
  border: 1px solid #a78bfa;
  background: linear-gradient(90deg, #ede9fe, #dbeafe);
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 700px) {
  .side-drawer { top: 0; left: 0; right: auto; width: min(96vw, 380px); height: 100dvh; }
}

.premium-modal.hidden { display: none !important; }

.premium-verify-note {
  margin: 6px 0 10px;
  font-size: .84rem;
  color: #475569;
}
.premium-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}
#premiumCodeInput {
  border: 1px solid #c4b5fd;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
  letter-spacing: .4px;
}

.premium-code-row.hidden { display: none !important; }


.model-badge.premium-model-badge {
  color: #7e22ce;
  border-color: #c084fc;
  background: linear-gradient(90deg, #f5d0fe, #ede9fe);
  box-shadow: 0 0 0 1px rgba(192, 132, 252, .3), 0 0 12px rgba(168, 85, 247, .25);
}

.web-wiki-excerpt {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.web-wiki-excerpt h4 {
  margin: 0 0 8px;
  color: #1e293b;
  font-size: .95rem;
}
.web-wiki-excerpt p {
  margin: 0 0 8px;
  color: #334155;
  line-height: 1.55;
  max-height: 280px;
  overflow: auto;
  white-space: normal;
}
.web-wiki-excerpt a {
  color: #4c1d95;
  font-weight: 700;
  text-decoration: none;
}

.web-main-answer {
  margin-top: 4px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.web-main-answer h4 {
  margin: 0 0 8px;
  color: #1e293b;
  font-size: .95rem;
}
.web-answer-text {
  margin: 0;
  color: #334155;
  line-height: 1.55;
  white-space: pre-line;
}
.web-read-more {
  margin-top: 8px;
  border: 1px solid #a78bfa;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 8px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}
.web-sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}
.web-sources h5 {
  margin: 0 0 8px;
  color: #475569;
  font-size: .88rem;
}
.web-source-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.web-source-list a,
.web-source-main {
  color: #4c1d95;
  font-weight: 700;
  text-decoration: none;
}
.web-source-main {
  display: inline-block;
  margin-top: 8px;
}


/* background settings */
.background-modal {
  position: fixed;
  inset: 0;
  z-index: 360;
  display: grid;
  place-items: center;
}
.background-modal.hidden { display: none !important; }
.background-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .6); backdrop-filter: blur(2px); }
.background-card {
  position: relative;
  width: min(560px, 92vw);
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .26);
  display: grid;
  gap: 10px;
}
.background-title-row { display: flex; justify-content: space-between; align-items: center; }
.background-title-row h3 { margin: 0; color: #312e81; }
.background-title-row button { border: none; border-radius: 8px; background: #e2e8f0; padding: 5px 10px; cursor: pointer; }
.background-row { display: grid; gap: 6px; }
.background-row label { font-size: .88rem; color: #475569; font-weight: 700; }
.background-row select,
.background-row input[type="range"] { width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px; }
.background-note { margin: 2px 0 0; font-size: .82rem; color: #64748b; }

body[class*="bg-theme-"] {
  position: relative;
  overflow-x: hidden;
}
body[class*="bg-theme-"]::before,
body[class*="bg-theme-"]::after {
  content: "";
  position: fixed;
  inset: -10%;
  pointer-events: none;
  z-index: -1;
}
body.bg-theme-1 { background: radial-gradient(circle at 20% 20%, #111827, #0f172a 65%); }
body.bg-theme-1::before { background-image: radial-gradient(circle, rgba(255,255,255,.45) 1px, transparent 1px); background-size: 4px 4px; opacity: .22; animation: bgStarMove 3s linear infinite; }
body.bg-theme-1::after { background: radial-gradient(circle at 0% 50%, rgba(168,85,247,.24), transparent 55%), radial-gradient(circle at 100% 50%, rgba(99,102,241,.22), transparent 45%); }
body.bg-theme-2 { background: linear-gradient(120deg, #0f172a, #1e293b, #0b3b57); }
body.bg-theme-3 { background: linear-gradient(140deg, #1f2937, #312e81, #1f2937); }
body.bg-theme-4 { background: linear-gradient(120deg, #111827, #334155); }
body.bg-theme-5 { background: linear-gradient(120deg, #0f172a, #155e75); }
body.bg-theme-6 { background: linear-gradient(120deg, #1f2937, #7c3aed); }
body.bg-theme-7 { background: linear-gradient(120deg, #020617, #1d4ed8, #701a75); }
body.bg-theme-8 { background: linear-gradient(120deg, #052e16, #14532d, #0f172a); }
body.bg-theme-9 { background: linear-gradient(120deg, #0f172a, #334155, #1e1b4b); }
body.bg-theme-10 { background: linear-gradient(120deg, #111827, #1e3a8a, #0f172a); }

body.bg-theme-7,
body.bg-theme-9 {
  background-size: 170% 170%;
  animation: softGradientFlow 16s ease-in-out infinite;
}

body.bg-theme-7::before,
body.bg-theme-9::before {
  opacity: .2;
  filter: saturate(1.25) blur(.2px);
  animation: bgStarMove 5.8s linear infinite;
}

body.bg-theme-7::after,
body.bg-theme-9::after {
  background:
    radial-gradient(circle at 14% 35%, rgba(168,85,247,.26), transparent 48%),
    radial-gradient(circle at 82% 62%, rgba(96,165,250,.24), transparent 52%),
    radial-gradient(circle at 55% 20%, rgba(244,114,182,.14), transparent 46%);
  animation: neonGlowDrift 9.5s ease-in-out infinite alternate;
}
body.bg-theme-2::before,
body.bg-theme-3::before,
body.bg-theme-4::before,
body.bg-theme-5::before,
body.bg-theme-6::before,
body.bg-theme-7::before,
body.bg-theme-8::before,
body.bg-theme-9::before,
body.bg-theme-10::before {
  background-image: radial-gradient(circle, rgba(255,255,255,.25) 1px, transparent 1px);
  background-size: 5px 5px;
  opacity: .12;
  animation: bgStarMove 4s linear infinite;
}
body.bg-theme-2::after,
body.bg-theme-3::after,
body.bg-theme-4::after,
body.bg-theme-5::after,
body.bg-theme-6::after,
body.bg-theme-7::after,
body.bg-theme-8::after,
body.bg-theme-9::after,
body.bg-theme-10::after {
  background: radial-gradient(circle at 10% 30%, rgba(168,85,247,.14), transparent 45%), radial-gradient(circle at 85% 70%, rgba(59,130,246,.16), transparent 45%);
}
@keyframes bgStarMove {
  from { transform: translateX(-8px) translateY(0); }
  to { transform: translateX(8px) translateY(-8px); }
}

@keyframes softGradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes neonGlowDrift {
  0% { transform: translateY(0px) scale(1); opacity: .72; }
  100% { transform: translateY(-10px) scale(1.06); opacity: .95; }
}

/* baluk.lens */
.lens-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  width: min(660px, 96vw);
  max-height: 78vh;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  box-shadow: 0 22px 48px rgba(15, 23, 42, .28);
  padding: 12px;
  z-index: 390;
}
.lens-panel.hidden { display: none !important; }

.lens-panel.lens-analyzing {
  box-shadow: 0 0 0 1px rgba(139, 92, 246, .45), 0 0 28px rgba(99, 102, 241, .35), 0 22px 48px rgba(15, 23, 42, .28);
  animation: lensPulse 1.1s ease-in-out infinite alternate;
}
@keyframes lensPulse {
  from { transform: translateY(0); }
  to { transform: translateY(-1px); }
}

.lens-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lens-head h3 { margin: 0; color: #312e81; }
.lens-head button { border: none; background: #e2e8f0; border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.lens-hint { margin: 8px 0; color: #475569; font-size: .86rem; }
.lens-drop-zone {
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  min-height: 92px;
  display: grid;
  place-content: center;
  gap: 7px;
  text-align: center;
  color: #475569;
  background: #fff;
}
.lens-drop-zone.dragging { border-color: #6366f1; background: #eef2ff; }
.lens-pick-btn {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg,#7c3aed,#4f46e5);
  color: #fff;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.lens-canvas-wrap { margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid #cbd5e1; background: conic-gradient(#f8fafc 0 25%, #e2e8f0 0 50%, #f8fafc 0 75%, #e2e8f0 0) 0 0/16px 16px; }
.lens-canvas-wrap.lens-canvas-live { box-shadow: inset 0 0 0 1px rgba(129, 140, 248, .3), 0 0 18px rgba(129, 140, 248, .35); }
#lensCanvas { width: 100%; height: auto; display: block; cursor: crosshair; touch-action: none; }
.lens-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.lens-analyze-btn {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg,#111827,#312e81);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}
.lens-status {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  font-size: .86rem;
}
.lens-status-live {
  animation: lensStatusShimmer 1.2s linear infinite;
  background-image: linear-gradient(90deg, #eef2ff 0%, #ddd6fe 35%, #eef2ff 70%);
  background-size: 220% 100%;
}
@keyframes lensStatusShimmer {
  from { background-position: 200% 0; }
  to { background-position: -20% 0; }
}
.lens-results {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}
.lens-results h4 { margin: 0 0 8px; color: #0f172a; }
.lens-results ol { margin: 0 0 8px 18px; padding: 0; }
.lens-results a { color: #1d4ed8; text-decoration: none; }
.lens-results a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  #lensCanvas { cursor: default; }
  .lens-panel {
    left: 8px;
    right: 8px;
    bottom: 74px;
    width: auto;
    max-height: 68vh;
  }
}


.typing-active::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  color: #6366f1;
  animation: typingCaretBlink 0.8s steps(1) infinite;
}

@keyframes typingCaretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* BALL.E visual refinement overrides */
.app.balle-bg-active::before {
  background:
    radial-gradient(circle at 10% 20%, rgba(34,197,94,.42) 0 8%, rgba(34,197,94,0) 9%),
    radial-gradient(circle at 25% 72%, rgba(250,204,21,.45) 0 8%, rgba(250,204,21,0) 9%),
    radial-gradient(circle at 45% 32%, rgba(239,68,68,.4) 0 8%, rgba(239,68,68,0) 9%),
    radial-gradient(circle at 72% 62%, rgba(168,85,247,.44) 0 8%, rgba(168,85,247,0) 9%),
    radial-gradient(circle at 87% 26%, rgba(250,204,21,.34) 0 7%, rgba(250,204,21,0) 8%),
    linear-gradient(120deg, rgba(16,185,129,.18), rgba(234,179,8,.18), rgba(239,68,68,.16), rgba(168,85,247,.22));
  background-size: 180% 180%;
  animation: balleBackdropFloat 10s ease-in-out infinite alternate, balleBgShift 7s linear infinite;
}
@keyframes balleBgShift { from { background-position: 0% 50%; } to { background-position: 160% 50%; } }

.balle-stage-canvas {
  border: 1px solid #d4d4d8;
  background: #e5e7eb;
}
.balle-stage-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(95deg, transparent 0%, rgba(255,255,255,.5) 48%, transparent 100%);
  transform: translateX(-120%);
  animation: balleCrossShine 2s linear infinite;
}
@keyframes balleCrossShine {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

.balle-core-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  letter-spacing: .08em;
  background: linear-gradient(120deg, #22c55e, #facc15, #ef4444, #a855f7, #22c55e);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 20px rgba(255,255,255,.35);
  animation: balleWordGlow 2.8s linear infinite;
  z-index: 3;
}
@keyframes balleWordGlow {
  from { background-position: 0% 50%; filter: drop-shadow(0 0 8px rgba(168,85,247,.45)); }
  to { background-position: 220% 50%; filter: drop-shadow(0 0 16px rgba(234,179,8,.55)); }
}
.balle-neon-scan {
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 0 14px rgba(34,197,94,.35), 0 0 18px rgba(250,204,21,.28), 0 0 20px rgba(239,68,68,.24), 0 0 22px rgba(168,85,247,.32);
  animation: balleBorderPulse 2s ease-in-out infinite;
  z-index: 2;
}
@keyframes balleBorderPulse {
  0%,100% { opacity: .75; }
  50% { opacity: 1; }
}

.balle-orb { filter: blur(.4px); opacity: .92; }


.account-icon-btn.guest-default {
  border-radius: 999px;
  padding: 0;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
}
.account-icon-btn .account-toggle-avatar { width: 30px; height: 30px; display: block; }
.account-icon-btn .account-toggle-menu {
  width: 28px;
  height: 28px;
  color: #0f172a;
}
.account-icon-btn.has-photo {
  border-radius: 999px;
  overflow: hidden;
  padding: 0;
  border: 1.5px solid #cbd5e1;
}
.account-icon-btn.has-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.voice-mode-icon {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #111;
  display: grid;
  place-items: center;
}
.voice-mode-icon .vm-lines {
  width: 12px;
  height: 14px;
  border-left: 3px solid #111;
  border-right: 3px solid #111;
  opacity: .85;
}
.voice-mode-panel {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(167,139,250,.28), rgba(30,27,75,.88));
  z-index: 120;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.voice-mode-shell {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: none;
  background:
    radial-gradient(circle at 20% 15%, rgba(216,180,254,.22), transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(147,51,234,.25), transparent 40%),
    linear-gradient(180deg, #2a0c48 0%, #17042b 100%);
  padding: 24px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  position: relative;
}
.voice-mode-core {
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: min(230px, 62vw);
  aspect-ratio: 1/1;
  border-radius: 50%;
  border: 3px solid #111;
  display: grid;
  place-items: center;
  position: relative;
  background: radial-gradient(circle at 35% 35%, #f3e8ff, #c084fc 55%, #6b21a8);
}
.voice-logo {
  font-weight: 900;
  color: #334155;
  letter-spacing: .03em;
}
.voice-mode-status {
  color: #f5d0fe;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(216,180,254,.45);
}
.voice-mode-actions {
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.voice-mute-btn,
.voice-web-btn,
.voice-close-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid #111;
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}
.voice-mute-btn {
  background: #ef4444;
  color: #fff;
}
.voice-mute-btn.muted { background: #9ca3af; }
.voice-web-btn {
  background: #dbeafe;
  color: #0f172a;
  border-color: #93c5fd;
  box-shadow: 0 8px 18px rgba(96,165,250,.35);
}
.voice-web-btn.active {
  background: linear-gradient(135deg, #60a5fa, #38bdf8);
  color: #fff;
  border-color: #38bdf8;
}




.voice-open-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.voice-drop {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #faf5ff, #d8b4fe 65%, #9333ea);
  box-shadow: 0 0 22px rgba(216,180,254,.95);
  transform: translateX(-50%);
  opacity: 0;
}
.voice-vapor {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  background: radial-gradient(circle, rgba(233,213,255,.9), rgba(168,85,247,.35), transparent 72%);
}
.voice-open-fx.play .voice-drop {
  animation: voiceDropFall 1.5s ease-in forwards;
}
.voice-open-fx.play .voice-vapor {
  animation: voiceVaporBurst 1.5s ease-out forwards;
}
@keyframes voiceDropFall {
  0% { opacity: 0; transform: translate(-50%, -26px) scale(.65); }
  14% { opacity: 1; }
  74% { opacity: 1; transform: translate(-50%, 52vh) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, 61vh) scale(.45); }
}
@keyframes voiceVaporBurst {
  0%, 58% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  72% { opacity: .95; transform: translate(-50%, -50%) scale(3.6); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(6); }
}
.voice-mode-panel.hidden { display: none !important; }
.voice-center-logo {
  width: min(150px, 45vw);
  color: #faf5ff;
  filter: drop-shadow(0 0 14px rgba(192,132,252,.65));
}
.voice-mode-core.speaking .voice-center-logo {
  color: #d946ef;
  animation: voiceLogoPulse .9s ease-in-out infinite;
}
@keyframes voiceLogoPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.voice-close-btn { z-index: 3; position: fixed; top: 16px; right: 16px; }


#chatSubmitBtn .voice-mode-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}
#chatSubmitBtn .voice-mode-icon .vm-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: .88;
}
#chatSubmitBtn .voice-mode-icon .vm-wave::before,
#chatSubmitBtn .voice-mode-icon .vm-wave::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid currentColor;
  border-radius: 50%;
  opacity: .38;
}
#chatSubmitBtn .voice-mode-icon .vm-wave::after {
  inset: -10px;
  opacity: .2;
}
#chatSubmitBtn .voice-mode-icon .vm-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  gap: 3px;
  height: 12px;
}
#chatSubmitBtn .voice-mode-icon .vm-bars span {
  width: 3px;
  border-radius: 999px;
  background: currentColor;
  animation: vmBarsPulse 1.1s ease-in-out infinite;
}
#chatSubmitBtn .voice-mode-icon .vm-bars span:nth-child(1) { height: 6px; animation-delay: 0s; }
#chatSubmitBtn .voice-mode-icon .vm-bars span:nth-child(2) { height: 11px; animation-delay: .12s; }
#chatSubmitBtn .voice-mode-icon .vm-bars span:nth-child(3) { height: 8px; animation-delay: .24s; }
@keyframes vmBarsPulse {
  0%, 100% { transform: scaleY(.82); opacity: .72; }
  50% { transform: scaleY(1.08); opacity: 1; }
}


/* Voice/send unified button refinements */
#chatSubmitBtn {
  background: #fff;
  color: #111827;
  border-color: #111827;
}
#chatSubmitBtn.voice-launch {
  border-radius: 14px;
  border-color: #7c3aed;
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  color: #fff;
  box-shadow: 0 8px 18px rgba(124,58,237,.32);
}
#chatSubmitBtn.voice-launch .voice-mode-icon {
  border-color: rgba(255,255,255,.95);
}
#chatSubmitBtn.voice-launch .voice-mode-icon .vm-wave,
#chatSubmitBtn.voice-launch .voice-mode-icon .vm-wave::before,
#chatSubmitBtn.voice-launch .voice-mode-icon .vm-wave::after,
#chatSubmitBtn.voice-launch .voice-mode-icon .vm-bars span {
  color: rgba(255,255,255,.95);
  border-color: rgba(255,255,255,.95);
  background: rgba(255,255,255,.95);
}

.baluk-engine-btn {
  width: 100%;
  border: 1px solid #d1d5db;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #111827;
  justify-content: flex-start;
  text-align: left;
  font: inherit;
  position: relative;
}
.baluk-engine-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.6px solid #111827;
  background: #fff;
  flex: 0 0 auto;
}
.baluk-engine-btn:hover {
  box-shadow: 0 0 0 1px rgba(17,24,39,.12), 0 10px 18px rgba(15,23,42,.08);
}
.baluk-engine-pill {
  background: linear-gradient(180deg, #ffffff, #eef2f7);
  border: 1px solid #d1d5db;
  color: #111827;
}

.app.engine-mode-active #chatArea,
.app.engine-mode-active #chatForm,
.app.engine-mode-active .thinking-toolbar,
.app.engine-mode-active #thinkingLimitBanner {
  display: none;
}

.engine-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background:
    radial-gradient(circle at 12% 8%, rgba(244, 114, 182, .14), transparent 24%),
    radial-gradient(circle at 86% 14%, rgba(59, 130, 246, .12), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(168, 85, 247, .10), transparent 30%),
    linear-gradient(180deg, #fdfdff 0%, #f4f7fb 52%, #eef3f8 100%);
}
.engine-workspace.hidden { display: none !important; }
.engine-workspace.engine-enter {
  animation: engineWorkspaceReveal .58s cubic-bezier(.2,.8,.2,1);
}
@keyframes engineWorkspaceReveal {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.engine-sidebar {
  border-right: 1px solid rgba(148, 163, 184, .26);
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,249,255,.92));
  padding: 20px 18px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 16px;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.6), 18px 0 40px rgba(15, 23, 42, .04);
  backdrop-filter: blur(16px);
}
.engine-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.engine-back-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1.8px solid #111827;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
}
.engine-brand-diamond,
.engine-diamond-btn {
  width: 46px;
  height: 46px;
  transform: rotate(45deg);
  border: 2px solid #111827;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}
.engine-brand-diamond {
  flex: 0 0 auto;
  font-weight: 900;
  font-size: .95rem;
}
.engine-brand-diamond > *,
.engine-brand-diamond,
.engine-diamond-btn > *,
.engine-diamond-btn {
  color: #111827;
}
.engine-brand-diamond,
.engine-diamond-btn span {
  transform: rotate(-45deg);
}
.engine-brand-copy {
  display: grid;
  gap: 2px;
}
.engine-brand-copy strong {
  font-size: 1.1rem;
  color: #111827;
}
.engine-brand-copy span,
.engine-sidebar-label {
  color: #475569;
  font-size: .86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.engine-new-chat-btn {
  border: 1px solid rgba(99, 102, 241, .26);
  background: linear-gradient(135deg, #ffffff, #f4edff);
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.engine-new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(124, 58, 237, .16);
}
.engine-chat-list {
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
}
.engine-chat-item {
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.92));
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}
.engine-chat-item.active {
  border-color: rgba(139, 92, 246, .30);
  background: linear-gradient(180deg, #ffffff, #f4edff);
  box-shadow: 0 18px 32px rgba(124, 58, 237, .14);
}
.engine-chat-open {
  border: none;
  background: transparent;
  text-align: left;
  font-weight: 800;
  color: #0f172a;
  cursor: pointer;
  padding: 0;
}
.engine-chat-actions {
  display: flex;
  gap: 8px;
}
.engine-chat-actions button {
  flex: 1;
  border: 1px solid rgba(148, 163, 184, .36);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  padding: 7px 8px;
  font-weight: 700;
  cursor: pointer;
}

.engine-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 22px 24px 24px;
  gap: 18px;
}
.engine-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.engine-thinking-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(99, 102, 241, .28);
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(244,237,255,.92));
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(124, 58, 237, .08);
}
.engine-panel-actions {
  display: flex;
  gap: 10px;
}
.engine-panel-btn {
  min-width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .34);
  background: linear-gradient(180deg, #fff, #f8fafc);
  font-weight: 900;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.engine-panel-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(124, 58, 237, .12);
}
.engine-panel-btn-wide {
  padding: 0 18px;
  min-width: 88px;
}
.engine-panel-btn.active {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  border-color: transparent;
}

.engine-canvas {
  min-height: 0;
  position: relative;
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 36px;
  background:
    radial-gradient(circle at 92% 10%, rgba(96,165,250,.08), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,250,255,.96));
  padding: 30px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(15, 23, 42, .09);
}
.engine-canvas.pristine {
  background:
    radial-gradient(circle at 16% 18%, rgba(168, 85, 247, .06), transparent 24%),
    #ffffff;
}
.engine-status-card {
  display: flex;
  align-items: center;
  gap: 18px;
  border: 2px solid #111827;
  border-radius: 24px;
  background: rgba(255,255,255,.9);
  padding: 18px 20px;
  max-width: 560px;
  box-shadow: 0 18px 40px rgba(15,23,42,.08);
}
.engine-status-card.hidden { display: none !important; }
.engine-status-card.processing {
  box-shadow: 0 24px 44px rgba(124,58,237,.16);
}
.engine-status-visual {
  position: relative;
  width: 160px;
  height: 90px;
  flex: 0 0 auto;
}
.engine-fish {
  position: absolute;
  left: 0;
  top: 12px;
  width: 124px;
  color: #111827;
}
.engine-bubbles span {
  position: absolute;
  right: 6px;
  top: 16px;
  border-radius: 999px;
  border: 1.5px solid #111827;
  padding: 4px 8px;
  background: #fff;
  font-size: .78rem;
  font-weight: 800;
  opacity: 0;
}
.engine-status-card.processing .engine-bubbles span:nth-child(1) {
  animation: engineBubbleFloat 1.8s ease-in-out infinite;
}
.engine-status-card.processing .engine-bubbles span:nth-child(2) {
  animation: engineBubbleFloat 1.8s ease-in-out .45s infinite;
}
.engine-status-card.processing .engine-bubbles span:nth-child(3) {
  animation: engineBubbleFloat 1.8s ease-in-out .9s infinite;
}
.engine-thinking-card .engine-bubbles span:nth-child(1) {
  animation: engineBubbleFloat 1.8s ease-in-out infinite;
}
.engine-thinking-card .engine-bubbles span:nth-child(2) {
  animation: engineBubbleFloat 1.8s ease-in-out .45s infinite;
}
.engine-thinking-card .engine-bubbles span:nth-child(3) {
  animation: engineBubbleFloat 1.8s ease-in-out .9s infinite;
}
@keyframes engineBubbleFloat {
  0% { transform: translate(82px, 54px) scale(.55); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(148px, -4px) scale(1); opacity: 0; }
}
.engine-status-copy strong {
  display: block;
  color: #0f172a;
  font-size: 1.05rem;
}
.engine-status-copy p {
  margin: 6px 0 0;
  color: #475569;
  line-height: 1.5;
}

.engine-project-stage {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}
.engine-project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.engine-project-head strong {
  display: block;
  font-size: 1.15rem;
  color: #111827;
}
.engine-project-head p {
  margin: 6px 0 0;
  color: #64748b;
  max-width: 58ch;
}
.engine-project-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.engine-project-badge {
  border: 1px solid #d8b4fe;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: .78rem;
  font-weight: 800;
  background: linear-gradient(180deg, #fff, #faf5ff);
  color: #6d28d9;
}
.engine-project-view {
  min-height: 360px;
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 32px;
  background:
    radial-gradient(circle at 90% 10%, rgba(96,165,250,.08), transparent 20%),
    linear-gradient(180deg, #ffffff, #fbfcff);
  overflow: hidden;
  position: relative;
}
.engine-thinking-scene {
  position: absolute;
  inset: 26px auto auto 26px;
  width: 390px;
  display: block;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}
.engine-thinking-actor {
  display: grid;
  gap: 16px;
  justify-items: start;
}

/* 2026 Engine Rebuild */
.ui-settings-btn { min-width: 82px; }

.ui-settings-modal,
.engine-settings-panel,
.engine-quota-panel {
  position: fixed;
  inset: 0;
  z-index: 420;
}
.ui-settings-modal.hidden,
.engine-settings-panel.hidden,
.engine-quota-panel.hidden { display: none !important; }
.ui-settings-backdrop,
.engine-quota-panel::before,
.engine-settings-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 20, 0.56);
  backdrop-filter: blur(12px);
}
.ui-settings-card,
.engine-settings-card,
.engine-quota-card {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100vw - 32px));
  margin: 12vh auto 0;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,247,252,0.98));
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
}
.ui-settings-head,
.engine-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.ui-settings-head h3,
.engine-settings-head strong,
.engine-quota-card strong {
  margin: 0;
  font-size: 1.05rem;
  color: #0f172a;
}
.ui-settings-head button,
.engine-settings-head button,
.engine-dock-head button,
.engine-quota-actions button:last-child {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background: rgba(255,255,255,0.82);
  color: #0f172a;
  cursor: pointer;
}
.ui-settings-block,
.engine-settings-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid rgba(226, 232, 240, 0.92);
}
.ui-settings-block:first-of-type,
.engine-settings-section:first-of-type { border-top: none; padding-top: 0; }
.ui-mode-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.06);
}
.ui-mode-switch button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: #475569;
}
.ui-mode-switch button.active {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.24);
}

body.ui-dark-mode {
  --bg: #090a13;
  --text: #eef2ff;
  --line: rgba(148, 163, 184, 0.24);
  --line-strong: #dbe3ff;
  --user: #181b2a;
  --bot: #101521;
  background: #090a13;
  color: #eef2ff;
}
body.ui-dark-mode .topbar,
body.ui-dark-mode .input-shell,
body.ui-dark-mode .chat-area,
body.ui-dark-mode .side-drawer,
body.ui-dark-mode .memory-panel,
body.ui-dark-mode .account-panel,
body.ui-dark-mode .math-studio-panel,
body.ui-dark-mode .plus-menu,
body.ui-dark-mode .background-card,
body.ui-dark-mode .premium-card {
  background: rgba(10, 14, 25, 0.94);
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
body.ui-dark-mode .brand,
body.ui-dark-mode .model-badge,
body.ui-dark-mode .drawer-head h3,
body.ui-dark-mode .drawer-tools-section h4,
body.ui-dark-mode .account-settings summary,
body.ui-dark-mode .memory-panel h3,
body.ui-dark-mode .account-panel h3,
body.ui-dark-mode .math-studio-panel h3 {
  color: #eef2ff;
}
body.ui-dark-mode .memory-btn,
body.ui-dark-mode .clear-btn,
body.ui-dark-mode .plus-btn,
body.ui-dark-mode #chatSubmitBtn,
body.ui-dark-mode .drawer-btn,
body.ui-dark-mode .premium-confirm-btn,
body.ui-dark-mode .premium-buy-btn,
body.ui-dark-mode .engine-top-btn {
  background: rgba(255,255,255,0.06);
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.24);
}
body.ui-dark-mode .msg.bot { background: rgba(255,255,255,0.06); color: #eef2ff; }
body.ui-dark-mode .msg.user { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; }
body.ui-dark-mode .model-menu,
body.ui-dark-mode .thinking-mode-menu,
body.ui-dark-mode .thinking-limit-banner { background: rgba(10, 14, 25, 0.96); color: #eef2ff; }
body.ui-dark-mode .thinking-mode-picker {
  background: rgba(255,255,255,.06);
  color: #ddd6fe;
  border-color: rgba(196,181,253,.35);
}
body.ui-dark-mode .thinking-mode-picker.active {
  color: #fff;
  background: linear-gradient(135deg, #6d28d9, #9333ea);
}
body.ui-dark-mode .thinking-mode-option { color: #eef2ff; }
body.ui-dark-mode .thinking-mode-option:hover,
body.ui-dark-mode .thinking-mode-option.active { background: rgba(139,92,246,.16); }
body.ui-dark-mode .thinking-mode-option small { color: #a5b4fc; }
.app.engine-mode-active .topbar,
.app.engine-mode-active #chatArea,
.app.engine-mode-active #chatForm,
.app.engine-mode-active .thinking-toolbar,
.app.engine-mode-active #thinkingLimitBanner,
.app.engine-mode-active #sideDrawer,
.app.engine-mode-active #memoryPanel,
.app.engine-mode-active #accountPanel,
.app.engine-mode-active #mathStudioPanel {
  display: none !important;
}

.engine-workspace {
  display: block;
  min-height: calc(100vh - 0px);
  background: radial-gradient(circle at top, rgba(129, 58, 255, 0.24), transparent 24%), linear-gradient(180deg, #090910 0%, #12101d 36%, #0a0912 100%);
  color: #eef2ff;
}
.engine-workspace.hidden { display: none !important; }
.engine-shell {
  position: relative;
  min-height: 100vh;
  padding: 24px 28px 34px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}
.engine-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.engine-top-btn {
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-radius: 14px;
  padding: 11px 16px;
  background: rgba(255,255,255,0.04);
  color: #eef2ff;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.engine-top-btn:hover,
.engine-chip-btn:hover,
.engine-icon-btn:hover,
.engine-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(124, 58, 237, 0.2);
}
.engine-wordmark {
  display: flex;
  align-items: center;
  gap: 14px;
}
.engine-brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: #e5e7eb;
  filter: drop-shadow(0 0 24px rgba(167,139,250,0.18));
}
.engine-brand-mark svg,
.engine-hero-logo svg {
  width: 100%;
  height: 100%;
}
.engine-wordmark-copy {
  display: grid;
  gap: 4px;
}
.engine-wordmark-copy strong {
  font-size: 1.08rem;
  letter-spacing: 0.02em;
}
.engine-wordmark-copy span {
  color: rgba(226, 232, 240, 0.72);
  font-size: 0.85rem;
}
.engine-main-layout {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  gap: 22px;
}
.engine-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}
.engine-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-top: 6vh;
}
.engine-hero-logo {
  width: 88px;
  height: 88px;
  color: #f8fafc;
  filter: drop-shadow(0 0 28px rgba(192, 132, 252, 0.16));
}
.engine-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.8rem);
  letter-spacing: -0.04em;
  font-weight: 750;
}
.engine-project-view {
  width: min(1080px, 100%);
  margin: 0 auto;
  min-height: 380px;
  max-height: 50vh;
  overflow: auto;
  padding: 8px 6px 18px;
}
.engine-project-empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: rgba(226, 232, 240, 0.52);
  text-align: center;
}
.engine-project-empty p {
  max-width: 48ch;
  line-height: 1.7;
}
.engine-conversation-feed {
  display: grid;
  gap: 14px;
}
.engine-conversation-bubble {
  max-width: min(720px, 86%);
  border-radius: 20px;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  backdrop-filter: blur(10px);
}
.engine-conversation-bubble.user {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.88), rgba(79, 70, 229, 0.86));
  color: #fff;
}
.engine-conversation-bubble.assistant {
  background: rgba(255,255,255,0.05);
  color: #eef2ff;
}
.engine-conversation-bubble strong {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.engine-conversation-bubble p,
.engine-conversation-bubble span {
  margin: 0;
  line-height: 1.65;
}
.engine-bottom-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}
.engine-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.engine-picker-row,
.engine-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.engine-diamond-btn {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(192, 132, 252, 0.34);
  background: linear-gradient(180deg, rgba(22, 18, 36, 0.94), rgba(11, 11, 18, 0.96));
  color: #eef2ff;
  display: grid;
  place-items: center;
  transform: rotate(45deg);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.engine-diamond-btn-text {
  display: inline-grid;
  place-items: center;
  transform: rotate(-45deg);
  font-weight: 800;
  font-size: 1rem;
}
.engine-diamond-btn-text svg {
  width: 22px;
  height: 22px;
}
.engine-mini-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(10, 10, 18, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 8px;
  z-index: 20;
}
.engine-mini-menu button {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  color: #eef2ff;
  font-weight: 700;
  cursor: pointer;
}
.engine-picker-wrap { position: relative; }
.engine-quota-wrap {
  min-width: 210px;
  display: grid;
  gap: 8px;
}
.engine-quota-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
}
.engine-quota-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.32);
}
.engine-quota-wrap strong {
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.84);
}
.engine-chip-btn,
.engine-icon-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: #eef2ff;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.engine-chip-btn {
  padding: 11px 16px;
}
.engine-icon-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
}
.engine-icon-btn svg {
  width: 18px;
  height: 18px;
}
.engine-chip-btn.active,
.engine-icon-btn.active,
.engine-mini-menu button.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(79, 70, 229, 0.28));
  border-color: rgba(196, 181, 253, 0.44);
  box-shadow: 0 16px 30px rgba(79, 70, 229, 0.16);
}
.engine-composer-shell {
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255,255,255,0.04);
  padding: 16px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}
.engine-composer {
  display: grid;
  gap: 12px;
}
.engine-composer textarea {
  width: 100%;
  min-height: 116px;
  max-height: 190px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-size: 1.04rem;
  line-height: 1.7;
}
.engine-composer textarea::placeholder {
  color: rgba(226, 232, 240, 0.5);
}
.engine-composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.engine-selection-meta {
  color: rgba(226, 232, 240, 0.72);
  font-size: 0.88rem;
}
.engine-submit-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(124, 58, 237, 0.24);
}
.engine-dock {
  position: absolute;
  top: 88px;
  right: 28px;
  bottom: 34px;
  width: min(560px, calc(100vw - 56px));
  border-radius: 28px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(8, 11, 20, 0.96);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.34);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  z-index: 40;
}
.engine-dock.hidden { display: none !important; }
.engine-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.engine-dock-head strong { color: #eef2ff; }
.engine-dock-body {
  padding: 18px 20px 22px;
  overflow: auto;
}
.engine-code-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.engine-code-tab {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  color: #e2e8f0;
  font-weight: 700;
  cursor: pointer;
}
.engine-code-tab.active {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border-color: transparent;
}
.engine-code-section { display: none; gap: 12px; }
.engine-code-section.active { display: grid; }
.engine-code-actions {
  display: flex;
  justify-content: flex-end;
}
.engine-code-copy {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  color: #eef2ff;
  cursor: pointer;
}
.engine-code-block-highlight {
  margin: 0;
  padding: 18px;
  border-radius: 20px;
  background: #090c17;
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: #eef2ff;
  overflow: auto;
}
.engine-preview-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 20px;
  background: #fff;
}
.engine-auth-gate {
  position: absolute;
  inset: 84px 28px 32px;
  display: grid;
  place-items: center;
}
.engine-auth-glow {
  position: absolute;
  inset: 12% 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.24), transparent 64%);
  filter: blur(22px);
}
.engine-auth-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  justify-items: start;
  padding: 32px 34px;
  width: min(560px, 100%);
  border-radius: 32px;
  border: 1px solid rgba(168, 85, 247, 0.24);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.24);
}
.engine-auth-logo {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: #f8fafc;
}
.engine-auth-phrase {
  margin: 0;
  color: rgba(226, 232, 240, 0.76);
  font-size: 1.08rem;
  min-height: 2.2em;
}
.engine-auth-btn,
.engine-quota-actions button:first-child {
  border: none;
  border-radius: 16px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(124, 58, 237, 0.24);
}
.engine-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.engine-switch input { display: none; }
.engine-switch-ui {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.34);
  position: relative;
  transition: background .18s ease;
}
.engine-switch-ui::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}
.engine-switch input:checked + .engine-switch-ui {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
}
.engine-switch input:checked + .engine-switch-ui::after {
  transform: translateX(24px);
}

body.ui-light-mode .engine-workspace {
  background: radial-gradient(circle at top, rgba(124, 58, 237, 0.10), transparent 26%), linear-gradient(180deg, #f6f5ff 0%, #eceffd 40%, #eef4fb 100%);
  color: #0f172a;
}
body.ui-light-mode .engine-top-btn,
body.ui-light-mode .engine-chip-btn,
body.ui-light-mode .engine-icon-btn,
body.ui-light-mode .engine-composer-shell,
body.ui-light-mode .engine-dock,
body.ui-light-mode .engine-auth-card {
  background: rgba(255,255,255,0.84);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.22);
}
body.ui-light-mode .engine-wordmark-copy span,
body.ui-light-mode .engine-selection-meta,
body.ui-light-mode .engine-auth-phrase,
body.ui-light-mode .engine-project-empty,
body.ui-light-mode .engine-conversation-bubble.assistant,
body.ui-light-mode .engine-quota-wrap strong {
  color: rgba(15, 23, 42, 0.72);
}
body.ui-light-mode .engine-project-view {
  color: #0f172a;
}
body.ui-light-mode .engine-conversation-bubble.assistant {
  background: rgba(255,255,255,0.68);
}
body.ui-light-mode .engine-composer textarea {
  color: #0f172a;
}
body.ui-light-mode .engine-composer textarea::placeholder {
  color: rgba(15, 23, 42, 0.46);
}
body.ui-light-mode .engine-brand-mark,
body.ui-light-mode .engine-hero-logo {
  color: #0f172a;
}
body.ui-light-mode .engine-code-block-highlight {
  background: #ffffff;
  color: #0f172a;
}

.engine-quota-wrap.is-premium .engine-quota-fill {
  background: linear-gradient(90deg, #7c3aed, #2563eb, #06b6d4, #7c3aed);
  background-size: 200% 100%;
  animation: engineQuotaPremium 3s linear infinite;
}
@keyframes engineQuotaPremium {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}

@media (max-width: 900px) {
  .engine-shell {
    padding: 16px 16px 22px;
  }
  .engine-topbar,
  .engine-control-row,
  .engine-composer-bottom {
    flex-direction: column;
    align-items: stretch;
  }
  .engine-wordmark {
    justify-content: center;
  }
  .engine-dock {
    inset: 84px 16px 16px;
    width: auto;
  }
  .engine-project-view {
    max-height: none;
    min-height: 300px;
  }
}
.engine-thinking-fish-wrap {
  position: relative;
  width: 260px;
  height: 126px;
}
.engine-thinking-fish-wrap .engine-fish {
  position: absolute;
  left: 0;
  top: 18px;
  width: 176px;
  color: #111827;
  filter: drop-shadow(0 12px 22px rgba(15,23,42,.12));
}
.engine-conversation-feed {
  display: grid;
  gap: 16px;
  padding: 28px;
}
.engine-conversation-bubble {
  max-width: min(76%, 620px);
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff, #f8f5ff);
  border: 1px solid rgba(148, 163, 184, .26);
  box-shadow: 0 16px 32px rgba(15, 23, 42, .06);
}
.engine-conversation-bubble.user {
  margin-left: auto;
  background: linear-gradient(135deg, #8b5cf6, #4f46e5);
  color: #ffffff;
}
.engine-conversation-bubble.thinking {
  border-style: dashed;
}
.engine-conversation-bubble strong {
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.engine-conversation-bubble p,
.engine-conversation-bubble span {
  margin: 0;
  line-height: 1.6;
}
.engine-bubbles {
  position: relative;
  width: 260px;
  height: 126px;
}
.engine-thinking-card {
  width: auto;
  display: grid;
  gap: 12px;
  text-align: left;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}
.engine-thinking-copy strong {
  display: block;
  font-size: 1.14rem;
  color: #111827;
  letter-spacing: -.02em;
}
.engine-thinking-copy p {
  margin: 8px 0 0;
  color: #64748b;
  max-width: 28ch;
}
.engine-project-view iframe {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: none;
  background: #fff;
}
.engine-project-empty,
.engine-project-python {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #94a3b8;
  text-align: center;
}
.engine-project-python pre {
  width: min(760px, 100%);
  margin: 0;
  text-align: left;
  white-space: pre-wrap;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 22px;
  padding: 18px;
}
.engine-example-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.engine-example-chip {
  border: 1px solid rgba(148, 163, 184, .34);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f8f5ff);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.engine-example-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, .36);
  box-shadow: 0 16px 28px rgba(124, 58, 237, .10);
}
.engine-log {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  max-width: min(760px, calc(100% - 40px));
  pointer-events: none;
}
.engine-log.hidden { display: none !important; }
.engine-log-entry {
  border: 2px solid #111827;
  border-radius: 22px;
  padding: 10px 14px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 24px rgba(15,23,42,.06);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.engine-log-entry.assistant {
  border-color: #d8b4fe;
  background: linear-gradient(180deg, #ffffff, #faf5ff);
}
.engine-log-entry.user {
  margin-left: auto;
  max-width: 75%;
  background: #111827;
  color: #fff;
}
.engine-log-entry.thinking {
  border-style: dashed;
  background: linear-gradient(180deg, #faf5ff, #ffffff);
}
.engine-log-entry.assistant strong,
.engine-log-entry.user strong {
  display: block;
  margin-bottom: 6px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.engine-log-entry p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}
.engine-log-meta {
  margin-top: 8px;
  color: #64748b;
  font-size: .82rem;
}

.engine-dock {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(250,249,255,.98));
  box-shadow: 0 26px 56px rgba(15,23,42,.16), 0 0 0 1px rgba(168,85,247,.08) inset;
  overflow: hidden;
  z-index: 4;
}
.engine-dock.hidden { display: none !important; }
.engine-dock-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #fff, #f8f5ff);
}
.engine-dock-head button {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}
.engine-dock-body {
  overflow: auto;
  padding: 22px;
}
.engine-code-block {
  margin: 0;
  border: 1px solid rgba(99, 102, 241, .18);
  border-radius: 22px;
  background: linear-gradient(180deg, #0b1020, #11182c);
  color: #e2e8f0;
  padding: 18px;
  font-size: .86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.engine-code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.engine-syntax-tag { color: #f472b6; }
.engine-syntax-attr { color: #f59e0b; }
.engine-syntax-string { color: #60a5fa; }
.engine-syntax-keyword { color: #c084fc; }
.engine-syntax-number { color: #fb7185; }
.engine-syntax-comment { color: #94a3b8; }
.engine-output-preview.clean iframe {
  width: 100%;
  min-height: 360px;
  border: none;
  border-radius: 26px;
  background: #ffffff;
}
.engine-dock-copy,
.engine-dock-run {
  margin-top: 12px;
  border: 2px solid #111827;
  background: linear-gradient(135deg, #ffffff, #f4edff);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}
.engine-output-preview {
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 20px;
  background: #ffffff;
  min-height: 100%;
}
.engine-output-preview.clean {
  padding: 0;
  border: none;
  background: #fff;
}
.engine-output-preview .blm-stage {
  display: grid;
  gap: 10px;
  min-height: 420px;
  align-content: start;
}
.engine-output-preview .blm-card,
.engine-output-preview .blm-calculator,
.engine-output-preview .blm-snake {
  border: 1.5px solid #cbd5e1;
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}
.engine-output-preview .blm-inline-btn {
  border: 1.5px solid #111827;
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 700;
}
.engine-output-preview input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
}
.engine-study-card {
  display: grid;
  gap: 18px;
}
.engine-study-card h4,
.engine-study-card p { margin: 0; }
.engine-study-stepper {
  display: grid;
  gap: 12px;
}
.engine-study-step {
  border: 1.5px solid #d8b4fe;
  border-radius: 18px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff, #faf5ff);
}
.engine-study-step strong {
  display: block;
  margin-bottom: 6px;
  color: #6d28d9;
}
.engine-study-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.engine-study-grid button {
  border: 1.6px solid #111827;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffffff, #f4edff);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
}
.engine-study-rule {
  border: 1px dashed #94a3b8;
  border-radius: 16px;
  padding: 12px 14px;
  color: #334155;
  line-height: 1.55;
  background: #fff;
}
.engine-notebook-area {
  width: 100%;
  min-height: 420px;
  border: 1.6px solid #111827;
  border-radius: 18px;
  padding: 14px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.engine-composer-shell {
  display: flex;
  justify-content: center;
}
.engine-composer {
  width: min(920px, 100%);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 36px;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(251,250,255,.95));
  padding: 18px 20px;
  box-shadow: 0 28px 46px rgba(15,23,42,.09), 0 0 0 1px rgba(168,85,247,.08) inset;
  backdrop-filter: blur(14px);
}
.engine-composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 1rem;
  min-height: 96px;
  background: transparent;
}
.engine-composer-bottom {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
}
.engine-picker-row {
  display: flex;
  gap: 16px;
}
.engine-picker-wrap {
  position: relative;
}
.engine-diamond-btn {
  cursor: pointer;
  font-weight: 900;
  font-size: 1rem;
}
.engine-diamond-btn {
  display: grid;
  place-items: center;
}
.engine-diamond-btn::before {
  content: attr(data-label);
}
.engine-diamond-btn {
  transform: rotate(45deg);
}
.engine-diamond-btn > span,
.engine-diamond-btn-text {
  transform: rotate(-45deg);
}
.engine-diamond-btn {
  line-height: 1;
}
.engine-mini-menu {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 10px);
  min-width: 220px;
  border: 2px solid #111827;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfaff);
  box-shadow: 0 20px 40px rgba(15,23,42,.12);
  padding: 8px;
  display: grid;
  gap: 8px;
  z-index: 40;
}
.engine-mini-menu.hidden { display: none !important; }
.engine-mini-menu button {
  border: 1px solid rgba(148, 163, 184, .34);
  background: linear-gradient(135deg, #ffffff, #f8f5ff);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}
.engine-mini-menu button:hover {
  border-color: rgba(139, 92, 246, .34);
  box-shadow: 0 12px 24px rgba(124, 58, 237, .10);
}
.engine-selection-meta {
  color: #475569;
  font-weight: 700;
}
.engine-submit-btn {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(124, 58, 237, .24);
}
.engine-submit-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 22px 34px rgba(124, 58, 237, .28);
}

@media (max-width: 980px) {
  .engine-workspace {
    grid-template-columns: 1fr;
  }
  .engine-sidebar {
    border-right: none;
    border-bottom: 2px solid #111827;
  }
}

@media (max-width: 760px) {
  .engine-stage {
    padding: 12px;
  }
  .engine-canvas {
    border-radius: 26px;
    padding: 16px;
  }
  .engine-toolbar,
  .engine-composer-bottom {
    grid-template-columns: 1fr;
    display: grid;
  }
  .engine-panel-actions,
  .engine-picker-row {
    flex-wrap: wrap;
  }
  .engine-status-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .engine-dock {
    inset: 0;
    max-height: none;
    height: auto;
  }
}

/* Baluk Engine reboot */
.engine-workspace {
  background:
    radial-gradient(circle at 10% 8%, rgba(168, 85, 247, .18), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(59, 130, 246, .14), transparent 24%),
    linear-gradient(180deg, #171322 0%, #1c1829 48%, #14111e 100%);
}
.engine-sidebar {
  background: linear-gradient(180deg, rgba(20, 17, 30, .92), rgba(17, 14, 26, .94));
  border-right: 1px solid rgba(167, 139, 250, .18);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03), 20px 0 46px rgba(0,0,0,.24);
}
.engine-back-btn,
.engine-new-chat-btn,
.engine-chat-actions button {
  border-color: rgba(167, 139, 250, .26);
  background: linear-gradient(180deg, rgba(36, 30, 53, .94), rgba(26, 22, 40, .94));
  color: #f5f3ff;
}
.engine-brand-diamond,
.engine-diamond-btn {
  border: 1px solid rgba(192, 132, 252, .44);
  background: linear-gradient(180deg, rgba(36, 29, 53, .98), rgba(20, 17, 30, .98));
  box-shadow: 0 14px 28px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.04);
}
.engine-brand-copy strong,
.engine-diamond-btn-text,
.engine-chat-open,
.engine-project-head strong,
.engine-thinking-copy strong,
.engine-thinking-meter,
.engine-panel-btn,
.engineSelectionMeta {
  color: #faf5ff;
}
.engine-brand-copy span,
.engine-sidebar-label,
.engine-project-head p,
.engine-thinking-copy p,
.engine-selection-meta {
  color: #b7afcf;
}
.engine-chat-item {
  background: linear-gradient(180deg, rgba(28, 24, 41, .96), rgba(20, 17, 30, .96));
  border-color: rgba(167, 139, 250, .16);
  box-shadow: 0 14px 26px rgba(0,0,0,.18);
}
.engine-chat-item.active {
  background: linear-gradient(180deg, rgba(46, 37, 72, .96), rgba(26, 22, 40, .96));
  border-color: rgba(192, 132, 252, .32);
  box-shadow: 0 18px 36px rgba(124, 58, 237, .22);
}
.engine-thinking-meter,
.engine-panel-btn,
.engine-composer,
.engine-dock,
.engine-project-view,
.engine-canvas {
  border-color: rgba(167, 139, 250, .18);
}
.engine-thinking-meter {
  background: linear-gradient(180deg, rgba(34, 28, 49, .94), rgba(24, 20, 35, .96));
  box-shadow: 0 16px 32px rgba(0,0,0,.24);
}
.engine-panel-btn {
  background: linear-gradient(180deg, rgba(34, 28, 49, .94), rgba(24, 20, 35, .96));
  color: #e9ddff;
}
.engine-panel-btn.active,
.engine-submit-btn {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  box-shadow: 0 18px 36px rgba(124, 58, 237, .28);
}
.engine-canvas {
  background:
    radial-gradient(circle at top right, rgba(139, 92, 246, .12), transparent 22%),
    linear-gradient(180deg, rgba(26, 22, 40, .98), rgba(19, 16, 30, .98));
  box-shadow: 0 30px 60px rgba(0,0,0,.26);
}
.engine-project-view {
  background:
    radial-gradient(circle at 88% 12%, rgba(96, 165, 250, .12), transparent 18%),
    linear-gradient(180deg, rgba(20, 17, 30, .98), rgba(16, 13, 25, .98));
}
.engine-project-badge {
  border-color: rgba(192, 132, 252, .26);
  background: linear-gradient(180deg, rgba(36, 29, 53, .94), rgba(20, 17, 30, .94));
  color: #e9d5ff;
}
.engine-project-empty {
  color: #8f87a7;
}
.engine-conversation-feed {
  padding: 30px;
}
.engine-conversation-bubble {
  background: linear-gradient(180deg, rgba(31, 27, 46, .96), rgba(20, 17, 30, .96));
  border-color: rgba(167, 139, 250, .16);
  box-shadow: 0 18px 36px rgba(0,0,0,.18);
  color: #f5f3ff;
}
.engine-conversation-bubble.user {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
}
.engine-conversation-bubble span {
  color: #b7afcf;
}
.engine-thinking-scene {
  inset: 34px auto auto 34px;
  width: 420px;
}
.engine-thinking-actor {
  gap: 18px;
}
.engine-thinking-fish-wrap {
  width: 320px;
  height: 150px;
}
.engine-thinking-fish-wrap .engine-fish {
  width: 210px;
  top: 28px;
  color: #f5f3ff;
  filter: drop-shadow(0 0 24px rgba(139, 92, 246, .18));
}
.engine-bubbles {
  width: 320px;
  height: 150px;
}
.engine-bubbles span {
  border-color: rgba(216, 180, 254, .32);
  background: linear-gradient(180deg, rgba(36, 29, 53, .98), rgba(20, 17, 30, .98));
  color: #f5f3ff;
  box-shadow: 0 10px 18px rgba(0,0,0,.22);
}
@keyframes engineBubbleFloat {
  0% { transform: translate(110px, 74px) scale(.55); opacity: 0; }
  22% { opacity: 1; }
  100% { transform: translate(228px, 6px) scale(1); opacity: 0; }
}
.engine-thinking-copy {
  padding-left: 10px;
}
.engine-thinking-copy strong {
  font-size: 1.2rem;
}
.engine-thinking-copy p {
  max-width: 30ch;
}
.engine-composer {
  background: linear-gradient(180deg, rgba(24, 20, 35, .98), rgba(16, 13, 25, .98));
  box-shadow: 0 26px 50px rgba(0,0,0,.26), 0 0 0 1px rgba(167, 139, 250, .08) inset;
}
.engine-composer textarea,
.engine-selection-meta {
  color: #f5f3ff;
}
.engine-composer textarea::placeholder {
  color: #847a9d;
}
.engine-mini-menu {
  border-color: rgba(167, 139, 250, .26);
  background: linear-gradient(180deg, rgba(26, 22, 40, .98), rgba(16, 13, 25, .98));
  box-shadow: 0 24px 44px rgba(0,0,0,.28);
}
.engine-mini-menu button {
  border-color: rgba(167, 139, 250, .18);
  background: linear-gradient(180deg, rgba(36, 29, 53, .96), rgba(20, 17, 30, .96));
  color: #f5f3ff;
}
.engine-dock {
  background: linear-gradient(180deg, rgba(26, 22, 40, .99), rgba(16, 13, 25, .99));
  box-shadow: 0 30px 60px rgba(0,0,0,.30), 0 0 0 1px rgba(167, 139, 250, .08) inset;
}
.engine-dock-head {
  background: linear-gradient(180deg, rgba(32, 27, 47, .98), rgba(21, 18, 32, .98));
  border-bottom-color: rgba(167, 139, 250, .16);
  color: #faf5ff;
}
.engine-dock-head button {
  border-color: rgba(167, 139, 250, .22);
  background: linear-gradient(180deg, rgba(36, 29, 53, .96), rgba(20, 17, 30, .96));
  color: #faf5ff;
}
.engine-output-preview.clean iframe {
  background: #ffffff;
}
.engine-code-block {
  border-color: rgba(139, 92, 246, .20);
  background: linear-gradient(180deg, #090b14, #111625);
}


.thinking-bubble.thinking-test {
  border: 1px solid rgba(168, 85, 247, .45);
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(34, 211, 238, .18), transparent 52%),
    radial-gradient(110% 140% at 100% 0%, rgba(250, 204, 21, .16), transparent 58%),
    radial-gradient(130% 150% at 100% 100%, rgba(239, 68, 68, .14), transparent 60%),
    linear-gradient(120deg, #f5f3ff, #ede9fe, #ecfeff, #fef9c3, #ffe4e6, #f5f3ff);
  background-size: 100% 100%, 100% 100%, 100% 100%, 320% 100%;
  box-shadow: 0 14px 30px rgba(147, 51, 234, .2), inset 0 0 0 1px rgba(255,255,255,.4);
  animation: testPulseFlow 2.2s linear infinite;
  position: relative;
  overflow: hidden;
}
.thinking-bubble.thinking-test::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.62) 48%, transparent 100%);
  transform: translateX(-120%) skewX(-18deg);
  animation: testShineSweep 2s ease-in-out infinite;
  pointer-events: none;
}
.thinking-bubble.thinking-test .thinking-head {
  color: #6d28d9;
  font-weight: 800;
}
@keyframes testPulseFlow {
  from { background-position: 0% 50%; }
  to { background-position: 220% 50%; }
}
@keyframes testShineSweep {
  0%, 26% { transform: translateX(-125%) skewX(-18deg); opacity: .1; }
  48% { opacity: .95; }
  100% { transform: translateX(125%) skewX(-18deg); opacity: .1; }
}

.test-question-card {
  background: #ffffff;
  border: 1px solid #ddd6fe;
  box-shadow: 0 8px 24px rgba(109, 40, 217, .12);
}
.test-head {
  display: inline-block;
  font-size: .84rem;
  font-weight: 800;
  color: #5b21b6;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.test-question {
  color: #1f2937;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 10px;
}
.test-options {
  display: grid;
  gap: 8px;
}
.test-option-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 600;
}
.test-option-btn:hover { border-color: #a78bfa; background: #f5f3ff; }
.test-option-btn:disabled { cursor: default; opacity: .96; }
.test-option-btn.correct { border-color: #22c55e; background: #ecfdf5; color: #14532d; }
.test-option-btn.wrong { border-color: #ef4444; background: #fef2f2; color: #7f1d1d; }
.test-opt-letter {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  font-size: .78rem;
  background: #fff;
  flex: 0 0 auto;
}
.test-feedback {
  margin-top: 10px;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  line-height: 1.45;
}
.test-feedback.correct { background: #ecfdf5; border: 1px solid #86efac; color: #166534; }
.test-feedback.wrong { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* 2026-04 geometry + settings fixes */
.ui-settings-card {
  pointer-events: auto;
}

.ui-settings-head button {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  min-width: 36px;
  min-height: 36px;
}

.math-studio-panel {
  display: flex;
  flex-direction: column;
}

.geometry-lab {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.geometry-card {
  display: grid;
  grid-template-rows: minmax(520px, 1fr) auto;
  min-height: calc(100vh - 300px);
  align-items: stretch;
  flex: 1 1 auto;
}

.geometry-sketch {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.geo-notebook {
  flex: 1 1 auto;
  min-height: calc(100vh - 390px);
  height: 100%;
}

@media (max-width: 900px) {
  .geometry-card {
    min-height: 520px;
    grid-template-rows: minmax(420px, 1fr) auto;
  }

  .geo-notebook {
    min-height: 420px;
  }
}
