/* ============================================================================
   XroFlora — Minimal Neutral Monochrome UI Stylesheet
   ============================================================================ */

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes modal-scale-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes text-shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

@keyframes soft-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ============================================================================
   Auth View
   ============================================================================ */

.auth-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg-main);
  z-index: 45;
}

.auth-card {
  width: min(396px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 28px 26px;
  box-shadow: var(--shadow-modal);
  animation: modal-scale-in 0.22s var(--ease-smooth);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.auth-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-card h1 {
  margin: 4px 0 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.auth-subtitle {
  margin: -6px 0 4px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.auth-card input {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.93rem;
  transition: border-color 0.16s var(--ease-smooth);
}

.auth-card input:focus {
  border-color: var(--text-primary);
  outline: none;
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 0.84rem;
  line-height: 1.4;
}

.error:empty {
  display: none;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn-primary {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s var(--ease-smooth), transform 0.14s var(--ease-smooth), opacity 0.16s var(--ease-smooth);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-secondary {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s var(--ease-smooth), border-color 0.16s var(--ease-smooth), transform 0.14s var(--ease-smooth);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-ghost {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.16s var(--ease-smooth), background-color 0.16s var(--ease-smooth);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 9px 18px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s var(--ease-smooth), color 0.16s var(--ease-smooth), transform 0.14s var(--ease-smooth);
}

.btn-danger-outline:hover {
  background: var(--danger-hover-bg);
  color: var(--danger);
}

.btn-danger-outline:active {
  transform: scale(0.98);
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.16s var(--ease-smooth), color 0.16s var(--ease-smooth), transform 0.14s var(--ease-smooth);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* ============================================================================
   Two-Column App Shell
   ============================================================================ */

.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg-main);
}

/* ============================================================================
   Left Sidebar (Matches Figma #F9F9F9 Light / #171717 Dark)
   ============================================================================ */

.sidebar {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin-left: 0;
  opacity: 1;
  visibility: visible;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: margin-left, opacity, transform;
  transition:
    margin-left 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1) 0.04s,
    border-color 0.22s ease,
    background-color 0.2s var(--ease-smooth),
    visibility 0s linear 0s;
}

.app-layout.sidebar-collapsed .sidebar {
  margin-left: -260px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  border-right-color: transparent;
  transition:
    margin-left 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease,
    border-color 0.18s ease,
    background-color 0.2s var(--ease-smooth),
    visibility 0s linear 0.26s;
}

.sidebar-header {
  height: 56px;
  padding: 0 12px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  padding: 4px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.89rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease-smooth), transform 0.12s var(--ease-smooth);
}

.sidebar-nav-item:hover {
  background: var(--bg-hover);
}

.sidebar-nav-item:active {
  transform: scale(0.98);
}

.sidebar-nav-svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.search-box {
  padding: 4px 4px 6px;
  animation: fade-in-up 0.16s var(--ease-smooth);
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.16s var(--ease-smooth);
}

.search-box input:focus {
  border-color: var(--border-strong);
}

/* Grouped Chat History */
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

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

.chat-group-label {
  padding: 4px 10px 6px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
  transition: background-color 0.14s var(--ease-smooth);
}

.chat-item:hover,
.chat-item.active {
  background: var(--bg-hover);
}

.chat-item-btn {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 30px 8px 10px;
  text-align: left;
  font-size: 0.87rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border-radius: 10px;
}

.chat-item.active .chat-item-btn {
  font-weight: 500;
}

.chat-delete-btn {
  position: absolute;
  right: 5px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s var(--ease-smooth), background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

.chat-item:hover .chat-delete-btn,
.chat-delete-btn:focus-visible {
  opacity: 1;
}

.chat-delete-btn:hover {
  color: var(--danger);
  background: var(--bg-elevated);
}

.chat-empty-hint {
  padding: 10px 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Sidebar Footer */
.sidebar-footer {
  position: relative;
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-promo-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s var(--ease-smooth);
}

.sidebar-promo-btn:hover {
  background: var(--bg-hover);
}

.sidebar-promo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
}

.sidebar-promo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.sidebar-promo-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-promo-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s var(--ease-smooth);
}

.account-trigger:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 0.95rem;
}

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

.user-name-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email-label:empty {
  display: none;
}

.account-chevron {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Popover Menus */
.account-menu,
.dropdown-menu {
  position: absolute;
  z-index: 40;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 216px;
  box-shadow: var(--shadow-popover);
}

.account-menu {
  bottom: calc(100% + 4px);
  left: 10px;
  right: 10px;
  animation: menu-pop-up 0.16s var(--ease-smooth);
}

.dropdown-menu {
  top: calc(100% + 6px);
  right: 0;
  animation: menu-pop-down 0.16s var(--ease-smooth);
}

.account-menu-info {
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.account-menu-info strong {
  font-size: 0.86rem;
  font-weight: 600;
}

.account-menu-info span {
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

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

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

.menu-item-danger:hover {
  background: var(--danger-hover-bg);
}

/* ============================================================================
   Main Shell & Top Bar (Matches Figma Desktop & Mobile Headers)
   ============================================================================ */

.shell {
  flex: 1 1 auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-main);
}

.chat-topbar {
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg-main);
  z-index: 20;
}

.topbar-left,
.topbar-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Desktop: smoothly slide & fade topbar sidebar toggle when sidebar collapses */
.topbar-sidebar-btn {
  display: inline-flex;
  width: 0;
  opacity: 0;
  margin-right: -8px;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(-8px) scale(0.92);
  transition:
    width 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    margin-right 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.16s var(--ease-smooth),
    color 0.16s var(--ease-smooth);
}

.app-layout.sidebar-collapsed .topbar-sidebar-btn {
  width: 36px;
  opacity: 1;
  margin-right: 0;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.topbar-model-stack {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Top-Left Model Selector */
.model-selector-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.model-selector-btn {
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 6px 10px;
  margin-left: -6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease-smooth), transform 0.12s var(--ease-smooth);
}

.model-selector-btn:hover,
.model-selector-btn[aria-expanded="true"] {
  background: var(--bg-hover);
}

.model-selector-btn:active {
  transform: scale(0.98);
}

.model-brand-name {
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.model-selector-label {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: min(200px, 38vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-selector-chevron {
  color: var(--text-muted);
  align-self: center;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-smooth);
}

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

/* Downward Popover Anchored to Top-Left Header */
.model-selector-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 45;
  width: min(310px, calc(100vw - 32px));
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-popover);
  animation: menu-pop-down 0.16s var(--ease-smooth);
  -webkit-overflow-scrolling: touch;
}

.model-option {
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  transition: background-color 0.14s var(--ease-smooth);
}

.model-option:hover,
.model-option.is-selected {
  background: var(--bg-hover);
}

.model-option-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.model-option-name {
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-option-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-option-check {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.model-option-add {
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
  padding-top: 10px;
  border-radius: 0 0 10px 10px;
}

.model-option-add .model-option-name {
  font-weight: 600;
}

/* Active chat title: hidden on desktop unless renaming (matches Figma), shown as subtitle on mobile */
.chat-title {
  display: none;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(260px, 54vw);
  cursor: pointer;
}

.rename-chat-form {
  display: inline-flex;
  align-items: center;
}

.rename-chat-input {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 0.88rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  width: min(280px, 50vw);
  outline: none;
}

.rename-chat-input:focus {
  border-color: var(--text-primary);
}

/* Top-Right Share Pill & Actions */
.topbar-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease-smooth), border-color 0.15s var(--ease-smooth), transform 0.12s var(--ease-smooth);
}

.topbar-share-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.topbar-share-btn:active {
  transform: scale(0.97);
}

.topbar-share-btn.is-shared {
  color: var(--success);
  border-color: var(--success);
}

.mobile-new-chat-btn {
  display: none;
}

/* ============================================================================
   Chat Stage: Centered Empty State → Docked Conversation Layout
   ============================================================================ */

.chat-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-column {
  width: min(740px, 100%);
  margin: 0 auto;
}

.chat-scroll {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 20px 24px;
  display: flex;
  flex-direction: column;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-scroll > .chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Empty State Centering (Exact Figma Desktop_-_Empty_State layout) */
.shell.is-empty .chat-stage {
  justify-content: center;
  padding-bottom: 24px;
}

.shell.is-empty .chat-scroll {
  flex: 0 1 auto;
  overflow: visible;
  padding: 0 20px 24px;
}

.shell.is-empty .chat-scroll > .chat-column {
  flex: 0 1 auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  animation: fade-in-up 0.28s var(--ease-smooth);
}

.empty-greeting {
  margin: 0;
  font-size: clamp(1.6rem, 2.8vw, 1.95rem);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.25;
  color: var(--text-primary);
  text-wrap: balance;
}

.empty-subtext {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ============================================================================
   Messages Stream (Pure Text-First Assistant Replies)
   ============================================================================ */

.messages {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 8px 0 20px;
}

.message {
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: fade-in-up 0.2s var(--ease-smooth);
}

.message.user {
  align-items: flex-end;
}

.user-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
  max-width: 76%;
}

.user-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.user-attachment-name {
  font-family: var(--font-mono);
  color: var(--text-primary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-attachment-size {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.user-bubble {
  max-width: 72%;
  background: var(--bg-user-bubble);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 0.96rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Assistant Message — 100% Pure Text-First on Canvas */
.message.assistant {
  align-items: stretch;
}

.assistant-stream {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.assistant-slot {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.assistant-slot:empty {
  display: none;
}

/* ============================================================================
   Minimal Inline Thinking & Automatic Web Research Disclosure (Smooth Accordion)
   ============================================================================ */

.thinking-disclosure {
  width: 100%;
  margin: 0 0 2px;
}

.thinking-trigger {
  border: 0;
  background: transparent;
  padding: 3px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.87rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  transition: color 0.16s var(--ease-smooth);
}

.thinking-trigger:hover {
  color: var(--text-primary);
}

.thinking-trigger[data-expandable="false"] {
  cursor: default;
}

.thinking-trigger-label {
  font-variant-numeric: tabular-nums;
}

.thinking-trigger-label.is-shimmering {
  background: linear-gradient(
    90deg,
    var(--shimmer-base) 0%,
    var(--shimmer-base) 35%,
    var(--shimmer-highlight) 50%,
    var(--shimmer-base) 65%,
    var(--shimmer-base) 100%
  );
  background-size: 240% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: text-shimmer 1.8s linear infinite;
}

.thinking-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.22s var(--ease-smooth), color 0.16s var(--ease-smooth);
}

.thinking-trigger:hover .thinking-chevron {
  color: var(--text-primary);
}

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

.thinking-collapse {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.24s var(--ease-smooth), opacity 0.2s var(--ease-smooth);
}

.thinking-disclosure.is-open .thinking-collapse {
  grid-template-rows: 1fr;
  opacity: 1;
}

.thinking-collapse-clip {
  overflow: hidden;
  min-height: 0;
}

.thinking-timeline {
  margin: 6px 0 8px 4px;
  padding: 2px 0 2px 15px;
  border-left: 1.5px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thinking-plain-content {
  margin: 0;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.thinking-plain-content + .thinking-plain-content {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.research-status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.research-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.research-status-line.is-active .research-status-dot {
  background: var(--text-primary);
  animation: soft-pulse 1.3s ease-in-out infinite;
}

.research-status-line.is-done .research-status-dot {
  background: var(--success);
}

.thinking-tools-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.tool-indicator {
  border: 0;
  background: transparent;
  padding: 3px 8px 3px 4px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.4;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

.tool-indicator:hover,
.tool-indicator.is-active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tool-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.tool-status-dot.status-running {
  background: var(--text-primary);
  animation: soft-pulse 1.2s ease-in-out infinite;
}

.tool-status-dot.status-done {
  background: var(--success);
}

.tool-status-dot.status-error {
  background: var(--danger);
}

.tool-indicator-name {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.tool-indicator-hint {
  color: var(--text-muted);
  font-size: 0.79rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(340px, 50vw);
}

/* Inline Notices (Retry, Network, Provider Error) */
.provider-retry-inline,
.slow-connection-inline {
  width: 100%;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 6px;
}

.provider-retry-inline.status-resumed,
.slow-connection-inline.status-recovered {
  border-color: var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.provider-error-inline {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--danger);
  background: var(--danger-hover-bg);
  color: var(--danger);
  font-size: 0.87rem;
  line-height: 1.45;
  word-break: break-word;
}

/* ============================================================================
   Markdown Typography & Code Blocks
   ============================================================================ */

.assistant-body {
  width: 100%;
  color: var(--text-primary);
  font-size: 0.97rem;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.assistant-body p {
  margin: 0 0 14px;
}

.assistant-body p:last-child {
  margin-bottom: 0;
}

.assistant-body h1,
.assistant-body h2,
.assistant-body h3,
.assistant-body h4,
.assistant-body h5,
.assistant-body h6 {
  margin: 22px 0 10px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.assistant-body h1:first-child,
.assistant-body h2:first-child,
.assistant-body h3:first-child {
  margin-top: 0;
}

.assistant-body h1 { font-size: 1.34rem; }
.assistant-body h2 { font-size: 1.18rem; }
.assistant-body h3 { font-size: 1.05rem; }
.assistant-body h4,
.assistant-body h5,
.assistant-body h6 { font-size: 0.96rem; }

.assistant-body ul,
.assistant-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.assistant-body li {
  margin-bottom: 5px;
}

.assistant-body li.md-task-item {
  list-style: none;
  margin-left: -18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.md-task-checkbox {
  margin: 0;
  accent-color: var(--text-primary);
}

.md-hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 18px 0;
}

.assistant-body a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.14s var(--ease-smooth);
}

.assistant-body a:hover {
  text-decoration-color: var(--text-primary);
}

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

/* GFM Tables with Tabular Numerals */
.md-table-wrap {
  width: 100%;
  margin: 16px 0;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-main);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.md-th,
.md-td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: top;
}

.md-th:last-child,
.md-td:last-child {
  border-right: 0;
}

.md-table tbody tr:last-child .md-td {
  border-bottom: 0;
}

.md-th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }

.md-quote {
  margin: 0 0 14px;
  padding: 10px 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: 12px;
  font-size: 0.93rem;
  color: var(--text-secondary);
}

.assistant-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 6px;
}

.code-block {
  margin: 14px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-code);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--bg-code-header);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.77rem;
  color: var(--text-secondary);
}

.code-lang {
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.code-copy-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.77rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

.code-copy-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
}

.code-block pre code {
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.55;
}

/* Inline Citations & Smooth Collapsible Sources Drawer */
.citation-marker {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
  vertical-align: baseline;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

.citation-marker:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sources-drawer-wrap {
  width: 100%;
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.24s var(--ease-smooth), opacity 0.2s var(--ease-smooth), margin-top 0.2s var(--ease-smooth);
}

.sources-drawer-wrap.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 12px;
}

.sources-drawer-clip {
  overflow: hidden;
  min-height: 0;
}

.sources-drawer {
  padding: 12px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--bg-sidebar);
}

.sources-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.source-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.84rem;
  flex-wrap: wrap;
}

.source-id {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.source-title {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}

a.source-title:hover {
  text-decoration: underline;
}

.source-meta-sep {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.source-status {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.source-status.verified {
  color: var(--success);
}

/* ============================================================================
   Assistant Minimal Icon Action Bar (Matches Figma Screenshots 1, 3, 4)
   ============================================================================ */

.message-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 10px;
}

.msg-action-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  height: 30px;
  min-width: 30px;
  padding: 0 7px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth), transform 0.12s var(--ease-smooth);
}

.msg-action-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-action-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.msg-action-btn.is-copied {
  color: var(--success);
}

.msg-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.msg-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.msg-action-svg {
  width: 16px;
  height: 16px;
  display: block;
}

.message-time {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.message-actions .message-time {
  margin-top: 0;
  margin-left: auto;
}

/* ============================================================================
   Scroll-to-Bottom Floating Button
   ============================================================================ */

.scroll-bottom-btn {
  position: absolute;
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  z-index: 15;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-popover);
  animation: fade-in-up 0.16s var(--ease-smooth);
  transition: background-color 0.15s var(--ease-smooth), transform 0.14s var(--ease-smooth);
}

.scroll-bottom-btn:hover {
  background: var(--bg-hover);
}

.scroll-bottom-btn:active {
  transform: translateX(-50%) scale(0.94);
}

/* ============================================================================
   Confirmation Card
   ============================================================================ */

.confirmation-card {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--warning-border);
  border-radius: 16px;
  background: var(--warning-bg);
  color: var(--text-primary);
  animation: fade-in-up 0.2s var(--ease-smooth);
}

.confirmation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.confirmation-risk {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--warning-text);
}

.confirmation-card p {
  margin: 0 0 12px;
  font-size: 0.91rem;
}

.confirmation-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================================
   Composer Box & 4-Column Empty-State Starter Cards (Exact Figma Layout)
   ============================================================================ */

.composer-region {
  padding: 4px 20px 6px;
  flex-shrink: 0;
}

.composer-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 11px 18px;
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: 24px;
  transition: border-color 0.18s var(--ease-smooth), background-color 0.18s var(--ease-smooth), box-shadow 0.18s var(--ease-smooth);
}

.composer-box:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.attachment-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-size: 0.78rem;
  color: var(--text-primary);
  max-width: 240px;
}

.attachment-chip-name {
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-chip-size {
  color: var(--text-muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.attachment-chip-remove {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
}

.attachment-chip-remove:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

.composer-box textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  padding: 2px 2px;
  min-height: 26px;
  max-height: 180px;
  font-size: 0.96rem;
  line-height: 1.5;
  outline: none;
  color: var(--text-primary);
}

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

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

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

.composer-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth), transform 0.12s var(--ease-smooth);
}

.composer-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.composer-icon-btn:active {
  transform: scale(0.94);
}

.composer-actions {
  display: flex;
  align-items: center;
}

.composer-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.14s var(--ease-smooth), opacity 0.15s var(--ease-smooth), background-color 0.15s var(--ease-smooth);
}

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

.send-btn:hover,
.stop-btn:hover {
  background: var(--accent-hover);
}

.composer-btn:active {
  transform: scale(0.94);
}

/* 4-Column Starter Prompt Cards (Exact Figma Empty State) */
.starter-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  animation: fade-in-up 0.3s var(--ease-smooth);
}

.starter-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s var(--ease-smooth), background-color 0.16s var(--ease-smooth), transform 0.16s var(--ease-smooth);
}

.starter-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-sidebar);
  transform: translateY(-1px);
}

.starter-card:active {
  transform: translateY(0) scale(0.98);
}

.starter-card-title {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.starter-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Footer Disclaimer */
.chat-disclaimer {
  padding: 6px 16px max(12px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

/* ============================================================================
   Two-Column Tabbed Settings Modal (Matches Figma Settings_Modal_5c71906e.png)
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: overlay-fade 0.16s var(--ease-smooth);
}

.settings-modal-card {
  width: min(680px, 100%);
  max-height: min(560px, calc(100dvh - 40px));
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-scale-in 0.2s var(--ease-smooth);
}

.settings-modal-header {
  padding: 18px 20px 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.settings-modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.settings-modal-body {
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.settings-tabs {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.settings-tab {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.89rem;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease-smooth), color 0.14s var(--ease-smooth);
}

.settings-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-tab.is-active {
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 500;
}

.settings-panels {
  padding: 20px 26px 24px;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.settings-panel {
  display: flex;
  flex-direction: column;
}

.settings-panel-title {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.settings-panel-hint {
  margin: -10px 0 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}

.settings-row-label {
  font-size: 0.91rem;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-row-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* Segmented Theme Control (Exact Figma Light | Dark | System) */
.theme-segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.theme-seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s var(--ease-smooth), color 0.16s var(--ease-smooth), box-shadow 0.16s var(--ease-smooth);
}

.theme-seg-btn:hover {
  color: var(--text-primary);
}

.theme-seg-btn.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-select,
.settings-select-full {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 32px 8px 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.16s var(--ease-smooth);
}

.settings-select:focus,
.settings-select-full:focus {
  border-color: var(--text-primary);
}

.settings-select-full {
  width: 100%;
}

.settings-danger-block {
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.settings-danger-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-danger-desc {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.settings-form {
  display: flex;
  flex-direction: column;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  cursor: pointer;
}

.settings-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.settings-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Connections Inside Settings */
.connections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.connections-empty {
  margin: 0;
  padding: 10px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.connection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-sidebar);
}

.connection-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.connection-item-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.connection-item-meta {
  font-size: 0.77rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-status { font-weight: 600; }
.connection-status.is-valid { color: var(--success); }
.connection-status.is-invalid { color: var(--danger); }
.connection-status.is-unreachable { color: var(--warning-text); }

.connection-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.connection-form input[type="url"],
.connection-form input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.16s var(--ease-smooth);
}

.connection-form input:focus {
  border-color: var(--text-primary);
}

.settings-account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 0 12px;
}

.settings-account-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-account-meta strong {
  font-size: 0.96rem;
  font-weight: 600;
}

.settings-account-meta span {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* ============================================================================
   Tool Inspector (Desktop Card & Mobile Bottom Sheet)
   ============================================================================ */

.tool-inspector-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.tool-inspector-root.is-mobile-sheet {
  pointer-events: auto;
}

.tool-step-card {
  position: fixed;
  pointer-events: auto;
  width: min(370px, calc(100vw - 32px));
  max-height: min(400px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-modal);
  animation: menu-pop-down 0.16s var(--ease-smooth);
  overflow: hidden;
}

.tool-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.44);
  animation: overlay-fade 0.16s var(--ease-smooth);
}

.tool-bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  pointer-events: auto;
  max-height: min(74dvh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  animation: sheet-slide-up 0.24s var(--ease-smooth);
  overflow: hidden;
}

.tool-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 2px auto 12px;
  flex-shrink: 0;
}

.tool-inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool-inspector-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.tool-inspector-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-inspector-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tool-inspector-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-inspector-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tool-inspector-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 4px 0 10px;
}

