/* ============================================================
   BuildAI — Layouts
   Load order: tokens.css → components.css → layouts.css
   ============================================================ */

/* ===== GLOBAL DEFAULTS ===== */
html, body {
  height: 100%;
  overflow: hidden;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-accent-b);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  z-index: var(--z-toast);
  transition: top var(--duration-fast);
}
.skip-link:focus { top: var(--space-4); }

/* ===== SPLASH SCREEN ===== */
.splash {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: var(--z-splash);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-slow) var(--ease-out);
}
.splash-logo {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse 1.5s ease-in-out infinite;
}
.app-loaded .splash {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* ===== APP SHELL (Dashboard / Settings) ===== */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
.app-shell.no-sidebar {
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "main";
}

/* ===== TOPBAR ===== */
.topbar {
  grid-area: topbar;
  height: var(--topbar-h);
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: var(--z-dropdown);
  flex-shrink: 0;
}
.topbar-logo {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.topbar-search-wrap {
  position: relative;
  margin-left: var(--space-2);
}
.topbar-search-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration-base);
}
.topbar-search-input {
  width: 0;
  opacity: 0;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: width var(--duration-base), opacity var(--duration-base);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  height: 32px;
  padding: 0 var(--space-3) 0 32px;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  outline: none;
}
.topbar-search-input::placeholder { color: var(--color-text-muted); }
.topbar-search-wrap.expanded .topbar-search-input {
  width: 240px;
  opacity: 1;
  pointer-events: all;
}
.topbar-search-wrap.expanded .topbar-search-btn { left: 6px; pointer-events: none; position: absolute; z-index: 1; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-1); }

/* Usage ring in topbar */
.usage-ring-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  cursor: default;
}
.usage-ring-svg {
  width: 28px;
  height: 28px;
  transform: rotate(-90deg);
}
.usage-ring-track {
  fill: none;
  stroke: var(--color-surface-3);
  stroke-width: 2.5;
}
.usage-ring-progress {
  fill: none;
  stroke: url(#ring-grad);
  stroke-width: 2.5;
  stroke-dasharray: 62.83;
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms var(--ease-out);
}
.usage-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  transform: rotate(0deg);
}

/* User avatar dropdown */
.user-menu {
  position: relative;
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  z-index: var(--z-dropdown);
  display: none;
  animation: slide-down var(--duration-fast) var(--ease-out);
}
.user-menu-dropdown.active { display: block; }
.user-menu-profile {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.user-menu-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.user-menu-email { font-size: 12px; color: var(--color-text-muted); }

/* ===== SIDEBAR ===== */
.sidebar {
  grid-area: sidebar;
  background: var(--color-surface-1);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: var(--sidebar-w);
  transition: width var(--duration-slow) var(--ease-out);
}
.sidebar--collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-label {
  opacity: 1;
  transition: opacity var(--duration-fast);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar--labels-hiding .sidebar-label { opacity: 0; }
.sidebar--collapsed .sidebar-label { display: none; }
.sidebar--labels-showing .sidebar-label {
  opacity: 0;
  animation: fade-in var(--duration-base) forwards;
}

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.sidebar-toggle {
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast), background var(--duration-fast);
  padding: 4px;
}
.sidebar-toggle:hover { background: var(--color-surface-3); color: var(--color-text-primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-2) 0; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  height: 36px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px var(--space-2);
  transition: background var(--duration-fast), color var(--duration-fast);
  position: relative;
}
.sidebar-item:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.sidebar-item.active {
  background: var(--color-surface-3);
  color: var(--color-text-primary);
  border-left: 2px solid var(--color-accent-b);
}
.sidebar-item--collapsed {
  justify-content: center;
  padding: 0;
  margin: 1px var(--space-1);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.sidebar-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--color-surface-4);
  color: var(--color-text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Folder tree */
.folder-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3) 0 var(--space-5);
  height: 32px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px var(--space-2);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.folder-item:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.folder-item.active { color: var(--color-text-primary); background: var(--color-surface-2); }
.folder-chevron {
  transition: transform var(--duration-base);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.folder-chevron.open { transform: rotate(90deg); }

.sidebar-footer {
  padding: var(--space-2);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ===== MAIN CONTENT AREA ===== */
.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--color-bg);
  position: relative;
}

/* ===== VIEW OUTLET ===== */
.view-outlet {
  grid-area: main;
  position: relative;
  height: 100%;
  overflow: hidden;
}
.view {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
}
.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition:
    opacity var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out);
}

