:root {
  color-scheme: light;
  --paper: #f5efe6;
  --paper-strong: #fffaf1;
  --ink: #17212b;
  --muted: #66727c;
  --line: #d4d8e6;
  --surface: rgba(255, 250, 241, 0.88);
  --surface-solid: #fffaf1;
  --surface-muted: rgba(255, 255, 255, 0.82);
  --field-bg: rgba(255, 255, 255, 0.82);
  --pill-bg: rgba(255, 250, 241, 0.76);
  --bubble-bg: #ffffff;
  --bubble-user: #dff1ee;
  --bubble-assistant: #fff6df;
  --head-overlay-a: rgba(255, 250, 241, 0.9);
  --head-overlay-b: rgba(255, 250, 241, 0.62);
  --panel-frost: rgba(255, 250, 241, 0.98);
  --control-bg: #fffaf1;
  --control-active: #e4ebff;
  --on-accent: #ffffff;
  --danger: #9c2f27;
  --logo-blue: #5d7df3;
  --logo-ink: #314795;
  --teal: #347f89;
  --teal-dark: #314795;
  --teal-soft: #e4ebff;
  --coral: #cf6159;
  --gold: #bb8b2d;
  --leaf: #60784d;
  --mood-a: #f1bc5b;
  --mood-b: #5d7df3;
  --mood-c: #cf6159;
  --theme-a: #f1bc5b;
  --theme-b: #5d7df3;
  --theme-c: #cf6159;
  --mood-intensity: 0.48;
  --mood-opacity: 0.56;
  --ui-scale: 1;
  --text-scale: 1;
  --motion-smoothness: 0.35;
  --motion-bounce: 0.65;
  --motion-pop-time: 420ms;
  --motion-loop-time: 1.5s;
  --motion-sweep-time: 730ms;
  --motion-bars-time: 1.08s;
  --motion-bubble-time: 2.48s;
  --motion-top-time: 2.55s;
  --motion-stage-time: 3.23s;
  --motion-logo-time: 1.65s;
  --motion-button-time: 2.03s;
  --motion-composer-time: 1.88s;
  --motion-hover-time: 132ms;
  --motion-lift: 6px;
  --motion-lift-neg: -6px;
  --motion-slam: 18px;
  --motion-slam-neg: -18px;
  --motion-pop-scale: 1.03;
  --motion-hover-scale: 1.055;
  --motion-stage-scale: 1.012;
  --motion-logo-scale: 1.12;
  --motion-logo-turn: 8deg;
  --motion-logo-turn-neg: -8deg;
  --motion-ease: cubic-bezier(0.16, 1.25, 0.24, 1);
  --drawer-top: min(calc(80px * var(--ui-scale)), 118px);
  --shadow: 0 18px 44px rgba(28, 33, 39, 0.15);
  --tight-shadow: 0 12px 28px rgba(28, 33, 39, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--theme-b) 15%, transparent), transparent 34%),
    linear-gradient(315deg, color-mix(in srgb, var(--theme-a) 16%, transparent), transparent 35%),
    var(--paper);
  color: var(--ink);
  font-size: calc(16px * var(--text-scale));
  transition: background 240ms ease, color 240ms ease;
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 35%, color-mix(in srgb, var(--mood-b) 16%, transparent) 48%, transparent 62%),
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--mood-c) 10%, transparent), transparent 30%);
  opacity: 0;
  transform: translateX(-10%);
}

body[data-animation-level="dramatic"]::before {
  opacity: 1;
  animation: dramaticSky 3.8s ease-in-out infinite alternate;
}

body[data-animation-level="calm"]::before,
body[data-reduce-motion="true"]::before {
  display: none;
}

body[data-color-scheme="sunset"] {
  --paper: #fff0e7;
  --paper-strong: #fffaf4;
  --ink: #241923;
  --muted: #725d64;
  --line: #dfc6bd;
  --logo-blue: #e06452;
  --logo-ink: #6f2f68;
  --teal: #9a5f6b;
  --teal-dark: #6f2f68;
  --teal-soft: #ffe0d8;
  --mood-a: #f0b354;
  --mood-b: #e06452;
  --mood-c: #6f2f68;
  --theme-a: #f0b354;
  --theme-b: #e06452;
  --theme-c: #6f2f68;
}

body[data-color-scheme="forest"] {
  --paper: #eef6ef;
  --paper-strong: #fbfff8;
  --ink: #14231f;
  --muted: #596b62;
  --line: #c7d9cd;
  --logo-blue: #367d66;
  --logo-ink: #24473e;
  --teal: #367d66;
  --teal-dark: #24473e;
  --teal-soft: #dceee3;
  --mood-a: #d4b75c;
  --mood-b: #367d66;
  --mood-c: #a45f5c;
  --theme-a: #d4b75c;
  --theme-b: #367d66;
  --theme-c: #a45f5c;
}

body[data-color-scheme="midnight"] {
  color-scheme: dark;
  --paper: #101827;
  --paper-strong: #172133;
  --ink: #f6f0e8;
  --muted: #b7c2d2;
  --line: #46536a;
  --danger: #ffaca3;
  --logo-blue: #8aa4ff;
  --logo-ink: #d3dcff;
  --teal: #8aa4ff;
  --teal-dark: #556dd4;
  --teal-soft: #25365a;
  --on-accent: #101827;
  --mood-a: #d6a85c;
  --mood-b: #8aa4ff;
  --mood-c: #d47d9e;
  --theme-a: #d6a85c;
  --theme-b: #8aa4ff;
  --theme-c: #d47d9e;
}

body[data-color-scheme="candy"] {
  --paper: #fff1fb;
  --paper-strong: #fffdf4;
  --ink: #2a1234;
  --muted: #7d5578;
  --line: #f0a7d8;
  --logo-blue: #ff64b7;
  --logo-ink: #7d4dff;
  --teal: #35c9c8;
  --teal-dark: #7d4dff;
  --teal-soft: #d9fff7;
  --mood-a: #ffe66d;
  --mood-b: #ff64b7;
  --mood-c: #62d7d1;
  --theme-a: #ffe66d;
  --theme-b: #ff64b7;
  --theme-c: #62d7d1;
}

