:root {
  color-scheme: light;
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18181b;
  background: #ffffff;
  --canvas: #fcfcfc;
  --sidebar: #fafafa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f7f7f8;
  --surface-hover: #f1f1f3;
  --surface-active: #eaeaec;
  --text: #18181b;
  --text-soft: #52525b;
  --text-muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #18181b;
  --accent-hover: #000000;
  --accent-soft: #f4f4f5;
  --accent-contrast: #ffffff;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warning: #92610a;
  --warning-soft: #fef3c7;
  --focus: #18181b;
  --code-bg: #141416;
  --code-text: #f4f4f5;
  --radius-sm: .5rem;
  --radius-md: .75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05), 0 5px 18px rgba(0, 0, 0, .05);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .16);
  --sidebar-width: 17.25rem;
  --transcript-width: 47.5rem;
  --control-size: 2.95rem;
  --icon-surface-size: 2.25rem;
  --visual-viewport-width: 100vw;
  --visual-viewport-height: 100dvh;
  --visual-viewport-offset-left: 0px;
  --visual-viewport-offset-top: 0px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body.chat-body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: .75rem;
  left: .75rem;
  transform: translateY(-180%);
  padding: .6rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  font-size: .82rem;
  font-weight: 760;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transition: transform .16s cubic-bezier(.2, .8, .2, 1);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.brand {
  color: inherit;
  font-size: 1.05rem;
  font-weight: 820;
  letter-spacing: -.035em;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.brand-lockup {
  display: flex;
  align-items: baseline;
  gap: .38rem;
  min-width: 0;
}

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

/* Authentication */

.auth-body {
  --canvas: #050505;
  --surface: #141414;
  --surface-raised: #1a1a1a;
  --text: #fcfcfc;
  --text-soft: #a1a1aa;
  --text-muted: #a1a1aa;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --accent: #fcfcfc;
  --accent-hover: #ffffff;
  --accent-contrast: #050505;
  --focus: #fcfcfc;
  --shadow-lg: none;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  color: var(--text);
  background: var(--canvas);
}

.auth-card {
  width: min(100%, 25rem);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: none;
}

.auth-card h1 {
  margin: 1.55rem 0 .2rem;
  font-size: 1.8rem;
  line-height: 1.12;
  letter-spacing: -.045em;
}

.auth-card form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .4rem;
  margin-top: 1.35rem;
}

.auth-card label {
  color: var(--text-soft);
  font-size: .78rem;
  font-weight: 680;
}

.auth-card input:not([type="checkbox"]) {
  width: 100%;
  min-height: 2.5rem;
  margin-bottom: .45rem;
  padding: .55rem .72rem;
  border: 1px solid var(--line-strong);
  border-radius: .65rem;
  background: var(--surface-raised);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.auth-card input:not([type="checkbox"]):focus-visible {
  outline: 0;
  border-color: color-mix(in srgb, var(--focus) 55%, var(--line-strong));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--focus) 32%, transparent),
    0 0 1.1rem color-mix(in srgb, var(--focus) 16%, transparent);
}

.auth-card button {
  min-height: 2.55rem;
  margin-top: .35rem;
  border: 0;
  border-radius: .65rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.auth-card button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.auth-card .auth-remember {
  width: max-content;
  min-height: 1.75rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-top: -.05rem;
  cursor: pointer;
}

.auth-remember input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.1rem;
  margin-top: 1.1rem;
  font-size: .8rem;
}

.auth-links a {
  color: var(--accent);
}

.error {
  max-width: var(--transcript-width);
  margin: var(--space-4) auto;
  padding: .75rem .9rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
}

/* Application shell */

.shell {
  position: fixed;
  top: var(--visual-viewport-offset-top);
  right: auto;
  left: var(--visual-viewport-offset-left);
  width: var(--visual-viewport-width);
  min-height: 0;
  height: var(--visual-viewport-height);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-columns .22s cubic-bezier(.2, .8, .2, 1);
}

.shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  transition: padding .22s cubic-bezier(.2, .8, .2, 1), border-color .18s ease, opacity .16s ease, transform .22s cubic-bezier(.2, .8, .2, 1);
}

.shell.sidebar-collapsed .sidebar {
  padding-right: 0;
  padding-left: 0;
  border-right-color: transparent;
  opacity: 0;
  transform: translateX(-1rem);
  pointer-events: none;
}

.sidebar-head,
.account {
  display: flex;
  align-items: center;
}

.sidebar-head {
  min-height: 3.25rem;
  justify-content: space-between;
  padding: 0 .4rem var(--space-2);
}

.sidebar-collapse {
  margin-left: auto;
}

.shell.sidebar-collapsed .mobile-nav-trigger {
  display: grid;
}

.grok-chat-shell {
  --grok-black: #050505;
  --grok-panel: #0d0d0d;
  --grok-panel-raised: #1a1a1a;
  --grok-line: rgba(255, 255, 255, .08);
  --grok-line-soft: rgba(255, 255, 255, .05);
  --grok-text: #fcfcfc;
  --grok-muted: #a1a1aa;
  --grok-faint: #71717a;
  --grok-main-glow: rgba(255, 255, 255, .04);
  --grok-sidebar-top: #050505;
  --grok-new-top: #1c1c1c;
  --grok-new-bottom: #141414;
  --grok-active-top: #202020;
  --grok-active-bottom: #1a1a1a;
  --grok-menu: #161616;
  --grok-table-head: #1a1a1a;
  --grok-table-row: #141414;
  --grok-code: #0a0a0a;
  --grok-inline-code: #1c1c1c;
  --grok-placeholder: #8b8b93;
  --grok-composer-top: #0f0f0f;
  --grok-user-bubble: #141414;
  --grok-content-width: 760px;
  --accent: #fcfcfc;
  --accent-hover: #ffffff;
  --accent-soft: #1c1c1c;
  --accent-contrast: #0a0a0a;
  --focus: #fcfcfc;
}

.chat-body:has(.grok-chat-shell) {
  background: #050505;
}

.grok-chat-shell .chat-main {
  background: var(--grok-black);
  isolation: isolate;
}

.grok-chat-shell .chat-main::before,
.grok-chat-shell .chat-main::after {
  display: none;
  background: transparent;
}

.grok-chat-shell .sidebar {
  background: var(--grok-black);
  border-right-color: var(--grok-line-soft);
}

.grok-chat-shell .brand {
  color: var(--grok-text);
}

.grok-chat-shell .sidebar-head {
  border-bottom: 0;
}

.grok-chat-shell .sidebar-collapse,
.grok-chat-shell .settings-popover,
.grok-chat-shell .account {
  color: var(--grok-muted);
}

.grok-chat-shell .sidebar-collapse:hover > svg,
.grok-chat-shell .account .icon-button:hover > svg {
  background: var(--grok-panel-raised);
  color: var(--grok-text);
}

.grok-brand-mark {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
}

