.main-content {
  flex: 1; display: flex; flex-direction: column;
  background: var(--surface-0); position: relative; min-width: 0;
  overflow: hidden;
}

/* Header */
.chat-header-wrap {
  position: sticky;
  top: 0;
  height: calc(var(--header-h) + var(--safe-area-inset-top));
  width: 100%;
  z-index: 10;
  padding-top: var(--safe-area-inset-top);
  background: var(--surface-0);
}
.chat-header-wrap .chat-header {
  top: var(--safe-area-inset-top);
}

.chat-header {
  height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 16px;
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0; background: var(--surface-0);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}

.mobile-menu-btn {
  display: none; width: 36px; height: 36px;
  border-radius: var(--radius-md); background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  align-items: center; justify-content: center;
}

.header-center { position: absolute; left: 50%; transform: translateX(-50%); }

.model-dropdown {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-md);
  background: none; border: none;
  color: var(--text-secondary); font-size: 15px; font-weight: 500;
  cursor: pointer; transition: all var(--transition-fast); font-family: inherit;
}
.model-dropdown:hover { background: var(--surface-2); color: var(--text-primary); }
.model-name { color: var(--text-primary); }
.provider-badge {
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  padding: 2px 7px; border-radius: 100px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-glow);
}
.provider-badge.local {
  background: rgba(34,197,94,0.12); color: var(--success);
  border-color: rgba(34,197,94,0.25);
}
.provider-badge.cloud {
  background: rgba(59,130,246,0.12); color: #3b82f6;
  border-color: rgba(59,130,246,0.25);
}

/* Model Progress Bar */
.model-progress {
  position: absolute; top: var(--header-h); left: 0; right: 0; z-index: 9;
  background: var(--surface-0); border-bottom: 1px solid var(--border-1);
  padding: 10px 16px; animation: fadeIn 0.3s ease;
}
.model-progress-inner {
  max-width: 500px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
}
.model-progress-label {
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; flex-shrink: 0;
}
.model-progress-bar-wrap {
  flex: 1; height: 6px; background: var(--surface-3);
  border-radius: 3px; overflow: hidden;
}
.model-progress-bar {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 3px; transition: width 0.3s ease;
}
.model-progress-text {
  font-size: 13px; font-weight: 600; color: var(--text-tertiary);
  min-width: 32px; text-align: right;
}

