/* Fable Minimalist Web Chat — ChatGPT-inspired ultra-minimalist monochrome workspace
 * Strict CSP (`style-src 'self'`), WCAG AA contrast (>= 4.5:1), >= 44px touch targets on mobile.
 */

:root {
  --chat-bg: #ffffff;
  --chat-sidebar-bg: #f7f7f8;
  --composer-bg: #fff;
  --chat-surface: #f4f4f4;
  --chat-surface-hover: #ececec;
  --chat-surface-elevated: #ffffff;
  --chat-border: rgba(13, 13, 13, 0.09);
  --chat-border-strong: rgba(13, 13, 13, 0.18);
  --chat-ink: #0d0d0d;
  --chat-muted: #555555;
  --chat-subtle: #666666;
  --chat-pill-active-bg: #0d0d0d;
  --chat-pill-active-ink: #ffffff;
  --chat-user-bubble: #f4f4f4;
  --chat-code-bg: #f7f7f8;
  --chat-code-header: #efefef;
  --chat-accent-soft: rgba(13, 13, 13, 0.05);
  --chat-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --chat-shadow-md: 0 8px 28px rgba(0, 0, 0, 0.08);
  --chat-shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.16);
  --chat-backdrop: rgba(0, 0, 0, 0.44);
  --chat-success: #137333;
  --chat-danger: #b3261e;
  --chat-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  --chat-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-width: 260px;
  --chat-ease: cubic-bezier(.2,.8,.2,1);
}

html[data-theme="dark"] {
  --chat-bg: #000;
  --chat-sidebar-bg: #000;
  --composer-bg: #212121;
  --chat-surface: #2f2f2f;
  --chat-surface-hover: #3a3a3a;
  --chat-surface-elevated: #2a2a2a;
  --chat-border: rgba(255, 255, 255, 0.1);
  --chat-border-strong: rgba(255, 255, 255, 0.2);
  --chat-ink: #ececec;
  --chat-muted: #b4b4b4;
  --chat-subtle: #9e9e9e;
  --chat-pill-active-bg: #ffffff;
  --chat-pill-active-ink: #0d0d0d;
  --chat-user-bubble: #2f2f2f;
  --chat-code-bg: #171717;
  --chat-code-header: #262626;
  --chat-accent-soft: rgba(255, 255, 255, 0.07);
  --chat-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
  --chat-shadow-md: 0 10px 32px rgba(0, 0, 0, 0.44);
  --chat-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.62);
  --chat-backdrop: rgba(0, 0, 0, 0.65);
  --chat-success: #81c995;
  --chat-danger: #f28b82;
}

.chat-image-thumbnail {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --chat-bg: #000;
    --chat-sidebar-bg: #000;
    --composer-bg: #212121;
    --chat-surface: #2f2f2f;
    --chat-surface-hover: #3a3a3a;
    --chat-surface-elevated: #2a2a2a;
    --chat-border: rgba(255, 255, 255, 0.1);
    --chat-border-strong: rgba(255, 255, 255, 0.2);
    --chat-ink: #ececec;
    --chat-muted: #b4b4b4;
    --chat-subtle: #9e9e9e;
    --chat-pill-active-bg: #ffffff;
    --chat-pill-active-ink: #0d0d0d;
    --chat-user-bubble: #2f2f2f;
    --chat-code-bg: #171717;
    --chat-code-header: #262626;
    --chat-accent-soft: rgba(255, 255, 255, 0.07);
    --chat-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
    --chat-shadow-md: 0 10px 32px rgba(0, 0, 0, 0.44);
    --chat-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.62);
    --chat-backdrop: rgba(0, 0, 0, 0.65);
    --chat-success: #81c995;
    --chat-danger: #f28b82;
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--chat-bg);
  color: var(--chat-ink);
  font-family: var(--chat-font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.fable-chat-body {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 900;
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.skip-link:focus {
  left: 12px;
}

/* App shell layout */
.chat-app {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--chat-bg);
}

/* Left collapsible sidebar */
.chat-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--chat-sidebar-bg);
  border-right: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: margin-left 0.2s ease, transform 0.2s ease;
}

.chat-app[data-sidebar="collapsed"] .chat-sidebar {
  margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 6px;
  gap: 6px;
}

.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.icon-btn:hover {
  background: var(--chat-surface-hover);
  color: var(--chat-ink);
}

.icon-btn:focus-visible,
.pill-btn:focus-visible,
.sidebar-item:focus-visible,
.composer-tool-btn:focus-visible,
.model-trigger:focus-visible {
  outline: 2px solid var(--chat-ink);
  outline-offset: 2px;
}

.sidebar-search-wrap {
  padding: 4px 10px 8px;
}

.sidebar-search-input {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg);
  color: var(--chat-ink);
  padding: 0 12px;
  font-size: 13.5px;
  font-family: inherit;
}

.sidebar-search-input::placeholder {
  color: var(--chat-subtle);
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--chat-border-strong);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--chat-subtle);
  letter-spacing: 0.01em;
}

.sidebar-mini-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  cursor: pointer;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sidebar-mini-btn:hover {
  background: var(--chat-surface-hover);
  color: var(--chat-ink);
}

.sidebar-item {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--chat-ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
  transition: background-color 180ms var(--chat-ease);
}

.sidebar-item:hover {
  background: var(--chat-surface-hover);
}

.sidebar-item.is-active {
  background: var(--chat-surface);
  font-weight: 500;
}

.sidebar-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-delete {
  opacity: 0;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.sidebar-item:hover .sidebar-item-delete,
.sidebar-item:focus-within .sidebar-item-delete {
  opacity: 1;
}

.sidebar-item-delete:hover {
  color: var(--chat-danger);
  background: var(--chat-accent-soft);
}

.sidebar-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--chat-subtle);
}

.sidebar-footer {
  border-top: 1px solid var(--chat-border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-upgrade-btn {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--chat-ink);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.sidebar-upgrade-btn:hover {
  background: var(--chat-surface-hover);
}

.sidebar-upgrade-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--chat-border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-upgrade-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-upgrade-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.25;
}

.sidebar-upgrade-sub {
  font-size: 12px;
  color: var(--chat-muted);
  line-height: 1.25;
}

.sidebar-account-btn {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--chat-ink);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.sidebar-account-btn:hover {
  background: var(--chat-surface-hover);
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.account-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-plan-badge {
  font-size: 11.5px;
  color: var(--chat-muted);
}

/* Main workspace column + split panes */
.chat-workspace {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  position: relative;
}

.chat-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--chat-bg);
}

/* Fable's quiet workspace: the first prompt sits at the center, then docks
   below the transcript once a conversation starts. No layout animation while streaming. */