body[data-color-scheme="ocean"] {
  color-scheme: dark;
  --paper: #06172f;
  --paper-strong: #08284c;
  --ink: #e9f8ff;
  --muted: #9fd4ee;
  --line: #1f74a8;
  --logo-blue: #25a8e0;
  --logo-ink: #c8f5ff;
  --teal: #20c7cb;
  --teal-dark: #0c4c73;
  --teal-soft: #0d3d68;
  --mood-a: #25c7e5;
  --mood-b: #0a5f9f;
  --mood-c: #18a9a8;
  --theme-a: #25c7e5;
  --theme-b: #0b4f91;
  --theme-c: #17b4b8;
}

body[data-color-scheme="ember"] {
  color-scheme: dark;
  --paper: #290407;
  --paper-strong: #4c0808;
  --ink: #fff0e7;
  --muted: #ffb58f;
  --line: #aa2b1c;
  --logo-blue: #ff4c1f;
  --logo-ink: #f5ad55;
  --teal: #ff7a24;
  --teal-dark: #a81712;
  --teal-soft: #5d1309;
  --mood-a: #ff8a28;
  --mood-b: #c91a17;
  --mood-c: #f5ad55;
  --theme-a: #ff7a24;
  --theme-b: #b81317;
  --theme-c: #f5ad55;
}

body[data-color-scheme="grape"] {
  --paper: #f3ecff;
  --paper-strong: #fbf7ff;
  --ink: #24133b;
  --muted: #6a5884;
  --line: #c9b5ef;
  --logo-blue: #7b45d8;
  --logo-ink: #4b1f83;
  --teal: #985ee8;
  --teal-dark: #4b1f83;
  --teal-soft: #eadfff;
  --mood-a: #b86bff;
  --mood-b: #7b45d8;
  --mood-c: #4b1f83;
  --theme-a: #b86bff;
  --theme-b: #7b45d8;
  --theme-c: #4b1f83;
}

body[data-color-scheme="mono"] {
  color-scheme: dark;
  --paper: #111315;
  --paper-strong: #191c20;
  --ink: #f1f2f2;
  --muted: #c4c8cc;
  --line: #626a73;
  --danger: #ffb0aa;
  --logo-blue: #aeb5bd;
  --logo-ink: #f1f2f2;
  --teal: #d0d4d8;
  --teal-dark: #aeb5bd;
  --teal-soft: #30363d;
  --mood-a: #d2d2d2;
  --mood-b: #aeb5bd;
  --mood-c: #7d858e;
  --theme-a: #d2d2d2;
  --theme-b: #aeb5bd;
  --theme-c: #7d858e;
}

body[data-color-scheme="cozy"] {
  color-scheme: dark;
  --paper: #24181d;
  --paper-strong: #34211f;
  --ink: #fff2e5;
  --muted: #d8aa9a;
  --line: #7d5148;
  --danger: #ffb4a3;
  --logo-blue: #d87345;
  --logo-ink: #f0b46b;
  --teal: #c35e58;
  --teal-dark: #8a3d32;
  --teal-soft: #4a2a23;
  --mood-a: #f0b46b;
  --mood-b: #d87345;
  --mood-c: #c35e58;
  --theme-a: #f0b46b;
  --theme-b: #d87345;
  --theme-c: #c35e58;
}

body[data-color-scheme="aurora"] {
  color-scheme: dark;
  --paper: #071b23;
  --paper-strong: #0d2d38;
  --ink: #ecfff7;
  --muted: #a4d7cf;
  --line: #2a8b8e;
  --danger: #ffb4c8;
  --logo-blue: #4ed4c8;
  --logo-ink: #b88cff;
  --teal: #6ee7b7;
  --teal-dark: #1c7f78;
  --teal-soft: #123d43;
  --mood-a: #8ee7ff;
  --mood-b: #b88cff;
  --mood-c: #6ee7b7;
  --theme-a: #8ee7ff;
  --theme-b: #b88cff;
  --theme-c: #6ee7b7;
}

body[data-color-scheme="citrus"] {
  --paper: #fbfff1;
  --paper-strong: #fff8ce;
  --ink: #1f2b11;
  --muted: #5d6f36;
  --line: #c8dc72;
  --logo-blue: #7dcf28;
  --logo-ink: #f29c1f;
  --teal: #2fbf78;
  --teal-dark: #578817;
  --teal-soft: #e6ffc4;
  --mood-a: #ffd94d;
  --mood-b: #ff8a22;
  --mood-c: #7ed957;
  --theme-a: #ffd94d;
  --theme-b: #ff8a22;
  --theme-c: #7ed957;
}

body[data-color-scheme="sunset"] {
  --surface: rgba(255, 246, 238, 0.92);
  --surface-solid: #fff9f3;
  --surface-muted: rgba(255, 255, 255, 0.88);
  --field-bg: rgba(255, 252, 248, 0.9);
  --pill-bg: rgba(255, 246, 238, 0.82);
  --bubble-bg: #fffdfa;
  --bubble-user: #ffe0d8;
  --bubble-assistant: #fff0cf;
  --head-overlay-a: rgba(255, 246, 238, 0.92);
  --head-overlay-b: rgba(255, 229, 216, 0.68);
  --panel-frost: rgba(255, 248, 242, 0.98);
  --control-bg: #fff9f3;
  --control-active: #ffe0d8;
}

body[data-color-scheme="forest"] {
  --surface: rgba(248, 255, 248, 0.92);
  --surface-solid: #fbfff8;
  --surface-muted: rgba(255, 255, 255, 0.88);
  --field-bg: rgba(255, 255, 255, 0.9);
  --pill-bg: rgba(244, 255, 245, 0.82);
  --bubble-bg: #ffffff;
  --bubble-user: #dceee3;
  --bubble-assistant: #fff4ce;
  --head-overlay-a: rgba(248, 255, 248, 0.92);
  --head-overlay-b: rgba(221, 241, 226, 0.7);
  --panel-frost: rgba(248, 255, 248, 0.98);
  --control-bg: #fbfff8;
  --control-active: #dceee3;
}

body[data-color-scheme="midnight"] {
  --surface: rgba(23, 33, 51, 0.94);
  --surface-solid: #172133;
  --surface-muted: rgba(16, 24, 39, 0.84);
  --field-bg: rgba(12, 18, 30, 0.9);
  --pill-bg: rgba(18, 27, 44, 0.94);
  --bubble-bg: #172133;
  --bubble-user: #244763;
  --bubble-assistant: #342d4b;
  --head-overlay-a: rgba(16, 24, 39, 0.95);
  --head-overlay-b: rgba(23, 33, 51, 0.78);
  --panel-frost: rgba(18, 27, 44, 0.96);
  --control-bg: #172133;
  --control-active: #25365a;
}