.grok-brand-mark svg {
  width: 1.65rem;
  height: 1.65rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grok-chat-shell .new-chat {
  margin-top: .25rem;
  border-color: transparent;
  border-radius: .625rem;
  background: transparent;
  color: var(--grok-text);
  box-shadow: none;
}

.grok-chat-shell .new-chat:hover,
.grok-chat-shell .search input:hover,
.grok-chat-shell .search input:focus,
.grok-chat-shell .conversation:hover,
.grok-chat-shell .conversation-row.menu-open .conversation {
  background: var(--grok-panel-raised);
}

.grok-chat-shell .search input,
.grok-chat-shell .conversation,
.grok-chat-shell .conversation-group,
.grok-chat-shell .account-name {
  color: var(--grok-muted);
}

.grok-chat-shell .search input {
  border-color: transparent;
  border-radius: .625rem;
  background: transparent;
}

.grok-chat-shell .search input:focus {
  border-color: transparent;
  box-shadow: none;
}

.grok-chat-shell .conversation {
  height: 2.25rem;
  font-size: .875rem;
}

.grok-chat-shell .conversation.active {
  background: var(--grok-panel-raised);
  color: var(--grok-text);
  box-shadow: none;
}

.grok-chat-shell .messages {
  padding-inline: max(1.5rem, calc((100% - var(--grok-content-width)) / 2));
  color: var(--grok-text);
}

.grok-chat-shell .message.user,
.grok-chat-shell .message.user:has(.message-media) {
  max-width: 90%;
}

.grok-chat-shell .message-content {
  color: var(--grok-text);
  font-size: 15px;
  font-weight: 400;
  line-height: 22.5px;
  letter-spacing: -0.1px;
}

.grok-chat-shell .message-content h1,
.grok-chat-shell .message-content h2,
.grok-chat-shell .message-content h3,
.grok-chat-shell .message-content h4,
.grok-chat-shell .message-content h5,
.grok-chat-shell .message-content h6 {
  color: var(--grok-text);
}

.grok-chat-shell .message-content strong,
.grok-chat-shell .message-content b {
  font-weight: 550;
}

.grok-chat-shell .message-content > * {
  color: inherit;
}

.grok-chat-shell .message-content p,
.grok-chat-shell .message-content li,
.grok-chat-shell .message-content td,
.grok-chat-shell .message-content th {
  color: inherit;
}

.grok-chat-shell .message-content blockquote,
.grok-chat-shell .message-content .message-muted {
  color: var(--grok-muted);
}

.grok-chat-shell .markdown-table-wrap {
  border-color: var(--grok-line);
  background: var(--grok-panel);
}

.grok-chat-shell .message-content th {
  background: var(--grok-table-head);
  color: var(--grok-muted);
}

.grok-chat-shell .message-content td {
  border-color: var(--grok-line);
}

.grok-chat-shell .message-content tbody tr:nth-child(even) {
  background: var(--grok-table-row);
}

.grok-chat-shell .message-content pre {
  border-color: var(--grok-line);
  background: var(--grok-code);
  color: var(--grok-text);
}

.grok-chat-shell .message-content :not(pre) > code {
  background: var(--grok-inline-code);
  color: var(--grok-text);
}

.grok-chat-shell .artifact-card {
  border-color: var(--grok-line);
  background: var(--grok-panel);
}

.grok-chat-shell .artifact-card:hover {
  border-color: color-mix(in srgb, var(--grok-text) 18%, transparent);
  background: var(--grok-panel-raised);
}

.grok-chat-shell .artifact-card:focus-visible {
  outline-color: var(--focus);
}

.grok-chat-shell .artifact-card-icon {
  background: var(--grok-panel-raised);
  color: var(--grok-muted);
}

.grok-chat-shell .artifact-card-name {
  color: var(--grok-text);
}

.grok-chat-shell .artifact-card-meta,
.grok-chat-shell .artifact-card-action {
  color: var(--grok-muted);
}

.grok-chat-shell .welcome {
  width: auto;
  margin-top: 0;
}

.grok-wordmark {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--grok-text, var(--text));
  font-family: "SF Pro Display", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(2.5rem, 4vw, 3.6rem);
  font-weight: 400;
  letter-spacing: -.06em;
  line-height: 1;
}

.grok-wordmark svg {
  width: clamp(3rem, 4.4vw, 4.25rem);
  height: clamp(3rem, 4.4vw, 4.25rem);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grok-chat-shell .composer-wrap {
  width: min(100%, var(--grok-content-width));
  padding: .7rem 0 max(1.6rem, env(safe-area-inset-bottom));
}

.grok-chat-shell .composer {
  border-color: color-mix(in srgb, var(--grok-text) 9%, transparent);
  border-radius: 2.5rem;
  background: linear-gradient(180deg, var(--grok-composer-top), var(--grok-panel));
  box-shadow: none;
}

.grok-chat-shell .chat-main .composer:focus-within {
  border-color: color-mix(in srgb, var(--grok-text) 18%, transparent);
  box-shadow: none;
  transform: none;
}

.grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateY(-7.5rem);
}

.grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) > .messages {
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  overflow: visible;
  padding: 0;
}

.grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) > .composer-wrap {
  flex: 0 0 auto;
  width: min(100%, var(--grok-content-width));
  margin: 1.95rem auto 0;
  padding: 0;
}

.grok-chat-shell .composer textarea {
  color: var(--grok-text);
}

.grok-chat-shell .message-user-bubble {
  max-width: 100%;
  font-size: 15px;
  font-weight: 400;
  line-height: 22.5px;
  letter-spacing: -0.1px;
  padding: 8px 16px;
  border-color: color-mix(in srgb, var(--grok-text) 8%, transparent);
  border-radius: 24px 24px 8px 24px;
  background: var(--grok-user-bubble);
}

.grok-chat-shell .composer textarea::placeholder {
  color: var(--grok-placeholder);
}