/* ===== PAGE CONTAINER ===== */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.5px;
}
.page-subtitle { font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: 4px; }

/* ===== GRID ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}
.card-grid--lg {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* ===== BUILDER SHELL ===== */
.builder-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--builder-sidebar-w) 1fr var(--builder-preview-w);
  grid-template-areas:
    "btopbar btopbar btopbar"
    "bsidebar bcenter bpreview";
  height: 100vh;
  overflow: hidden;
}
.builder-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr var(--builder-preview-w);
}
.builder-shell.preview-hidden {
  grid-template-columns: var(--builder-sidebar-w) 1fr 0;
}

.builder-topbar {
  grid-area: btopbar;
  height: var(--topbar-h);
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: var(--z-dropdown);
}
.builder-topbar-left  { display: flex; align-items: center; gap: var(--space-2); flex: 1; min-width: 0; }
.builder-topbar-center { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.builder-topbar-right  { display: flex; align-items: center; gap: var(--space-2); flex: 1; justify-content: flex-end; }
.builder-project-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.builder-project-name:hover { background: var(--color-surface-3); }

.builder-sidebar {
  grid-area: bsidebar;
  background: var(--color-surface-1);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--duration-slow) var(--ease-out);
}

.builder-center {
  grid-area: bcenter;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--color-bg);
}

.builder-preview {
  grid-area: bpreview;
  display: flex;
  flex-direction: column;
  background: var(--color-surface-1);
  border-left: 1px solid var(--color-border);
  overflow: hidden;
  position: relative;
  transition: width var(--duration-base);
}

/* Build progress bar */
.build-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 5;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--duration-base);
}
.build-progress-bar.active { opacity: 1; }
.build-progress-inner {
  height: 100%;
  background: var(--accent-gradient);
  width: 0;
  transition: width 3s linear;
}

/* Drag handle */
.drag-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 2;
  transition: background var(--duration-fast);
  flex-shrink: 0;
  align-self: stretch;
}
.drag-handle:hover, .drag-handle.dragging {
  background: var(--color-accent-b);
  opacity: 0.3;
}
.drag-handle-dots {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.drag-handle-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

/* ===== CHAT PANEL ===== */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}

/* Message */
.msg {
  display: flex;
  gap: var(--space-3);
  max-width: 100%;
}
.msg--user { flex-direction: row-reverse; }
.msg-avatar { flex-shrink: 0; }
.msg-body { flex: 1; min-width: 0; }
.msg--user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

.msg-bubble {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
  color: var(--color-text-primary);
  max-width: 100%;
}
.msg--user .msg-bubble {
  background: var(--color-surface-3);
  border-radius: var(--radius-md) var(--radius-sm) var(--radius-md) var(--radius-md);
}
.msg-time { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Thinking block */
.msg-thinking {
  margin-bottom: var(--space-2);
}
.msg-thinking-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  user-select: none;
}
.msg-thinking-header .folder-chevron { width: 12px; height: 12px; }
.msg-thinking-content {
  display: none;
  font-size: 12px;
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid var(--color-border);
  margin-top: var(--space-2);
  line-height: var(--leading-loose);
}
.msg-thinking.expanded .msg-thinking-content { display: block; }
.msg-thinking.expanded .msg-thinking-header .folder-chevron { transform: rotate(90deg); }
.msg-thinking-duration {
  background: var(--color-surface-3);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}