body[data-color-scheme="candy"] {
  --surface: rgba(255, 241, 251, 0.93);
  --surface-solid: #fff7fd;
  --surface-muted: rgba(255, 231, 246, 0.88);
  --field-bg: rgba(255, 253, 244, 0.94);
  --pill-bg: rgba(217, 255, 247, 0.86);
  --bubble-bg: #fffdf4;
  --bubble-user: #ffe0f2;
  --bubble-assistant: #e0fff8;
  --head-overlay-a: rgba(255, 232, 247, 0.94);
  --head-overlay-b: rgba(217, 255, 247, 0.72);
  --panel-frost: rgba(255, 246, 252, 0.98);
  --control-bg: #fffdf4;
  --control-active: #ffe0f2;
}

body[data-color-scheme="ocean"] {
  --surface: rgba(8, 40, 76, 0.94);
  --surface-solid: #0a315d;
  --surface-muted: rgba(6, 29, 55, 0.9);
  --field-bg: rgba(5, 24, 49, 0.94);
  --pill-bg: rgba(9, 61, 103, 0.9);
  --bubble-bg: #09284d;
  --bubble-user: #0e4677;
  --bubble-assistant: #07365b;
  --head-overlay-a: rgba(8, 45, 84, 0.96);
  --head-overlay-b: rgba(5, 79, 122, 0.82);
  --panel-frost: rgba(8, 32, 62, 0.98);
  --control-bg: #09284d;
  --control-active: #0d568d;
  --on-accent: #e9f8ff;
}

body[data-color-scheme="ember"] {
  --surface: rgba(76, 8, 8, 0.94);
  --surface-solid: #651009;
  --surface-muted: rgba(47, 5, 6, 0.9);
  --field-bg: rgba(39, 4, 6, 0.94);
  --pill-bg: rgba(116, 24, 11, 0.9);
  --bubble-bg: #4b0908;
  --bubble-user: #851a12;
  --bubble-assistant: #692109;
  --head-overlay-a: rgba(86, 9, 9, 0.96);
  --head-overlay-b: rgba(186, 55, 18, 0.82);
  --panel-frost: rgba(62, 7, 9, 0.98);
  --control-bg: #4b0908;
  --control-active: #9b2a13;
  --on-accent: #fff0e7;
}

body[data-color-scheme="grape"] {
  --surface: rgba(248, 242, 255, 0.93);
  --surface-solid: #fbf7ff;
  --surface-muted: rgba(236, 225, 255, 0.88);
  --field-bg: rgba(255, 251, 255, 0.92);
  --pill-bg: rgba(234, 223, 255, 0.86);
  --bubble-bg: #fbf7ff;
  --bubble-user: #e6d7ff;
  --bubble-assistant: #f0e7ff;
  --head-overlay-a: rgba(248, 242, 255, 0.94);
  --head-overlay-b: rgba(226, 211, 255, 0.76);
  --panel-frost: rgba(248, 242, 255, 0.98);
  --control-bg: #fbf7ff;
  --control-active: #e6d7ff;
}

body[data-color-scheme="mono"] {
  color-scheme: dark;
  --paper: #111315;
  --paper-strong: #191c20;
  --ink: #f1f2f2;
  --muted: #c4c8cc;
  --line: #626a73;
  --surface: rgba(25, 28, 32, 0.94);
  --surface-solid: #191c20;
  --surface-muted: rgba(14, 16, 18, 0.84);
  --field-bg: rgba(8, 10, 12, 0.9);
  --pill-bg: rgba(20, 23, 26, 0.94);
  --bubble-bg: #191c20;
  --bubble-user: #30363d;
  --bubble-assistant: #25282d;
  --head-overlay-a: rgba(17, 19, 21, 0.95);
  --head-overlay-b: rgba(31, 35, 39, 0.78);
  --panel-frost: rgba(20, 23, 26, 0.96);
  --control-bg: #191c20;
  --control-active: #30363d;
  --on-accent: #111315;
  --logo-blue: #aeb5bd;
  --logo-ink: #f1f2f2;
  --teal: #d0d4d8;
  --teal-dark: #aeb5bd;
  --teal-soft: #30363d;
  --mood-a: #d2d2d2;
  --mood-b: #aeb5bd;
  --mood-c: #7d858e;
  --theme-a: #d2d2d2;
  --theme-b: #aeb5bd;
  --theme-c: #7d858e;
}

body[data-color-scheme="cozy"] {
  --surface: rgba(53, 34, 31, 0.94);
  --surface-solid: #3b2721;
  --surface-muted: rgba(36, 24, 29, 0.88);
  --field-bg: rgba(31, 21, 24, 0.92);
  --pill-bg: rgba(78, 44, 36, 0.9);
  --bubble-bg: #34211f;
  --bubble-user: #553026;
  --bubble-assistant: #473029;
  --head-overlay-a: rgba(52, 33, 31, 0.96);
  --head-overlay-b: rgba(93, 53, 38, 0.78);
  --panel-frost: rgba(43, 29, 31, 0.98);
  --control-bg: #34211f;
  --control-active: #553026;
  --on-accent: #24181d;
}

body[data-color-scheme="aurora"] {
  --surface: rgba(13, 45, 56, 0.94);
  --surface-solid: #0e3340;
  --surface-muted: rgba(7, 27, 35, 0.88);
  --field-bg: rgba(6, 24, 31, 0.92);
  --pill-bg: rgba(18, 61, 67, 0.9);
  --bubble-bg: #0d2d38;
  --bubble-user: #174f58;
  --bubble-assistant: #24385a;
  --head-overlay-a: rgba(9, 34, 43, 0.96);
  --head-overlay-b: rgba(42, 139, 142, 0.74);
  --panel-frost: rgba(9, 33, 42, 0.98);
  --control-bg: #0d2d38;
  --control-active: #174f58;
  --on-accent: #071b23;
}

body[data-color-scheme="citrus"] {
  --surface: rgba(252, 255, 226, 0.93);
  --surface-solid: #fff8ce;
  --surface-muted: rgba(239, 255, 200, 0.88);
  --field-bg: rgba(255, 255, 244, 0.94);
  --pill-bg: rgba(230, 255, 196, 0.86);
  --bubble-bg: #fffff0;
  --bubble-user: #e6ffc4;
  --bubble-assistant: #fff0b8;
  --head-overlay-a: rgba(255, 248, 206, 0.94);
  --head-overlay-b: rgba(230, 255, 196, 0.72);
  --panel-frost: rgba(252, 255, 226, 0.98);
  --control-bg: #fffff0;
  --control-active: #e6ffc4;
}