.grok-chat-shell .model-trigger {
  height: 40px;
  gap: .5rem;
  padding: 6px 8px 6px 14px;
  border-color: transparent;
  background: transparent;
  color: var(--grok-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 21px;
}

.grok-chat-shell .model-trigger:hover,
.grok-chat-shell .model-trigger[aria-expanded="true"] {
  border-color: transparent;
  background: var(--grok-panel-raised);
}

.grok-chat-shell .model-menu,
.grok-chat-shell .settings-popover,
.grok-chat-shell .regenerate-menu {
  border-color: var(--grok-line);
  background: var(--grok-menu);
  color: var(--grok-text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .035);
}

.grok-chat-shell .model-menu button:hover,
.grok-chat-shell .regenerate-option:hover,
.grok-chat-shell .settings-popover select:hover {
  background: var(--grok-panel-raised);
}

.grok-chat-shell .model-option-title,
.grok-chat-shell .regenerate-model-name {
  color: var(--grok-text);
}

.grok-chat-shell .model-option-description,
.grok-chat-shell .model-option-provider,
.grok-chat-shell .regenerate-model-hint,
.grok-chat-shell .regenerate-menu-label,
.grok-chat-shell .settings-popover label {
  color: var(--grok-muted);
}

.grok-chat-shell .settings-popover select {
  border-color: var(--grok-line);
  background: var(--grok-panel);
  color: var(--grok-text);
}

.grok-chat-shell .icon-button,
.grok-chat-shell .attach,
.grok-chat-shell .dictation,
.grok-chat-shell .copy-message,
.grok-chat-shell .message-action,
.grok-chat-shell .composer-note {
  color: var(--grok-muted);
}

.grok-chat-shell .icon-button:hover > svg,
.grok-chat-shell .attach:hover > svg,
.grok-chat-shell .dictation:hover > svg,
.grok-chat-shell .copy-message:hover,
.grok-chat-shell .message-action:hover {
  color: var(--grok-text);
}

.grok-chat-shell .attachment {
  border-color: var(--grok-line);
  background: var(--grok-panel);
  color: var(--grok-muted);
}

.grok-chat-shell .attachment:hover {
  border-color: color-mix(in srgb, var(--grok-text) 18%, transparent);
  background: var(--grok-panel-raised);
}

.grok-chat-shell .attachment:hover .attachment-remove,
.grok-chat-shell .attachment:focus-visible .attachment-remove {
  color: var(--grok-text);
}

.grok-chat-shell .model-trigger-mark {
  display: none;
}

.grok-chat-shell .model-trigger-caret {
  width: .75rem;
  height: .75rem;
}

.grok-chat-shell .dictation {
  position: relative;
}

.grok-chat-shell .dictation[aria-pressed="true"] {
  color: var(--grok-text);
}

.grok-chat-shell .dictation-wave {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: currentColor;
  opacity: 0;
  pointer-events: none;
  transform: scale(.82);
  transition: opacity .2s ease, transform .24s cubic-bezier(.2, .8, .2, 1);
}

.grok-chat-shell .dictation-wave > span {
  width: 1.5px;
  height: .9rem;
  border-radius: 999px;
  background: currentColor;
  transform: scaleY(.3);
  transform-origin: center;
}

.grok-chat-shell .dictation-wave > span:nth-child(1),
.grok-chat-shell .dictation-wave > span:nth-child(5) {
  height: .42rem;
}

.grok-chat-shell .dictation-wave > span:nth-child(2),
.grok-chat-shell .dictation-wave > span:nth-child(4) {
  height: .68rem;
}

.grok-chat-shell .dictation[aria-pressed="true"] .dictation-mic {
  opacity: 0;
  transform: scale(.78);
}

.grok-chat-shell .dictation[aria-pressed="true"] .dictation-wave {
  opacity: 1;
  transform: scale(1);
}

.grok-chat-shell .dictation[aria-pressed="true"] .dictation-wave > span {
  animation: dictation-level .92s ease-in-out infinite;
}

@keyframes dictation-level {
  0%, 100% { opacity: .46; transform: scaleY(.3); }
  50% { opacity: 1; transform: scaleY(1); }
}

.grok-chat-shell .dictation-status {
  color: var(--grok-muted);
  font-weight: 650;
}

.grok-chat-shell .send > svg {
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 50%;
  background: var(--grok-text);
  color: var(--grok-black);
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.grok-chat-shell .send > svg > path {
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.grok-chat-shell .send:hover > svg,
.grok-chat-shell .send:disabled > svg,
.grok-chat-shell .send:disabled:hover > svg {
  background: var(--grok-text);
  color: var(--grok-black);
  box-shadow: none;
}

.new-chat {
  width: 100%;
  min-height: 2.65rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: 0 .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font-weight: 700;
  text-align: left;
  transition: border-color .16s ease, background-color .16s ease;
}

.new-chat:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.search input {
  width: 100%;
  min-height: 2.55rem;
  margin: .65rem 0;
  padding: .65rem .75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
}

.search input:hover,
.search input:focus {
  border-color: var(--line-strong);
  background: var(--surface);
}

.conversation-list {
  min-height: 0;
  flex: 1;
  display: grid;
  align-content: start;
  gap: .15rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.grok-chat-shell .conversation-list {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.grok-chat-shell .conversation-list:hover,
.grok-chat-shell .conversation-list:focus-within {
  scrollbar-color: rgba(255, 255, 255, .24) transparent;
}

.grok-chat-shell .conversation-list::-webkit-scrollbar {
  width: .4rem;
}

.grok-chat-shell .conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.grok-chat-shell .conversation-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
  background-clip: padding-box;
}

.grok-chat-shell .conversation-list:hover::-webkit-scrollbar-thumb,
.grok-chat-shell .conversation-list:focus-within::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, .24);
}

.conversation-row {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  border-radius: var(--radius-md);
}

.conversation-row.menu-open {
  z-index: 2;
}

.conversation-row.menu-open .conversation {
  padding-right: 7.4rem;
}

.conversation-rename {
  width: 100%;
  height: 2.4rem;
  padding: 0 4.8rem 0 .7rem;
  border: 1px solid var(--focus);
  border-radius: var(--radius-md);
  outline: 0;
  background: var(--surface-raised);
  color: var(--text);
  font-size: .86rem;
  font-weight: 640;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 16%, transparent);
}

.conversation {
  width: 100%;
  height: 2.4rem;
  display: block;
  padding: 0 3rem 0 .75rem;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: transparent;
  font-size: .86rem;
  text-align: left;
  text-overflow: ellipsis;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
  white-space: nowrap;
}

.conversation:hover,
.conversation-row.menu-open .conversation {
  background: var(--surface-hover);
}

.conversation:hover {
  transform: translateX(2px);
}

.conversation.active {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--text);
  font-weight: 640;
}

.conversation.pinned::before {
  content: "";
  display: inline-block;
  width: .38rem;
  height: .38rem;
  margin-right: .5rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: .12rem;
}

.conversation-more {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
}

.conversation-more:hover,
.conversation-more:focus-visible {
  background: var(--surface-active);
  color: var(--text);
}

.conversation-panel {
  position: absolute;
  top: .15rem;
  right: .15rem;
  z-index: 3;
  height: 2.25rem;
  display: flex;
  align-items: center;
  gap: .1rem;
  padding: .05rem;
  border-radius: var(--radius-sm);
  background: var(--surface-active);
  box-shadow: inset 0 0 0 1px var(--line);
  animation: action-tray-in .16s cubic-bezier(.2, .8, .2, 1);
}

.conversation-action {
  width: 2.15rem;
  height: 2.15rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background-color .14s ease, color .14s ease, transform .14s ease;
}

.conversation-action:hover {
  background: var(--surface-raised);
  transform: translateY(-1px);
}

@keyframes action-tray-in {
  from { opacity: 0; transform: translateX(5px) scale(.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes menu-in-up {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes menu-in-down {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.conversation-action svg {
  width: 1.05rem;
  height: 1.05rem;
}

.conversation-panel .conversation-action.danger {
  color: var(--danger);
}

.account {
  gap: var(--space-2);
  padding: var(--space-3) .25rem 0;
  border-top: 1px solid var(--line);
}

.account form {
  display: contents;
}

.avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: .65rem;
  background: var(--text);
  color: var(--canvas);
  font-size: .78rem;
  font-weight: 800;
}

.account-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--text-soft);
  font-size: .86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: .1rem;
}

.settings-popover {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: calc(100% + .6rem);
  width: 15.5rem;
  display: grid;
  gap: .75rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: menu-in-up .16s cubic-bezier(.2, .8, .2, 1);
}

.settings-popover label {
  display: grid;
  gap: .3rem;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
}

.settings-popover select {
  min-height: 2.35rem;
  padding: 0 .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: .8rem;
}

.settings-popover .setting-toggle {
  grid-template-columns: 1fr auto;
  align-items: center;
  color: var(--text-soft);
  font-size: .8rem;
}

.setting-toggle input {
  accent-color: var(--accent);
}

.icon-button,
.attach,
.dictation,
.send,
.stop {
  width: var(--control-size);
  height: var(--control-size);
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
}

.icon-button:hover,
.attach:hover,
.dictation:hover {
  background: transparent;
  color: var(--text);
}

.icon-button > svg,
.attach > svg,
.dictation > svg,
.send > svg,
.stop > svg,
.conversation-more > svg {
  width: var(--icon-surface-size);
  height: var(--icon-surface-size);
  padding: .5rem;
  border-radius: var(--radius-sm);
  transition: background-color .14s ease, color .14s ease, opacity .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}

.icon-button:hover > svg,
.attach:hover > svg,
.dictation:hover > svg,
.conversation-more:hover > svg,
.conversation-more:focus-visible > svg {
  background: var(--surface-hover);
}

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

/* Transcript */

.chat-main {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--canvas);
}

/* The service notice is conditional and the nav trigger and drop indicator are
   absolutely positioned, so auto-placement cannot be trusted to line the rows
   up: without this the transcript takes the auto row, grows to the full height
   once the chat is long, and squeezes the composer out of the viewport. */
.chat-main > .service-notice {
  grid-row: 1;
}

.chat-main > .messages {
  grid-row: 2;
}

.chat-main > .composer-wrap {
  grid-row: 3;
}

.chat-main::before,
.chat-main::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

.chat-main::before {
  inset: -30%;
  background:
    radial-gradient(ellipse 34% 42% at 18% 26%, color-mix(in srgb, var(--accent) 28%, transparent) 0, transparent 72%),
    radial-gradient(ellipse 38% 34% at 82% 18%, color-mix(in srgb, var(--accent-soft) 34%, transparent) 0, transparent 74%),
    radial-gradient(ellipse 35% 40% at 72% 84%, color-mix(in srgb, var(--accent) 15%, transparent) 0, transparent 72%);
  opacity: .7;
  animation: ambient-mesh-a 30s ease-in-out infinite alternate;
}

.chat-main::after {
  inset: -18%;
  background: linear-gradient(118deg, transparent 28%, color-mix(in srgb, var(--accent) 5%, transparent) 43%, transparent 58%);
  opacity: .68;
  animation: ambient-mesh-b 24s ease-in-out infinite alternate;
}

.service-notice,
.messages,
.composer-wrap {
  z-index: 1;
}

.service-notice {
  width: min(calc(100% - 2rem), var(--transcript-width));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: .7rem;
  margin: 1rem auto 0;
  padding: .8rem .9rem;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning-soft) 88%, var(--surface));
  color: color-mix(in srgb, var(--warning) 88%, var(--text));
  box-shadow: var(--shadow-sm);
}