.tool-inspector-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-inspector-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-inspector-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tool-inspector-pre {
  margin: 0;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-code);
  font-family: var(--font-mono);
  font-size: 0.77rem;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 165px;
  overflow-y: auto;
}

/* ============================================================================
   Mobile Backdrop & Responsive Layout (Matches Figma Mobile_-_Chat_039fe5f3.png)
   ============================================================================ */

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.26s;
}

.app-layout.mobile-sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

@media (max-width: 768px) {
  .sidebar,
  .app-layout.sidebar-collapsed .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(280px, 84vw);
    min-width: 0;
    margin-left: 0;
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
    border-right-color: var(--border-subtle);
    box-shadow: none;
    transform: translate3d(-100%, 0, 0);
    will-change: transform;
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s linear 0.28s;
  }

  .app-layout.mobile-sidebar-open .sidebar,
  .app-layout.sidebar-collapsed.mobile-sidebar-open .sidebar {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.22);
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s linear 0s;
  }

  .chat-topbar {
    height: 58px;
    padding: 0 12px;
  }

  .topbar-sidebar-btn {
    width: 36px;
    opacity: 1;
    margin-right: 0;
    pointer-events: auto;
    transform: none;
  }

  .topbar-model-stack {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .model-selector-btn {
    padding: 2px 6px;
    margin-left: -4px;
  }

  .model-brand-name,
  .model-selector-label {
    font-size: 1rem;
  }

  .chat-title {
    display: block;
    padding-left: 2px;
    line-height: 1.25;
  }

  .shell.is-empty .chat-title {
    display: none;
  }

  .topbar-share-btn {
    display: none;
  }

  .mobile-new-chat-btn {
    display: inline-flex;
  }

  .chat-scroll {
    padding: 10px 16px 20px;
  }

  .shell.is-empty .chat-scroll {
    padding: 0 16px 18px;
  }

  .user-bubble {
    max-width: 85%;
    padding: 11px 16px;
  }

  .composer-region {
    padding: 4px 12px 4px;
  }

  .starter-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .starter-card {
    padding: 12px 13px;
  }

  .settings-modal-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-tabs {
    flex-direction: row;
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px 14px;
    overflow-x: auto;
  }

  .settings-panels {
    padding: 16px 18px 20px;
  }

  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .thinking-trigger-label.is-shimmering {
    background: none;
    color: var(--text-secondary);
    animation: none;
  }
}