body[data-calm-background="true"] {
  background: var(--paper);
}

body[data-high-contrast="true"] {
  --paper: #fbfbf7;
  --paper-strong: #ffffff;
  --ink: #07111d;
  --muted: #33404d;
  --line: #344154;
  --danger: #8c1515;
  --teal-soft: #dce5ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

body[data-mood="steady"] {
  --mood-a: #d4b46a;
  --mood-b: #577d76;
  --mood-c: #5d6d76;
}

body[data-mood="heavy"],
body[data-mood="drained"] {
  --mood-a: #a9a096;
  --mood-b: #4f6670;
  --mood-c: #8a6d64;
}

body[data-mood="sad"] {
  --mood-a: #8ea7ad;
  --mood-b: #506d78;
  --mood-c: #9c8f7d;
}

body[data-mood="angry"] {
  --mood-a: #c87165;
  --mood-b: #6f4e4a;
  --mood-c: #26313b;
}

body[data-mood="celebrating"],
body[data-mood="hopeful"] {
  --mood-a: #d2a742;
  --mood-b: #60855f;
  --mood-c: #cf6159;
}

body[data-mood="focused"] {
  --mood-a: #9a8f61;
  --mood-b: #0d6f70;
  --mood-c: #334451;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 250, 241, 0.24), transparent 32%),
    linear-gradient(135deg, #5d7df3, #4866d1 58%, #314795);
  transition: opacity 360ms ease, visibility 360ms ease;
}

body[data-ready="true"] .loading-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 18px;
  transform: translateY(-8px);
}

.loading-card img {
  width: 118px;
  height: 118px;
  border-radius: 30px;
  box-shadow: 0 26px 54px rgba(23, 33, 43, 0.24);
  animation: logoBreathe 1.4s ease-in-out infinite;
}

.loading-bars {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  align-items: end;
  gap: 7px;
  height: 30px;
}

.loading-bars span {
  display: block;
  border-radius: 999px;
  background: var(--paper-strong);
  animation: loadingBounce 760ms ease-in-out infinite;
}

.loading-bars span:nth-child(1) {
  height: 14px;
}

.loading-bars span:nth-child(2) {
  height: 24px;
  animation-delay: 110ms;
}

.loading-bars span:nth-child(3) {
  height: 18px;
  animation-delay: 220ms;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: calc(10px * var(--ui-scale));
  height: 100dvh;
  padding: calc(10px * var(--ui-scale));
  overflow: hidden;
}

.top-bar,
.conversation,
.top-drawer {
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--tight-shadow);
}

.top-bar {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: 94px 190px minmax(0, 1fr) 104px;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: calc(8px * var(--ui-scale));
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(49, 71, 149, 0.2);
}

.brand h1,
.brand p,
.drawer-head h2,
.drawer-head p {
  margin: 0;
}

.brand h1 {
  font-size: 1.04rem;
}

.brand p,
.drawer-head p {
  color: var(--muted);
  font-size: 0.76rem;
}

.top-action,
.primary-action,
.send-button,
.ghost-button,
.rail-actions button,
.item-button,
.mood-display {
  min-height: calc(38px * var(--ui-scale));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
}

.top-action {
  display: inline-grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 calc(10px * var(--ui-scale));
  font-size: 0.86rem;
  font-weight: 800;
}

.top-action > span:first-child {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
}

.top-action > span:first-child::before,
.top-action > span:first-child::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 180ms ease, top 180ms ease, box-shadow 180ms ease;
}

.top-action > span:first-child::before {
  top: 4px;
  box-shadow: 0 5px 0 currentColor;
}

.top-action > span:first-child::after {
  top: 14px;
}

#toggleSettings > span:first-child::before {
  top: 3px;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

#toggleSettings > span:first-child::after {
  top: 1px;
  right: auto;
  left: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 8px 5px 0 currentColor, 3px 10px 0 currentColor;
}

.top-action[aria-expanded="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.primary-action,
.send-button {
  border-color: var(--teal-dark);
  background: linear-gradient(135deg, var(--logo-ink), var(--logo-blue));
  color: var(--on-accent);
  font-weight: 800;
}

.primary-action.compact {
  min-width: 62px;
  min-height: 34px;
}

.ghost-button:hover,
.rail-actions button:hover,
.item-button:hover,
.top-action:hover {
  border-color: var(--teal);
}

.danger-text {
  color: var(--danger);
}

.mood-display {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--theme-b) 16%, var(--control-bg)), color-mix(in srgb, var(--theme-a) 18%, var(--control-bg))),
    var(--control-bg);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 240ms ease;
}

.mood-display:hover {
  border-color: var(--mood-b);
  transform: translateY(-1px);
}

.mood-bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 4px;
  width: 34px;
  height: 28px;
}

.mood-bars span {
  display: block;
  border-radius: 999px 999px 3px 3px;
  opacity: var(--mood-opacity);
  transform-origin: bottom;
  animation: moodLift 1.8s ease-in-out infinite;
}

.mood-bars span:nth-child(1) {
  height: 56%;
  background: var(--mood-a);
}

.mood-bars span:nth-child(2) {
  height: 88%;
  background: var(--mood-b);
  animation-delay: 140ms;
}

.mood-bars span:nth-child(3) {
  height: 68%;
  background: var(--mood-c);
  animation-delay: 280ms;
}

.mood-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mood-copy strong,
.mood-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mood-copy strong {
  font-size: 0.88rem;
}

.mood-copy small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  border: 0;
  background: rgba(23, 33, 43, 0.12);
  backdrop-filter: blur(2px);
}

.drawer-backdrop[hidden] {
  display: none;
}

.top-drawer {
  position: absolute;
  top: var(--drawer-top);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  width: min(430px, calc(100% - 20px));
  max-height: min(640px, calc(100dvh - var(--drawer-top) - 10px));
  min-height: 0;
  padding: calc(12px * var(--ui-scale));
  background: var(--panel-frost);
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-115% + var(--drawer-drag, 0px))) scale(0.98);
  transform-origin: top center;
  transition: transform 240ms cubic-bezier(0.2, 0.85, 0.2, 1), opacity 180ms ease;
}