.service-notice > svg {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: .05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.service-notice strong {
  display: block;
  font-size: .86rem;
  letter-spacing: -.01em;
}

.service-notice p {
  margin: .08rem 0 0;
  color: var(--text-soft);
  font-size: .8rem;
  line-height: 1.4;
}

@keyframes ambient-mesh-a {
  from { transform: translate3d(-2%, -2%, 0) scale(1); }
  to { transform: translate3d(3%, 4%, 0) scale(1.05); }
}

@keyframes ambient-mesh-b {
  from { transform: translate3d(-6%, 2%, 0) rotate(-2deg); }
  to { transform: translate3d(7%, -3%, 0) rotate(3deg); }
}

.messages {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(1.5rem, 4vw, 3.5rem) max(1rem, calc((100% - var(--transcript-width)) / 2));
  scroll-behavior: auto;
  scrollbar-gutter: stable;
}

.welcome {
  width: min(100%, 32rem);
  display: grid;
  justify-items: center;
  margin: clamp(4rem, 17vh, 10rem) auto 0;
  text-align: center;
}

.mark {
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  background: var(--text);
  color: var(--canvas);
  font-size: 1.35rem;
  font-weight: 850;
  box-shadow: var(--shadow-sm);
}

.welcome h1 {
  margin: 1.25rem 0 .2rem;
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  line-height: 1.1;
  letter-spacing: -.05em;
}

.welcome p {
  margin: 0;
  color: var(--text-muted);
}

.message {
  position: relative;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 1.75rem;
  animation: message-enter .28s cubic-bezier(.2, .8, .2, 1);
}

@keyframes message-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  width: fit-content;
  max-width: min(80%, 37rem);
  margin-left: auto;
  margin-bottom: 2.2rem;
}

.message.user:has(.message-media) {
  width: min(80%, 37rem);
}

.message-user-bubble {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  padding: 10px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 15%, var(--line));
  border-radius: var(--radius-lg) var(--radius-lg) .35rem var(--radius-lg);
  background: var(--accent-soft);
}

.message-media {
  display: grid;
  justify-items: end;
  gap: .65rem;
  margin-bottom: .65rem;
}

.message-media .image-thumbnail {
  margin-top: 0;
}

.message-media .media-expired {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  max-width: 100%;
  padding: .5rem .8rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: var(--radius-lg);
  color: var(--muted, inherit);
  font-size: .85rem;
  overflow-wrap: anywhere;
}

.message-media .media-expired svg {
  width: 1em;
  height: 1em;
  flex: none;
}

.message.assistant {
  padding: 0;
}

.message.assistant:has(.regenerate-control.open) {
  padding-bottom: var(--regenerate-menu-space, 0);
}

.message-content {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0;
}

.message-content strong,
.message-content b {
  font-weight: 600;
}

.message-content p {
  margin: 0;
}

.message-content > * {
  margin-block: 0;
}

.message-content > * + * {
  margin-top: 1rem;
}

.message-content > p + p {
  margin-top: var(--space-4);
}

.message-content > blockquote + :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 1.5rem;
}

.message-content > .markdown-table-wrap + p {
  margin-top: 1.35rem;
}

.message-content > p + :is(.markdown-table-wrap, pre) {
  margin-top: 1.2rem;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.message-content h1 {
  font-size: 1.45rem;
}

.message-content h2 {
  font-size: 1.2rem;
}

.message-content h3 {
  font-size: 1.05rem;
}

.message-content h4,
.message-content h5,
.message-content h6 {
  font-size: 1rem;
}

.message-content > :is(h1, h2, h3, h4, h5, h6) + * {
  margin-top: .65rem;
}

.message-content > * + :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 1.7rem;
}

.message-content ul,
.message-content ol {
  margin: 0;
  padding-left: 1.45rem;
}

.message-content li + li {
  margin-top: .35rem;
}

.message-content blockquote {
  margin-right: 0;
  margin-left: 0;
  padding: .2rem 0 .2rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--text-soft);
}

.message-content hr {
  margin-right: 0;
  margin-left: 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.message-content a {
  color: var(--accent);
  text-underline-offset: .16em;
}

.message-content pre {
  position: relative;
  max-width: 100%;
  margin-right: 0;
  margin-left: 0;
  padding: 2.8rem 1rem 1rem;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--code-text) 14%, transparent);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  color: var(--code-text);
  overscroll-behavior-inline: contain;
}

.message-content code {
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.message-content :not(pre) > code {
  padding: .12rem .32rem;
  border-radius: .3rem;
  background: var(--surface-subtle);
  color: var(--text-soft);
}

.math-inline {
  white-space: nowrap;
}

.math-display {
  max-width: 100%;
  padding: .25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  overscroll-behavior-inline: contain;
}

.math-display .katex-display {
  margin: 0;
}

.math-error {
  color: var(--danger);
  font: .9em/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
}

.message-content pre .code-copy {
  position: absolute;
  top: .55rem;
  right: .55rem;
  width: var(--control-size);
  height: var(--control-size);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--code-text);
}

.message-content pre .code-copy svg {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 0;
  background: transparent;
  transition: color .14s ease, opacity .14s ease, transform .14s ease;
}

.message-content pre .code-copy:hover {
  color: #ffffff;
}

.message-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.markdown-table-wrap {
  max-width: 100%;
  margin-right: 0;
  margin-left: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  overscroll-behavior-inline: contain;
}

.markdown-table-wrap:focus-visible {
  outline-offset: 3px;
}

.message-content table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: .9rem;
}

.message-content th,
.message-content td {
  padding: .72rem .85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.message-content th {
  background: var(--surface-subtle);
  color: var(--text-soft);
  font-size: .74rem;
  font-weight: 780;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.message-content tbody tr:last-child td {
  border-bottom: 0;
}

.message-content tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 3.5%, transparent);
}

.message-actions {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: .1rem;
  margin-top: .4rem;
}

