:root {
  --bg: #f4f2fb;
  --surface: #ffffff;
  --text: #1c1d2b;
  --muted: #6b6f8a;
  --primary: #1c1c24;
  --primary-dark: #000000;
  --border: #e6e2f5;
  --bubble-user: #1c1c24;
  --bubble-user-text: #ffffff;
  --bubble-assistant: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121018;
    --surface: #1c1a26;
    --text: #ecebf5;
    --muted: #9997b3;
    --border: #2c2938;
    --bubble-assistant: #1c1a26;
    --primary: #3a3a44;
    --primary-dark: #2b2b33;
    --bubble-user: #3a3a44;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
/* one font everywhere — inputs, textareas, selects and buttons all inherit */
input, textarea, select, button { font-family: inherit; }

#app {
  max-width: 100%;
  width: 100%;
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(28, 28, 36, 0.15);
}

/* ---------- sidebar (conversations) ---------- */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
#sidebar-overlay.open { opacity: 1; pointer-events: auto; }
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 276px;
  max-width: 82vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 12px 12px;
  transform: translateX(-100%);
  transition: transform .24s ease;
  box-shadow: 0 0 40px rgba(0, 0, 0, .18);
}
.sidebar.open { transform: translateX(0); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 0 4px; }
.new-chat-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 11px; margin-bottom: 16px;
  background: var(--primary); color: #fff; border: none; border-radius: 999px;
  font-size: .92rem; font-weight: 700; cursor: pointer;
}
.new-chat-btn svg { width: 18px; height: 18px; fill: currentColor; }
.new-chat-btn:active { background: var(--primary-dark); }
.sidebar-section { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 6px 6px; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  color: var(--text); font-size: .9rem; line-height: 1.3;
}
.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--bg); font-weight: 600; }
.chat-item .ci-icon { width: 16px; height: 16px; fill: var(--muted); flex-shrink: 0; }
.chat-item .ci-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item .ci-del { opacity: 0; border: none; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; flex-shrink: 0; }
.chat-item:hover .ci-del { opacity: .8; }
.chat-item .ci-del:hover { background: var(--border); opacity: 1; }
@media (hover: none) { .chat-item .ci-del { opacity: .55; } }
.chat-empty { color: var(--muted); font-size: .85rem; padding: 8px 10px; }
.sidebar-foot { border-top: 1px solid var(--border); margin-top: 8px; padding: 10px 6px 2px; color: var(--muted); font-size: .72rem; }

.icon-btn {
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:active { background: var(--border); }
.icon-btn.primary { background: var(--primary); color: #fff; }
.icon-btn.primary:active { background: var(--primary-dark); }
.icon-btn[hidden] { display: none; }

#chat-log {
  flex: 1;
  overflow-y: auto;
  /* center a readable column on wide/full-width screens while keeping
     left/right bubble alignment inside it */
  padding: 16px max(16px, calc((100% - 900px) / 2));
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.bubble { max-width: min(82%, 640px); }
/* the home screen spans the full column so its options can sit far right */
#chat-log > .home { max-width: none; width: 100%; }

/* ---------- highlight-to-ask popover ---------- */
.highlight-popover {
  position: fixed;
  width: 280px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  z-index: 27;
  overflow: hidden;
}
.highlight-popover[hidden] { display: none; }
.highlight-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px 7px 12px;
  background: var(--primary);
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.highlight-popover-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  opacity: .85;
}
.highlight-popover-header button:active { opacity: 1; }
.highlight-popover-body {
  padding: 11px 13px;
  font-size: .88rem;
  line-height: 1.45;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text);
}
.highlight-popover-body p { margin: 0 0 8px; }
.highlight-popover-body p:last-child { margin-bottom: 0; }
.highlight-popover-body.muted { color: var(--muted); font-style: italic; }
.popover-question { font-weight: 600; font-size: .78rem; margin-bottom: 7px; }
.popover-choice-row { display: flex; gap: 5px; }
.popover-choice-btn {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 0;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
}
.popover-choice-btn:active { background: var(--primary-dark); }

.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: .95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }

/* code rendering (chat bubbles + highlight popover) */
.bubble pre,
.highlight-popover-body pre {
  background: #0d0d12;
  color: #f2f2f5;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  white-space: pre;
}
.bubble pre code,
.highlight-popover-body pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  line-height: 1.5;
  background: none;
  padding: 0;
  color: inherit;
}
.bubble code,
.highlight-popover-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: rgba(127, 127, 127, .18);
  padding: 1px 4px;
  border-radius: 4px;
}

/* clean tables, lists, rules and bold section labels */
.bubble .table-wrap,
.highlight-popover-body .table-wrap { overflow-x: auto; margin: 8px 0; }
.bubble table.md-table,
.highlight-popover-body table.md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .88rem;
  white-space: normal;
}
.bubble table.md-table th,
.bubble table.md-table td,
.highlight-popover-body table.md-table th,
.highlight-popover-body table.md-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.bubble table.md-table thead th,
.highlight-popover-body table.md-table thead th {
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}
.bubble table.md-table tbody tr:last-child td,
.highlight-popover-body table.md-table tbody tr:last-child td { border-bottom: none; }
.bubble table.md-table tbody tr:nth-child(even),
.highlight-popover-body table.md-table tbody tr:nth-child(even) { background: rgba(127, 127, 127, .06); }
.bubble ul, .bubble ol,
.highlight-popover-body ul, .highlight-popover-body ol { margin: 6px 0 8px; padding-left: 20px; }
.bubble li,
.highlight-popover-body li { margin: 2px 0; }
.bubble p.md-label,
.highlight-popover-body p.md-label { margin: 10px 0 4px; }
.bubble p.md-label:first-child,
.highlight-popover-body p.md-label:first-child { margin-top: 0; }
.bubble hr,
.highlight-popover-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
.bubble a,
.highlight-popover-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