.top-drawer.dragging {
  transition: none;
}

.rail {
  left: 10px;
}

.context-panel {
  right: 10px;
  scrollbar-gutter: stable;
}

body[data-menu="chats"] #chatDrawer,
body[data-menu="settings"] #settingsDrawer {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(var(--drawer-drag, 0px)) scale(1);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-head h2 {
  font-size: 1rem;
}

.drawer-grip {
  width: 52px;
  height: 6px;
  flex: 0 0 auto;
  margin: 0 auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  touch-action: none;
}

.field,
.title-label,
.composer > label {
  display: grid;
  gap: 5px;
}

.field span,
.title-label span,
.composer > label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: calc(36px * var(--ui-scale));
  padding: 0 calc(10px * var(--ui-scale));
}

textarea {
  resize: none;
  padding: calc(9px * var(--ui-scale)) calc(10px * var(--ui-scale));
  line-height: 1.42;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent);
}

.chat-list,
.item-list {
  display: grid;
  gap: calc(8px * var(--ui-scale));
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-list {
  flex: 1;
  align-content: start;
  padding-right: 2px;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 7px;
}

.chat-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chat-card:hover {
  transform: translateY(-1px);
}

.chat-card.active {
  border-color: var(--logo-blue);
  background: var(--teal-soft);
}

.chat-card strong,
.chat-card span,
.chat-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-card strong {
  font-size: 0.9rem;
}

.chat-card span {
  color: var(--muted);
  font-size: 0.76rem;
}

.chat-card small {
  color: var(--theme-a);
  font-size: 0.7rem;
  font-weight: 800;
}

.conversation {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 980px);
  min-height: 0;
  justify-self: center;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.conversation-head {
  position: relative;
  min-height: 86px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--surface-solid);
}

.conversation-head img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
}

.conversation-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--head-overlay-a), var(--head-overlay-b));
}

.head-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
}

.title-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.title-label input {
  max-width: 620px;
  min-height: 40px;
  border-color: rgba(23, 33, 43, 0.18);
  background: var(--field-bg);
  font-size: 1.14rem;
  font-weight: 800;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
  min-height: 0;
  padding: calc(12px * var(--ui-scale));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.empty-state {
  max-width: 520px;
  margin: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state h2 {
  font-size: 1.06rem;
}

.empty-state p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.message {
  display: flex;
  animation: messageIn 190ms ease both;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(700px, 86%);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bubble-bg);
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-text {
  display: inline;
}

.message-word {
  display: inline-block;
  max-width: 100%;
  border-radius: 4px;
  transition: color var(--motion-hover-time) ease, text-shadow var(--motion-hover-time) ease, transform var(--motion-hover-time) ease, background var(--motion-hover-time) ease;
}

.message.user .bubble {
  border-color: color-mix(in srgb, var(--theme-b) 32%, var(--line));
  background: var(--bubble-user);
}

.message.assistant .bubble {
  border-color: color-mix(in srgb, var(--mood-c) 24%, var(--line));
  background: var(--bubble-assistant);
}

.thinking-bubble {
  min-width: min(300px, 88%);
}

.thinking-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.thinking-copy {
  font-weight: 850;
  background: linear-gradient(90deg, var(--logo-ink), var(--logo-blue), var(--coral), var(--logo-ink));
  background-size: 240% 100%;
  color: transparent;
  background-clip: text;
  animation: thinkingText 1.8s ease-in-out infinite;
}

.thinking-sweep {
  position: relative;
  display: inline-grid;
  min-width: 82px;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.82em;
  font-weight: 800;
  overflow: hidden;
}

.thinking-sweep span {
  grid-area: 1 / 1;
  opacity: 0;
  transform: translateY(8px);
  animation: thinkingWord 3.6s ease-in-out infinite;
}

.thinking-sweep span:nth-child(2) {
  animation-delay: 1.2s;
}

.thinking-sweep span:nth-child(3) {
  animation-delay: 2.4s;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--logo-blue);
  animation: dotPulse 900ms ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 140ms;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 280ms;
}

.message-time {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.7rem;
}

.composer {
  position: relative;
  display: grid;
  gap: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale));
  padding-bottom: max(calc(10px * var(--ui-scale)), env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-frost);
  overflow: hidden;
}

.composer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--theme-b) 18%, transparent), transparent);
  opacity: 0;
  transform: translateX(-65%);
  pointer-events: none;
}

.composer > * {
  position: relative;
  z-index: 1;
}

.composer textarea {
  min-height: 58px;
  max-height: 150px;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.send-button {
  min-width: 86px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.send-button::after {
  content: "";
  position: absolute;
  inset: -35% auto -35% -45%;
  z-index: -1;
  width: 38%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--theme-a) 54%, transparent), transparent);
  opacity: 0;
  transform: skewX(-18deg);
  pointer-events: none;
}

.menu-section {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  overflow: hidden;
}

.menu-section summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 850;
}

.menu-section summary::-webkit-details-marker {
  display: none;
}

.menu-section summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 180ms ease;
}

.menu-section[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.menu-section summary small {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-a) 22%, var(--control-bg));
  color: var(--ink);
  font-size: 0.72rem;
}

.panel-section {
  min-height: 0;
  padding: 0 10px 10px;
  overflow-y: auto;
}

.menu-section[open] .panel-section,
.menu-section[open] .rail-actions {
  animation: menuDrop 190ms ease both;
}

.rail-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.settings-grid {
  display: grid;
  gap: 5px;
}

.setting-label {
  margin-top: 2px;
  color: var(--logo-ink);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.range-field {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.range-field span,
.toggle-row span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.range-field input {
  min-height: 18px;
  height: 18px;
  accent-color: var(--logo-blue);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 7px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--theme-b));
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--theme-b) 36%, var(--control-bg)), color-mix(in srgb, var(--theme-c) 24%, var(--control-bg)));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -6px;
  border: 2px solid var(--control-bg);
  border-radius: 999px;
  background: var(--logo-blue);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--theme-b) 26%, transparent);
}

input[type="range"]::-moz-range-track {
  height: 7px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--theme-b));
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--theme-b) 36%, var(--control-bg)), color-mix(in srgb, var(--theme-c) 24%, var(--control-bg)));
}

input[type="range"]::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 2px solid var(--control-bg);
  border-radius: 999px;
  background: var(--logo-blue);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--theme-b) 26%, transparent);
}

.range-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.range-stack small {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 850;
  line-height: 1;
}