.copy-message,
.message-action {
  width: var(--control-size);
  height: var(--control-size);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

.message.assistant .copy-message,
.message.assistant .message-action {
  width: 2rem;
  height: 2rem;
}

.message.user .message-actions {
  position: absolute;
  top: calc(100% + .35rem);
  right: .15rem;
  margin-top: 0;
}

.message.user .message-actions .message-action {
  width: 1.9rem;
  height: 1.9rem;
}

.regenerate-control {
  position: relative;
  width: fit-content;
  margin-top: 0;
}

.regenerate-action {
  width: 2rem;
  height: 2rem;
  color: var(--text-muted);
}

.regenerate-action svg {
  width: 1.05rem;
  height: 1.05rem;
}

.regenerate-control.open .regenerate-action,
.regenerate-action:hover,
.regenerate-action:focus-visible {
  color: var(--accent);
}

.regenerate-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + .4rem);
  bottom: auto;
  left: 0;
  width: 13.75rem;
  max-width: calc(var(--visual-viewport-width) - 2rem);
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
  animation: menu-in-down .16s cubic-bezier(.2, .8, .2, 1);
}

.regenerate-menu-label {
  display: block;
  padding: .4rem .55rem .3rem;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.regenerate-option {
  width: 100%;
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: 1.55rem 1fr auto;
  align-items: center;
  gap: .45rem;
  padding: .35rem .55rem;
  border: 0;
  border-radius: .65rem;
  background: transparent;
  text-align: left;
}

.regenerate-option:hover,
.regenerate-option:focus-visible {
  background: var(--surface-hover);
}

.regenerate-option-check {
  color: var(--accent);
  font-size: .78rem;
  opacity: 0;
}

.regenerate-option[aria-current="true"] .regenerate-option-check {
  opacity: 1;
}

.regenerate-model-icon {
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
}

.regenerate-model-copy {
  display: grid;
  gap: .02rem;
}

.regenerate-model-name {
  color: var(--text);
  font-size: .79rem;
  font-weight: 680;
}

.regenerate-model-hint {
  color: var(--text-muted);
  font-size: .67rem;
}

.message.user.editing {
  width: min(100%, var(--message-edit-width, 40rem));
}

.message.user.editing .message-user-bubble {
  width: 100%;
  padding: .72rem .8rem .48rem;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 88%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 7%, transparent);
}

.message.user.editing .message-user-bubble,
.message.user.editing .message-content,
.message.user.editing .message-edit-controls {
  transform-origin: top right;
  animation: message-edit-in .22s cubic-bezier(.2, .8, .2, 1);
}

.message-inline-editor {
  width: 100%;
  min-height: 1.85rem;
  max-height: 11rem;
  padding: .1rem .15rem .35rem;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  caret-color: var(--accent);
}

.message-edit-controls {
  display: flex;
  justify-content: flex-end;
  gap: .05rem;
  margin-top: .05rem;
}

.message-edit-controls .message-action {
  width: 1.85rem;
  height: 1.85rem;
}

.message-edit-controls [aria-label="Send edited message"] {
  color: var(--accent);
}

.branch-pruning {
  animation: branch-out .17s cubic-bezier(.4, 0, 1, 1) forwards;
  animation-delay: calc(var(--branch-index, 0) * 12ms);
}

@keyframes branch-out {
  to { opacity: 0; transform: translateY(-5px) scale(.992); }
}

@keyframes message-edit-in {
  from { opacity: .72; transform: translateY(-3px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.copy-message:hover,
.copy-message:focus-visible,
.copy-message.copied,
.message-action:hover,
.message-action:focus-visible {
  background: transparent;
  color: var(--text);
}

.copy-message svg,
.message-action svg {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 0;
  background: transparent;
  transition: color .14s ease, opacity .14s ease, transform .14s ease;
}

.copy-message.copied,
.message-content pre .code-copy[aria-label="Copied"] {
  color: var(--accent);
}

.copy-message.copied svg,
.code-copy[aria-label="Copied"] svg {
  animation: copy-confirm .28s cubic-bezier(.2, .9, .25, 1);
}

@keyframes copy-confirm {
  0% { opacity: .35; transform: scale(.7) rotate(-8deg); }
  65% { opacity: 1; transform: scale(1.18) rotate(0); }
  100% { opacity: 1; transform: scale(1); }
}

.message.cursor .message-actions {
  visibility: hidden;
}

.message.settled {
  animation: message-settle .32s cubic-bezier(.2, .8, .2, 1);
}

.message.failed {
  color: var(--text-soft);
}

.message-retry {
  width: min(100%, var(--transcript-width));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .7rem;
  color: color-mix(in srgb, var(--danger) 88%, var(--text));
  font-size: .84rem;
  font-weight: 470;
  letter-spacing: -.005em;
}

.message-retry .message-action {
  width: auto;
  height: 1.8rem;
  display: inline-flex;
  flex: 0 0 auto;
  gap: .3rem;
  padding: 0;
  color: color-mix(in srgb, var(--danger) 82%, var(--text));
  font: inherit;
  font-size: .8rem;
  font-weight: 590;
  line-height: 1;
}

.message-retry .message-action:hover {
  color: var(--danger);
}

.message-retry .message-action svg {
  width: 1rem;
  height: 1rem;
}

@keyframes message-settle {
  from { opacity: .72; transform: translateY(3px); }
}

.thinking {
  min-height: 1.75rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 620;
}

.thinking-elapsed {
  min-width: 2.25rem;
  color: var(--text-soft);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}

.thinking-matrix {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  color: var(--accent);
  overflow: visible;
  order: -1;
}

.thinking-matrix-cell {
  fill: currentColor;
  opacity: .2;
  animation: thinking-matrix-cell 1.333333s linear infinite;
}

.thinking-matrix-cell:nth-child(2) { animation-delay: -.166667s; }
.thinking-matrix-cell:nth-child(3) { animation-delay: -.333333s; }
.thinking-matrix-cell:nth-child(4) { animation-delay: -.5s; }
.thinking-matrix-cell:nth-child(5) { animation-delay: -.666667s; }
.thinking-matrix-cell:nth-child(6) { animation-delay: -.833333s; }
.thinking-matrix-cell:nth-child(7) { animation-delay: -1s; }
.thinking-matrix-cell:nth-child(8) { animation-delay: -1.166667s; }
.thinking-matrix-cell:nth-child(9) { animation-delay: -1.333333s; }

@keyframes thinking-matrix-cell {
  0% { opacity: .2; animation-timing-function: cubic-bezier(.45, 0, .1, 1); }
  31.25% { opacity: 1; animation-timing-function: cubic-bezier(.45, 0, .1, 1); }
  50% { opacity: 1; animation-timing-function: cubic-bezier(.45, 0, .1, 1); }
  100% { opacity: .2; }
}

/* Composer */

.composer-wrap {
  width: min(100%, calc(var(--transcript-width) + 2rem));
  min-width: 0;
  max-width: 100%;
  margin: auto;
  padding: .45rem 1rem max(1rem, env(safe-area-inset-bottom));
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.attachment-list:not(:empty) {
  margin-bottom: .45rem;
}

.attachment {
  max-width: min(100%, 16rem);
  min-height: 2.6rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  padding: .28rem .45rem .28rem .3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-soft);
  font-size: .78rem;
  text-align: left;
  animation: attachment-in .24s cubic-bezier(.2, .8, .2, 1);
  transition: border-color .14s ease, background-color .14s ease;
}

.attachment.removing {
  pointer-events: none;
  animation: attachment-out .16s ease forwards;
}

@keyframes attachment-in {
  from { opacity: 0; transform: translateY(4px) scale(.96); }
}

@keyframes attachment-out {
  to { opacity: 0; transform: translateY(-3px) scale(.94); }
}

.attachment:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.attachment:hover .attachment-remove,
.attachment:focus-visible .attachment-remove {
  color: var(--text);
}

.attachment-preview,
.attachment-file-icon {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border-radius: .38rem;
}

.attachment-preview {
  object-fit: cover;
  background: var(--surface-raised);
}

.attachment-file-icon {
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  color: var(--text-muted);
}

.attachment-file-icon svg {
  width: 1rem;
  height: 1rem;
}

.attachment-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.composer {
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(58px, auto);
  align-items: center;
  padding: 0 .7rem;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.composer.unavailable {
  border-style: dashed;
  background: color-mix(in srgb, var(--surface-subtle) 78%, var(--surface-raised));
  box-shadow: none;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--text-muted) 40%, var(--line));
  box-shadow: none;
  transform: none;
}

.composer.unavailable:focus-within {
  border-color: var(--line-strong);
  box-shadow: none;
  transform: none;
}

.composer-input {
  min-width: 0;
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-self: stretch;
}

.composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.2rem;
  max-height: 10rem;
  overflow-y: hidden;
  resize: none;
  min-height: 3.75rem;
  padding: 16px 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.composer textarea::-webkit-scrollbar {
  width: .35rem;
}

.composer textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

.composer-toolbar {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: contents;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 .3rem .25rem;
}

.composer-tools {
  grid-column: 1;
  grid-row: 1;
}

.composer-submit {
  grid-column: 3;
  grid-row: 1;
  gap: .35rem;
}

.composer-tools,
.composer-submit {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.model-picker {
  position: relative;
}

.model-trigger {
  height: 2.3rem;
  display: flex;
  align-items: center;
  gap: .44rem;
  padding: 0 .58rem 0 .64rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-soft);
  font-size: .84rem;
  font-weight: 680;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}

.model-trigger:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.model-trigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--surface-hover);
  color: var(--text);
}