.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px;
  color: var(--chat-ink);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.sidebar-brand img { border-radius: 8px; }
.thread-row { padding: 0 5px 0 0; gap: 0; }
.thread-open {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  min-width: 0;
  min-height: 40px;
  padding: 9px 10px;
  flex: 1;
  display: flex;
  text-align: left;
  cursor: pointer;
  border-radius: inherit;
}
.thread-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.workspace-notice {
  color: var(--chat-muted);
  font-size: 12px;
  text-align: center;
  padding: 8px 20px;
  line-height: 1.6;
  flex-shrink: 0;
}
#temporary-notice { background: var(--chat-surface); border-block: 1px solid var(--chat-border); }
.chat-main[data-empty="true"] .chat-stage {
  flex: 1 1 0;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0;
  overflow: visible;
}
.chat-main[data-empty="true"] .chat-stage-inner { flex: none; width: 100%; padding-bottom: 28px; }
.chat-main[data-empty="true"] .chat-empty-state { margin: 0; padding: 0; }
.chat-main[data-empty="true"] .chat-messages { display: none; }
.chat-main[data-empty="true"] .composer-dock { flex: 1.25 1 0; padding-top: 0; }
.chat-main[data-empty="true"] .composer-caption { position: absolute; bottom: 14px; left: 16px; right: 16px; }
.chat-main[data-empty="true"] #efficiency-meter-btn { display: none; }
.starter-chips { max-width: 640px; }
:where(button, a, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--chat-ink);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: 0.45; }

@media (max-width: 767px) {
  .chat-main[data-empty="true"] .chat-stage { margin-top: 0; min-height: 130px; }
  .chat-main[data-empty="true"] { overflow-y: auto; }
  .chat-main[data-empty="true"] .composer-dock { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .thread-open { min-height: 44px; }
  .sidebar-item-delete { opacity: 1; }
}

@media (max-width: 430px) {
  .topbar-right { gap: 3px; }
  #temp-chat-btn { font-size: 11px; padding-inline: 8px; }
  #save-temp-chat-btn { font-size: 11px; padding-inline: 9px; }
  .workspace-notice { padding-inline: 16px; }
}

@media (max-height: 650px) {
  .chat-main[data-empty="true"] .chat-stage { min-height: 80px; }
  .chat-main[data-empty="true"] .starter-chips { display: none; }
}

/* Ultra-clean ChatGPT header */
.chat-topbar {
  height: 56px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-picker-wrap {
  position: relative;
}

.model-trigger {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-ink);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-height: 38px;
  width: 200px;
  max-width: 100%;
}

#active-model-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-trigger-logo, .model-trigger-chevron { flex-shrink: 0; }
.model-trigger-chevron { margin-left: auto; transition: rotate 140ms ease; }
.model-trigger[aria-expanded="true"] .model-trigger-chevron { rotate: 180deg; }
.model-trigger[aria-expanded="true"] { background: var(--chat-surface); }

#model-picker-menu {
  position: fixed;
  width: 338px;
  min-width: 0;
  max-width: calc(100vw - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  transform: none;
  transform-origin: top left;
  animation: model-picker-in 180ms var(--chat-ease);
}
#model-picker-menu.is-closing { animation: model-picker-out 160ms var(--chat-ease) forwards; pointer-events: none; }
@keyframes model-picker-in { from { opacity: 0; translate: 0 -4px; scale: .98; } to { opacity: 1; translate: 0; scale: 1; } }
@keyframes model-picker-out { to { opacity: 0; translate: 0 -3px; scale: .98; } }
#model-picker-menu .menu-section-label { font-size: 12px; padding: 8px 10px; color: var(--chat-muted); }
#model-picker-menu .model-row { padding: 12px 10px; gap: 12px; min-height: 66px; }
#model-picker-menu .menu-item-title { font-size: 14px; font-weight: 600; line-height: 20px; }
#model-picker-menu .menu-item-desc { font-size: 12px; line-height: 18px; }
#model-picker-menu .menu-item:hover, #model-picker-menu .menu-item:focus-visible { background: var(--chat-surface-hover); }
#model-picker-menu .menu-item:focus-visible { outline: 2px solid var(--chat-ink); outline-offset: -2px; }
#model-picker-menu .menu-item.is-selected { background: var(--chat-surface); }
#model-picker-menu .model-row-check { display: inline-flex; align-items: center; justify-content: center; }
#model-picker-menu .is-locked .model-row-check { color: var(--chat-muted); }
#model-picker-menu .model-upgrade-item { justify-content: flex-start; padding: 12px 10px; gap: 12px; }
#model-picker-menu .model-upgrade-item .menu-item-main { flex: 1; min-width: 0; }
#model-picker-menu .model-upgrade-item > svg { flex-shrink: 0; }

.model-trigger:hover {
  background: var(--chat-surface);
}

.model-trigger-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.model-trigger-chevron {
  color: var(--chat-muted);
}

.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 270px;
  background: var(--chat-surface-elevated);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: var(--chat-shadow-md);
  padding: 6px;
  z-index: 60;
}

.popover-menu--right {
  left: auto;
  right: 0;
}

#help-menu { overflow-y: auto; overscroll-behavior: contain; }

.popover-menu--up {
  top: auto;
  bottom: calc(100% + 8px);
}

.menu-section-label {
  padding: 6px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--chat-subtle);
}

.menu-item {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--chat-ink);
  border-radius: 10px;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}

.menu-item:hover {
  background: var(--chat-surface);
}

.menu-item.is-selected {
  background: var(--chat-accent-soft);
}

.menu-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-item-title {
  font-weight: 500;
  font-size: 14px;
}

.menu-item-desc {
  font-size: 12px;
  color: var(--chat-muted);
}

.menu-divider {
  height: 1px;
  background: var(--chat-border);
  margin: 5px 4px;
}

.pill-btn {
  appearance: none;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  min-height: 36px;
  border: 1px solid var(--chat-border-strong);
  background: transparent;
  color: var(--chat-ink);
  transition: background-color 0.14s ease, opacity 0.14s ease;
}

.pill-btn:hover {
  background: var(--chat-surface);
}

.pill-btn--solid {
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  border-color: var(--chat-pill-active-bg);
}

.pill-btn--solid:hover {
  background: var(--chat-pill-active-bg);
  opacity: 0.88;
}

.pill-btn--subtle {
  border-color: var(--chat-border);
  background: var(--chat-surface);
  font-size: 12.5px;
  padding: 5px 11px;
  min-height: 32px;
}

.temp-chat-pill[aria-pressed="true"] {
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  border-color: var(--chat-pill-active-bg);
}