/* nicer math: superscripts/subscripts + stacked fractions */
.bubble sup, .bubble sub,
.highlight-popover-body sup, .highlight-popover-body sub { line-height: 0; font-size: .75em; }
.bubble .frac, .highlight-popover-body .frac {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  vertical-align: -0.55em;
  margin: 0 2px;
  font-size: .95em;
}
.bubble .frac-n, .highlight-popover-body .frac-n {
  border-bottom: 1px solid currentColor;
  padding: 0 4px;
  line-height: 1.25;
}
.bubble .frac-d, .highlight-popover-body .frac-d { padding: 0 4px; line-height: 1.25; }
.bubble-user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}
.bubble-assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble.intro { color: var(--muted); }
.bubble.error { border-color: #dc2626; color: #dc2626; }

.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* composer as one rounded card (input on top, controls row below) */
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 12px calc(10px + var(--safe-bottom));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}
.composer:focus-within { border-color: var(--primary); }
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer-spacer { flex: 1; }
.icon-btn { flex-shrink: 0; }
.icon-btn.round { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); }
.icon-btn.round.primary { border-color: var(--primary); }
.icon-btn.round svg { width: 20px; height: 20px; }

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: .82rem;
  color: var(--text);
  overflow: hidden;
  flex-shrink: 0;
}
.model-pill:hover { border-color: var(--primary); }
.model-pill #model-pill-model { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-pill #model-pill-level { color: var(--muted); white-space: nowrap; }
/* on narrow phones, drop the level label so the model name stays readable */
@media (max-width: 430px) {
  .model-pill { flex-shrink: 1; }
  .model-pill #model-pill-level { display: none; }
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 0;
  background: var(--surface);
  flex-shrink: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.chip .chip-ico { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.chip:hover { border-color: var(--primary); }

/* interactive robot mascot — pink eyes, emotes, draggable (no auto-roaming) */
:root { --bot-glow: #ff5fa2; }
#mascot {
  position: fixed;
  left: 14px; top: 60%;
  z-index: 26;
  /* she stays put; a brief transition only smooths a resize/rest snap */
  transition: left .35s ease, top .35s ease;
  will-change: left, top;
}
#mascot.dragging { transition: none; cursor: grabbing; }
#mascot.dragging .mascot-face { animation: none; }
#mascot-btn { border: none; background: none; padding: 0; cursor: grab; width: 58px; height: 68px; touch-action: none; }
#mascot.dragging #mascot-btn { cursor: grabbing; }
.mascot-face { width: 58px; height: 68px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .28)); animation: mascotFloat 4.5s ease-in-out infinite; }
.r-head, .r-ear, .r-body { fill: var(--primary); }
.r-ant { stroke: var(--primary); stroke-width: 3; stroke-linecap: round; }
.r-ant-tip { fill: var(--bot-glow); animation: antPulse 2s ease-in-out infinite; }
.r-screen, .r-belly { fill: #0e1626; }
.r-eye { fill: var(--bot-glow); transform-box: fill-box; transform-origin: center; animation: mascotBlink 5.5s infinite; }
/* every non-default eye group is hidden until a state turns it on */
.r-eyes-happy, .r-eyes-wink, .r-eyes-love, .r-eyes-surprised, .r-eyes-sleepy,
.r-eyes-star, .r-eyes-cool, .r-eyes-sad, .r-eyes-focused, .r-eyes-dizzy, .r-think { display: none; }
.r-eyes-happy path, .r-eyes-wink path, .r-eyes-sleepy path { fill: none; stroke: var(--bot-glow); stroke-width: 3.2; stroke-linecap: round; }
.r-eyes-wink rect { fill: var(--bot-glow); }
.r-eyes-love path { fill: var(--bot-glow); }
.r-eyes-surprised circle { fill: var(--bot-glow); }
.r-eyes-star path { fill: var(--bot-glow); }
.r-eyes-cool path { fill: var(--bot-glow); }
.r-eyes-cool .r-cool-glass { fill: #0e1626; }
.r-eyes-cool .r-cool-bar { fill: none; stroke: var(--bot-glow); stroke-width: 2; }
.r-eyes-sad rect { fill: var(--bot-glow); }
.r-eyes-sad .r-brow { fill: none; stroke: var(--bot-glow); stroke-width: 2.6; stroke-linecap: round; }
.r-eyes-focused rect { fill: var(--bot-glow); }
.r-eyes-dizzy path { fill: none; stroke: var(--bot-glow); stroke-width: 2.4; stroke-linecap: round; }
.r-think circle { fill: var(--bot-glow); }
#mascot-btn:hover .mascot-face { transform: scale(1.06); }
@keyframes mascotFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes mascotBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }
@keyframes antPulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
/* thinking: eyes off, bouncing dots on the screen */
#mascot.thinking .r-eyes { display: none; }
#mascot.thinking .r-think { display: block; }
#mascot.thinking .r-think circle { animation: mascotDots 1s infinite; }
#mascot.thinking .r-think circle:nth-child(2) { animation-delay: .15s; }
#mascot.thinking .r-think circle:nth-child(3) { animation-delay: .3s; }
@keyframes mascotDots { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
/* emotions: swap which eye group shows (thinking always wins, handled above) */
#mascot.emote-happy .r-eyes, #mascot.happy .r-eyes,
#mascot.emote-wink .r-eyes,
#mascot.emote-love .r-eyes,
#mascot.emote-surprised .r-eyes,
#mascot.emote-sleepy .r-eyes,
#mascot.emote-star .r-eyes,
#mascot.emote-cool .r-eyes,
#mascot.emote-sad .r-eyes,
#mascot.emote-focused .r-eyes,
#mascot.emote-dizzy .r-eyes { display: none; }
#mascot.emote-happy .r-eyes-happy, #mascot.happy .r-eyes-happy { display: block; }
#mascot.emote-wink .r-eyes-wink { display: block; }
#mascot.emote-love .r-eyes-love { display: block; }
#mascot.emote-surprised .r-eyes-surprised { display: block; }
#mascot.emote-sleepy .r-eyes-sleepy { display: block; }
#mascot.emote-star .r-eyes-star { display: block; }
#mascot.emote-cool .r-eyes-cool { display: block; }
#mascot.emote-sad .r-eyes-sad { display: block; }
#mascot.emote-focused .r-eyes-focused { display: block; }
#mascot.emote-dizzy .r-eyes-dizzy { display: block; }
#mascot.emote-love .mascot-face { animation: mascotFloat 4.5s ease-in-out infinite, mascotLove 1.4s ease-in-out infinite; }
#mascot.emote-surprised .mascot-face { animation: mascotSurprise .5s ease; }
#mascot.emote-star .mascot-face { animation: mascotFloat 4.5s ease-in-out infinite, mascotLove 1s ease-in-out infinite; }
#mascot.emote-dizzy .mascot-face { animation: mascotDizzy .8s ease; }
#mascot.emote-sad .mascot-face { animation: mascotSad 1.2s ease; }
@keyframes mascotLove { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes mascotSurprise { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-6px) scale(1.1); } 100% { transform: translateY(0) scale(1); } }
@keyframes mascotDizzy { 0% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } 100% { transform: rotate(0); } }
@keyframes mascotSad { 0% { transform: translateY(0); } 50% { transform: translateY(4px); } 100% { transform: translateY(0); } }
/* happy: smiley eyes + a celebratory bounce */
#mascot.happy .mascot-face { animation: mascotHappy .7s ease; }
@keyframes mascotHappy { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-10px) scale(1.08); } 60% { transform: translateY(0) scale(1); } 80% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
#confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
#prompt-input.nudge { animation: inputNudge .9s ease; }
@keyframes inputNudge { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px var(--bot-glow); } 60% { box-shadow: 0 0 0 3px var(--bot-glow); } }
.mascot-bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  width: max-content;
  max-width: 220px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 9px 12px;
  font-size: .82rem;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.mascot-bubble[hidden] { display: none; }