/* Code block inside message */
.msg-code-block {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: var(--space-2);
  font-size: 12.5px;
}
.msg-code-header {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.msg-code-filename { font-size: 12px; font-family: var(--font-mono); color: var(--color-text-secondary); flex: 1; }
.msg-code-lang {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface-3);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: var(--space-2);
}
.msg-code-copy { color: var(--color-text-muted); cursor: pointer; transition: color var(--duration-fast); }
.msg-code-copy:hover { color: var(--color-text-primary); }
.msg-code-body {
  padding: var(--space-3);
  overflow-x: auto;
  font-family: var(--font-mono);
  line-height: var(--leading-loose);
  color: var(--color-text-primary);
  white-space: pre;
}

/* File changes */
.msg-file-changes { margin-top: var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.msg-file-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.msg-file-row:hover { background: var(--color-surface-3); }
.msg-file-op {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--weight-bold);
  width: 14px;
  flex-shrink: 0;
}
.msg-file-op--add    { color: var(--color-accent-g); }
.msg-file-op--modify { color: var(--color-warning); }
.msg-file-op--delete { color: var(--color-danger); }
.msg-file-path { font-family: var(--font-mono); font-size: 12px; color: var(--color-text-secondary); }

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: var(--space-8);
  text-align: center;
}
.chat-welcome-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-gradient);
  filter: blur(20px);
  opacity: 0.5;
  margin-bottom: -40px;
  animation: orb-pulse 3s ease-in-out infinite;
}
.chat-welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 1;
}
.chat-welcome-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.chat-welcome-subtitle { font-size: var(--text-sm); color: var(--color-text-secondary); max-width: 360px; margin-bottom: var(--space-6); }
.chat-welcome-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  width: 100%;
  max-width: 540px;
}
.chat-welcome-card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--duration-base), background var(--duration-base), transform var(--duration-fast);
  text-align: left;
}
.chat-welcome-card:hover {
  border-color: #3a3a3a;
  background: var(--color-surface-2);
  transform: translateY(-2px);
}
.chat-welcome-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
}
.chat-welcome-card-title { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: 3px; }
.chat-welcome-card-desc { font-size: 11px; color: var(--color-text-muted); line-height: 1.4; }

/* Chat input area */
.chat-input-area {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.chat-input-box {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-base), box-shadow var(--duration-base);
}
.chat-input-box:focus-within {
  border-color: rgba(51,102,255,0.4);
  box-shadow: 0 0 0 3px rgba(51,102,255,0.06);
}
.chat-input-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  padding: var(--space-3) var(--space-4);
  resize: none;
  min-height: 44px;
  max-height: 200px;
  line-height: var(--leading-loose);
  caret-color: var(--color-accent-b);
}
.chat-input-textarea::placeholder { color: var(--color-text-muted); }
.chat-input-toolbar {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3) var(--space-2);
  gap: var(--space-1);
  border-top: 1px solid var(--color-border-subtle);
}
.chat-input-toolbar-left  { display: flex; align-items: center; gap: var(--space-1); flex: 1; }
.chat-input-toolbar-right { display: flex; align-items: center; gap: var(--space-2); }
.chat-token-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.chat-token-count--warn   { color: var(--color-warning); }
.chat-token-count--danger { color: var(--color-danger); }