.model-trigger-caret {
  width: .9rem;
  height: .9rem;
  transition: transform .14s ease;
}

.model-trigger-mark {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  color: var(--accent);
}

.model-trigger[aria-expanded="true"] .model-trigger-caret {
  transform: rotate(180deg);
}

.model-menu {
  position: absolute;
  z-index: 4;
  bottom: calc(100% + .45rem);
  right: 0;
  left: auto;
  width: 15rem;
  max-width: calc(var(--visual-viewport-width) - 1.5rem);
  padding: .3rem;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  transform-origin: bottom right;
  animation: menu-in-up .16s cubic-bezier(.2, .8, .2, 1);
}

.model-menu button {
  width: 100%;
  height: 3.3rem;
  display: grid;
  grid-template-columns: 1.45rem 1fr auto;
  align-content: center;
  align-items: center;
  gap: .6rem;
  padding: .34rem .56rem;
  border: 0;
  border-radius: .8rem;
  background: transparent;
  font-size: .8rem;
  text-align: left;
}

.model-option-check {
  width: 1rem;
  color: var(--accent);
  font-size: .78rem;
  opacity: 0;
  text-align: center;
}

.model-menu button[aria-selected="true"] .model-option-check {
  opacity: 1;
}

.model-option-mark {
  width: 1.2rem;
  height: 1.2rem;
  justify-self: center;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: round;
  color: var(--text-soft);
  transition: color .16s ease;
}

.model-icon-bolt-base {
  fill: currentColor;
  stroke: none;
}

.model-icon-bolt-pulse {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: .18 .82;
  stroke-dashoffset: 1;
  opacity: 0;
}