.header-actions { display: flex; align-items: center; gap: 2px; opacity: 1; transition: opacity 0.2s ease, margin-left 0.2s ease; }
.main-content:not(.sidebar-visible) .header-actions {
  margin-left: 40px;
}
.header-actions.hidden { opacity: 0; pointer-events: none; }
.header-action-btn { width: 34px; height: 34px; }
.header-action-text { display: none; font-size: 13px; font-weight: 500; }
.header-action-btn.has-text { width: auto; padding: 0 10px; gap: 6px; }
.header-action-btn.has-text .header-action-text { display: inline; }
.mobile-header-menu-btn { display: none; opacity: 1; transition: opacity 0.2s ease; }
.mobile-header-menu-btn.hidden { opacity: 0; pointer-events: none; }
.mobile-header-dropdown { display: none; position: absolute; top: calc(var(--header-h) + 8px); right: 12px; background: var(--surface-1); border: 1px solid var(--border-1); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 100; min-width: 150px; }
.mobile-header-dropdown.show { display: block; }
.mobile-header-dropdown-item { width: 100%; padding: 10px 14px; text-align: left; background: none; border: none; color: var(--text-secondary); font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.mobile-header-dropdown-item:hover { background: var(--surface-2); color: var(--text-primary); }
.mobile-header-dropdown-item-danger { color: #ff3b30; }
.mobile-header-dropdown-item-danger:hover { background: rgba(255, 59, 48, 0.1); color: #ff3b30; }
.mobile-header-dropdown-item-danger svg { color: #ff3b30; }

/* Dropdown Menu */
.dropdown-menu {
  display: none; position: fixed;
  top: calc(var(--header-h) + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--surface-1);
  border: 1px solid var(--border-1); border-radius: var(--radius-lg);
  padding: 8px; width: min(340px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - var(--header-h) - 24px));
  box-shadow: var(--shadow-lg); z-index: 100;
  animation: dropdownIn 0.2s ease;
  overflow: hidden;
  flex-direction: column;
}
.dropdown-menu.open { display: flex; }
@media (min-width: 1025px) {
  .main-content.sidebar-visible .dropdown-menu {
    left: calc(50% + var(--sidebar-width) / 2);
  }
}

/* Dropdown Tabs */
.dropdown-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin: 4px 4px 0;
  flex-shrink: 0;
}
.dropdown-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dropdown-tab:hover { color: var(--text-secondary); }
.dropdown-tab.active {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.dropdown-divider { height: 1px; background: var(--border-1); margin: 8px 8px 4px; flex-shrink: 0; }
.dropdown-options {
  overflow-y: auto;
  padding: 0 4px 4px;
  -webkit-overflow-scrolling: touch;
}
.dropdown-options::-webkit-scrollbar { width: 4px; }
.dropdown-options::-webkit-scrollbar-track { background: transparent; }
.dropdown-options::-webkit-scrollbar-thumb { background: var(--surface-5); border-radius: 2px; }

/* Dropdown Option with Vendor */
.dropdown-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 10px; border-radius: var(--radius-md);
  background: none; border: none;
  color: var(--text-secondary); font-size: 14px;
  font-family: inherit; cursor: pointer; text-align: left;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}
.dropdown-option:hover { background: var(--surface-2); color: var(--text-primary); }
.dropdown-option:active { transform: scale(0.98); }
.dropdown-option.active { color: var(--accent); background: var(--accent-soft); }

.vendor-logo {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.vendor-logo svg {
  width: 16px; height: 16px;
}

.option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.option-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.option-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.dropdown-option .model-tag {
  margin-left: auto; font-size: 12px; padding: 3px 8px;
  border-radius: 6px; background: var(--surface-3); color: var(--text-muted);
  font-weight: 600; letter-spacing: 0.3px;
  flex-shrink: 0;
}
.dropdown-option.active .model-tag { background: var(--accent-glow); color: var(--accent); }

.active-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  margin-left: 4px;
}

.webgpu-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  margin: 8px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}
.webgpu-notice svg {
  flex-shrink: 0;
  color: var(--warning);
  margin-top: 2px;
}
.webgpu-notice .notice-text strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

/* Chat Scroll */
.chat-scroll { position: absolute; top: var(--header-h); left: 0; right: 0; bottom: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; padding-top: var(--safe-area-inset-top); }
.chat-container { min-height: 100%; display: flex; flex-direction: column; padding-bottom: 140px; }

/* Welcome layout — center input vertically */
.main-content.welcome-layout {
  flex-direction: column;
  gap: 40px;
}
.main-content.welcome-layout .chat-header-wrap {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 21;
  align-self: flex-start;
}
.main-content.welcome-layout .chat-scroll {
  flex: 0 0 auto;
  overflow: visible;
}
.main-content.welcome-layout .chat-container {
  min-height: 0;
}
.input-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  transition: transform 0.5s linear(0 0%, 0 1.8%, 0.01 3.6%, 0.03 6.35%, 0.07 9.1%, 0.13 11.4%, 0.19 13.4%, 0.27 15%, 0.34 16.1%, 0.54 18.35%, 0.66 20.6%, 0.72 22.4%, 0.77 24.6%, 0.81 27.3%, 0.85 30.4%, 0.88 35.1%, 0.92 40.6%, 0.94 47.2%, 0.96 55%, 0.98 64%, 0.99 74.4%, 1 86.4%, 1 100%);
  padding-bottom: var(--safe-area-inset-bottom);
  padding-left: var(--safe-area-inset-left);
  padding-right: var(--safe-area-inset-right);
}
.main-content.welcome-layout .input-area {
  transform: translateY(-50vh);
}
@media (max-width: 1024px) {
  .main-content.welcome-layout .input-area {
    transform: translateY(-40vh);
  }
}
@media (max-width: 768px) {
  .main-content.welcome-layout .input-area {
    transform: translateY(-30vh);
  }
}
