*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #E8162A;
  --red-bright: #FF2A2A;
  --green: #00C853;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 252px;
}

/* ---------- Themes ---------- */
html[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-sidebar: #FCFCFC;
  --panel: #FFFFFF;
  --panel-2: #F7F7F8;
  --raised: #F2F2F3;
  --text: #0D0D0D;
  --text-2: #5B5B60;
  --muted: #8A8A90;
  --border: rgba(13,13,13,0.09);
  --border-strong: rgba(13,13,13,0.16);
  --accent: #E8162A;
  --icon-accent: #E8162A;
  --shadow-card: 0 1px 2px rgba(13,13,13,0.05), 0 1px 3px rgba(13,13,13,0.04);
  --shadow-pop: 0 12px 32px rgba(13,13,13,0.14);
  --glow: none;
  --mascot-eye: #FFFFFF;
  --mascot-acc-bg: #1a1a1a;
  --bubble-user: #0D0D0D;
  --bubble-user-text: #FFFFFF;
  --heat-0: #EFEFF1;
  --hero-veil: rgba(255,255,255,0.90);
  --hero-opacity: 0.10;
}

html[data-theme="dark"] {
  --bg: #0A0A0A;
  --bg-sidebar: #0D0D0D;
  --panel: #131314;
  --panel-2: #161617;
  --raised: #1C1C1E;
  --text: #EDEDED;
  --text-2: #A8A8AE;
  --muted: #77777E;
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --accent: #FF2A2A;
  --icon-accent: #FF2A2A;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-pop: 0 16px 40px rgba(0,0,0,0.6);
  --glow: drop-shadow(0 0 8px rgba(255,42,42,0.5));
  --mascot-eye: #0A0A0A;
  --mascot-acc-bg: #000;
  --bubble-user: #EDEDED;
  --bubble-user-text: #0D0D0D;
  --heat-0: #1A1A1C;
  --hero-veil: rgba(10,10,10,0.88);
  --hero-opacity: 0.16;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--accent); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- Hero video (unchanged behavior, retuned to the new tokens) ---------- */
.hero-video {
  position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover;
  z-index: -2; opacity: var(--hero-opacity);
}
.hero-overlay { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--hero-veil); }
@media (prefers-reduced-motion: reduce) { .hero-video { display: none; } }
html[data-motion="reduced"] .hero-video { display: none; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

.menu-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  width: 36px; height: 36px; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); cursor: pointer;
}
.menu-toggle svg { width: 18px; height: 18px; }
.sidebar-backdrop { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 12px 8px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand .logo-icon { width: 38px; height: 38px; flex-shrink: 0; }
.brand-word { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 19px;
  color: var(--accent); letter-spacing: -0.01em; line-height: 1.1;
}
.brand-tag {
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.14em;
  color: var(--muted); text-transform: uppercase; margin-top: 2px;
}

.logo-icon { display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.logo-icon img { width: 78%; height: 78%; object-fit: contain; filter: var(--glow); }
.logo-icon--rounded { border-radius: 22%; background: var(--panel-2); border: 1px solid var(--border); }
.logo-icon--squircle { border-radius: 30%; background: var(--panel-2); border: 1px solid var(--border); }
.logo-icon--circle { border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); }
.logo-icon--bare { background: none; border: none; }
.logo-icon--bare img { width: 100%; height: 100%; }
html[data-theme="dark"] .logo-icon--rounded,
html[data-theme="dark"] .logo-icon--squircle,
html[data-theme="dark"] .logo-icon--circle { border-color: rgba(255,42,42,0.35); background: rgba(255,42,42,0.04); }

.nav-section { margin-bottom: 14px; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 0 8px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 9px; border-radius: var(--r-sm); border: none; background: transparent;
  font-family: var(--font-body); font-size: 13.5px; color: var(--text-2);
  text-align: left; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item.active { background: var(--raised); color: var(--accent); font-weight: 500; }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-ic { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-2); display: block; }
.nav-item:hover .nav-ic { color: var(--text); }
.nav-count { margin-left: auto; font-size: 10.5px; font-family: var(--font-mono); color: var(--muted); }

/* Collapsible sidebar groups */
.group { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.group-head {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 8px;
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  font-family: var(--font-body);
}
.group-head:hover { color: var(--text-2); }
.group-chev { width: 13px; height: 13px; margin-left: auto; transition: transform .2s var(--ease); }
.group.open .group-chev { transform: rotate(180deg); }
.group-body { display: none; padding: 6px 0 2px; }
.group.open .group-body { display: block; animation: fade .18s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.chat-row {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 9px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--panel);
  font-size: 12.5px; color: var(--text-2); cursor: pointer; margin-bottom: 5px;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.chat-row:hover { color: var(--text); border-color: var(--border-strong); }
.chat-row.active { border-color: var(--accent); color: var(--text); }
.chat-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.row-del {
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px;
  display: flex; flex-shrink: 0; border-radius: 4px;
}
.row-del svg { width: 13px; height: 13px; }
.row-del:hover { color: var(--accent); }

/* User card + theme toggle at the sidebar foot */
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel);
  cursor: pointer; text-align: left; transition: border-color .15s var(--ease);
}
.user-card:hover { border-color: var(--border-strong); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--panel-2); display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.user-avatar img { width: 76%; height: 76%; object-fit: contain; }
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.2; }
.user-plan { font-size: 11px; color: var(--muted); }
.user-card .icon-btn { flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: transparent; border: none; color: var(--text-2); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 14px; height: 14px; }