.range-stack small span {
  font-size: inherit;
  font-weight: inherit;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.segmented-control button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented-control button.active {
  border-color: var(--logo-blue);
  background: var(--control-active);
}

.scheme-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.scheme-picker button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 5px;
  min-height: 30px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--ink);
  font-size: 0.66rem;
  font-weight: 850;
}

.scheme-picker button.active {
  border-color: var(--logo-blue);
  background: var(--control-active);
}

.scheme-swatch {
  display: block;
  width: 22px;
  height: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--control-bg) 52%, transparent);
}

.scheme-swatch.vennto {
  background: linear-gradient(120deg, #5d7df3 0 44%, #f1bc5b 44% 68%, #cf6159 68%);
}

.scheme-swatch.sunset {
  background: linear-gradient(120deg, #e06452 0 44%, #f0b354 44% 68%, #6f2f68 68%);
}

.scheme-swatch.forest {
  background: linear-gradient(120deg, #367d66 0 44%, #d4b75c 44% 68%, #a45f5c 68%);
}

.scheme-swatch.midnight {
  background: linear-gradient(120deg, #101827 0 44%, #8aa4ff 44% 68%, #d47d9e 68%);
}

.scheme-swatch.candy {
  background: linear-gradient(120deg, #ff64b7 0 34%, #ffe66d 34% 58%, #62d7d1 58%);
}

.scheme-swatch.ocean {
  background: linear-gradient(120deg, #06172f 0 38%, #0b4f91 38% 68%, #20c7cb 68%);
}

.scheme-swatch.ember {
  background: linear-gradient(120deg, #290407 0 36%, #b81317 36% 66%, #ff7a24 66%);
}

.scheme-swatch.grape {
  background: linear-gradient(120deg, #4b1f83 0 38%, #7b45d8 38% 68%, #b86bff 68%);
}

.scheme-swatch.mono {
  background: linear-gradient(120deg, #0b0d0f 0 38%, #30363d 38% 68%, #aeb5bd 68%);
}

.scheme-swatch.cozy {
  background: linear-gradient(120deg, #24181d 0 36%, #d87345 36% 66%, #f0b46b 66%);
}

.scheme-swatch.aurora {
  background: linear-gradient(120deg, #071b23 0 36%, #b88cff 36% 62%, #6ee7b7 62%);
}

.scheme-swatch.citrus {
  background: linear-gradient(120deg, #ffd94d 0 36%, #ff8a22 36% 62%, #7ed957 62%);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.toggle-row span {
  min-width: 0;
  line-height: 1.22;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--logo-blue);
}

.toggle-row input[type="checkbox"] {
  appearance: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field-bg);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--theme-a) 18%, transparent);
}

.toggle-row input[type="checkbox"]::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--logo-blue);
  transform: scale(0);
  transition: transform 140ms var(--motion-ease);
}

.toggle-row input[type="checkbox"]:checked {
  border-color: var(--logo-blue);
  background: var(--control-active);
}

.toggle-row input[type="checkbox"]:checked::after {
  transform: scale(1);
}

.note-card,
.memory-card {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  animation: menuDrop 170ms ease both;
}

.edit-card {
  background: color-mix(in srgb, var(--paper-strong) 78%, var(--mood-a));
}

.edit-card .field span {
  font-size: 0.68rem;
}

.note-card h3,
.memory-card p {
  margin: 0;
}

.note-card h3 {
  font-size: 0.94rem;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.note-meta span {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.note-meta .stamp {
  color: var(--ink);
  font-weight: 850;
}

.note-body,
.memory-card p {
  color: var(--ink);
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.item-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.item-button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 0.78rem;
}

body[data-density="compact"] .messages {
  gap: 6px;
}

body[data-density="compact"] .bubble {
  padding-top: 8px;
  padding-bottom: 8px;
  line-height: 1.34;
}

body[data-density="compact"] .composer textarea {
  min-height: 46px;
}

body[data-density="roomy"] .messages {
  gap: 16px;
}

body[data-density="roomy"] .bubble {
  padding-top: 14px;
  padding-bottom: 14px;
  line-height: 1.62;
}

body[data-density="roomy"] .composer textarea {
  min-height: 74px;
}

body[data-large-touch="true"] .top-action,
body[data-large-touch="true"] .primary-action,
body[data-large-touch="true"] .send-button,
body[data-large-touch="true"] .ghost-button,
body[data-large-touch="true"] .item-button,
body[data-large-touch="true"] .rail-actions button,
body[data-large-touch="true"] .segmented-control button {
  min-height: 46px;
}

body[data-high-contrast="true"] .bubble,
body[data-high-contrast="true"] .menu-section,
body[data-high-contrast="true"] .note-card,
body[data-high-contrast="true"] .memory-card,
body[data-high-contrast="true"] input,
body[data-high-contrast="true"] textarea,
body[data-high-contrast="true"] select {
  border-width: 2px;
}

body[data-high-contrast="true"] .message.user .bubble {
  background: #d9f6ff;
}

body[data-high-contrast="true"] .message.assistant .bubble {
  background: #fff5d7;
}

body[data-reduce-motion="true"] *,
body[data-reduce-motion="true"] *::before,
body[data-reduce-motion="true"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

body[data-reduce-motion="true"] .thinking-copy {
  color: var(--logo-ink);
  background: none;
}

body[data-reduce-motion="true"] .thinking-sweep span:first-child {
  opacity: 1;
  transform: none;
}

body[data-animation-level="calm"] .message,
body[data-animation-level="calm"] .mood-bars span,
body[data-animation-level="calm"] .loading-card img {
  animation: none;
}

body[data-animation-level="dramatic"] .mood-display {
  animation: panelGlow var(--motion-loop-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .mood-bars span {
  animation-duration: var(--motion-bars-time);
}

body[data-animation-level="dramatic"] .message {
  animation: messagePop var(--motion-pop-time) ease-out both;
}

body[data-animation-level="dramatic"] .message.assistant .bubble {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mood-b) 22%, transparent), 0 14px 34px color-mix(in srgb, var(--mood-b) 16%, transparent);
  animation: bubbleGlow var(--motion-bubble-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .thinking-bubble {
  position: relative;
  overflow: hidden;
}

body[data-animation-level="dramatic"] .thinking-bubble::after {
  content: "";
  position: absolute;
  inset: -35% auto -35% -40%;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.52), transparent);
  transform: skewX(-18deg);
  animation: thinkingSweep var(--motion-sweep-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"][data-menu="chats"] #chatDrawer,
body[data-animation-level="dramatic"][data-menu="settings"] #settingsDrawer {
  animation: drawerSlam var(--motion-pop-time) ease-out both;
}

body[data-animation-level="dramatic"] .top-bar {
  animation: topCharge var(--motion-top-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .conversation {
  animation: stageBreathe var(--motion-stage-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .brand-mark {
  animation: logoSpinPop var(--motion-logo-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .top-action,
body[data-animation-level="dramatic"] .send-button,
body[data-animation-level="dramatic"] .ghost-button,
body[data-animation-level="dramatic"] .item-button,
body[data-animation-level="dramatic"] .segmented-control button,
body[data-animation-level="dramatic"] .scheme-picker button {
  transition: transform var(--motion-hover-time) var(--motion-ease), box-shadow var(--motion-hover-time) ease, border-color 140ms ease;
}

body[data-animation-level="dramatic"] .top-action:hover,
body[data-animation-level="dramatic"] .send-button:hover,
body[data-animation-level="dramatic"] .ghost-button:hover,
body[data-animation-level="dramatic"] .item-button:hover,
body[data-animation-level="dramatic"] .segmented-control button:hover,
body[data-animation-level="dramatic"] .scheme-picker button:hover {
  transform: translateY(-1px) scale(1.015);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--mood-b) 22%, transparent);
}

body[data-animation-level="dramatic"] .menu-section[open] {
  animation: sectionBoom var(--motion-pop-time) ease-out both;
}

body[data-animation-level="dramatic"] .composer {
  animation: composerGlow var(--motion-composer-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .brand h1,
body[data-animation-level="dramatic"] .mood-copy strong,
body[data-animation-level="dramatic"] .composer > label,
body[data-animation-level="dramatic"] .setting-label {
  background: linear-gradient(90deg, var(--ink), var(--theme-b), var(--theme-c), var(--ink));
  background-size: 260% 100%;
  background-clip: text;
}

body[data-animation-level="dramatic"] .top-bar:hover .brand h1,
body[data-animation-level="dramatic"] .mood-display:hover .mood-copy strong,
body[data-animation-level="dramatic"] .composer:focus-within > label,
body[data-animation-level="dramatic"] .menu-section:hover .setting-label {
  color: transparent;
  animation: textCharge var(--motion-loop-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"] .bubble:hover .message-word {
  animation: wordSpark 760ms ease both;
  animation-delay: calc(var(--word-index) * 22ms);
}

body[data-animation-level="dramatic"] .message-word:hover {
  color: var(--logo-ink);
  background: color-mix(in srgb, var(--theme-a) 18%, transparent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--theme-b) 40%, transparent);
  transform: translateY(-1px) scale(1.045);
}

body[data-animation-level="dramatic"] #messageInput {
  caret-color: var(--logo-blue);
}

body[data-animation-level="dramatic"][data-user-typing="true"] .composer::before {
  opacity: 1;
  animation: typingSweep var(--motion-sweep-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"][data-user-typing="true"] #messageInput {
  animation: typingField var(--motion-loop-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"][data-send-ready="true"] #sendButton {
  animation: sendReady var(--motion-loop-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"][data-send-ready="true"] #sendButton::after,
body[data-animation-level="dramatic"][data-sending="true"] #sendButton::after {
  opacity: 1;
  animation: sendSweep var(--motion-sweep-time) ease-in-out infinite;
}

body[data-animation-level="dramatic"][data-sending="true"] #sendButton {
  animation: sendLaunch var(--motion-loop-time) ease-in-out infinite;
}

body[data-reduce-motion="true"] *,
body[data-reduce-motion="true"] *::before,
body[data-reduce-motion="true"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

.hidden {
  display: none !important;
}

body[data-sending="true"] #sendButton {
  opacity: 0.72;
  pointer-events: none;
}

@keyframes menuDrop {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes moodLift {
  0%,
  100% {
    transform: scaleY(0.72);
  }
  50% {
    transform: scaleY(calc(0.84 + var(--mood-intensity) * 0.16));
  }
}

@keyframes logoBreathe {
  0%,
  100% {
    transform: scale(0.96) rotate(-1deg);
  }
  50% {
    transform: scale(1.04) rotate(1deg);
  }
}

@keyframes loadingBounce {
  0%,
  100% {
    transform: scaleY(0.54);
    opacity: 0.64;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes thinkingText {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes dotPulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.38;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes thinkingWord {
  0%,
  100% {
    opacity: 0;
    transform: translateY(8px);
  }
  12%,
  28% {
    opacity: 1;
    transform: translateY(0);
  }
  40% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes dramaticSky {
  from {
    transform: translateX(-12%) rotate(-2deg) scale(1);
  }
  to {
    transform: translateX(12%) rotate(2deg) scale(1.06);
  }
}

@keyframes panelGlow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  50% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--theme-b) 26%, transparent), 0 10px 26px color-mix(in srgb, var(--mood-b) 18%, transparent);
  }
}

@keyframes messagePop {
  0% {
    opacity: 0;
    filter: saturate(0.8);
    transform: translateY(5px);
  }
  68% {
    opacity: 1;
    filter: saturate(1.18);
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    filter: saturate(1);
    transform: translateY(0);
  }
}

@keyframes bubbleGlow {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.18);
  }
}

@keyframes thinkingSweep {
  from {
    left: -44%;
  }
  to {
    left: 110%;
  }
}

@keyframes drawerSlam {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(var(--drawer-drag, 0px));
  }
}

@keyframes topCharge {
  0%,
  100% {
    box-shadow: var(--tight-shadow);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 16px 34px color-mix(in srgb, var(--mood-b) 28%, transparent);
    transform: translateY(0);
  }
}

@keyframes stageBreathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    box-shadow: 0 18px 46px color-mix(in srgb, var(--theme-b) 20%, transparent);
    transform: scale(1);
  }
}

@keyframes logoSpinPop {
  0%,
  100% {
    filter: saturate(1);
    transform: rotate(-1deg);
  }
  50% {
    filter: saturate(1.25);
    transform: rotate(1.5deg);
  }
}

@keyframes sectionBoom {
  0% {
    opacity: 0.86;
    box-shadow: inset 0 0 0 color-mix(in srgb, var(--theme-b) 0%, transparent);
  }
  100% {
    opacity: 1;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-b) 18%, transparent);
  }
}

@keyframes composerGlow {
  0%,
  100% {
    box-shadow: inset 0 1px 0 transparent;
  }
  50% {
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--mood-b) 44%, transparent), 0 -12px 28px color-mix(in srgb, var(--mood-b) 12%, transparent);
  }
}

@keyframes textCharge {
  0%,
  100% {
    background-position: 0% 50%;
    text-shadow: 0 0 0 transparent;
  }
  50% {
    background-position: 100% 50%;
    text-shadow: 0 0 16px color-mix(in srgb, var(--theme-b) 32%, transparent);
  }
}

@keyframes wordSpark {
  0% {
    color: inherit;
    text-shadow: 0 0 0 transparent;
    transform: translateY(0);
  }
  45% {
    color: var(--logo-ink);
    text-shadow: 0 0 14px color-mix(in srgb, var(--theme-b) 36%, transparent);
    transform: translateY(-1px);
  }
  100% {
    color: inherit;
    text-shadow: 0 0 0 transparent;
    transform: translateY(0);
  }
}

@keyframes typingSweep {
  from {
    transform: translateX(-65%);
  }
  to {
    transform: translateX(65%);
  }
}

@keyframes typingField {
  0%,
  100% {
    box-shadow: inset 0 0 0 transparent;
  }
  50% {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-b) 30%, transparent), 0 0 20px color-mix(in srgb, var(--theme-b) 14%, transparent);
  }
}

@keyframes sendReady {
  0%,
  100% {
    box-shadow: 0 0 0 color-mix(in srgb, var(--theme-b) 0%, transparent);
    filter: saturate(1);
  }
  50% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--theme-a) 40%, transparent), 0 10px 24px color-mix(in srgb, var(--theme-b) 28%, transparent);
    filter: saturate(1.18);
  }
}

@keyframes sendSweep {
  from {
    left: -45%;
  }
  to {
    left: 115%;
  }
}

@keyframes sendLaunch {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.35) brightness(1.04);
  }
}

@media (min-width: 1160px) {
  .app-shell {
    grid-template-columns: minmax(260px, 0.8fr) minmax(520px, 1.65fr) minmax(300px, 0.95fr);
    grid-template-rows: auto minmax(0, 1fr);
    padding: 14px;
    gap: 12px;
    transition: grid-template-columns 260ms cubic-bezier(0.2, 0.85, 0.2, 1);
  }

  .top-bar {
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: 124px 220px minmax(280px, 1fr) 124px;
  }

  .drawer-backdrop {
    display: none;
  }

  .top-drawer {
    position: relative;
    top: auto;
    z-index: 1;
    width: auto;
    max-height: none;
    height: 100%;
    min-height: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none !important;
    transition: opacity 220ms ease, transform 260ms cubic-bezier(0.2, 0.85, 0.2, 1), padding 260ms ease, border-color 180ms ease, box-shadow 180ms ease;
  }

  .rail {
    grid-column: 1;
    grid-row: 2;
    left: auto;
  }

  .context-panel {
    grid-column: 3;
    grid-row: 2;
    right: auto;
    width: auto;
  }

  .conversation {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .conversation-head {
    min-height: 92px;
  }

  .drawer-grip {
    display: none;
  }

  body[data-desktop-chats="false"]:not([data-desktop-settings="false"]) .app-shell {
    grid-template-columns: minmax(0, 0fr) minmax(720px, 1.7fr) minmax(300px, 0.8fr);
  }

  body[data-desktop-settings="false"]:not([data-desktop-chats="false"]) .app-shell {
    grid-template-columns: minmax(260px, 0.7fr) minmax(720px, 1.7fr) minmax(0, 0fr);
  }

  body[data-desktop-chats="false"][data-desktop-settings="false"] .app-shell {
    grid-template-columns: minmax(0, 0fr) minmax(820px, 1fr) minmax(0, 0fr);
  }

  body[data-desktop-chats="false"] #chatDrawer,
  body[data-desktop-settings="false"] #settingsDrawer {
    min-width: 0;
    padding-right: 0;
    padding-left: 0;
    overflow: hidden;
    border-color: transparent;
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
  }

  body[data-desktop-chats="false"] #chatDrawer {
    transform: translateX(-18px) scale(0.985) !important;
  }

  body[data-desktop-settings="false"] #settingsDrawer {
    transform: translateX(18px) scale(0.985) !important;
  }
}