/* sleeping: eyes shut, gentle breathing, dozing 'z's */
#mascot.sleeping .r-eyes,
#mascot.sleeping .r-think { display: none; }
#mascot.sleeping .r-eyes-sleepy { display: block; }
#mascot.sleeping .r-ant-tip { animation: none; opacity: .3; }
#mascot.sleeping .mascot-face { animation: mascotBreathe 4.2s ease-in-out infinite; }
#mascot.sleeping #mascot-btn { cursor: pointer; }
@keyframes mascotBreathe { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(1px) scale(.985); } }
.mascot-z {
  position: absolute;
  bottom: 78%;
  right: -4px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--bot-glow);
  pointer-events: none;
  opacity: 0;
}
#mascot.sleeping .mascot-z { animation: mascotZ 2.6s ease-in-out infinite; }
#mascot.sleeping .mascot-z:nth-of-type(2) { animation-delay: .8s; font-size: .95rem; right: 4px; }
#mascot.sleeping .mascot-z:nth-of-type(3) { animation-delay: 1.6s; font-size: 1.1rem; right: 12px; }
@keyframes mascotZ {
  0% { opacity: 0; transform: translateY(6px) scale(.7); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px) scale(1.1); }
}
@media (max-width: 480px) { #mascot-btn, .mascot-face { width: 48px; height: 48px; } }

/* home / empty state — intro on the left, a 3D options bar on the right */
.home { display: flex; flex-wrap: wrap; gap: 30px; align-items: center; justify-content: space-between; padding: 48px clamp(20px, 5vw, 72px); width: 100%; box-sizing: border-box; min-height: 60%; }
.home-intro { text-align: left; max-width: 420px; flex: 1 1 320px; }
.home-badge { justify-content: flex-start; }
.home-badge { display: inline-flex; }
.home-badge .brand-dot { width: 20px; height: 20px; }
.home-title { font-size: 1.4rem; margin: 14px 0 4px; }
.home-title .home-spark { width: 20px; height: 20px; fill: currentColor; vertical-align: -3px; }
.home-sub { color: var(--muted); margin: 0 0 12px; font-size: .95rem; }
.home-tip { color: var(--muted); font-size: .8rem; margin: 12px 0 0; line-height: 1.5; }
.home-bar { display: flex; flex-direction: column; gap: 12px; flex: 0 0 auto; margin-left: auto; }
.home-example {
  display: flex; align-items: center; gap: 11px;
  min-width: 216px;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  font-size: .92rem; font-weight: 600;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 3px 0 rgba(0, 0, 0, .10), 0 8px 16px rgba(0, 0, 0, .16);
  transition: transform .09s ease, box-shadow .09s ease;
}
.home-example .home-ico { width: 19px; height: 19px; fill: currentColor; flex-shrink: 0; }
.home-example:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 5px 0 rgba(0, 0, 0, .10), 0 12px 22px rgba(0, 0, 0, .2); }
.home-example:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 1px 0 rgba(0, 0, 0, .10), 0 3px 8px rgba(0, 0, 0, .16); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .home-example { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 3px 0 rgba(0, 0, 0, .5), 0 8px 18px rgba(0, 0, 0, .5); }
}

