@layer legacy {
/* --cg-* aliases onto the canonical --aios-* tokens in aios-design-system.css,
   so this file automatically follows the shared palette/theme instead of
   maintaining its own. No per-theme override needed here: --aios-* already
   switches on [data-theme="dark"]. */
:root {
  --cg-bg: var(--aios-bg);
  --cg-sidebar: var(--aios-sidebar-bg);
  --cg-surface: var(--aios-surface);
  --cg-surface-hover: var(--aios-surface-hover);
  --cg-elevated: var(--aios-elevated);
  --cg-text: var(--aios-text);
  --cg-muted: var(--aios-text-muted);
  --cg-line: var(--aios-border);
  --cg-accent: var(--aios-accent);
  --cg-accent-soft: var(--aios-accent-soft);
  --cg-danger: var(--aios-danger);
  --cg-radius: var(--aios-radius-md);
  --cg-sidebar-width: var(--aios-sidebar);
}

html,
body,
#app {
  min-height: 100%;
  color: var(--cg-text) !important;
  background: var(--cg-bg) !important;
}

body {
  letter-spacing: 0 !important;
}

button,
input,
textarea,
select {
  letter-spacing: 0 !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cg-accent) !important;
  outline-offset: 2px;
}

/* Main workspace */
.app-shell {
  min-height: 100dvh !important;
  display: grid !important;
  grid-template-columns: var(--cg-sidebar-width) minmax(0, 1fr) !important;
  color: var(--cg-text) !important;
  background: var(--cg-bg) !important;
}

#app .app-shell > .sidebar {
  position: sticky !important;
  top: 0 !important;
  z-index: calc(var(--z-shell) + 2) !important;
  width: var(--cg-sidebar-width) !important;
  height: 100dvh !important;
  min-height: 0 !important;
  padding: 12px 10px !important;
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) auto !important;
  gap: 8px !important;
  overflow: hidden !important;
  border: 0 !important;
  border-right: 1px solid var(--cg-line) !important;
  border-radius: 0 !important;
  background: var(--cg-sidebar) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#app .sidebar .brand-lockup {
  min-height: 54px !important;
  padding: 6px 10px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

#app .sidebar .brand-lockup .brand-mark.aios-logo-mark {
  width: 118px !important;
  min-width: 118px !important;
  max-width: 118px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  flex: 0 0 118px !important;
  justify-content: flex-start !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

#app .sidebar .brand-lockup .brand-mark img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: left center !important;
}

#app .sidebar .school-chip {
  min-height: 58px !important;
  padding: 10px 12px !important;
  display: grid !important;
  gap: 2px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}

#app .sidebar .school-chip strong {
  color: var(--cg-text) !important;
  font-size: 13px !important;
}

#app .sidebar .school-chip span {
  color: var(--cg-muted) !important;
  font-size: 11px !important;
}

#app .sidebar .nav {
  min-height: 0 !important;
  padding: 4px 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  overflow-y: auto !important;
  scrollbar-width: thin;
}

#app .sidebar .nav-item {
  width: 100% !important;
  min-height: 42px !important;
  padding: 6px 10px !important;
  display: grid !important;
  grid-template-columns: 24px minmax(0, 1fr) !important;
  gap: 10px !important;
  align-items: center !important;
  color: var(--cg-text) !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  text-align: left !important;
}

#app .sidebar .nav-item:hover,
#app .sidebar .nav-item.active {
  color: var(--cg-text) !important;
  border-color: transparent !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
}

#app .app-shell > .sidebar .nav .nav-item.active,
#app .app-shell > .sidebar .nav .nav-item:hover {
  color: var(--cg-text) !important;
  border-color: transparent !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
}

#app .sidebar .nav-item-icon {
  width: 24px !important;
  min-width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-muted) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#app .sidebar .nav-item.active .nav-item-icon {
  color: var(--cg-text) !important;
  background: transparent !important;
}

#app .sidebar .nav-item-icon svg {
  width: 18px !important;
  height: 18px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 1.8 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

#app .sidebar .nav-item-label {
  min-width: 0 !important;
  overflow: hidden !important;
  color: inherit !important;
  font-size: 13px !important;
  font-weight: 560 !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

#app .sidebar .sidebar-footer {
  padding-top: 8px !important;
  display: grid !important;
  gap: 8px !important;
  border-top: 1px solid var(--cg-line) !important;
  background: transparent !important;
}

#app .sidebar .sidebar-account {
  width: 100% !important;
  min-height: 48px !important;
  padding: 6px 8px !important;
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) !important;
  gap: 9px !important;
  align-items: center !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  text-align: left !important;
}

#app .sidebar .sidebar-account:hover {
  background: var(--cg-surface) !important;
}

#app .sidebar .account-avatar {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 50% !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
  filter: none !important;
}

#app .sidebar .sidebar-account > div {
  min-width: 0 !important;
  display: grid !important;
  gap: 1px !important;
}

#app .sidebar .sidebar-account strong,
#app .sidebar .sidebar-account span {
  overflow: hidden !important;
  color: var(--cg-text) !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

#app .sidebar .sidebar-account strong {
  font-size: 12px !important;
}

#app .sidebar .sidebar-account span {
  color: var(--cg-muted) !important;
  font-size: 10px !important;
}

#app .sidebar .sidebar-status-row {
  min-height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
}

#app .sidebar .cloud-sync {
  padding: 0 !important;
  color: var(--cg-muted) !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 10px !important;
}

#app .sidebar .cloud-sync.ok {
  color: #4ade80 !important;
}

#app .sidebar .sidebar-utilities {
  display: flex !important;
  gap: 3px !important;
}

#app .sidebar .sidebar-utilities .icon-button {
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-muted) !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  box-shadow: none !important;
}

#app .sidebar .sidebar-utilities .icon-button:hover {
  color: var(--cg-text) !important;
  background: var(--cg-surface) !important;
}

.app-shell > .main {
  min-width: 0 !important;
  min-height: 100dvh !important;
  color: var(--cg-text) !important;
  background: var(--cg-bg) !important;
}

.app-shell:not(.chat-shell) .content {
  width: 100% !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
  padding: 32px 34px 56px !important;
  color: var(--cg-text) !important;
  background: transparent !important;
}

.app-shell:not(.chat-shell) .page-title h2,
.app-shell:not(.chat-shell) h1,
.app-shell:not(.chat-shell) h2,
.app-shell:not(.chat-shell) h3,
.app-shell:not(.chat-shell) strong {
  color: var(--cg-text) !important;
}

.app-shell:not(.chat-shell) .page-title p,
.app-shell:not(.chat-shell) .meta,
.app-shell:not(.chat-shell) .hint,
.app-shell:not(.chat-shell) .empty {
  color: var(--cg-muted) !important;
}