/* Conversation stage */
.chat-stage {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.chat-stage-inner {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 16px 20px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Centered ChatGPT empty greeting state */
.chat-empty-state {
  margin: auto 0;
  padding: 32px 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.empty-heading {
  margin: 0;
  font-size: clamp(1.5rem, 3.2vw, 1.9rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.22;
  color: var(--chat-ink);
}

.empty-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  font-size: 12.5px;
  color: var(--chat-muted);
}

.starter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 660px;
  margin: 18px auto 0;
}

.starter-chip {
  appearance: none;
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  min-height: 38px;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.starter-chip:hover {
  background: var(--chat-surface);
  color: var(--chat-ink);
  border-color: var(--chat-border-strong);
}

/* Transcript messages */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row--user {
  align-items: flex-end;
}

.user-bubble {
  max-width: min(76%, 560px);
  background: var(--chat-user-bubble);
  color: var(--chat-ink);
  padding: 11px 18px;
  border-radius: 22px;
  font-size: 15.5px;
  line-height: 1.52;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.user-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.attachment-pill {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  font-size: 12.5px;
  color: var(--chat-ink);
}

.attachment-pill > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.attachment-pill-remove {
  flex-shrink: 0;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.msg-edit-box {
  width: 100%;
  max-width: 620px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border-strong);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-edit-textarea {
  width: 100%;
  min-height: 76px;
  border: 0;
  background: transparent;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
}

.msg-edit-textarea:focus {
  outline: none;
}

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

/* Assistant unboxed turn (authentic ChatGPT style) */
.msg-row--assistant {
  align-items: stretch;
}

.assistant-turn {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Search & Deep Research activity card */
.activity-trace {
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--chat-muted);
}

.activity-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--chat-ink);
  animation: fablePulse 550ms ease-in infinite alternate;
}

@keyframes fablePulse {
  from { transform: scale(1); }
  to { transform: scale(.75); }
}

.research-steps {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.research-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--chat-muted);
}

.research-step.is-done {
  color: var(--chat-ink);
}

.research-disclosure > summary {
  cursor: pointer;
  justify-content: flex-start;
  list-style: none;
}

.research-disclosure > summary::-webkit-details-marker { display: none; }
.research-disclosure > summary::before { content: "›"; }
.research-disclosure[open] > summary::before { transform: rotate(90deg); }
.research-disclosure[open] .research-steps { margin-top: 8px; }

.research-step.is-current {
  color: var(--chat-ink);
  animation: research-step-pulse 1.8s ease-in-out infinite;
}

@keyframes research-step-pulse {
  0%, 100% { text-decoration-color: transparent; }
  50% { text-decoration-color: currentColor; }
}

@media (prefers-reduced-motion: reduce) {
  .research-step.is-current, .pulse-dot { animation: none; }
}

.source-chips-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  border-radius: 999px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  color: var(--chat-ink);
  font-size: 12px;
  text-decoration: none;
  max-width: 220px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

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

.source-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Domain Icons (CSP-safe inline SVG + deterministic tones) */
.source-domain-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  background: var(--chat-surface);
  color: var(--chat-ink);
}

.source-domain-icon--wikipedia { background: #eaeaea; color: #111111; }
.source-domain-icon--github { background: #1f2328; color: #ffffff; }
.source-domain-icon--arxiv { background: #b31b1b; color: #ffffff; }
.source-domain-icon--hn { background: #ff6600; color: #ffffff; }
.source-domain-icon--stackoverflow { background: #f48024; color: #ffffff; }
.source-domain-icon--mdn { background: #0d0d0d; color: #ffffff; }
.source-domain-icon--academic { background: #1e3a5f; color: #ffffff; }
.source-domain-icon--gov { background: #264653; color: #ffffff; }
.source-domain-icon--fondation { background: #0d0d0d; color: #ffffff; }

.source-domain-icon--domain.source-domain-icon--tone-0 { background: #1d3557; color: #ffffff; }
.source-domain-icon--domain.source-domain-icon--tone-1 { background: #2d6a4f; color: #ffffff; }
.source-domain-icon--domain.source-domain-icon--tone-2 { background: #5a189a; color: #ffffff; }
.source-domain-icon--domain.source-domain-icon--tone-3 { background: #6d4c41; color: #ffffff; }
.source-domain-icon--domain.source-domain-icon--tone-4 { background: #37474f; color: #ffffff; }
.source-domain-icon--domain.source-domain-icon--tone-5 { background: #7f1d1d; color: #ffffff; }

.source-domain-monogram {
  line-height: 1;
}

/* Collapsible Thinking / Reasoning block */
.thinking-disclosure {
  border-radius: 12px;
}

.thinking-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--chat-muted);
  padding: 4px 0;
  user-select: none;
}

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

.thinking-summary:hover {
  color: var(--chat-ink);
}

.thinking-chevron {
  transition: transform 0.16s ease;
}

.thinking-disclosure[open] .thinking-chevron {
  transform: rotate(90deg);
}

.thinking-body {
  margin-top: 6px;
  padding: 8px 0 8px 14px;
  border-left: 2px solid var(--chat-border-strong);
  color: var(--chat-muted);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* Assistant Markdown typography */
.assistant-prose {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--chat-ink);
  overflow-wrap: break-word;
}

.assistant-prose > *:first-child {
  margin-top: 0;
}

.assistant-prose > *:last-child {
  margin-bottom: 0;
}

.assistant-prose p,
.assistant-prose ul,
.assistant-prose ol,
.assistant-prose blockquote,
.assistant-prose table {
  margin: 0 0 14px;
}

.assistant-prose h1,
.assistant-prose h2,
.assistant-prose h3,
.assistant-prose h4 {
  margin: 20px 0 10px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.assistant-prose h1 { font-size: 1.4rem; }
.assistant-prose h2 { font-size: 1.22rem; }
.assistant-prose h3 { font-size: 1.08rem; }

.assistant-prose ul,
.assistant-prose ol {
  padding-left: 22px;
}

.assistant-prose li + li {
  margin-top: 5px;
}

.assistant-prose a {
  color: var(--chat-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant-prose code {
  font-family: var(--chat-font-mono);
  font-size: 0.875em;
  background: var(--chat-surface);
  padding: 2px 6px;
  border-radius: 6px;
}

.assistant-prose blockquote {
  border-left: 3px solid var(--chat-border-strong);
  padding-left: 14px;
  color: var(--chat-muted);
}

.assistant-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.assistant-prose th,
.assistant-prose td {
  border: 1px solid var(--chat-border);
  padding: 8px 12px;
  text-align: left;
}

.assistant-prose th {
  background: var(--chat-sidebar-bg);
  font-weight: 600;
}

/* Inline Citation Pill `[1]` */
.cite-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: baseline;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  color: var(--chat-muted);
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: none !important;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.cite-pill:hover {
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  border-color: var(--chat-pill-active-bg);
}

/* Code block with ChatGPT header + Open in Canvas */
.code-card {
  margin: 14px 0;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--chat-code-bg);
}

.code-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: var(--chat-code-header);
  font-size: 12px;
  color: var(--chat-muted);
}

.code-card-lang {
  font-family: var(--chat-font-mono);
  font-weight: 500;
}

.code-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-action-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.code-action-btn:hover {
  background: var(--chat-accent-soft);
  color: var(--chat-ink);
}

.code-card pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--chat-font-mono);
  font-size: 13.2px;
  line-height: 1.55;
}

.code-card pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* Perplexity/ChatGPT stacked Sources button + message actions bar */
.turn-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.sources-stack-btn {
  appearance: none;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  padding: 4px 11px 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--chat-ink);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.sources-stack-btn:hover {
  background: var(--chat-surface-hover);
}

.sources-stack-icons {
  display: inline-flex;
  align-items: center;
}

.sources-stack-icons .source-domain-icon {
  width: 16px;
  height: 16px;
  margin-left: -4px;
  box-shadow: 0 0 0 1.5px var(--chat-bg);
}

.sources-stack-icons .source-domain-icon:first-child {
  margin-left: 0;
}

.turn-icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--chat-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.turn-icon-btn:hover {
  background: var(--chat-surface);
  color: var(--chat-ink);
}

.branch-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--chat-muted);
}

/* Follow-up smart chips */
.followup-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.followup-chip {
  appearance: none;
  background: transparent;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--chat-muted);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.followup-chip:hover {
  background: var(--chat-surface);
  color: var(--chat-ink);
}

/* Floating Pill Composer (ChatGPT signature rounded dock) */
.composer-dock {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 0 16px 12px;
  flex-shrink: 0;
  position: relative;
}

.composer-shell {
  background: var(--chat-bg);
  border: 1px solid var(--chat-border-strong);
  border-radius: 28px;
  padding: 14px 12px 10px 20px;
  box-shadow: var(--chat-shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-shell:focus-within {
  border-color: var(--chat-border-strong);
  box-shadow: var(--chat-shadow-md);
}

.composer-tools { position: relative; }
.composer-tools > summary { border: 0; list-style: none; }
.composer-tools > summary::-webkit-details-marker { display: none; }
.composer-tools[open] > summary { background: var(--chat-surface); color: var(--chat-ink); }
.composer-tools-panel {
  position: absolute;
  bottom: calc(100% + 16px);
  left: -44px;
  z-index: 65;
  width: 244px;
  max-height: min(360px, calc(50dvh - 60px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 7px;
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  background: var(--chat-surface-elevated);
  box-shadow: var(--chat-shadow-md);
}
.composer-tools-panel .composer-tool-btn { width: 100%; min-height: 42px; border: 0; border-radius: 10px; justify-content: flex-start; gap: 12px; }
.composer-tools-panel .focus-select { width: calc(100% - 12px); margin: 5px 6px 9px; }
.composer-mode-summary { min-width: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--chat-muted); }
.composer-toolbar .composer-tools-left { flex: 1; flex-wrap: nowrap; min-width: 0; }
#attach-image-btn, #attach-file-btn, #voice-input-btn { border: 0; }

.sidebar-guest { padding: 16px 8px 8px; }
.sidebar-guest h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.4; }
.sidebar-guest p { margin: 0 0 14px; color: var(--chat-muted); font-size: 12px; line-height: 1.6; }
.sidebar-guest-login { width: 100%; background: var(--chat-surface-hover); }
.chat-app[data-auth="guest"] .sidebar-search-wrap,
.chat-app[data-auth="guest"] section.sidebar-nav-group,
.chat-app[data-auth="guest"] #sidebar-upgrade-btn,
.chat-app[data-auth="guest"] #sidebar-new-chat-btn { display: none; }
.chat-app[data-auth="guest"] .sidebar-top { justify-content: space-between; margin-bottom: 16px; }

@keyframes workspace-appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat-empty-state { animation: workspace-appear 180ms ease-out; }
.chat-modal[open] { animation: workspace-appear 300ms cubic-bezier(.2,0,0,1); }
.composer-tools-panel, .popover-menu, .starter-chips {
  opacity: 0;
  translate: 0 4px;
  transition: opacity 220ms cubic-bezier(.16,1,.3,1), translate 220ms cubic-bezier(.16,1,.3,1), display 220ms allow-discrete;
}
.composer-tools[open] .composer-tools-panel, .popover-menu:not([hidden]), .starter-chips:not([hidden]) { opacity: 1; translate: 0 0; }
.composer-tools:not([open]) .composer-tools-panel, .popover-menu[hidden], .starter-chips[hidden] { pointer-events: none; }
@starting-style {
  .composer-tools[open] .composer-tools-panel, .popover-menu:not([hidden]), .starter-chips:not([hidden]) { opacity: 0; translate: 0 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-empty-state, .chat-modal[open], .composer-tools[open] .composer-tools-panel, .popover-menu:not([hidden]), .starter-chips:not([hidden]) { animation: none; }
  .composer-tools-panel, .popover-menu, .starter-chips { transition: none; }
}
@media (max-width: 560px) {
  .starter-chips { gap: 7px; margin-top: 16px; }
  .starter-chip { font-size: 12px; padding: 7px 10px; }
  .composer-mode-summary { max-width: 110px; }
  .composer-dock { padding-inline: 12px; }
  .composer-tools-panel { left: -42px; }
  .chat-topbar { padding-inline: 8px; }
  .chat-app[data-auth="guest"] #topbar-settings-btn,
  .chat-app[data-auth="guest"] #temp-chat-btn { display: none; }
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.composer-textarea {
  width: 100%;
  min-height: 28px;
  max-height: 200px;
  border: 0;
  background: transparent;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.5;
  resize: none;
  padding: 2px 0;
}

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

.composer-textarea:focus {
  outline: none;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-tools-left,
.composer-tools-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.composer-tool-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-muted);
  border-radius: 999px;
  height: 34px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.composer-tool-btn--icon {
  width: 34px;
  padding: 0;
  justify-content: center;
}

.composer-tool-btn:hover {
  background: var(--chat-surface-hover);
  color: var(--chat-ink);
}

.composer-tool-btn[aria-pressed="true"] {
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  border-color: var(--chat-pill-active-bg);
}

.focus-select {
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg);
  color: var(--chat-ink);
  padding: 0 10px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

.send-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.14s ease, transform 0.12s ease;
}

.send-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.composer-caption {
  margin: 7px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--chat-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.efficiency-pill {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--chat-muted);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.efficiency-pill:hover {
  background: var(--chat-surface);
  color: var(--chat-ink);
}

/* Slash Command Palette above composer */
.slash-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 16px;
  right: 16px;
  max-width: 420px;
  background: var(--chat-surface-elevated);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: var(--chat-shadow-md);
  padding: 6px;
  z-index: 50;
}

.slash-item {
  appearance: none;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}

.slash-item:hover,
.slash-item.is-active {
  background: var(--chat-surface);
}

.slash-cmd {
  font-family: var(--chat-font-mono);
  font-weight: 600;
  font-size: 12.5px;
}

.slash-desc {
  font-size: 12px;
  color: var(--chat-muted);
}

/* Right-side Canvas Split Pane & Sources Drawer */
.side-pane {
  width: min(46vw, 560px);
  min-width: 340px;
  height: 100%;
  border-left: 1px solid var(--chat-border);
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.side-pane--sources {
  width: 360px;
  min-width: 310px;
}

.side-pane-head {
  height: 56px;
  padding: 0 14px;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.side-pane-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.side-pane-title {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-pane-tabs {
  display: inline-flex;
  background: var(--chat-surface);
  border-radius: 999px;
  padding: 2px;
}

.side-pane-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--chat-muted);
  font-family: inherit;
  cursor: pointer;
}

.side-pane-tab[aria-selected="true"] {
  background: var(--chat-bg);
  color: var(--chat-ink);
  box-shadow: var(--chat-shadow-sm);
}

.side-pane-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.canvas-host {
  flex: 1;
  min-height: 240px;
}

.canvas-editor {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--chat-code-bg);
  color: var(--chat-ink);
  font-family: var(--chat-font-mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 16px;
  resize: none;
}

.canvas-editor:focus {
  outline: none;
}

/* Sources Drawer cards */
.sources-drawer-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-drawer-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--chat-border);
  background: var(--chat-sidebar-bg);
  text-decoration: none;
  color: var(--chat-ink);
  transition: border-color 0.14s ease;
}

.source-drawer-card:hover {
  border-color: var(--chat-border-strong);
}

.source-drawer-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--chat-muted);
}

.source-drawer-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.source-drawer-snippet {
  font-size: 12.8px;
  color: var(--chat-muted);
  line-height: 1.48;
}

/* Citation Hover Preview Card */
.citation-hover-card {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 320px;
  background: var(--chat-surface-elevated);
  border: 1px solid var(--chat-border-strong);
  border-radius: 14px;
  box-shadow: var(--chat-shadow-md);
  padding: 12px 14px;
  z-index: 80;
  pointer-events: none;
}

/* Dialogs / Modals: Settings, Upgrade your plan, Context Meter, New Project */
.chat-modal {
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  padding: 0;
  background: var(--chat-surface-elevated);
  color: var(--chat-ink);
  box-shadow: var(--chat-shadow-lg);
  max-width: min(94vw, 720px);
  width: 100%;
  max-height: 88dvh;
  overflow: hidden;
}

.chat-modal--plans {
  max-width: min(96vw, 1080px);
}

.chat-modal--compact {
  max-width: min(92vw, 480px);
}

.chat-modal::backdrop {
  background: var(--chat-backdrop);
  backdrop-filter: blur(3px);
}

.modal-shell {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--chat-border);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Settings Modal 2-column ChatGPT layout */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 380px;
  max-height: calc(88dvh - 65px);
}

.settings-nav {
  border-right: 1px solid var(--chat-border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--chat-sidebar-bg);
}

.settings-tab-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--chat-muted);
  font-family: inherit;
  cursor: pointer;
}

.settings-tab-btn:hover {
  background: var(--chat-surface-hover);
  color: var(--chat-ink);
}

.settings-tab-btn[aria-selected="true"] {
  background: var(--chat-surface);
  color: var(--chat-ink);
}

.settings-panels {
  padding: 18px 22px;
  overflow-y: auto;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--chat-border);
}

.settings-row .pill-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row-label {
  font-size: 14px;
  font-weight: 500;
}

.settings-row-desc {
  font-size: 12.5px;
  color: var(--chat-muted);
  margin-top: 2px;
}

.memory-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

#memory-editor-modal .context-body {
  min-height: 0;
  overflow-y: auto;
}

.memory-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--chat-border);
  min-width: 0;
}

.memory-text {
  margin: 0 0 10px;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memory-item .msg-edit-actions {
  flex-wrap: wrap;
}

.settings-textarea {
  width: 100%;
  min-height: 92px;
  margin-top: 8px;
  border-radius: 12px;
  border: 1px solid var(--chat-border-strong);
  background: var(--chat-bg);
  color: var(--chat-ink);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
}

/* ChatGPT-style "Upgrade your plan" Modal */
.plans-modal-body {
  padding: 24px 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.plans-modal-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.plans-segment {
  display: inline-flex;
  background: var(--chat-surface);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid var(--chat-border);
}

.plans-segment-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--chat-muted);
  font-family: inherit;
  cursor: pointer;
}

.plans-segment-btn[aria-selected="true"] {
  background: var(--chat-bg);
  color: var(--chat-ink);
  box-shadow: var(--chat-shadow-sm);
}

.plans-cards-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.plan-modal-card {
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  padding: 20px;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plan-modal-card--featured {
  border-color: var(--chat-ink);
  box-shadow: var(--chat-shadow-sm);
}

.plan-modal-name {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.plan-modal-price-line {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.plan-modal-currency {
  font-size: 16px;
  color: var(--chat-muted);
  font-weight: 500;
}

.plan-modal-amount {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.plan-modal-period {
  font-size: 12.5px;
  color: var(--chat-muted);
}

.plan-modal-tagline {
  margin: 0;
  font-size: 13px;
  color: var(--chat-muted);
  min-height: 36px;
}

.plan-modal-cta {
  width: 100%;
  min-height: 40px;
}

.plans-modal-title { font-weight: 400; }
.plans-segment { padding: 6px; border-radius: 20px; }
.plans-segment-btn { padding: 12px 16px; border-radius: 16px; transition: background-color 150ms cubic-bezier(.4,0,.2,1), color 150ms cubic-bezier(.4,0,.2,1); }
.plans-cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.plan-modal-card, .plan-modal-card--featured { min-width: 0; padding: 20px 18px; border-radius: 6px; box-shadow: none; border-color: var(--chat-border); }
.plan-modal-name { order: 0; font-size: 28px; line-height: 36px; font-weight: 400; }
.plan-modal-tagline { order: 1; font-size: 14px; line-height: 22px; min-height: 66px; }
.plan-modal-price-line { order: 2; flex-wrap: wrap; margin-block: 10px; }
.plan-modal-amount { font-size: 48px; font-weight: 400; }
.plan-modal-cta { order: 3; border-radius: 999px; background: var(--chat-ink); color: var(--chat-bg); }
.plan-modal-cta:not(.pill-btn--solid):hover { color: var(--chat-ink); }
.plan-modal-features { order: 4; }
.plan-modal-inherits { order: 4; margin: 20px 0 12px; font-size: 13px; font-weight: 600; }
@media (max-width: 767px) {
  .plans-cards-grid { grid-template-columns: minmax(0, 1fr); }
}

.plan-modal-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--chat-ink);
}

.plan-modal-features li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.plan-modal-features svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.plans-footnote {
  margin: 0;
  font-size: 12px;
  color: var(--chat-muted);
  text-align: center;
  max-width: 680px;
}

/* Context & Token Efficiency Meter Modal */
.context-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.context-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.context-stat-box {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--chat-border);
  background: var(--chat-sidebar-bg);
}

.context-stat-value {
  font-size: 18px;
  font-weight: 600;
}

.context-stat-label {
  font-size: 11.5px;
  color: var(--chat-muted);
}

.context-cat-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

.context-cat-row {
  display: flex;
  justify-content: space-between;
  color: var(--chat-muted);
}

/* Status Toast */
.chat-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--chat-pill-active-bg);
  color: var(--chat-pill-active-ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--chat-shadow-md);
  z-index: 120;
}

.chat-toast--attachment {
  position: absolute;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: calc(100% - 32px);
  max-height: min(200px, 30vh);
  overflow-y: auto;
  border-radius: 12px;
}

/* Mobile backdrop when sidebar drawer is open */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--chat-backdrop);
  z-index: 35;
}

/* Mobile responsive adjustments (<= 768px) — >= 44px touch targets */
@media (max-width: 767px) {
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    margin-left: 0 !important;
    transform: translateX(0);
    box-shadow: var(--chat-shadow-lg);
  }

  .chat-app[data-sidebar="collapsed"] .chat-sidebar {
    transform: translateX(-105%);
    box-shadow: none;
  }

  .chat-topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .topbar-left,
  .topbar-right {
    gap: 4px;
    min-width: 0;
  }

  .model-trigger {
    padding: 6px 8px;
    font-size: 15px;
    white-space: nowrap;
  }

  .temp-chat-pill span {
    display: none;
  }

  .temp-chat-pill {
    width: 44px;
    padding: 0;
  }

  #topbar-signup-link {
    display: none;
  }

  #topbar-login-link {
    padding: 0 14px;
    white-space: nowrap;
  }

  #topbar-settings-btn {
    display: none;
  }

  .icon-btn,
  .composer-tool-btn,
  .send-btn,
  .pill-btn,
  .model-trigger,
  .sidebar-item {
    min-height: 44px;
    white-space: nowrap;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .composer-tool-btn--icon,
  .send-btn {
    width: 44px;
    height: 44px;
  }

  .user-bubble {
    max-width: 88%;
  }

  .side-pane,
  .side-pane--sources {
    position: fixed;
    inset: 0;
    width: 100%;
    min-width: 0;
    z-index: 45;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--chat-border);
  }

  .context-stat-grid {
    grid-template-columns: 1fr;
  }
}