.model-icon-flame {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  opacity: .7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-icon-bulb-filament {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  opacity: .55;
}

.model-icon-bulb-ray {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes model-bolt-current {
  0%, 100% { opacity: .15; stroke-dashoffset: 1; }
  18% { opacity: 1; }
  42% { opacity: .45; }
  62% { opacity: 1; }
  82% { opacity: .35; stroke-dashoffset: -.35; }
}

@keyframes model-rocket-flame {
  0%, 100% { opacity: .38; stroke-dashoffset: .15; transform: scale(.8); }
  45% { opacity: 1; stroke-dashoffset: 0; transform: scale(1.12); }
  70% { opacity: .58; transform: scale(.92); }
}

@keyframes model-bulb-light {
  0%, 100% { opacity: .42; stroke-dashoffset: .15; }
  22% { opacity: 1; stroke-dashoffset: 0; }
  42% { opacity: .62; }
  58% { opacity: 1; }
}

@keyframes model-bulb-rays {
  0%, 100% { opacity: .25; transform: scale(.88); }
  28% { opacity: 1; transform: scale(1.12); }
  54% { opacity: .5; transform: scale(.96); }
  72% { opacity: 1; transform: scale(1); }
}

.model-menu [data-model="grok-fast"] .model-option-mark {
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-option-mark-fill {
  fill: currentColor;
  stroke: none;
}

.model-option-mark-fill path:last-child {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: square;
}

.model-option-copy {
  min-width: 0;
  display: grid;
  gap: .08rem;
}

.model-option-title {
  font-size: .84rem;
  font-weight: 690;
  line-height: 1.05;
}

.model-option-description {
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.model-option-provider {
  color: var(--text-muted);
}

.model-menu button:hover {
  background: var(--surface-hover);
}

.model-menu button[aria-selected="true"] .model-option-check {
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .model-menu button[data-model="grok-auto"]:is(:hover, :focus-visible) .model-icon-flame {
    animation: model-rocket-flame 900ms ease-in-out infinite;
    transform-box: fill-box;
    transform-origin: center;
  }

  .model-menu button[data-model="grok-fast"]:is(:hover, :focus-visible) .model-icon-bolt-pulse {
    animation: model-bolt-current 620ms linear infinite;
  }

  .model-menu button[data-model="grok-4"]:is(:hover, :focus-visible) .model-icon-bulb-filament {
    animation: model-bulb-light 1100ms ease-in-out infinite;
  }

  .model-menu button[data-model="grok-4"]:is(:hover, :focus-visible) .model-icon-bulb-ray {
    animation: model-bulb-rays 1100ms ease-in-out infinite;
  }
}

.mobile-nav-trigger {
  position: absolute;
  z-index: 2;
  top: max(.75rem, env(safe-area-inset-top));
  left: max(.75rem, env(safe-area-inset-left));
  border: 1px solid var(--line);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.send,
.stop {
  background: transparent;
  color: var(--accent-contrast);
}

.send > svg {
  background: var(--accent);
  transition: background-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.send:hover > svg {
  background: var(--accent-hover);
  transform: translateY(-1px) scale(1.04);
  box-shadow: var(--shadow-sm);
}

.send:disabled {
  opacity: 1;
}

.send:disabled > svg,
.send:disabled:hover > svg {
  background: var(--surface-hover);
  color: var(--text-muted);
  transform: none;
  box-shadow: none;
}

.stop > svg {
  background: var(--text);
}

.stop svg {
  fill: currentColor;
  stroke: none;
}

.composer-note {
  margin: .45rem 0 0;
  color: var(--text-muted);
  font-size: .72rem;
  text-align: center;
}

.conversation-group {
  margin: .7rem .7rem .2rem;
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 760;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.conversation-group:first-child {
  margin-top: .3rem;
}

.conversation mark {
  border-radius: .18rem;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: inherit;
}

.conversation-empty {
  margin: 1.2rem .7rem;
  color: var(--text-muted);
  font-size: .8rem;
}

.conversation.title-updated {
  animation: title-refresh .55s cubic-bezier(.2, .8, .2, 1);
}

@keyframes title-refresh {
  0% { color: var(--accent); transform: translateX(-3px); }
}

.drop-indicator {
  position: absolute;
  z-index: 5;
  inset: .75rem;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--accent) 65%, transparent);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  color: var(--accent);
  font-size: .85rem;
  font-weight: 720;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.drop-indicator:not([hidden]) span {
  animation: drop-label-in .18s cubic-bezier(.2, .8, .2, 1);
}

@keyframes drop-label-in {
  from { opacity: 0; transform: translateY(4px); }
}

.toast-region {
  position: fixed;
  z-index: 10;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: grid;
  gap: .4rem;
  pointer-events: none;
}

.toast {
  min-width: 13rem;
  max-width: min(23rem, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-raised) 96%, transparent);
  color: var(--text);
  font-size: .78rem;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in .2s cubic-bezier(.2, .8, .2, 1);
}

.toast button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 800;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

:root[data-ambient="off"] .chat-main::before,
:root[data-ambient="off"] .chat-main::after {
  display: none;
}

/* Images */

.image-thumbnail {
  width: min(100%, var(--image-preview-width, 32rem));
  height: auto;
  aspect-ratio: var(--image-preview-ratio, 4 / 3);
  display: grid;
  grid-template-areas: "image";
  margin-top: .85rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 2rem;
  background: #0a0a0a;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 72%, transparent);
  isolation: isolate;
}

.generated-image {
  grid-area: image;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.image-thumbnail-footer {
  grid-area: image;
  align-self: end;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 3.75rem 1.15rem .95rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .74));
  font-size: .84rem;
  font-weight: 760;
  pointer-events: none;
}

.image-thumbnail-footer svg {
  width: 1.15rem;
  height: 1.15rem;
}

/* Generated file cards: standalone `[Artifact: ...](/images/...)` links
   rendered as compact, fully clickable file cards beneath the prose. */

.artifact-card {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) 1rem;
  gap: 12px;
  align-items: center;
  width: min(100%, 22rem);
  margin-top: .85rem;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.artifact-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.artifact-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.artifact-card-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: .5rem;
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.artifact-card-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

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

.artifact-card-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  color: var(--text);
}

.artifact-card-meta {
  font-size: .8rem;
  color: var(--text-muted);
}

.artifact-card-action {
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.artifact-card-action svg {
  width: 1.05rem;
  height: 1.05rem;
}

.image-viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #000;
  color: #f5f5f5;
  box-shadow: none;
}

.image-viewer::backdrop {
  background: #000;
}

.image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.image-viewer-toolbar {
  min-height: 3.5rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .25rem;
  padding: .35rem .6rem;
  border-bottom: 1px solid #171717;
  background: #000;
}

#image-viewer-title {
  overflow: hidden;
  padding-inline: .35rem;
  font-size: .82rem;
  font-weight: 650;
  letter-spacing: -.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.image-zoom-controls {
  display: flex;
  align-items: center;
  padding: .2rem;
  border: 1px solid #303030;
  border-radius: 1rem;
  background: #1e1e1e;
}

.image-zoom-controls button,
.image-viewer-action {
  width: 2.45rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: .52rem;
  background: transparent;
  color: inherit;
  text-decoration: none;
  transition: color .14s ease, background-color .14s ease;
}

.image-zoom-controls button:hover,
.image-viewer-action:hover {
  background: #333;
}

.image-zoom-controls button:disabled {
  opacity: .3;
}

.image-zoom-controls #zoom-reset {
  width: 3.65rem;
  color: #f5f5f6;
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.image-viewer-action {
  border: 1px solid transparent;
}

.image-viewer-action svg,
.image-zoom-controls svg {
  width: 1.12rem;
  height: 1.12rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.image-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: clamp(.75rem, 2vw, 2rem);
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  background: #000;
  scrollbar-color: #454545 transparent;
}

.image-viewer-canvas {
  width: max-content;
  height: max-content;
  min-width: 100%;
  min-height: 100%;
  display: flex;
}

.image-stage img {
  width: auto;
  height: auto;
  display: block;
  margin: auto;
  background: #000;
  box-shadow: none;
  opacity: 0;
  transition: opacity .12s ease;
  user-select: none;
}

.image-stage img.is-ready {
  opacity: 1;
  transition: opacity .12s ease, width .16s ease;
}

.image-stage.is-zoomed {
  cursor: grab;
}

.image-stage.is-panning {
  cursor: grabbing;
}

.image-stage.is-panning img {
  pointer-events: none;
}

.image-stage:focus-visible {
  outline: 0;
  box-shadow: none;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .48);
}

.mobile-only {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .message.user .message-actions,
  .conversation-more {
    opacity: 0;
    transition: opacity .14s ease, background-color .14s ease;
  }

  .message.user:hover .message-actions,
  .message.user:focus-within .message-actions,
  .conversation-row:hover .conversation-more,
  .conversation-row:focus-within .conversation-more,
  .conversation-more[aria-expanded="true"] {
    opacity: 1;
  }
}

@media (max-width: 960px) {
  :root {
    --sidebar-width: 17rem;
  }

  .messages {
    padding-inline: clamp(1rem, 4vw, 2.5rem);
  }

  .composer-wrap {
    width: 100%;
    padding-inline: clamp(.75rem, 3vw, 2rem);
  }
}

@media (max-width: 760px) {
  html,
  body,
  .shell,
  .chat-main {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 3;
    inset: 0 auto 0 0;
    width: min(88vw, 19rem);
    padding-top: max(var(--space-3), env(safe-area-inset-top));
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-collapse {
    display: none;
  }

  .settings-popover {
    position: fixed;
    right: .75rem;
    bottom: max(4rem, calc(env(safe-area-inset-bottom) + 3.5rem));
    left: .75rem;
    width: auto;
  }

  .toast-region {
    right: .65rem;
    bottom: max(5.4rem, calc(env(safe-area-inset-bottom) + 4.8rem));
    left: .65rem;
  }

  .toast {
    max-width: none;
  }

  .chat-main::before,
  .chat-main::after {
    inset: -34%;
    opacity: .62;
  }

  .chat-main::before {
    animation-duration: 42s;
  }

  .chat-main::after {
    inset: -24%;
    animation-duration: 34s;
  }

  .mobile-only {
    display: grid;
  }

  .scrim:not([hidden]) {
    z-index: 2;
    display: block;
  }

  .messages {
    width: 100%;
    padding: 4.75rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
  }

  .chat-main:has(.service-notice) .messages {
    padding-top: 1.5rem;
  }

  .service-notice {
    width: auto;
    margin: 4.5rem max(.75rem, env(safe-area-inset-right)) 0 max(.75rem, env(safe-area-inset-left));
  }

  .message,
  .message-content {
    min-width: 0;
    max-width: 100%;
  }

  .message.user {
    max-width: 90%;
  }

  .composer-wrap {
    width: 100%;
    max-width: 100%;
    padding-right: max(.65rem, env(safe-area-inset-right));
    padding-left: max(.65rem, env(safe-area-inset-left));
  }

  .image-viewer-toolbar {
    min-height: 3.5rem;
    padding-left: max(.35rem, env(safe-area-inset-left));
    padding-right: max(.5rem, env(safe-area-inset-right));
  }

  .image-thumbnail {
    border-radius: 1.5rem;
  }

  .image-stage {
    padding: .75rem;
  }
}

@media (max-width: 390px) {
  .composer-toolbar {
    gap: .2rem;
  }

  .composer-tools,
  .composer-submit {
    gap: .1rem;
  }

}

html.compact-visual-viewport .model-trigger {
  width: var(--control-size);
  justify-content: center;
  padding-inline: 0;
}

html.compact-visual-viewport .model-trigger-caret {
  display: none;
}

html.compact-visual-viewport .model-trigger #model-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    color: #fcfcfc;
    background: #050505;
    --canvas: #0a0a0a;
    --sidebar: #050505;
    --surface: #141414;
    --surface-raised: #191919;
    --surface-subtle: #1c1c1c;
    --surface-hover: #222222;
    --surface-active: #282828;
    --text: #fcfcfc;
    --text-soft: #c8c8cd;
    --text-muted: #a1a1aa;
    --line: #262629;
    --line-strong: #333338;
    --accent: #fcfcfc;
    --accent-hover: #ffffff;
    --accent-soft: #1c1c1c;
    --accent-contrast: #0a0a0a;
    --danger: #f87171;
    --danger-soft: #2a1517;
    --warning: #e2b45c;
    --warning-soft: #2d2415;
    --focus: #fcfcfc;
    --code-bg: #0d0d0d;
    --code-text: #f4f4f5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 8px 24px rgba(0, 0, 0, .16);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .5);
  }

  .image-thumbnail {
    background: #0f0f10;
  }

}

:root[data-theme="light"] {
  color-scheme: light;
  color: #18181b;
  background: #ffffff;
  --canvas: #fcfcfc;
  --sidebar: #fafafa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f7f7f8;
  --surface-hover: #f1f1f3;
  --surface-active: #eaeaec;
  --text: #18181b;
  --text-soft: #52525b;
  --text-muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #18181b;
  --accent-hover: #000000;
  --accent-soft: #f4f4f5;
  --accent-contrast: #ffffff;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warning: #92610a;
  --warning-soft: #fef3c7;
  --focus: #18181b;
  --code-bg: #141416;
  --code-text: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05), 0 5px 18px rgba(0, 0, 0, .05);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .16);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  color: #fcfcfc;
  background: #050505;
  --canvas: #0a0a0a;
  --sidebar: #050505;
  --surface: #141414;
  --surface-raised: #191919;
  --surface-subtle: #1c1c1c;
  --surface-hover: #222222;
  --surface-active: #282828;
  --text: #fcfcfc;
  --text-soft: #c8c8cd;
  --text-muted: #a1a1aa;
  --line: #262629;
  --line-strong: #333338;
  --accent: #fcfcfc;
  --accent-hover: #ffffff;
  --accent-soft: #1c1c1c;
  --accent-contrast: #0a0a0a;
  --danger: #f87171;
  --danger-soft: #2a1517;
  --warning: #e2b45c;
  --warning-soft: #2d2415;
  --focus: #fcfcfc;
  --code-bg: #0d0d0d;
  --code-text: #f4f4f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 8px 24px rgba(0, 0, 0, .16);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .5);
}