/* Model selector */
.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.model-selector-btn:hover { background: var(--color-surface-4); border-color: #3a3a3a; }
.model-selector-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  width: 240px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: none;
}
.model-selector-dropdown.active { display: block; animation: slide-up var(--duration-fast) var(--ease-out); }
.model-selector-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--duration-fast);
  position: relative;
}
.model-selector-item:hover { background: var(--color-surface-3); }
.model-selector-item.active { border-left: 2px solid var(--color-accent-b); background: var(--color-surface-3); }
.model-item-info { flex: 1; min-width: 0; }
.model-item-name { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: 2px; }
.model-item-desc { font-size: 11px; color: var(--color-text-muted); }
.model-item-badge {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.model-item-badge--fast  { background: var(--color-success-bg); color: #7affcc; }
.model-item-badge--smart { background: var(--color-info-bg); color: #8ab4ff; }
.model-item-badge--max   { background: var(--color-danger-bg); color: #ff8ab4; }
.model-speed-bars { display: flex; gap: 2px; align-items: flex-end; }
.model-speed-bar {
  width: 4px;
  height: 12px;
  border-radius: 2px;
  background: var(--color-surface-4);
}
.model-speed-bar.filled-fast  { background: var(--color-success); }
.model-speed-bar.filled-smart { background: var(--color-info); }
.model-speed-bar.filled-max   { background: var(--color-danger); }

/* ===== PREVIEW PANEL ===== */
.preview-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 40px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.preview-browser-dots { display: flex; gap: 5px; flex-shrink: 0; }
.preview-browser-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.preview-browser-dot--red    { background: #ff5f57; }
.preview-browser-dot--yellow { background: #febc2e; }
.preview-browser-dot--green  { background: #28c840; }
.preview-url-bar {
  flex: 1;
  height: 26px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3);
  font-size: 12px;
  color: var(--color-text-muted);
  outline: none;
  font-family: var(--font-mono);
  cursor: text;
}
.preview-url-bar:focus { border-color: rgba(51,102,255,0.5); color: var(--color-text-primary); }
.preview-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.preview-tab-item {
  padding: 0 var(--space-4);
  height: 36px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  white-space: nowrap;
}
.preview-tab-item.active { color: var(--color-text-primary); border-bottom-color: var(--color-accent-b); }
.preview-tab-item:hover { color: var(--color-text-secondary); }
.preview-content { flex: 1; overflow: hidden; position: relative; }
.preview-iframe-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  overflow: hidden;
}
.preview-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: var(--text-sm);
}

/* Device toggles */
.preview-device-bar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border);
  height: 36px;
  flex-shrink: 0;
  justify-content: space-between;
}
.preview-device-btn {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.preview-device-btn:hover { background: var(--color-surface-3); color: var(--color-text-secondary); }
.preview-device-btn.active { background: var(--color-surface-3); color: var(--color-accent-b); }

/* Mobile/tablet device frames */
.device-frame--mobile .preview-iframe-wrap {
  width: 375px;
  height: 670px;
  border-radius: 28px;
  border: 3px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
  position: relative;
}
.device-frame--mobile .preview-iframe-wrap::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  z-index: 1;
}
.device-frame--tablet .preview-iframe-wrap {
  width: 768px;
  height: 580px;
  border-radius: 16px;
  border: 3px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

/* Console */
.console-view { font-family: var(--font-mono); font-size: 12px; overflow-y: auto; height: 100%; }
.console-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.02);
}
.console-row--error { background: rgba(255,51,102,0.04); border-left: 3px solid var(--color-danger); }
.console-row--warn  { background: rgba(245,166,35,0.04); border-left: 3px solid var(--color-warning); }
.console-time { color: var(--color-text-muted); flex-shrink: 0; font-size: 11px; }
.console-type { font-size: 9px; font-weight: var(--weight-bold); text-transform: uppercase; padding: 1px 4px; border-radius: 2px; flex-shrink: 0; margin-top: 1px; }
.console-type--info  { background: var(--color-info-bg);    color: #8ab4ff; }
.console-type--warn  { background: var(--color-warning-bg); color: #ffd080; }
.console-type--error { background: var(--color-danger-bg);  color: #ff8ab4; }
.console-msg { color: var(--color-text-secondary); line-height: 1.5; word-break: break-all; }

/* Network */
.network-view { overflow-y: auto; height: 100%; }
.network-row {
  display: grid;
  grid-template-columns: 64px 1fr 48px 80px;
  align-items: center;
  padding: 0 var(--space-3);
  height: 32px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  gap: var(--space-2);
  font-size: 12px;
}
.network-row:hover { background: var(--color-surface-2); }
.method-badge {
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  text-align: center;
}
.method-badge--get    { background: var(--color-success-bg); color: #7affcc; }
.method-badge--post   { background: var(--color-info-bg);    color: #8ab4ff; }
.method-badge--put    { background: var(--color-warning-bg); color: #ffd080; }
.method-badge--delete { background: var(--color-danger-bg);  color: #ff8ab4; }
.network-url { color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; }
.status-code { font-family: var(--font-mono); font-size: 11px; }
.status-code--2xx { color: var(--color-success); }
.status-code--4xx { color: var(--color-warning); }
.status-code--5xx { color: var(--color-danger); }
.timing-bar-wrap { display: flex; align-items: center; gap: var(--space-1); }
.timing-bar { height: 3px; border-radius: 2px; background: var(--color-accent-b); opacity: 0.6; }
.timing-ms { font-size: 10px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* Preview footer */
.preview-footer {
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-1);
  flex-shrink: 0;
}
.preview-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.preview-status-dot--ready   { background: var(--color-success); }
.preview-status-dot--building { background: var(--color-warning); animation: pulse 1s ease-in-out infinite; }
.preview-status-dot--error   { background: var(--color-danger); }
.preview-status-text { font-size: 12px; color: var(--color-text-muted); }
.preview-footer-spacer { flex: 1; }

/* ===== CODE EDITOR ===== */
.code-view-split {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.file-tree {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  background: var(--color-surface-1);
}
.file-tree-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
}
.file-tree-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 28px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  user-select: none;
}
.file-tree-item:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.file-tree-item.active { background: var(--color-surface-3); color: var(--color-text-primary); }
.file-tree-item--folder { font-weight: var(--weight-medium); }
.file-tree-indent-1 { padding-left: calc(var(--space-3) + 12px); }
.file-tree-indent-2 { padding-left: calc(var(--space-3) + 24px); }

.code-editor-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.code-editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-1);
  flex-shrink: 0;
  overflow-x: auto;
}
.code-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 36px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.code-tab:hover { background: var(--color-surface-2); color: var(--color-text-secondary); }
.code-tab.active { background: var(--color-bg); color: var(--color-text-primary); }
.code-tab-close {
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast), background var(--duration-fast);
  color: var(--color-text-muted);
}
.code-tab:hover .code-tab-close, .code-tab.active .code-tab-close { opacity: 1; }
.code-tab-close:hover { background: var(--color-surface-4); color: var(--color-text-primary); }

.code-breadcrumbs {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  height: 28px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-1);
  flex-shrink: 0;
}

/* Code editor layers */
.code-editor {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--color-bg);
  font-size: 12.5px;
  line-height: 1.8;
}
.line-highlight {
  position: absolute;
  left: 40px;
  right: 0;
  background: rgba(255,255,255,0.03);
  pointer-events: none;
  transition: top 80ms;
  height: calc(12.5px * 1.8);
}
.line-numbers {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  text-align: right;
  padding: var(--space-3) var(--space-2) var(--space-3) 0;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}
.code-textarea {
  position: absolute;
  inset: 0;
  padding: var(--space-3) var(--space-3) var(--space-3) 48px;
  background: transparent;
  color: transparent;
  caret-color: var(--color-accent-b);
  resize: none;
  z-index: 1;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.8;
  overflow: auto;
  white-space: pre;
}
.code-highlight-overlay {
  position: absolute;
  inset: 0;
  padding: var(--space-3) var(--space-3) var(--space-3) 48px;
  pointer-events: none;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.8;
  overflow: hidden;
  color: var(--color-text-primary);
}

/* Syntax highlight colors */
.sh-keyword  { color: #ff8ab4; }
.sh-string   { color: #a3ffda; }
.sh-comment  { color: var(--color-text-muted); font-style: italic; }
.sh-number   { color: #ffd080; }
.sh-function { color: #8ab4ff; }
.sh-tag      { color: #ff8ab4; }
.sh-attr     { color: #ffd080; }
.sh-value    { color: #a3ffda; }

/* Find/replace bar */
.find-replace-bar {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-1);
  flex-shrink: 0;
}
.find-replace-bar.active { display: flex; animation: slide-down var(--duration-fast) var(--ease-out); }
.find-input {
  width: 200px;
  height: 28px;
  padding: 0 var(--space-2);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 12px;
  outline: none;
}
.find-input:focus { border-color: rgba(51,102,255,0.5); }
.find-match-count { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; }

/* Diff highlight */
.diff-added   { background: rgba(51,255,153,0.06); border-left: 3px solid var(--color-accent-g); color: #c8ffd4; }
.diff-removed { background: rgba(255,51,102,0.06); border-left: 3px solid var(--color-accent-r); color: #ffc8d4; }

/* ===== VERSION HISTORY ===== */
.history-layout { display: flex; height: 100%; overflow: hidden; }
.history-timeline {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: var(--space-4);
  position: relative;
}
.history-timeline::before {
  content: '';
  position: absolute;
  left: calc(var(--space-4) + 7px);
  top: var(--space-8);
  bottom: var(--space-4);
  width: 2px;
  background: var(--color-border);
}
.history-version-entry {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  cursor: pointer;
  position: relative;
}
.history-version-entry.active .history-version-card {
  border-color: var(--color-accent-b);
  background: var(--color-surface-2);
}
.history-node {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  z-index: 1;
  transition: border-color var(--duration-base);
}
.history-version-entry.active .history-node,
.history-version-entry:hover .history-node { border-color: var(--color-accent-b); }
.history-version-entry:first-child .history-node {
  width: 16px;
  height: 16px;
  background: var(--accent-gradient);
  border: none;
  margin-top: 2px;
}
.history-version-card {
  flex: 1;
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}
.history-version-card:hover { border-color: #3a3a3a; background: var(--color-surface-2); }
.history-version-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.history-version-summary { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.4; }
.history-version-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.history-detail-panel { flex: 1; overflow-y: auto; padding: var(--space-6); }
.history-detail-title { font-size: var(--text-xl); font-weight: var(--weight-semibold); margin-bottom: var(--space-4); }

/* ===== SETTINGS LAYOUT ===== */
.settings-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.settings-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-1);
  padding: var(--space-6) var(--space-3);
  overflow-y: auto;
}
.settings-section-label {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--color-text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
  margin-top: var(--space-3);
}
.settings-section-label:first-child { margin-top: 0; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.settings-nav-item:hover { background: var(--color-surface-3); color: var(--color-text-primary); }
.settings-nav-item.active { background: var(--color-surface-3); color: var(--color-text-primary); border-left: 2px solid var(--color-accent-b); }
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8) var(--space-6);
  max-width: 680px;
  position: relative;
}
.settings-section-title { font-size: var(--text-xl); font-weight: var(--weight-semibold); margin-bottom: 4px; letter-spacing: -0.3px; }
.settings-section-desc { font-size: var(--text-sm); color: var(--color-text-secondary); margin-bottom: var(--space-6); }
.settings-divider { height: 1px; background: var(--color-border); margin: var(--space-6) 0; }

/* ===== ONBOARDING OVERLAY ===== */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
}
.onboarding-overlay.active { display: flex; }
.onboarding-card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: calc(100vw - 32px);
  padding: var(--space-8);
  position: relative;
  box-shadow: var(--shadow-elevated);
  animation: fade-in var(--duration-slow) var(--ease-out);
}
.onboarding-step { display: none; }
.onboarding-step.active { display: block; }
.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}
.onboarding-skip {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

/* ===== AUTH PAGES ===== */
.auth-layout {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  background: var(--color-bg);
  position: relative;
  overflow: hidden;
}
.auth-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.auth-bg-orb--1 {
  width: 500px; height: 500px;
  background: rgba(51,102,255,0.06);
  top: -150px; right: -100px;
}
.auth-bg-orb--2 {
  width: 400px; height: 400px;
  background: rgba(255,51,102,0.04);
  bottom: -100px; left: -100px;
}
.auth-card {
  width: 440px;
  max-width: 100%;
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 120px rgba(51,102,255,0.08);
}
.auth-logo {
  text-align: center;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-6);
  display: block;
}
.auth-title { font-size: var(--text-2xl); font-weight: var(--weight-semibold); text-align: center; letter-spacing: -0.5px; margin-bottom: 4px; }
.auth-subtitle { font-size: var(--text-sm); color: var(--color-text-secondary); text-align: center; margin-bottom: var(--space-6); }

/* ===== LANDING PAGE ===== */
.site-wrap { overflow-y: auto; height: 100vh; }
.site-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-dropdown);
  transition: background var(--duration-base), border-color var(--duration-base);
}
.site-nav.nav--scrolled {
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #1a1a1a;
}
.site-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 64px;
  display: flex;
  align-items: center;
  gap: var(--space-8);
}
.site-nav-logo {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  flex-shrink: 0;
}
.site-nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  flex: 1;
  justify-content: center;
}
.site-nav-link {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast);
}
.site-nav-link:hover { color: var(--color-text-primary); }
.site-nav-actions { display: flex; align-items: center; gap: var(--space-2); }
.site-nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}
.site-nav-hamburger:hover { background: var(--color-surface-3); }
.hamburger-bar {
  width: 20px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition: transform 200ms, opacity 100ms;
}