/* Thread geometry */
.chat-stage { scroll-behavior: auto; overflow-anchor: none; }
.chat-stage-inner { max-width: 800px; padding: 24px 16px 32px; }
.assistant-turn { width: 100%; max-width: 720px; margin-inline: auto; }
.assistant-prose { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.assistant-prose h1, .assistant-prose h2, .assistant-prose h3, .assistant-prose h4 { line-height: 1.4; font-weight: 600; margin: 24px 0 10px; }
.assistant-prose h1 { font-size: 23px; letter-spacing: -.025em; }
.assistant-prose h2 { font-size: 20px; letter-spacing: -.02em; }
.assistant-prose h3 { font-size: 17px; }
.assistant-prose h4 { font-size: 15px; }
.assistant-prose > :first-child { margin-top: 0; }
.assistant-prose > :last-child { margin-bottom: 0; }
.assistant-prose p, .assistant-prose ul, .assistant-prose ol { margin-bottom: 14px; }
.assistant-prose code { font-size: .875em; line-height: inherit; border-radius: 5px; }
.assistant-prose table { display: block; overflow-x: auto; max-width: 100%; border-radius: 10px; }
.assistant-prose th, .assistant-prose td { min-width: 150px; padding: 10px 12px; overflow-wrap: normal; }
.assistant-prose blockquote { margin-left: 0; padding-left: 16px; border-left-width: 2px; }
.user-bubble { background: var(--chat-user-bubble); color: var(--chat-ink); font-size: 14px; line-height: 1.55; border-radius: 16px; padding: 8px 13px; max-width: 70%; }
.turn-icon-btn { width: 32px; height: 32px; }
.turn-footer { gap: 4px; transition: opacity 180ms var(--chat-ease); }
.turn-footer .turn-icon-btn { transition: opacity 180ms var(--chat-ease), background-color 180ms var(--chat-ease); }
.msg-row--assistant .turn-footer .turn-icon-btn { opacity: 0; }
.msg-row--assistant:hover .turn-footer .turn-icon-btn, .msg-row--assistant:focus-within .turn-footer .turn-icon-btn { opacity: 1; }
.msg-row--user > .turn-footer { opacity: 0; }
.msg-row--user:hover > .turn-footer, .msg-row--user:focus-within > .turn-footer { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .msg-row--user > .turn-footer, .msg-row--assistant .turn-footer .turn-icon-btn { opacity: 1; }
  .turn-icon-btn { min-width: 44px; min-height: 44px; }
}
.code-card { border-radius: 12px; background: var(--chat-code-bg); }
.code-card-head { background: var(--chat-code-header); padding: 6px 12px; }
.code-action-btn { width: 32px; height: 32px; justify-content: center; padding: 0; }
.code-card pre { font-size: 13px; line-height: 1.65; padding: 16px; }
.starter-suggestions { position: relative; margin: 16px auto 0; width: fit-content; }
.starter-suggestions > .starter-chip { font-size: 12px; color: var(--chat-muted); padding: 7px 14px; background: transparent; }
.starter-suggestions .starter-chips { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 280px; max-width: calc(100vw - 32px); max-height: min(280px, 50dvh); overflow-y: auto; margin: 0; padding: 8px; flex-direction: column; flex-wrap: nowrap; background: var(--composer-bg); border: 1px solid var(--chat-border); box-shadow: var(--chat-shadow-md); border-radius: 16px; z-index: 25; }
.starter-suggestions .starter-chip { text-align: left; }
.chat-main[data-empty="true"] .starter-suggestions .starter-chips { display: flex; }
.scroll-bottom-btn { position: absolute; bottom: calc(100% + 12px); left: calc(50% - 18px); width: 36px; height: 36px; background: var(--composer-bg); border: 1px solid var(--chat-border); color: var(--chat-ink); border-radius: 50%; box-shadow: var(--chat-shadow-sm); cursor: pointer; display: grid; place-items: center; padding: 0; z-index: 5; }
@media (max-width: 767px) {
  .chat-stage-inner { padding-inline: 16px; }
}

/* Shell geometry */
@media (min-width: 768px) {
  .chat-main { container-type: inline-size; }
  @container (max-width: 400px) {
    .model-trigger { width: clamp(80px, calc(100cqw - 128px), 200px); }
    .chat-topbar { height: auto; flex-wrap: wrap; padding-block: 8px; }
    .chat-topbar > .topbar-right { margin-left: auto; max-width: 100%; flex-wrap: wrap; justify-content: flex-end; }
    .chat-topbar .popover-menu { min-width: 0; max-width: calc(100cqw - 28px); }
    .composer-shell .composer-textarea { grid-area: 3 / 1 / 4 / -1; min-height: 40px; padding-block: 8px; }
    .composer-shell .composer-tools { grid-area: 4 / 1; }
    .composer-shell .composer-tools-right { grid-area: 4 / 3; }
  }
}

.chat-sidebar {
  transition: width 220ms cubic-bezier(.2,.8,.2,1), min-width 220ms cubic-bezier(.2,.8,.2,1), transform 220ms cubic-bezier(.2,.8,.2,1);
}
.chat-app[data-sidebar="collapsed"] .chat-sidebar { width: 56px; min-width: 56px; margin-left: 0; }
.sidebar-search-shortcut, .sidebar-settings-shortcut, .mobile-product-name, .sidebar-open-mobile { display: none; }
.sidebar-item > svg, .sidebar-item > img { flex-shrink: 0; }
.sidebar-guest { padding: 20px 10px; }
.sidebar-guest h2 { font-size: 17px; line-height: 24px; font-weight: 650; }
.sidebar-guest p { font-size: 13px; line-height: 20px; }
.sidebar-guest-login { min-height: 44px; border: 0; }
.chat-app[data-sidebar="collapsed"] .sidebar-top { flex-direction: column; padding: 8px 6px; gap: 4px; margin: 0; }
.chat-app[data-sidebar="collapsed"] .sidebar-brand { justify-content: center; width: 44px; height: 36px; }
.chat-app[data-sidebar="collapsed"] .sidebar-brand span,
.chat-app[data-sidebar="collapsed"] .sidebar-item-title,
.chat-app[data-sidebar="collapsed"] .sidebar-search-wrap,
.chat-app[data-sidebar="collapsed"] section.sidebar-nav-group,
.chat-app[data-sidebar="collapsed"] .sidebar-upgrade-copy,
.chat-app[data-sidebar="collapsed"] .account-meta,
.chat-app[data-sidebar="collapsed"] .sidebar-guest h2,
.chat-app[data-sidebar="collapsed"] .sidebar-guest p { display: none; }
.chat-app[data-sidebar="collapsed"] .sidebar-search-shortcut { display: flex; flex-shrink: 0; margin: 0 6px 4px; }
.chat-app[data-sidebar="collapsed"] .sidebar-settings-shortcut { display: flex; }
.chat-app[data-sidebar="collapsed"] #sidebar-new-chat-btn { display: none; }
.chat-app[data-sidebar="collapsed"] .sidebar-scroll { padding: 0 6px; }
.chat-app[data-sidebar="collapsed"] .sidebar-item { width: 44px; height: 44px; padding: 0; justify-content: center; }
.chat-app[data-sidebar="collapsed"] .sidebar-footer { padding: 8px 6px; }
.chat-app[data-sidebar="collapsed"] .sidebar-upgrade-btn,
.chat-app[data-sidebar="collapsed"] .sidebar-account-btn { padding: 0; width: 44px; height: 44px; justify-content: center; }
.chat-app[data-sidebar="collapsed"] .sidebar-guest { padding: 0; }
.chat-app[data-sidebar="collapsed"] .sidebar-guest-login { font-size: 0; width: 44px; padding: 0; }
.chat-app[data-sidebar="collapsed"] .sidebar-guest-login::after { content: "↪"; font-size: 22px; }
.chat-topbar { height: auto; min-height: 61px; }
.composer-dock { max-width: 800px; }
.composer-shell {
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) 88px;
  grid-template-rows: auto auto auto;
  align-items: center;
  gap: 0;
  padding: 3px 6px;
  background: var(--composer-bg);
  border: 1px solid var(--chat-border);
  box-shadow: 0 2px 12px #00000008;
}
.composer-shell:focus-within { border-color: var(--chat-border-strong); box-shadow: 0 0 0 3px var(--chat-accent-soft), 0 2px 12px #00000008; }
html[data-theme="dark"] .composer-shell { box-shadow: inset 0 0 1px #fff3; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .composer-shell { box-shadow: inset 0 0 1px #fff3; }
}
.composer-toolbar, .composer-toolbar .composer-tools-left { display: contents; }
.composer-textarea { grid-area: 3 / 2; min-width: 0; min-height: 24px; padding: 0 6px; font-size: 15px; line-height: 24px; overflow-y: auto; }
.composer-tools { grid-area: 3 / 1; align-self: end; }
.composer-tools > summary { width: 44px; height: 44px; padding: 0; justify-content: center; color: var(--chat-ink); }
.composer-tools-right { grid-area: 3 / 3; align-self: end; flex-wrap: nowrap; gap: 0; }
.composer-tools-right > button { width: 44px; height: 44px; min-width: 44px; padding: 0; }
.composer-tools-panel { left: 0; bottom: calc(100% + 8px); width: 244px; max-height: min(360px, max(80px, calc(var(--shell-height, 100dvh) - 100px))); }
.composer-mode-summary { grid-area: 2 / 1 / 3 / -1; display: flex; flex-wrap: wrap; gap: 6px; max-width: none; white-space: normal; padding: 4px 8px; }
.composer-mode-summary:empty { display: none; }
.composer-mode-pill { display: inline-flex; gap: 10px; align-items: center; border: 1px solid var(--chat-border); border-radius: 999px; padding: 5px 10px; font: 500 12px/20px var(--chat-font-sans); color: var(--chat-ink); background: var(--chat-surface); cursor: pointer; }
.composer-mode-pill::after { content: "×"; font-size: 16px; }
.composer-attachments { grid-area: 1 / 1 / 2 / -1; padding: 8px; min-width: 0; }
.attachment-pill { max-width: 100%; min-width: 0; }
.attachment-pill > span { overflow-wrap: anywhere; min-width: 0; }
.composer-caption { flex-wrap: wrap; gap: 4px 8px; }
.composer-caption { font-size: 11px; line-height: 18px; }
.chat-topbar .icon-btn { border: 0; box-shadow: none; }
.sidebar-nav .sidebar-item { min-height: 40px; gap: 10px; padding: 8px 10px; }
.sidebar-item.thread-row { min-height: 40px; }
.sidebar-nav > section.sidebar-nav-group { margin-top: 8px; }
.sidebar-group-head { font-size: 11px; font-weight: 600; letter-spacing: .025em; }
.sidebar-item > svg, .composer-tools-panel .composer-tool-btn > svg { width: 18px; height: 18px; flex-shrink: 0; }
.context-stat-grid { grid-template-columns: 1fr; }
.send-btn { transition: background-color 150ms cubic-bezier(.4,0,.2,1), color 150ms cubic-bezier(.4,0,.2,1), opacity 150ms cubic-bezier(.4,0,.2,1); }
@media (prefers-reduced-motion: reduce) {
  .plans-segment-btn, .send-btn { transition: none; }
  .msg-row--appearing, .pulse-dot { animation: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .msg-row--appearing { animation: message-reveal 180ms var(--chat-ease) both; }
}
@keyframes message-reveal { from { opacity: 0; } to { opacity: 1; } }
.privacy-caption-link { border: 0; padding: 0; color: inherit; background: transparent; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.composer-caption .privacy-consent__settings { position: static; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: inherit; font: inherit; }
.chat-empty-state h1 { font-size: clamp(20px, 2.5vw, 28px); line-height: 1.3; font-weight: 500; max-width: none; margin-inline: auto; letter-spacing: -.025em; text-wrap: balance; }
.sidebar-backdrop { border: 0; padding: 0; opacity: 1; cursor: default; }
body.fable-chat-body { display: flex; flex-direction: column; height: 100dvh; }
body.fable-chat-body .chat-app { flex: 1; min-height: 0; height: auto; }
body.fable-chat-body > .privacy-consent__settings { display: none; }
body.fable-chat-body #fondation-privacy-consent {
  position: relative;
  order: -1;
  z-index: auto;
  flex: 0 0 auto;
  inset: auto;
  width: 100%;
  max-height: 34dvh;
  margin: 0;
  padding: 12px 20px;
  border: 0;
  border-bottom: 1px solid var(--chat-border);
  border-radius: 0;
  background: var(--composer-bg);
  color: var(--chat-ink);
  box-shadow: none;
  animation: none;
  --privacy-ink: var(--chat-ink);
  --privacy-muted: var(--chat-muted);
  --privacy-line: var(--chat-border);
}
body.fable-chat-body .privacy-consent__inner { max-width: 1000px; margin: auto; gap: 8px; }
body.fable-chat-body .privacy-consent__copy h2 { font: 600 15px/20px var(--chat-font-sans); }
body.fable-chat-body .privacy-consent__copy p { font-size: 12px; line-height: 18px; }
body.fable-chat-body .privacy-consent__status:empty { display: none; }
body.fable-chat-body .privacy-consent__button { background: var(--chat-surface); color: var(--chat-ink); }
@media (min-width: 768px) {
  #sidebar-open-btn { display: none; }
}
@media (max-width: 767px) {
  .sidebar-settings-shortcut { display: flex; }
  .chat-sidebar { width: min(310px, calc(100vw - 48px)); min-width: min(310px, calc(100vw - 48px)); height: 100dvh; background: var(--composer-bg); }
  .chat-app[data-sidebar="collapsed"] .chat-sidebar { width: min(310px, calc(100vw - 48px)); min-width: min(310px, calc(100vw - 48px)); margin-left: 0; visibility: hidden; transition: transform 220ms cubic-bezier(.2,.8,.2,1), visibility 220ms; }
  .chat-app[data-sidebar="open"] .chat-sidebar { transform: translateX(0); }
  .chat-topbar { display: grid; grid-template-columns: minmax(44px,1fr) auto minmax(44px,1fr); padding-inline: 8px; gap: 0; }
  .topbar-left { display: contents; }
  #sidebar-open-btn { grid-column: 1; grid-row: 1; }
  .topbar-left > .model-picker-wrap { grid-column: 2; grid-row: 1; min-width: 0; }
  .chat-topbar > .topbar-right { grid-column: 3; grid-row: 1; justify-content: flex-end; gap: 0; }
  .model-trigger { font-size: 17px; padding-inline: 8px; gap: 4px; width: 164px; max-width: 48vw; }
  #sidebar-open-btn .sidebar-open-desktop { display: none; }
  #sidebar-open-btn .sidebar-open-mobile { display: block; }
  .model-trigger-logo { display: none; }
  #active-model-label { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #model-picker-menu { transform: none; max-width: calc(100vw - 24px); }
  #save-temp-chat-btn { font-size: 0; width: 44px; padding: 0; }
  #save-temp-chat-btn::after { content: "Save"; font-size: 12px; }
  .chat-app[data-auth="signed-in"] #topbar-settings-btn { display: flex; }
  .sidebar-footer > .model-picker-wrap .popover-menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; max-width: calc(100vw - 60px); }
  .composer-dock { padding-inline: 12px; }
  .composer-shell { padding-block: 1px; }
  .composer-textarea { font-size: 16px; }
  .composer-caption { font-size: 10px; line-height: 16px; }
  .chat-main[data-empty="true"] .chat-stage-inner { padding-bottom: 24px; }
  .composer-dock { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat-empty-state h1 { font-size: clamp(18px, 5.5vw, 22px); }
  body.fable-chat-body #fondation-privacy-consent { padding: 10px 12px; }
}

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

.model-row { gap: 12px; }
.model-row .menu-item-main { min-width: 0; flex: 1; }
.model-row .menu-item-desc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-row-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.model-row-check { width: 18px; flex-shrink: 0; text-align: center; }
.model-upgrade-item { margin-top: 4px; }
.icon-btn > svg, .composer-tool-btn > svg, .send-btn > svg, .sidebar-item > svg { width: 18px; height: 18px; stroke-width: 1.8; }
.plan-modal-card[data-selected="true"] { border-color: var(--chat-ink); }
[data-settings-panel="account"] .settings-row { flex-wrap: wrap; gap: 16px; }
[data-settings-panel="account"] .topbar-right { flex-wrap: wrap; }
#settings-account-email { overflow-wrap: anywhere; }
#settings-billing-status, #plans-billing-status { color: var(--chat-ink); font-size: 14px; line-height: 1.5; }