.theme-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.theme-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; min-width: 0; }
.theme-label svg { width: 15px; height: 15px; flex-shrink: 0; }

.foot-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.round-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: border-color .15s var(--ease), color .15s var(--ease), transform .12s var(--ease);
}
.round-btn svg { width: 15px; height: 15px; }
.round-btn:hover { border-color: var(--border-strong); color: var(--text); }
.round-btn:active { transform: scale(.92); }
.round-btn--accent { color: var(--accent); border-color: rgba(232,22,42,0.35); }
.round-btn--accent:hover { border-color: var(--accent); color: var(--accent); }

/* Uploaded replacements for the built-in line-art icons. */
.custom-icon { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-title {
  font-size: 19px; font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.topbar-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.model-pick {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--accent); }
#modelSelect {
  background: transparent; color: var(--text); border: none; outline: none;
  font-family: var(--font-body); font-size: 12.5px; cursor: pointer; max-width: 190px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-family: var(--font-body); font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--accent); border-color: var(--border); }
.btn-danger:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }

.view { flex: 1; overflow-y: auto; min-height: 0; }
.view-inner { max-width: 940px; margin: 0 auto; padding: 24px; }

/* ---------- Home dashboard ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 2px; }
.tab {
  padding: 6px 12px; border-radius: var(--r-sm); border: none; background: none;
  font-family: var(--font-body); font-size: 13px; color: var(--muted); cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; background: var(--raised); }

.seg { display: flex; gap: 2px; margin-left: auto; background: var(--panel-2); padding: 3px; border-radius: var(--r-sm); }
.seg button {
  padding: 4px 10px; border-radius: 6px; border: none; background: none;
  font-family: var(--font-body); font-size: 11.5px; color: var(--muted); cursor: pointer;
}
.seg button.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-card); }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}
.stat {
  padding: 13px 15px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.stat:nth-child(4n) { border-right: none; }
.stat:nth-child(n+5) { border-bottom: none; }
.stat-label { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.stat-value { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.stat-value.sm { font-size: 15px; }

.heatmap-wrap { padding: 16px; overflow-x: auto; }
.heatmap {
  display: grid; grid-auto-flow: column;
  grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px;
  width: max-content;
}
.heat-cell { border-radius: 3px; background: var(--heat-0); }
.heat-cell[data-level="1"] { background: rgba(232,22,42,0.30); }
.heat-cell[data-level="2"] { background: rgba(232,22,42,0.50); }
.heat-cell[data-level="3"] { background: rgba(232,22,42,0.72); }
.heat-cell[data-level="4"] { background: var(--accent); }
.heat-foot { padding: 0 16px 14px; font-size: 12px; color: var(--muted); }

.section-title { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }

.quick-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.quick-card {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 16px 8px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel); cursor: pointer; font-family: var(--font-body);
  color: var(--text); transition: border-color .15s var(--ease), transform .12s var(--ease);
}
.quick-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick-card svg { width: 26px; height: 26px; }
.quick-label { font-size: 11.5px; color: var(--text-2); text-align: center; }

.home-foot { text-align: center; padding: 34px 0 18px; }
.home-foot .mascot { width: 46px; height: 36px; margin: 0 auto 8px; }
.home-foot-tag { font-family: var(--font-display); font-weight: 700; color: var(--accent); font-size: 15px; }

/* ---------- Site Editor ---------- */
/* Doubled class so this beats the base .settings-shell two-column rule
   regardless of which block comes first in the file. */