/* Mobile nav drawer */
.mobile-nav-drawer {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: #0d0d0d;
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-dropdown);
  transform: translateY(-100%);
  transition: transform 250ms var(--ease-out);
  pointer-events: none;
}
.mobile-nav-drawer.open { transform: translateY(0); pointer-events: all; }
.mobile-nav-drawer-links { display: flex; flex-direction: column; padding: var(--space-2) 0; }
.mobile-nav-drawer-link {
  padding: 0 var(--space-4);
  height: 48px;
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.mobile-nav-drawer-link:hover { background: var(--color-surface-2); color: var(--color-text-primary); }
.mobile-nav-drawer-actions { padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); border-top: 1px solid var(--color-border); }

/* Landing sections */
.landing-section { padding: var(--space-16) var(--space-6); max-width: 1200px; margin: 0 auto; }
.section-fade { opacity: 0; transform: translateY(20px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
.section-fade.visible { opacity: 1; transform: translateY(0); }

/* Mobile bottom nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-surface-1);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-dropdown);
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bottom-nav-items {
  display: flex;
  height: 56px;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color var(--duration-fast);
  font-size: 10px;
}
.mobile-nav-item.active { color: var(--color-accent-b); }
.mobile-nav-item:hover { color: var(--color-text-secondary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 768px) {
  html, body { overflow: auto; }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar { display: none; }

  .builder-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "btopbar" "bcenter";
  }
  .builder-sidebar { display: none; }
  .builder-preview { display: none; }
  .builder-shell .builder-center { grid-area: bcenter; }

  .mobile-bottom-nav { display: block; }
  .main { padding-bottom: 56px; }
  .chat-panel { padding-bottom: 56px; }

  .site-nav-links { display: none; }
  .site-nav-actions .btn-ghost { display: none; }
  .site-nav-hamburger { display: flex; }

  .card-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .chat-welcome-cards { grid-template-columns: 1fr 1fr; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90vh; }

  .history-layout { flex-direction: column; }
  .history-timeline { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid var(--color-border); }

  .settings-layout { flex-direction: column; }
  .settings-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--color-border); padding: var(--space-3); }
  .settings-nav-item { display: inline-flex; }

  .notification-panel { width: 100%; }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
  .chat-welcome-cards { grid-template-columns: 1fr; }
  .auth-card { padding: var(--space-6); }
  .page { padding: var(--space-4); }
}