:root[data-theme="dark"] .image-thumbnail {
  background: #0f0f10;
}

:root[data-theme="light"] .image-thumbnail {
  background: var(--surface-subtle);
}

:root[data-theme="light"] .grok-chat-shell {
  --grok-black: #ffffff;
  --accent: #111112;
  --accent-hover: #000000;
  --accent-soft: #f4f4f5;
  --accent-contrast: #ffffff;
  --focus: #111112;
  --grok-panel: #ffffff;
  --grok-panel-raised: #f4f4f5;
  --grok-line: rgba(0, 0, 0, .1);
  --grok-line-soft: rgba(0, 0, 0, .06);
  --grok-text: #111112;
  --grok-muted: #71717a;
  --grok-faint: #a1a1aa;
  --grok-main-glow: rgba(0, 0, 0, .035);
  --grok-sidebar-top: #fbfbfc;
  --grok-new-top: #ffffff;
  --grok-new-bottom: #f4f4f5;
  --grok-active-top: #f1f1f3;
  --grok-active-bottom: #eaeaec;
  --grok-menu: #ffffff;
  --grok-table-head: #f4f4f5;
  --grok-table-row: #fafafa;
  --grok-code: #141416;
  --grok-inline-code: #f4f4f5;
  --grok-placeholder: #8e8e96;
  --grok-composer-top: #ffffff;
  --grok-user-bubble: #f4f4f5;
}

:root[data-theme="light"] .grok-chat-shell .chat-main::before,
:root[data-theme="light"] .grok-chat-shell .chat-main::after {
  opacity: .28;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .grok-chat-shell {
    --grok-black: #ffffff;
    --grok-panel: #ffffff;
    --grok-panel-raised: #f4f4f5;
    --grok-line: rgba(0, 0, 0, .1);
    --grok-line-soft: rgba(0, 0, 0, .06);
    --grok-text: #111112;
    --grok-muted: #71717a;
    --grok-faint: #a1a1aa;
    --grok-main-glow: rgba(0, 0, 0, .035);
    --grok-sidebar-top: #fbfbfc;
    --grok-new-top: #ffffff;
    --grok-new-bottom: #f4f4f5;
    --grok-active-top: #f1f1f3;
    --grok-active-bottom: #eaeaec;
    --grok-menu: #ffffff;
    --grok-table-head: #f4f4f5;
    --grok-table-row: #fafafa;
    --grok-code: #141416;
    --grok-inline-code: #f4f4f5;
    --grok-placeholder: #8e8e96;
    --grok-composer-top: #ffffff;
    --grok-user-bubble: #f4f4f5;
    --accent: #111112;
    --accent-hover: #000000;
    --accent-soft: #f4f4f5;
    --accent-contrast: #ffffff;
    --focus: #111112;
  }

  :root:not([data-theme]) .grok-chat-shell .chat-main::before,
  :root:not([data-theme]) .grok-chat-shell .chat-main::after {
    opacity: .28;
  }
}

@media (max-width: 760px) {
  .grok-chat-shell .messages {
    padding: 4.75rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
  }

  .grok-chat-shell .composer-wrap {
    width: 100%;
    padding-right: max(.65rem, env(safe-area-inset-right));
    padding-left: max(.65rem, env(safe-area-inset-left));
    padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1.25rem));
  }

  .grok-chat-shell .welcome {
    margin-top: clamp(3rem, 23.5vh, 10rem);
  }

  .grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
    justify-content: normal;
  }

  .grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) {
    transform: none;
  }

  .grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) > .messages {
    grid-row: 2;
    width: auto;
    height: auto;
    overflow: auto;
    padding: 4.75rem max(1rem, env(safe-area-inset-right)) 1.5rem max(1rem, env(safe-area-inset-left));
  }

  .grok-chat-shell .chat-main:not(:has(.messages .message)):not(:has(.service-notice)) > .composer-wrap {
    grid-row: 3;
    width: 100%;
    margin: 0;
    padding-right: max(.65rem, env(safe-area-inset-right));
    padding-left: max(.65rem, env(safe-area-inset-left));
    padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1.25rem));
  }

  .grok-chat-shell .composer {
    padding: 0 .45rem;
    border-radius: 1.9rem;
  }

  .grok-chat-shell .composer textarea {
    padding: 14px 4px 0;
  }

  .grok-chat-shell .model-trigger {
    max-width: 6.5rem;
  }

  .grok-chat-shell .composer-submit .icon-button,
  .grok-chat-shell .dictation {
    width: 2.6rem;
    height: 2.6rem;
    flex: 0 0 2.6rem;
  }

  .grok-chat-shell .chat-main:not(:has(.messages .message)) .composer-submit {
    gap: .1rem;
  }
}

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

  .thinking-matrix-cell {
    animation: none !important;
    opacity: .2 !important;
  }

  .model-icon-bolt-pulse {
    animation: none !important;
    opacity: 0;
  }

  .model-icon-bolt-base {
    fill: currentColor;
  }

  .model-icon-flame,
  .model-icon-bulb-filament {
    animation: none !important;
    opacity: 1;
    stroke-dashoffset: 0;
  }

  .model-icon-bulb-ray {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}