.settings-shell.settings-shell--wide { grid-template-columns: 1fr; }

.editor-tabs {
  display: flex; gap: 4px; padding: 12px 30px 0; border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.editor-tabs .tab { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 9px 13px; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.editor-tabs .tab svg { width: 15px; height: 15px; }

.asset-slot {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 9px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel);
}
.slot-thumb {
  width: 58px; height: 58px; flex-shrink: 0; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 6px;
}
.slot-preview { max-width: 100%; max-height: 100%; object-fit: contain; }
.slot-preview--icon { width: 26px; height: 26px; color: var(--text-2); }
.slot-preview--icon svg { width: 100%; height: 100%; }
.slot-meta { flex: 1; min-width: 0; }
.slot-label { font-size: 13.5px; font-weight: 500; }
.slot-value { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.slot-actions { display: flex; gap: 5px; flex-shrink: 0; align-items: center; }
.slot-actions .btn { padding: 6px 10px; font-size: 12px; cursor: pointer; }
.slot-actions .btn svg { width: 13px; height: 13px; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.asset-tile {
  position: relative; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel); padding: 8px; text-align: center;
}
.asset-tile--pick { cursor: pointer; font-family: var(--font-body); color: var(--text); }
.asset-tile--pick:hover { border-color: var(--accent); }
.tile-thumb {
  height: 74px; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 7px;
}
.tile-thumb img, .tile-thumb video { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile-name { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-tile > .icon-btn { position: absolute; top: 4px; right: 4px; background: var(--panel); border: 1px solid var(--border); }

.text-row label { display: flex; align-items: center; gap: 8px; }
.text-key { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.text-row.is-changed .text-key { color: var(--accent); }
.text-reset {
  margin-left: auto; background: none; border: none; color: var(--accent);
  font-size: 11px; cursor: pointer; font-family: var(--font-body); padding: 0;
}
.text-default { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Prompt Engineer ---------- */
.prompt-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.prompt-grid { display: grid; gap: 12px; }
.prompt-card { padding: 15px 16px; }
.prompt-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.prompt-title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; }
.prompt-body {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; color: var(--text-2);
  background: var(--panel-2); border-radius: var(--r-sm); padding: 11px 13px;
  max-height: 132px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.prompt-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; }
.tag {
  font-size: 10.5px; font-family: var(--font-mono); padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.prompt-uses { font-size: 11px; color: var(--muted); flex-shrink: 0; }

.img-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-strip--sm { margin-top: 10px; }
.img-thumb {
  position: relative; width: 76px; height: 76px; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--border); background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.img-strip--sm .img-thumb { width: 56px; height: 56px; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb button {
  position: absolute; top: 3px; right: 3px; width: 19px; height: 19px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.62); border: none; border-radius: 50%; color: #fff; cursor: pointer; padding: 0;
}
.img-thumb button svg { width: 11px; height: 11px; }
.img-thumb button:hover { background: var(--accent); }

/* Image attachments in the composer show as thumbnails, not just filenames. */
.chip--img { padding: 3px 8px 3px 3px; gap: 7px; }
.chip--img img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; }

/* ---------- Mascot ---------- */
.mascot { position: relative; color: var(--accent); filter: var(--glow); flex-shrink: 0; }
.mascot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mascot-svg rect, .mascot-svg path { transition: none; }

html:not([data-motion="reduced"]) .mascot[data-state="idle"] svg { animation: m-breathe 4s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot[data-state="thinking"] svg { animation: m-bob .9s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot[data-state="coding"] svg { animation: m-bob 1.3s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot[data-state="success"] svg { animation: m-pop .5s var(--ease); }
html:not([data-motion="reduced"]) .mascot[data-state="error"] svg { animation: m-shake .4s ease-in-out; }
html:not([data-motion="reduced"]) .mascot[data-state="excited"] svg { animation: m-bounce .6s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot[data-state="sleeping"] svg { animation: m-sleep 3.4s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot[data-state="loading"] svg { animation: m-breathe 2s ease-in-out infinite; }

html:not([data-motion="reduced"]) .mascot-acc--dots circle { animation: m-dots 1.3s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot-acc--dots circle:nth-child(2) { animation-delay: .18s; }
html:not([data-motion="reduced"]) .mascot-acc--dots circle:nth-child(3) { animation-delay: .36s; }
html:not([data-motion="reduced"]) .mascot-acc--spinner circle { transform-origin: 15.6px 9.2px; animation: m-spin 1s linear infinite; }
html:not([data-motion="reduced"]) .mascot-acc--zzz text { animation: m-dots 2.4s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot-acc--zzz text:nth-child(2) { animation-delay: .3s; }
html:not([data-motion="reduced"]) .mascot-acc--zzz text:nth-child(3) { animation-delay: .6s; }
html:not([data-motion="reduced"]) .mascot-acc--sparkles path { animation: m-twinkle 1.6s ease-in-out infinite; }
html:not([data-motion="reduced"]) .mascot-acc--sparkles path:nth-child(2) { animation-delay: .4s; }
html:not([data-motion="reduced"]) .mascot-acc--sparkles path:nth-child(3) { animation-delay: .8s; }
html:not([data-motion="reduced"]) .mascot-acc--alert { animation: m-blink .7s steps(1) infinite; }

@keyframes m-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes m-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7%); } }
@keyframes m-bounce { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-12%) scale(1.05); } }
@keyframes m-pop { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes m-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6%); } 75% { transform: translateX(6%); } }
@keyframes m-sleep { 0%,100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.02) translateY(2%); } }
@keyframes m-dots { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes m-spin { to { transform: rotate(360deg); } }
@keyframes m-twinkle { 0%,100% { opacity: .2; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes m-blink { 0%,50% { opacity: 1; } 51%,100% { opacity: .3; } }

/* ---------- Chat ---------- */
.messages { display: flex; flex-direction: column; gap: 16px; padding: 24px; max-width: 860px; margin: 0 auto; }
.empty-state { margin: auto; text-align: center; max-width: 460px; color: var(--muted); padding: 60px 20px; }
.empty-state .mascot { width: 74px; height: 58px; margin: 0 auto 16px; }
.empty-state h2 { font-size: 19px; color: var(--text); font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; line-height: 1.7; }
.empty-state code { font-family: var(--font-mono); color: var(--accent); font-size: 12.5px; }

/* The hero uses the full logo lockup (mascot + wordmark), so it needs more
   room than the bare mark does elsewhere. */
.hero-logo { width: 240px; max-width: 62vw; margin: 0 auto 14px; }
.hero-logo img { width: 100%; height: auto; object-fit: contain; filter: var(--glow); display: block; }
html:not([data-motion="reduced"]) .hero-logo img { animation: hero-float 5s ease-in-out infinite; transform-origin: center bottom; }
@keyframes hero-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.02); }
}
.hero-hello {
  font-family: var(--font-display); letter-spacing: 0.02em;
  font-size: 22px !important; color: var(--accent) !important; margin-bottom: 10px !important;
}

.msg {
  max-width: 74ch; padding: 12px 16px; border-radius: var(--r-lg); line-height: 1.7;
  white-space: pre-wrap; word-wrap: break-word; animation: msg-in .28s var(--ease); font-size: 14.5px;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.msg-user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-text); border-bottom-right-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-assistant.msg-error { border-color: var(--accent); color: var(--accent); }
.msg code { font-family: var(--font-mono); font-size: 13px; }
.msg pre { background: var(--panel-2); padding: 11px 13px; border-radius: var(--r-sm); overflow-x: auto; margin: 7px 0; }

.type-cursor { display: inline-block; width: 15px; height: 12px; margin-left: 5px; vertical-align: -1px; color: var(--accent); }
.type-cursor svg { width: 100%; height: 100%; overflow: visible; }
html:not([data-motion="reduced"]) .type-cursor { animation: m-bob .5s ease-in-out infinite; }

.typing-dots { display: inline-flex; gap: 4px; padding: 3px 0; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: m-dots 1.1s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

/* ---------- Composer ---------- */
.composer-wrap { padding: 0 24px 20px; flex-shrink: 0; }
.composer-inner { max-width: 860px; margin: 0 auto; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attachments:empty { display: none; }
.chip {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 11px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  font-size: 11.5px; font-family: var(--font-mono);
}
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; display: flex; padding: 0; }
.chip button svg { width: 12px; height: 12px; }
.chip button:hover { color: var(--accent); }

.composer {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel);
  box-shadow: var(--shadow-card); overflow: hidden; transition: border-color .15s var(--ease);
}
.composer:focus-within { border-color: var(--border-strong); }
.composer-top { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 8px; }
#promptInput {
  flex: 1; resize: none; background: none; border: none; outline: none; color: var(--text);
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.6; max-height: 180px; padding: 2px 0;
}
#promptInput::placeholder { color: var(--muted); }
.composer-bar {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px;
  border-top: 1px solid var(--border); background: var(--panel-2);
}
.bar-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 6px;
  background: none; border: none; color: var(--muted); font-family: var(--font-body);
  font-size: 11.5px; cursor: pointer;
}
.bar-chip:hover { background: var(--raised); color: var(--text); }
.bar-chip svg { width: 13px; height: 13px; }
.bar-spacer { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 30px; height: 17px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .18s var(--ease); flex-shrink: 0;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: #fff; transition: transform .18s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(13px); }

/* ---------- Settings overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; display: none; }
.overlay.open { display: block; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.settings-shell {
  position: absolute; inset: 4vh 5vw; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-pop); overflow: hidden;
  display: grid; grid-template-columns: 246px 1fr; animation: pop .2s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.settings-nav { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.settings-nav-scroll { flex: 1; overflow-y: auto; padding: 12px 10px; }
.settings-brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.settings-brand .logo-icon { width: 34px; height: 34px; }

.search-box {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 12px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel);
}
.search-box svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.search-box input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: var(--font-body); font-size: 12.5px; }
.search-box kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px;
}

.settings-panel { overflow-y: auto; }
.settings-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 26px 30px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.settings-head p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.settings-body { padding: 24px 30px 40px; max-width: 720px; }

.field-group { margin-bottom: 30px; }
.field-group > h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.field-group > .hint { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field input[type="text"], .field select, .field textarea {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 11px; font-family: var(--font-body); font-size: 13.5px;
  outline: none; transition: border-color .15s var(--ease); width: 100%;
}
.field textarea { resize: vertical; min-height: 120px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--border-strong); }
.field .counter { font-size: 11px; color: var(--muted); text-align: right; font-family: var(--font-mono); }

.pref-row {
  display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border);
}
.pref-row:last-child { border-bottom: none; }
.pref-text { flex: 1; min-width: 0; }
.pref-text strong { display: block; font-size: 13.5px; font-weight: 500; }
.pref-text span { font-size: 12.5px; color: var(--muted); }
.pref-control { flex-shrink: 0; }

.choice { display: flex; gap: 6px; }
.choice button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 42px; height: 36px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2);
  font-family: var(--font-body); font-size: 12.5px; cursor: pointer;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.choice button svg { width: 16px; height: 16px; }
.choice button:hover { border-color: var(--border-strong); color: var(--text); }
.choice button.active { border-color: var(--accent); color: var(--accent); }

.avatar-edit { position: relative; width: 112px; height: 112px; flex-shrink: 0; }
.avatar-edit .logo-icon { width: 100%; height: 100%; border-radius: var(--r-lg); }
.avatar-edit .icon-btn {
  position: absolute; right: -6px; bottom: -6px; background: var(--panel);
  border: 1px solid var(--border); width: 28px; height: 28px;
}
.profile-row { display: flex; gap: 22px; align-items: flex-start; }
.profile-fields { flex: 1; min-width: 0; }

.notice {
  display: flex; gap: 10px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--panel-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
  line-height: 1.6;
}
.notice svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); margin-top: 1px; }
.notice strong { color: var(--text); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv dt { color: var(--muted); }
.kv dd { font-family: var(--font-mono); font-size: 12.5px; text-align: right; word-break: break-all; }

.pill { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.pill.ready { color: var(--green); border: 1px solid var(--green); }
.pill.missing { color: var(--accent); border: 1px solid var(--accent); }

.list-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); margin-bottom: 8px;
}
.list-row .list-main { flex: 1; min-width: 0; }
.list-row .list-title { font-size: 13px; font-weight: 500; }
.list-row .list-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.list-actions { display: flex; gap: 5px; flex-shrink: 0; }

.inline-form { display: flex; gap: 7px; margin-bottom: 12px; }
.inline-form input, .inline-form textarea {
  flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 10px; font-family: var(--font-body); font-size: 13px;
  outline: none; resize: none;
}
.inline-form input:focus, .inline-form textarea:focus { border-color: var(--border-strong); }

.empty-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; padding: 4px 0; }

/* File browser */
.file-crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.file-crumbs button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.file-crumbs button:hover { color: var(--accent); }
.file-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.file-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; cursor: pointer; background: none; border: none; color: var(--text-2);
  font-family: var(--font-body); text-align: left; width: 100%;
}
.file-row:hover { background: var(--raised); color: var(--text); }
.file-row svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); }
.file-row.is-dir svg { color: var(--accent); }
.file-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Generic modal (skill editor, file preview) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90; display: none; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: block; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(560px, 92vw); max-height: 84vh; overflow-y: auto; z-index: 91; display: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--shadow-pop);
}
.modal.open { display: block; animation: pop .18s var(--ease); }
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.file-preview {
  font-family: var(--font-mono); font-size: 12px; background: var(--panel-2); padding: 13px;
  border-radius: var(--r-sm); max-height: 52vh; overflow: auto; white-space: pre-wrap;
  word-break: break-word; line-height: 1.6;
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500; z-index: 120; opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; }
  .topbar { padding-left: 58px; }
  .sidebar {
    position: fixed; inset: 0 22% 0 0; z-index: 70;
    transform: translateX(-100%); transition: transform .26s var(--ease);
    box-shadow: 2px 0 30px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.5); }
  .settings-shell { inset: 0; border-radius: 0; grid-template-columns: 1fr; }
  .settings-nav { display: none; }
  .settings-nav.mobile-open { display: flex; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(4n) { border-right: 1px solid var(--border); }
  .stat:nth-child(2n) { border-right: none; }
  .stat:nth-child(n+5) { border-bottom: 1px solid var(--border); }
  .stat:nth-child(n+7) { border-bottom: none; }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .view-inner, .messages { padding: 16px; }
  .composer-wrap { padding: 0 16px 16px; }
  .profile-row { flex-direction: column; }
  .settings-body, .settings-head { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 640px) {
  /* Let the title keep a readable line of its own instead of being crushed
     to an ellipsis by the model picker. */
  .topbar { flex-wrap: wrap; row-gap: 10px; padding-top: 14px; }
  .topbar-title { font-size: 15px; order: 1; width: 100%; }
  .topbar-actions { order: 2; width: 100%; }
  .model-pick { flex: 1; min-width: 0; }
  #modelSelect { max-width: none; width: 100%; font-size: 12px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 17px; }
  .pref-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}