/* one-tap follow-ups under the latest answer */
.followups { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; margin: -2px 0 4px; }
.fu-chip {
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.fu-chip:hover { border-color: var(--primary); color: var(--text); }

/* reading accessibility */
#app[data-textsize="large"] .bubble { font-size: 1.05rem; }
#app[data-textsize="larger"] .bubble { font-size: 1.18rem; }
#app[data-easyread="on"] .bubble { line-height: 1.75; letter-spacing: .015em; }
#app[data-easyread="on"] .bubble li { margin: 5px 0; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.attach-preview[hidden] { display: none; }
.attach-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.attach-preview img[hidden] { display: none; }
#attach-name {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#attach-name[hidden] { display: none; }
#attach-name::before {
  content: '';
  flex-shrink: 0;
  width: 18px; height: 18px;
  background: currentColor;
  -webkit-mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8 1.5V8h4.5z'/%3E%3C/svg%3E");
  mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zm8 1.5V8h4.5z'/%3E%3C/svg%3E");
}
.attach-preview button {
  background: var(--border);
  color: var(--text);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* images inside chat bubbles */
.bubble img.chat-img {
  max-width: 100%;
  border-radius: 10px;
  margin: 6px 0 2px;
  display: block;
}

/* download button under a bubble */
.bubble-tools {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.bubble-tools button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bubble-tools button:active { color: var(--text); }
.bubble-tools svg { width: 14px; height: 14px; fill: currentColor; }
#prompt-input {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  max-height: 120px;
  padding: 4px 6px 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  line-height: 1.4;
}
#prompt-input:focus { outline: none; }
#prompt-input::placeholder { color: var(--muted); }

.settings-panel {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.settings-panel[hidden] { display: none; }
@media (min-width: 560px) {
  .settings-panel { align-items: center; }
}
.settings-card {
  background: var(--surface);
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + var(--safe-bottom));
}
@media (min-width: 560px) {
  .settings-card { border-radius: 20px; }
}
.settings-card h2 { margin: 0 0 16px; }
.field {
  display: block;
  margin-bottom: 14px;
  font-size: .88rem;
  color: var(--muted);
}
.field span { display: block; margin-bottom: 6px; }
.field.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field.row span { margin-bottom: 0; }
.field input[type="password"],
.field select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .95rem;
}
.field input[type="checkbox"] { width: 20px; height: 20px; }
.field-hint { font-size: .78rem; color: var(--muted); margin: -6px 0 16px; line-height: 1.4; }
.mono { font-family: ui-monospace, monospace; }

.settings-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: var(--border); color: var(--text); }

/* animated cursor character */
#cassie-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  pointer-events: none;
  z-index: 30;
  transform: translate(-100px, -100px);
  transition: transform .09s linear;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
}
#cassie-cursor.detour { transition: transform .4s cubic-bezier(.34, 1.3, .4, 1); }
#cassie-cursor svg { width: 18px; height: 18px; }
#cassie-cursor svg path {
  fill: #ffffff;
  stroke: rgba(0, 0, 0, .55);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
#cassie-cursor.thinking svg { animation: spin-tilt 1s ease-in-out infinite; }
#cassie-cursor .ring {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #1c1c24;
  opacity: 0;
  transform: scale(0.4);
}
#cassie-cursor.clicking .ring {
  animation: click-ring .5s ease-out;
}

@keyframes click-ring {
  0% { opacity: .8; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.6); }
}
@keyframes spin-tilt {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-18deg); }
}