@media (max-width: 720px) {
  .app-shell {
    gap: 8px;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 8px 8px;
  }

  .top-bar {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 6px;
    min-height: 96px;
    padding: 6px;
  }

  .top-action {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 36px;
    padding: 0;
  }

  .top-action > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .brand {
    justify-content: center;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand h1 {
    font-size: 0.96rem;
  }

  .brand p {
    font-size: 0.7rem;
  }

  .mood-display {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 38px;
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 6px 8px;
  }

  .mood-bars {
    width: 28px;
    height: 24px;
  }

  .mood-copy strong {
    font-size: 0.82rem;
  }

  .mood-copy small {
    font-size: 0.68rem;
  }

  .top-drawer {
    top: calc(120px + env(safe-area-inset-top, 0px));
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100dvh - 130px - env(safe-area-inset-top, 0px));
    padding: 10px;
  }

  .context-panel {
    right: 8px;
  }

  .conversation-head {
    min-height: 70px;
  }

  .head-content {
    gap: 6px;
    padding: 8px;
  }

  .title-label input {
    min-height: 34px;
    font-size: 0.98rem;
  }

  .ghost-button,
  .send-button,
  .item-button,
  .rail-actions button {
    min-height: 34px;
  }

  .messages {
    gap: 9px;
    padding: 10px;
  }

  .bubble {
    max-width: 94%;
    padding: 9px 10px;
    font-size: 0.92rem;
    line-height: 1.42;
  }

  .composer {
    gap: 7px;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .composer textarea {
    min-height: 48px;
    max-height: 118px;
    font-size: 0.92rem;
  }

  .composer-actions {
    gap: 7px;
  }

  .send-button {
    min-width: 76px;
  }

  .rail-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .brand p {
    display: none;
  }

  .top-bar {
    min-height: 88px;
  }

  .top-drawer {
    top: calc(112px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 122px - env(safe-area-inset-top, 0px));
  }

  .conversation-head {
    min-height: 66px;
  }

  .bubble {
    max-width: 96%;
    font-size: 0.9rem;
  }
}

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