.app-shell:not(.chat-shell) .panel,
.app-shell:not(.chat-shell) .metric,
.app-shell:not(.chat-shell) .hero-panel,
.app-shell:not(.chat-shell) .request-card,
.app-shell:not(.chat-shell) .data-table-wrap {
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: var(--cg-radius) !important;
  background: var(--cg-elevated) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.app-shell:not(.chat-shell) .primary {
  color: #ffffff !important;
  border-color: var(--cg-accent) !important;
  border-radius: 8px !important;
  background: var(--cg-accent) !important;
  box-shadow: none !important;
  transform: none !important;
}

.app-shell:not(.chat-shell) .secondary,
.app-shell:not(.chat-shell) .ghost {
  color: var(--cg-text) !important;
  border-color: var(--cg-line) !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* ChatGPT-like chat */
.app-shell.chat-shell {
  height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.app-shell.chat-shell > .main,
.app-shell.chat-shell .content,
.app-shell.chat-shell .content:has(.aios-chat-app) {
  width: 100% !important;
  max-width: none !important;
  height: 100dvh !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.app-shell.chat-shell .aios-chat-app,
.app-shell.chat-shell .aios-chat-app.chat-roomy {
  width: 100% !important;
  height: 100dvh !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-columns: clamp(288px, 23vw, 320px) minmax(0, 1fr) !important;
  overflow: hidden !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cg-bg) !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .aios-chat-app.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
}

.app-shell.chat-shell .aios-chat-app.sidebar-collapsed > .aios-chat-sidebar,
.app-shell.chat-shell .aios-chat-app.sidebar-collapsed > .chat-sidebar-backdrop {
  display: none !important;
}

.app-shell.chat-shell .aios-chat-sidebar {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 10px !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  gap: 10px !important;
  overflow: hidden !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-right: 1px solid var(--cg-line) !important;
  border-radius: 0 !important;
  background: var(--cg-sidebar) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.app-shell.chat-shell .chat-sidebar-head,
.app-shell.chat-shell .chat-new-row {
  min-height: 44px !important;
}

.app-shell.chat-shell .chat-new-side-logo {
  display: none !important;
}

.app-shell.chat-shell .chat-new-button {
  min-height: 42px !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .chat-search {
  min-height: 40px !important;
  padding: 0 12px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .conversation-groups {
  min-height: 0 !important;
  padding: 4px 0 !important;
  overflow-y: auto !important;
}

.app-shell.chat-shell .conversation-item {
  padding: 9px 10px !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .conversation-item:hover,
.app-shell.chat-shell .conversation-item.active {
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .conversation-main strong {
  color: var(--cg-text) !important;
}

.app-shell.chat-shell .conversation-main span,
.app-shell.chat-shell .conversation-meta,
.app-shell.chat-shell .conversation-meta em {
  color: var(--cg-muted) !important;
}

/* Keep the conversation row uncluttered but ALWAYS expose a Delete button
   (the other row actions stay hidden). This rule loads last, so it is the
   authoritative reveal; mobile positioning/styling lives in aios-mobile-final.css. */
.app-shell.chat-shell .conversation-actions {
  display: flex !important;
}

.app-shell.chat-shell .conversation-actions .icon-button:not([data-action^="delete-chat"]) {
  display: none !important;
}

.app-shell.chat-shell .aios-chat-main {
  min-width: 0 !important;
  min-height: 0 !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  overflow: hidden !important;
  color: var(--cg-text) !important;
  background: var(--cg-bg) !important;
}

.app-shell.chat-shell .aios-chat-topbar {
  min-height: 64px !important;
  max-height: none !important;
  padding: 8px 14px !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  overflow: visible !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--cg-line) !important;
  border-radius: 0 !important;
  background: color-mix(in srgb, var(--cg-bg) 92%, transparent) !important;
  box-shadow: none !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

.app-shell.chat-shell .chat-mobile-app-menu {
  display: none !important;
}

.app-shell.chat-shell .chat-mobile-title {
  min-width: 62px !important;
  color: var(--cg-text) !important;
}

.app-shell.chat-shell .chat-selectors {
  min-width: 0 !important;
  margin-left: auto !important;
  display: flex !important;
  align-items: end !important;
  gap: 8px !important;
  overflow-x: auto !important;
}

.app-shell.chat-shell .chat-selectors .chat-ai-routing {
  display: contents !important;
}

.app-shell.chat-shell .chat-selectors .field {
  width: auto !important;
  min-width: 132px !important;
  margin: 0 !important;
  display: grid !important;
  gap: 3px !important;
}

.app-shell.chat-shell .chat-selectors .field > span,
.app-shell.chat-shell .chat-selectors .field > label {
  color: var(--cg-muted) !important;
  font-size: 10px !important;
}

.app-shell.chat-shell .chat-selectors select,
.app-shell.chat-shell .chat-selectors .model-pill {
  width: 100% !important;
  min-height: 38px !important;
  padding: 0 30px 0 10px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 8px !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
  font-size: 12px !important;
}

.app-shell.chat-shell .chat-model-menu {
  position: relative !important;
  margin-left: auto !important;
}

.app-shell.chat-shell .chat-model-trigger {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  min-height: 36px !important;
  padding: 0 10px !important;
  color: var(--cg-muted) !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
}

.app-shell.chat-shell .chat-model-trigger:hover,
.app-shell.chat-shell .chat-model-trigger[aria-expanded="true"] {
  color: var(--cg-text) !important;
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .chat-model-trigger .icon-symbol {
  font-size: 11px !important;
  opacity: 0.7;
}

.app-shell.chat-shell .chat-model-popover {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  right: 0 !important;
  z-index: calc(var(--z-shell) + 3) !important;
  width: 220px !important;
  display: grid !important;
  gap: 10px !important;
  padding: 12px !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 12px !important;
  background: var(--cg-elevated) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28) !important;
}

.app-shell.chat-shell .chat-model-popover .field {
  width: 100% !important;
  margin: 0 !important;
  display: grid !important;
  gap: 4px !important;
}

.app-shell.chat-shell .chat-model-popover .field > label {
  color: var(--cg-muted) !important;
  font-size: 11px !important;
}

.app-shell.chat-shell .chat-model-popover select {
  width: 100% !important;
  min-height: 38px !important;
  padding: 0 10px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 8px !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
  font-size: 13px !important;
}

.app-shell.chat-shell .aios-chat-topbar > .icon-button,
.app-shell.chat-shell .chat-mobile-new,
.app-shell.chat-shell .chat-mobile-exit {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .aios-chat-topbar > .icon-button:hover,
.app-shell.chat-shell .chat-mobile-new:hover,
.app-shell.chat-shell .chat-mobile-exit:hover {
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .aios-chat-messages {
  min-height: 0 !important;
  padding: 28px max(22px, calc((100% - 820px) / 2)) 160px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 22px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  color: var(--cg-text) !important;
  background: var(--cg-bg) !important;
}

.app-shell.chat-shell .chat-message {
  width: 100% !important;
  max-width: 780px !important;
  margin: 0 auto !important;
  display: grid !important;
  grid-template-columns: 34px minmax(0, 1fr) !important;
  gap: 10px !important;
  color: var(--cg-text) !important;
}

.app-shell.chat-shell .chat-message.user {
  width: min(82%, 650px) !important;
  margin-left: auto !important;
  margin-right: max(0px, calc((100% - 780px) / 2)) !important;
  display: block !important;
}

.app-shell.chat-shell .chat-message .message-avatar {
  width: 30px !important;
  height: 30px !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 8px !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .chat-message .message-avatar-image {
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
}

.app-shell.chat-shell .chat-message.ai .message-avatar {
  width: 34px !important;
  height: 34px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.app-shell.chat-shell .chat-message.user .message-avatar {
  display: none !important;
}

.app-shell.chat-shell .chat-message .message-body {
  min-width: 0 !important;
  padding: 0 !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .chat-message.user .message-body {
  padding: 12px 14px !important;
  border-radius: 18px !important;
  background: var(--cg-surface) !important;
}

body[data-theme] .app-shell.chat-shell .aios-chat-main .chat-message.ai .message-body {
  padding: 0 !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-theme] .app-shell.chat-shell .aios-chat-main .chat-message.user .message-body {
  padding: 12px 14px !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 18px !important;
  background: var(--cg-surface) !important;
  box-shadow: none !important;
}

body[data-theme] .app-shell.chat-shell .chat-message .message-body::before,
body[data-theme] .app-shell.chat-shell .chat-message .message-body::after {
  display: none !important;
  content: none !important;
  background: none !important;
  animation: none !important;
}

.app-shell.chat-shell .chat-message .message-meta,
.app-shell.chat-shell .chat-message .message-meta strong,
.app-shell.chat-shell .chat-message .message-meta time {
  color: var(--cg-muted) !important;
}

.app-shell.chat-shell .chat-message.user .message-meta strong {
  display: none !important;
}

.app-shell.chat-shell .chat-message .message-text,
.app-shell.chat-shell .chat-message .message-text p,
.app-shell.chat-shell .chat-message .message-text li {
  color: var(--cg-text) !important;
  font-size: 15px !important;
  line-height: 1.65 !important;
}

.app-shell.chat-shell .message-actions .icon-button,
.app-shell.chat-shell .message-actions button {
  color: var(--cg-muted) !important;
  border: 0 !important;
  border-radius: 7px !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .message-actions button:hover {
  color: var(--cg-text) !important;
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .welcome-screen {
  width: min(720px, 100%) !important;
  min-height: 100% !important;
  margin: 0 auto !important;
  padding: clamp(72px, 13vh, 130px) 0 18px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  color: var(--cg-text) !important;
  text-align: center !important;
}

.app-shell.chat-shell .welcome-screen .ai-orb {
  display: none !important;
}

.app-shell.chat-shell .welcome-screen h1 {
  max-width: 660px !important;
  margin: 0 !important;
  color: var(--cg-text) !important;
  font-size: clamp(32px, 4vw, 46px) !important;
  line-height: 1.08 !important;
  font-weight: 680 !important;
}

.app-shell.chat-shell .welcome-screen p {
  max-width: 520px !important;
  margin: 0 !important;
  color: var(--cg-muted) !important;
  font-size: 14px !important;
}

.app-shell.chat-shell .welcome-prompts {
  width: 100% !important;
  margin-top: auto !important;
  padding-top: 32px !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
}

.app-shell.chat-shell .suggestion-card {
  min-height: 54px !important;
  padding: 11px 13px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 12px !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  text-align: left !important;
}

.app-shell.chat-shell .suggestion-card:hover {
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .composer-wrap {
  position: relative !important;
  z-index: calc(var(--z-shell) + 1) !important;
  width: 100% !important;
  padding: 10px 20px max(14px, env(safe-area-inset-bottom)) !important;
  display: grid !important;
  justify-items: center !important;
  border: 0 !important;
  background: linear-gradient(to top, var(--cg-bg) 72%, transparent) !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .claude-composer {
  width: min(780px, 100%) !important;
  min-height: 56px !important;
  max-height: min(45dvh, 280px) !important;
  padding: 7px 8px !important;
  display: grid !important;
  grid-template-columns: 40px minmax(0, 1fr) 40px 42px !important;
  align-items: end !important;
  gap: 4px !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 28px !important;
  background: var(--cg-elevated) !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16) !important;
  backdrop-filter: none !important;
}

.app-shell.chat-shell .claude-composer textarea {
  min-height: 40px !important;
  max-height: 180px !important;
  padding: 10px 4px !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  resize: none !important;
}

.app-shell.chat-shell .claude-composer textarea::placeholder {
  color: var(--cg-muted) !important;
}

.app-shell.chat-shell .claude-composer .icon-button {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  color: var(--cg-text) !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  box-shadow: none !important;
}

.app-shell.chat-shell .claude-composer .icon-button:hover {
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .claude-composer #aios-send,
.app-shell.chat-shell .claude-composer [data-action="stop-aios-generation"] {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--cg-accent) !important;
  box-shadow: none !important;
  font-size: 0 !important;
}

.app-shell.chat-shell .claude-composer #aios-send:disabled {
  color: var(--cg-muted) !important;
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .claude-composer #aios-send .icon-symbol {
  color: currentColor !important;
  font-size: 20px !important;
  font-weight: 650 !important;
  line-height: 1 !important;
}

.app-shell.chat-shell .attachment-tray {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}

.app-shell.chat-shell .attachment-chip {
  max-width: 100% !important;
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 10px !important;
  background: var(--cg-surface) !important;
}

.app-shell.chat-shell .composer-tools-popover {
  color: var(--cg-text) !important;
  border: 1px solid var(--cg-line) !important;
  border-radius: 12px !important;
  background: var(--cg-elevated) !important;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24) !important;
}

/* The tools menu belongs to the + button and must float above the composer. */
.app-shell.chat-shell .composer-wrap,
.app-shell.chat-shell .claude-composer,
.app-shell.chat-shell .composer-tools {
  overflow: visible !important;
}

.app-shell.chat-shell .composer-tools {
  position: static !important;
}

.app-shell.chat-shell .claude-composer {
  position: relative !important;
  contain: none !important;
}

.app-shell.chat-shell #aios-tools-popover {
  position: absolute !important;
  left: 0 !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(100% + 12px) !important;
  width: min(330px, calc(100vw - 32px)) !important;
  z-index: calc(var(--z-drawer) + 6) !important;
  transform-origin: bottom left !important;
}

.app-shell.chat-shell .chat-actions {
  display: none !important;
}

/* Mobile shell and drawers */
.mobile-shell-header,
.mobile-menu-button {
  display: none !important;
}

@media (max-width: 820px) {
  :root {
    --cg-sidebar-width: 0px;
  }

  body.aios-mobile-menu-open,
  html.aios-mobile-menu-open {
    overflow: hidden !important;
  }

  #app .app-shell {
    min-height: 100dvh !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 60px minmax(0, 1fr) !important;
    overflow-x: hidden !important;
  }

  #app .app-shell > .sidebar {
    display: none !important;
  }

  .app-shell > .mobile-shell-header {
    position: sticky !important;
    top: 0 !important;
    z-index: calc(var(--z-shell) + 5) !important;
    width: 100% !important;
    height: 60px !important;
    padding: 8px 10px !important;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px !important;
    grid-template-rows: 44px !important;
    gap: 6px !important;
    align-items: center !important;
    border: 0 !important;
    border-bottom: 1px solid var(--cg-line) !important;
    background: color-mix(in srgb, var(--cg-bg) 92%, transparent) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }

  .mobile-shell-menu,
  .mobile-shell-account,
  .mobile-shell-new-chat {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    color: var(--cg-text) !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .mobile-shell-menu:hover,
  .mobile-shell-account:hover,
  .mobile-shell-new-chat:hover {
    background: var(--cg-surface) !important;
  }

  .mobile-shell-brand {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    padding: 0 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 0 !important;
    color: var(--cg-text) !important;
    border: 0 !important;
    border-radius: 22px !important;
    background: var(--cg-surface) !important;
    box-shadow: none !important;
  }

  .mobile-shell-brand strong,
  .mobile-shell-brand small {
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    color: var(--cg-text) !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .mobile-shell-brand strong {
    font-size: 13px !important;
  }

  .mobile-shell-brand small {
    color: var(--cg-muted) !important;
    font-size: 9px !important;
  }

  .app-shell:not(.chat-shell) > .main {
    min-height: 0 !important;
  }

  .app-shell:not(.chat-shell) .content {
    width: 100% !important;
    max-width: none !important;
    min-height: calc(100dvh - 60px) !important;
    padding: 22px 16px 40px !important;
  }

  .app-shell:not(.chat-shell) .page-title {
    gap: 16px !important;
  }

  .app-shell:not(.chat-shell) .page-title h2 {
    font-size: 28px !important;
  }

  .app-shell:not(.chat-shell) .metric-grid,
  .app-shell:not(.chat-shell) .card-grid,
  .app-shell:not(.chat-shell) .split {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .app-shell.chat-shell {
    grid-template-rows: minmax(0, 1fr) !important;
  }

  .app-shell.chat-shell > .mobile-shell-header {
    display: none !important;
  }

  .app-shell.chat-shell > .main,
  .app-shell.chat-shell .content,
  .app-shell.chat-shell .content:has(.aios-chat-app) {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .app-shell.chat-shell .aios-chat-app,
  .app-shell.chat-shell .aios-chat-app.chat-roomy,
  .app-shell.chat-shell .aios-chat-app.sidebar-collapsed {
    width: 100% !important;
    height: 100dvh !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }

  .app-shell.chat-shell .aios-chat-sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: calc(var(--z-drawer) + 4) !important;
    width: min(344px, calc(100vw - 24px)) !important;
    height: 100dvh !important;
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)) !important;
    border-right: 1px solid var(--cg-line) !important;
    border-radius: 0 16px 16px 0 !important;
    background: var(--cg-sidebar) !important;
    box-shadow: 18px 0 60px rgba(0, 0, 0, 0.24) !important;
  }

  .app-shell.chat-shell .chat-sidebar-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: calc(var(--z-drawer) + 2) !important;
    display: block !important;
    border: 0 !important;
    background: rgba(0, 0, 0, 0.34) !important;
    backdrop-filter: blur(4px) !important;
  }

  .app-shell.chat-shell .aios-chat-app.sidebar-collapsed > .aios-chat-sidebar,
  .app-shell.chat-shell .aios-chat-app.sidebar-collapsed > .chat-sidebar-backdrop {
    display: none !important;
  }

  .app-shell.chat-shell .aios-chat-main {
    width: 100% !important;
    height: 100dvh !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
  }

  .app-shell.chat-shell .aios-chat-topbar {
    width: 100% !important;
    min-height: 60px !important;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px !important;
    display: grid !important;
    grid-template-columns: 42px 42px minmax(0, 1fr) 42px !important;
    grid-template-rows: 42px auto !important;
    gap: 6px !important;
  }

  .app-shell.chat-shell .chat-mobile-app-menu,
  .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle,
  .app-shell.chat-shell .chat-mobile-new {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 50% !important;
  }

  .app-shell.chat-shell .chat-mobile-app-menu {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  .app-shell.chat-shell .chat-mobile-title {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    padding: 0 14px !important;
    display: flex !important;
    align-items: center !important;
    color: var(--cg-text) !important;
    border: 0 !important;
    border-radius: 21px !important;
    background: var(--cg-surface) !important;
  }

  .app-shell.chat-shell .chat-mobile-new {
    grid-column: 4 !important;
    grid-row: 1 !important;
  }

  .app-shell.chat-shell .chat-mobile-exit {
    display: none !important;
  }

  body[data-theme] .app-shell.chat-shell .aios-chat-topbar > .chat-mobile-exit {
    display: none !important;
  }

  .app-shell.chat-shell .chat-selectors {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .app-shell.chat-shell .chat-model-menu {
    display: none !important;
  }

  .app-shell.chat-shell .chat-selectors::-webkit-scrollbar {
    display: none;
  }

  .app-shell.chat-shell .chat-selectors .field {
    flex: 0 0 auto !important;
    min-width: 112px !important;
  }

  .app-shell.chat-shell .chat-selectors .field > span,
  .app-shell.chat-shell .chat-selectors .field > label {
    display: none !important;
  }

  .app-shell.chat-shell .chat-selectors select,
  .app-shell.chat-shell .chat-selectors .model-pill {
    min-height: 36px !important;
    font-size: 11px !important;
  }

  .app-shell.chat-shell .aios-chat-messages {
    width: 100% !important;
    padding: 20px 14px 118px !important;
    gap: 20px !important;
  }

  .app-shell.chat-shell .chat-message {
    grid-template-columns: 28px minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  .app-shell.chat-shell .chat-message.user {
    width: min(88%, 340px) !important;
    margin-right: 0 !important;
  }

  .app-shell.chat-shell .chat-message.user .message-body {
    padding: 11px 13px !important;
  }

  body[data-theme] .app-shell.chat-shell .aios-chat-main .chat-message.ai .message-body {
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body[data-theme] .app-shell.chat-shell .aios-chat-main .chat-message.user .message-body {
    padding: 11px 13px !important;
    border: 0 !important;
    border-radius: 18px !important;
    background: var(--cg-surface) !important;
    box-shadow: none !important;
  }

  .app-shell.chat-shell .chat-message .message-text,
  .app-shell.chat-shell .chat-message .message-text p,
  .app-shell.chat-shell .chat-message .message-text li {
    font-size: 14px !important;
    line-height: 1.55 !important;
  }

  .app-shell.chat-shell .welcome-screen {
    min-height: 100% !important;
    padding: clamp(62px, 12vh, 108px) 0 8px !important;
  }

  .app-shell.chat-shell .welcome-screen h1 {
    max-width: 350px !important;
    font-size: clamp(30px, 9vw, 38px) !important;
  }

  .app-shell.chat-shell .welcome-screen p {
    max-width: 330px !important;
    font-size: 13px !important;
  }

  .app-shell.chat-shell .welcome-prompts {
    width: calc(100vw - 28px) !important;
    margin-top: auto !important;
    padding-top: 28px !important;
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .app-shell.chat-shell .welcome-prompts::-webkit-scrollbar {
    display: none;
  }

  .app-shell.chat-shell .suggestion-card {
    flex: 0 0 min(78vw, 290px) !important;
    min-height: 58px !important;
  }

  .app-shell.chat-shell .composer-wrap {
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    box-sizing: border-box !important;
    padding: 8px 10px max(10px, env(safe-area-inset-bottom)) !important;
  }

  .app-shell.chat-shell .claude-composer {
    box-sizing: border-box !important;
    background: var(--cg-elevated) !important;
  }

  .app-shell.chat-shell .claude-composer {
    min-height: 56px !important;
    padding: 7px !important;
    grid-template-columns: 40px minmax(0, 1fr) 40px 40px !important;
    border-radius: 26px !important;
  }

  .app-shell.chat-shell .composer-tools-popover {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    top: auto !important;
    bottom: calc(100% + 12px) !important;
    width: min(320px, calc(100vw - 24px)) !important;
  }
}

@media (max-width: 420px) {
  .app-shell > .mobile-shell-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
  }

  .mobile-shell-account {
    display: none !important;
  }

  .mobile-shell-new-chat {
    grid-column: 3 !important;
  }

  .mobile-shell-brand small {
    display: none !important;
  }
}

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

/* iPhone experience: one stable, ChatGPT-like mobile composition. */
@media (max-width: 820px) {
  :root {
    --mobile-header-height: calc(62px + env(safe-area-inset-top));
    --mobile-page-pad: 16px;
    --mobile-control: 44px;
  }

  html,
  body,
  #app {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100% !important;
    overflow-x: clip !important;
    overscroll-behavior-x: none !important;
  }

  body {
    min-height: 100dvh !important;
    -webkit-text-size-adjust: 100% !important;
    touch-action: pan-y !important;
  }

  .app-shell {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    grid-template-rows: var(--mobile-header-height) minmax(0, 1fr) !important;
    background: var(--cg-bg) !important;
  }

  body .app-shell {
    display: grid !important;
  }

  .app-shell > .mobile-shell-header {
    position: fixed !important;
    inset: 0 0 auto 0 !important;
    z-index: calc(var(--z-shell) + 8) !important;
    height: var(--mobile-header-height) !important;
    padding: calc(9px + env(safe-area-inset-top)) 12px 9px !important;
    grid-template-columns: var(--mobile-control) minmax(0, 1fr) var(--mobile-control) !important;
    grid-template-rows: var(--mobile-control) !important;
    gap: 8px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--cg-line) !important;
    background: color-mix(in srgb, var(--cg-bg) 76%, transparent) !important;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--cg-line) 70%, transparent) !important;
    backdrop-filter: blur(28px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(28px) saturate(150%) !important;
  }

  .mobile-shell-menu,
  .mobile-shell-account,
  .mobile-shell-new-chat {
    width: var(--mobile-control) !important;
    min-width: var(--mobile-control) !important;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    border: 1px solid var(--cg-line) !important;
    border-radius: 50% !important;
    background: color-mix(in srgb, var(--cg-elevated) 68%, transparent) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    backdrop-filter: blur(18px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(140%) !important;
  }

  .mobile-shell-menu:active,
  .mobile-shell-account:active,
  .mobile-shell-new-chat:active {
    transform: scale(0.96) !important;
  }

  .mobile-shell-brand {
    height: var(--mobile-control) !important;
    padding: 0 12px !important;
    align-items: center !important;
    border: 1px solid var(--cg-line) !important;
    border-radius: 22px !important;
    background: color-mix(in srgb, var(--cg-elevated) 66%, transparent) !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06) !important;
    backdrop-filter: blur(18px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(140%) !important;
  }

  .mobile-shell-brand strong {
    font-size: 15px !important;
    font-weight: 650 !important;
    text-align: center !important;
  }

  .mobile-shell-brand small,
  .mobile-shell-account {
    display: none !important;
  }

  .mobile-shell-new-chat {
    grid-column: 3 !important;
  }

  .app-shell:not(.chat-shell) > .main {
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: calc(100dvh - var(--mobile-header-height)) !important;
    overflow-x: clip !important;
  }

  /* The grid reserves the header row; the content must not reserve it again. */
  html body #app .app-shell:not(.chat-shell) {
    /* The retired bottom tab bar must not reserve an empty 90px band. */
    padding-bottom: 0 !important;
    grid-template-rows: var(--mobile-header-height) minmax(0, 1fr) !important;
  }
  html body #app .app-shell:not(.chat-shell) > .main {
    display: flex !important;
    flex-direction: column !important;
    padding-top: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
  }
  html body #app .app-shell:not(.chat-shell) > .main > .content {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .app-shell:not(.chat-shell) .content {
    min-height: calc(100dvh - var(--mobile-header-height)) !important;
    padding: 20px var(--mobile-page-pad) calc(36px + env(safe-area-inset-bottom)) !important;
    animation: mobile-page-enter 260ms cubic-bezier(0.22, 1, 0.36, 1) both !important;
  }

  .app-shell:not(.chat-shell) .page-title {
    margin-bottom: 20px !important;
    align-items: flex-start !important;
  }

  .app-shell:not(.chat-shell) .page-title h2 {
    font-size: clamp(27px, 8vw, 34px) !important;
    line-height: 1.08 !important;
  }

  .app-shell:not(.chat-shell) .card,
  .app-shell:not(.chat-shell) .panel,
  .app-shell:not(.chat-shell) .metric-card {
    max-width: 100% !important;
    border-color: var(--cg-line) !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--cg-elevated) 88%, transparent) !important;
    box-shadow: none !important;
  }

  /* Chat header */
  .app-shell.chat-shell .aios-chat-main {
    min-width: 0 !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    background: var(--cg-bg) !important;
  }

  .app-shell.chat-shell .aios-chat-topbar {
    position: relative !important;
    z-index: calc(var(--z-shell) + 5) !important;
    min-height: calc(60px + env(safe-area-inset-top)) !important;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px !important;
    grid-template-columns: 44px 44px minmax(0, 1fr) 44px !important;
    grid-template-rows: 44px auto !important;
    gap: 8px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--cg-line) !important;
    background: color-mix(in srgb, var(--cg-bg) 78%, transparent) !important;
    box-shadow: none !important;
    backdrop-filter: blur(28px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(28px) saturate(150%) !important;
  }

  .app-shell.chat-shell .chat-mobile-app-menu,
  .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle,
  .app-shell.chat-shell .chat-mobile-new {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    color: var(--cg-text) !important;
    border: 1px solid var(--cg-line) !important;
    border-radius: 50% !important;
    background: color-mix(in srgb, var(--cg-elevated) 66%, transparent) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
  }

  html body #app .app-shell.chat-shell .aios-chat-topbar > .chat-mobile-app-menu,
  html body #app .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle,
  html body #app .app-shell.chat-shell .aios-chat-topbar > .chat-mobile-new {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
  }

  .app-shell.chat-shell .chat-mobile-app-menu:active,
  .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle:active,
  .app-shell.chat-shell .chat-mobile-new:active {
    transform: scale(0.96) !important;
  }

  .app-shell.chat-shell .chat-mobile-title {
    height: 44px !important;
    padding: 0 12px !important;
    justify-content: center !important;
    border: 0 !important;
    border-radius: 22px !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .app-shell.chat-shell .chat-mobile-title strong {
    width: 100% !important;
    overflow: hidden !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .app-shell.chat-shell .chat-selectors {
    min-height: 0 !important;
    padding: 0 !important;
    justify-content: center !important;
    overflow: visible !important;
  }

  .app-shell.chat-shell .chat-selectors > .field,
  .app-shell.chat-shell .chat-selectors > .field:has(#chat-subject),
  .app-shell.chat-shell .chat-selectors > .field:has(#chat-class),
  .app-shell.chat-shell .chat-ai-routing > .field:first-child {
    display: none !important;
  }

  .app-shell.chat-shell .chat-ai-routing {
    width: auto !important;
    max-width: min(220px, calc(100vw - 32px)) !important;
    display: block !important;
  }

  .app-shell.chat-shell .chat-ai-routing > .field {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .app-shell.chat-shell .chat-selectors select,
  .app-shell.chat-shell .chat-selectors .model-pill {
    width: auto !important;
    max-width: min(220px, calc(100vw - 32px)) !important;
    min-height: 34px !important;
    padding: 0 32px 0 12px !important;
    color: var(--cg-muted) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border: 1px solid var(--cg-line) !important;
    border-radius: 17px !important;
    background-color: color-mix(in srgb, var(--cg-elevated) 62%, transparent) !important;
    box-shadow: none !important;
  }

  /* Conversation */
  .app-shell.chat-shell .aios-chat-messages {
    min-width: 0 !important;
    padding: 22px 14px 22px !important;
    gap: 22px !important;
    scroll-padding-bottom: 112px !important;
    overscroll-behavior-y: contain !important;
  }

  .app-shell.chat-shell .chat-message {
    width: 100% !important;
    max-width: 720px !important;
    margin-inline: auto !important;
    animation: mobile-message-enter 240ms cubic-bezier(0.22, 1, 0.36, 1) both !important;
  }

  .app-shell.chat-shell .chat-message.user {
    width: min(88%, 360px) !important;
    max-width: 88% !important;
    margin-right: 0 !important;
    margin-left: auto !important;
  }

  .app-shell.chat-shell .chat-message.user .message-body {
    padding: 12px 14px !important;
    border-radius: 20px !important;
    background: var(--cg-surface) !important;
  }

  .app-shell.chat-shell .chat-message.ai {
    grid-template-columns: 28px minmax(0, 1fr) !important;
  }

  .app-shell.chat-shell .chat-message .message-text,
  .app-shell.chat-shell .chat-message .message-text p,
  .app-shell.chat-shell .chat-message .message-text li {
    color: var(--cg-text) !important;
    font-size: 15px !important;
    line-height: 1.55 !important;
  }

  .app-shell.chat-shell .welcome-screen {
    width: 100% !important;
    min-height: 100% !important;
    padding: clamp(42px, 9vh, 82px) 0 4px !important;
    justify-content: flex-start !important;
  }

  .app-shell.chat-shell .welcome-screen h1 {
    width: min(100%, 360px) !important;
    font-size: clamp(31px, 9vw, 39px) !important;
    line-height: 1.03 !important;
    text-align: center !important;
  }

  .app-shell.chat-shell .welcome-screen p {
    width: min(100%, 340px) !important;
    text-align: center !important;
  }

  .app-shell.chat-shell .welcome-prompts {
    width: calc(100vw - 28px) !important;
    margin-top: auto !important;
    padding: 24px 0 4px !important;
    scroll-snap-type: x proximity !important;
  }

  .app-shell.chat-shell .suggestion-card {
    flex: 0 0 min(76vw, 286px) !important;
    min-height: 64px !important;
    padding: 14px 16px !important;
    border: 1px solid var(--cg-line) !important;
    border-radius: 16px !important;
    background: color-mix(in srgb, var(--cg-elevated) 72%, transparent) !important;
    box-shadow: none !important;
    scroll-snap-align: start !important;
  }

  /* Composer grows with content but never leaves the viewport. */
  .app-shell.chat-shell .composer-wrap {
    position: relative !important;
    z-index: calc(var(--z-shell) + 6) !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    padding: 8px 12px max(10px, env(safe-area-inset-bottom)) !important;
    background: linear-gradient(to bottom, transparent, var(--cg-bg) 30%) !important;
    pointer-events: none !important;
  }

  .app-shell.chat-shell .claude-composer {
    width: 100% !important;
    max-width: 720px !important;
    min-width: 0 !important;
    min-height: 56px !important;
    max-height: min(190px, 34dvh) !important;
    margin: 0 auto !important;
    padding: 7px !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px !important;
    align-items: end !important;
    border: 1px solid color-mix(in srgb, var(--cg-line) 82%, transparent) !important;
    border-radius: 28px !important;
    background: color-mix(in srgb, var(--cg-elevated) 82%, transparent) !important;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.14) !important;
    backdrop-filter: blur(30px) saturate(155%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(155%) !important;
    pointer-events: auto !important;
    overflow: hidden !important;
  }

  .app-shell.chat-shell .claude-composer:has(.attachment-chip) {
    border-radius: 22px !important;
  }

  .app-shell.chat-shell .claude-composer textarea {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    max-height: 132px !important;
    padding: 9px 4px 7px !important;
    overflow-y: auto !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    resize: none !important;
  }

  .app-shell.chat-shell .claude-composer .icon-button,
  .app-shell.chat-shell .claude-composer #aios-send,
  .app-shell.chat-shell .claude-composer [data-action="stop-aios-generation"] {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    align-self: end !important;
    border-radius: 50% !important;
  }

  .app-shell.chat-shell .claude-composer #aios-send {
    color: #ffffff !important;
    background: var(--cg-accent) !important;
  }

  html body #app .app-shell.chat-shell .chat-tool-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }


  html body #app .app-shell.chat-shell #aios-tools-button,
  html body #app .app-shell.chat-shell #aios-mic-button {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
  }

  .app-shell.chat-shell .attachment-tray:not(.empty) {
    max-height: 66px !important;
    padding: 2px 2px 4px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  .app-shell.chat-shell .attachment-chip {
    flex: 0 0 auto !important;
    max-width: min(280px, calc(100vw - 68px)) !important;
    border-radius: 12px !important;
  }

  /* Main navigation drawer */

  /* Conversation-history drawer follows the same material language. */
  .app-shell.chat-shell .aios-chat-sidebar {
    width: min(356px, calc(100vw - 24px)) !important;
    padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom)) !important;
    border-radius: 0 24px 24px 0 !important;
    background: color-mix(in srgb, var(--cg-sidebar) 88%, transparent) !important;
    box-shadow: 22px 0 60px rgba(0, 0, 0, 0.26) !important;
    backdrop-filter: blur(34px) saturate(145%) !important;
    -webkit-backdrop-filter: blur(34px) saturate(145%) !important;
    animation: mobile-drawer-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both !important;
  }

  .app-shell.chat-shell .chat-sidebar-head,
  .app-shell.chat-shell .chat-new-row,
  .app-shell.chat-shell .chat-search,
  .app-shell.chat-shell .conversation-groups {
    min-width: 0 !important;
  }

  .app-shell.chat-shell .chat-sidebar-head {
    min-height: 52px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  .app-shell.chat-shell .chat-sidebar-head .brand-lockup {
    min-width: 0 !important;
    height: 44px !important;
    padding: 0 8px !important;
    display: flex !important;
    align-items: center !important;
    border: 0 !important;
    background: transparent !important;
  }

  .app-shell.chat-shell .chat-sidebar-head .brand-lockup .brand-mark {
    display: none !important;
  }

  .app-shell.chat-shell .chat-sidebar-head .brand-lockup > span {
    display: block !important;
    color: var(--cg-text) !important;
    font-size: 21px !important;
    font-weight: 700 !important;
  }

  .app-shell.chat-shell .chat-new-row {
    grid-template-columns: 66px minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .app-shell.chat-shell .chat-new-side-logo {
    width: 66px !important;
    min-width: 66px !important;
    height: 50px !important;
    display: grid !important;
    place-items: center !important;
    overflow: hidden !important;
  }

  .app-shell.chat-shell .chat-new-side-logo .brand-mark,
  .app-shell.chat-shell .chat-new-side-logo img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }

  .app-shell.chat-shell .chat-new-button {
    width: 100% !important;
    min-height: 50px !important;
    color: #ffffff !important;
    border-radius: 14px !important;
    background: var(--cg-accent) !important;
    box-shadow: none !important;
  }

  .app-shell.chat-shell .chat-search {
    min-height: 44px !important;
    border-radius: 13px !important;
  }

  .app-shell.chat-shell .conversation-groups {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body[data-theme="light"] .app-shell.chat-shell .chat-message.user .message-body,
  body[data-theme="light"] .app-shell.chat-shell .chat-message.user .message-text,
  body[data-theme="light"] .app-shell.chat-shell .chat-message.user .message-text p,
  body[data-theme="light"] .app-shell.chat-shell .chat-message.user .message-author,
  body[data-theme="light"] .app-shell.chat-shell .chat-message.user .message-time {
    color: var(--cg-text) !important;
  }

  body.aios-mobile-menu-open .toast {
    bottom: calc(78px + env(safe-area-inset-bottom)) !important;
  }

  body:has(.app-shell.chat-shell):not(.aios-mobile-menu-open) .toast {
    top: calc(116px + env(safe-area-inset-top)) !important;
    right: 12px !important;
    bottom: auto !important;
    left: 12px !important;
    width: auto !important;
    max-width: 420px !important;
    margin-inline: auto !important;
  }
}

@media (max-width: 380px) {
  .app-shell.chat-shell .aios-chat-topbar {
    padding-inline: 9px !important;
    grid-template-columns: 42px 42px minmax(0, 1fr) 42px !important;
    gap: 5px !important;
  }

  .app-shell.chat-shell .chat-mobile-app-menu,
  .app-shell.chat-shell .aios-chat-topbar > .chat-sidebar-toggle,
  .app-shell.chat-shell .chat-mobile-new {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
  }

  .app-shell.chat-shell .aios-chat-messages {
    padding-inline: 12px !important;
  }
}

@keyframes mobile-page-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes mobile-drawer-in {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes mobile-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell:not(.chat-shell) .content,
  .app-shell.chat-shell .chat-message,
  .app-shell.chat-shell .aios-chat-sidebar {
    animation: none !important;
  }
}

/* Role menus are grouped into labelled sections, so the mobile sheet is longer
   than it used to be. These rules give the list back the vertical space that the
   sheet chrome was taking, without dropping any touch target below 44px. */

/* Short viewports (320x568, 375x667) densify the sheet chrome further. */
}

/* Canonical mobile navigation; replaces the historical menu overrides. */
@layer legacy {
  @media (max-width: 820px) {
    #app #modal-root .modal-backdrop:has(.mobile-menu-sheet) {
      display: flex !important;
      align-items: stretch !important;
      justify-content: flex-start !important;
      padding: 0 !important;
      overflow: hidden !important;
      background: rgb(0 0 0 / 32%) !important;
      backdrop-filter: none !important;
    }
    #app #modal-root .modal:has(.mobile-menu-sheet) {
      position: relative !important;
      display: block !important;
      width: min(360px, calc(100vw - 24px)) !important;
      max-width: none !important;
      height: 100dvh !important;
      max-height: 100dvh !important;
      min-height: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      overflow: hidden !important;
      border: 0 !important;
      border-radius: 0 var(--aios-radius-lg) var(--aios-radius-lg) 0 !important;
      background: var(--aios-sidebar-bg) !important;
      color: var(--aios-text) !important;
      box-shadow: var(--aios-shadow) !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      contain: none !important;
    }
    #app #modal-root .modal:has(.mobile-menu-sheet) > .section-title {
      /* Retain the dialog name without a duplicate visual header. */
      position: absolute !important;
      width: 1px !important;
      height: 1px !important;
      min-height: 0 !important;
      padding: 0 !important;
      margin: 0 !important;
      overflow: hidden !important;
      clip-path: inset(50%);
    }
    #app #modal-root .modal:has(.mobile-menu-sheet) > .section-title button { display: none !important; }
    #app #modal-root .mobile-menu-sheet {
      box-sizing: border-box;
      display: grid !important;
      grid-template-rows: auto auto minmax(44px, 1fr) auto auto !important;
      gap: 8px !important;
      width: 100% !important;
      height: 100% !important;
      min-height: 0 !important;
      max-height: 100% !important;
      padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
      overflow: hidden !important;
      border: 0 !important;
      border-radius: 0 !important;
      background: var(--aios-sidebar-bg) !important;
      box-shadow: none !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
    }
    #app #modal-root .mobile-menu-sheet button {
      --aios-button-border-width: 0px;
      --aios-button-depth: 0px;
      --aios-button-radius: var(--aios-radius-md);
      --aios-button-edge: transparent;
      box-sizing: border-box;
      min-width: 44px;
      min-height: 44px;
      font: inherit;
    }
    #app #modal-root .mobile-menu-drawer-head {
      display: grid !important;
      grid-template-columns: minmax(0, 1fr) 44px !important;
      align-items: center !important;
      gap: 8px !important;
      padding: 0 0 8px !important;
      min-height: 52px !important;
      border-bottom: 1px solid var(--aios-border) !important;
    }
    #app #modal-root .mobile-menu-drawer-head > div { min-width: 0; }
    #app #modal-root .mobile-menu-drawer-head strong { display: block; font-size: 21px !important; line-height: 1.2; color: var(--aios-text) !important; }
    #app #modal-root .mobile-menu-drawer-head span { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px !important; color: var(--aios-text-muted) !important; }
    #app #modal-root .mobile-menu-drawer-head button {
      display: grid; place-items: center;
      width: 44px !important; height: 44px !important;
      padding: 0 !important;
      background: transparent !important;
      color: var(--aios-text) !important;
    }
    #app #modal-root .mobile-menu-account-card {
      display: grid !important;
      grid-template-columns: 40px minmax(0, 1fr) 16px !important;
      gap: 10px !important; align-items: center !important;
      width: 100% !important; min-height: 64px !important;
      padding: 8px !important;
      text-align: left;
      background: var(--aios-surface) !important;
      color: var(--aios-text) !important;
    }
    #app #modal-root .mobile-menu-account-card > span:not(.account-avatar) { min-width: 0; }
    #app #modal-root .mobile-menu-account-card strong,
    #app #modal-root .mobile-menu-account-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #app #modal-root .mobile-menu-account-card strong { font-size: 14px !important; line-height: 1.4; }
    #app #modal-root .mobile-menu-account-card small { font-size: 12px !important; color: var(--aios-text-muted) !important; line-height: 1.5; }
    #app #modal-root .mobile-menu-account-card .account-avatar {
      display: grid !important; place-items: center !important;
      width: 40px !important; height: 40px !important; min-width: 40px !important;
      border-radius: 50% !important; overflow: hidden;
      background: var(--aios-accent-strong) !important; color: var(--aios-bg) !important;
      box-shadow: none !important;
    }
    #app #modal-root .mobile-menu-list {
      display: flex !important; flex-direction: column !important;
      justify-content: flex-start !important; gap: 4px !important;
      min-height: 0 !important; min-width: 0;
      overflow-y: auto !important; overflow-x: hidden !important;
      padding: 2px !important; margin: 0 !important;
      overscroll-behavior: contain; scrollbar-width: thin;
      scroll-padding-block: 6px;
    }
    #app #modal-root .mobile-menu-sheet .mobile-menu-item {
      display: grid !important; grid-template-columns: 24px minmax(0, 1fr) 16px !important;
      flex: 0 0 auto; align-items: center !important; gap: 12px !important;
      width: 100% !important; min-height: 48px !important;
      padding: 10px !important; text-align: left;
      background: transparent !important; color: var(--aios-text) !important;
      backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    }
    #app #modal-root .mobile-menu-item strong { font-size: 15px !important; font-weight: 550 !important; line-height: 1.35; white-space: normal !important; overflow-wrap: anywhere; color: inherit !important; }
    #app #modal-root .mobile-menu-sheet .mobile-menu-item.active { background: var(--aios-accent-soft) !important; color: var(--aios-text) !important; }
    #app #modal-root .mobile-menu-item.active strong { font-weight: 750 !important; }
    #app #modal-root .mobile-menu-icon,
    #app #modal-root .mobile-menu-action-icon { display: grid; place-items: center; width: 24px !important; height: 24px !important; color: inherit !important; background: transparent !important; border: 0 !important; }
    #app #modal-root .mobile-menu-sheet svg { width: 20px; height: 20px; }
    #app #modal-root .mobile-menu-item.active .mobile-menu-icon { color: var(--aios-accent-strong) !important; }
    #app #modal-root .mobile-menu-chevron { display: grid; place-items: center; width: 16px !important; height: 16px !important; background: transparent !important; border-radius: 0 !important; box-shadow: none !important; transform: rotate(180deg); color: var(--aios-text-muted) !important; }
    #app #modal-root .mobile-menu-chevron .icon-symbol { color: inherit !important; width: 8px !important; height: 8px !important; min-width: 0 !important; min-height: 0 !important; background: transparent !important; border-radius: 0 !important; border-width: 0 0 1.5px 1.5px !important; box-shadow: none !important; }
    #app #modal-root .mobile-menu-sheet svg { fill: none !important; stroke: currentColor !important; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    #app #modal-root .modal:has(.mobile-menu-sheet)::before, #app #modal-root .modal:has(.mobile-menu-sheet)::after { display: none !important; }
    #app #modal-root .mobile-menu-chevron svg { width: 14px; height: 14px; }
    #app #modal-root .mobile-menu-section { margin: 12px 0 2px; padding-inline: 10px; font-size: 11px; color: var(--aios-text-muted) !important; }
    #app #modal-root .mobile-menu-actions {
      display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
      gap: 4px !important; padding: 8px 0 0 !important;
      border-top: 1px solid var(--aios-border) !important;
    }
    #app #modal-root .mobile-menu-action-line {
      display: flex !important; align-items: center !important; justify-content: flex-start !important;
      gap: 8px !important; width: 100% !important; min-width: 0 !important; min-height: 44px !important;
      padding: 8px !important; font-size: 12px !important; line-height: 1.35;
      background: transparent !important; color: var(--aios-text-muted) !important;
    }
    #app #modal-root .mobile-menu-action-icon { flex: 0 0 20px; }
    #app #modal-root .mobile-menu-action-line.danger { color: var(--aios-danger) !important; }
    #app #modal-root .mobile-menu-chat-fab {
      display: flex !important; align-items: center !important; justify-content: center !important;
      position: static !important; gap: 8px !important;
      width: 100% !important; min-width: 0 !important; height: 48px !important; min-height: 48px !important;
      margin: 0 !important; padding: 10px 16px !important;
      background: var(--aios-accent-strong) !important; color: var(--aios-bg) !important;
      font-size: 15px !important; font-weight: 700 !important;
    }
    #app #modal-root .mobile-menu-chat-fab span { color: inherit !important; font-size: inherit !important; }
    #app #modal-root .mobile-menu-sheet button:focus-visible { outline: 2px solid var(--aios-accent-strong) !important; outline-offset: -2px; }
    @media (hover: hover) {
      #app #modal-root .mobile-menu-item:not(.active):hover,
      #app #modal-root .mobile-menu-action-line:hover,
      #app #modal-root .mobile-menu-drawer-head button:hover { background: var(--aios-surface-hover) !important; }
    }
    @media (max-height: 480px) {
      #app #modal-root .mobile-menu-sheet { gap: 4px !important; padding-block: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-bottom)) !important; }
      #app #modal-root .mobile-menu-account-card { min-height: 48px !important; padding-block: 4px !important; }
      #app #modal-root .mobile-menu-drawer-head { min-height: 44px !important; padding-bottom: 0 !important; }
      #app #modal-root .mobile-menu-actions { padding-top: 4px !important; }
    }
  }
}
