@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root, [data-theme="light"] {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --color-bg: #f5f5f3;
  --color-surface: #ffffff;
  --color-surface-2: #fafaf8;
  --color-surface-offset: #ececea;
  --color-divider: #dddbd8;
  --color-border: #d0cec9;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-text-faint: #a0a0a0;
  --color-text-inverse: #ffffff;

  --color-primary: #0c5e63;
  --color-primary-hover: #094a4e;
  --color-primary-light: #e6f2f2;
  --color-primary-surface: #d4eced;

  --color-success: #1a7a3a;
  --color-success-bg: #e8f5e9;
  --color-error: #c62828;
  --color-error-bg: #fce4ec;
  --color-warning: #e65100;
  --color-warning-bg: #fff3e0;
  --color-info: #1565c0;
  --color-info-bg: #e3f2fd;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --transition: 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --color-bg: #141414;
  --color-surface: #1e1e1e;
  --color-surface-2: #252525;
  --color-surface-offset: #1a1a1a;
  --color-divider: #2e2e2e;
  --color-border: #3a3a3a;
  --color-text: #e0e0e0;
  --color-text-muted: #888;
  --color-text-faint: #555;
  --color-text-inverse: #1a1a1a;

  --color-primary: #4db6ac;
  --color-primary-hover: #26a69a;
  --color-primary-light: #1a2e2e;
  --color-primary-surface: #1e3232;

  --color-success: #66bb6a;
  --color-success-bg: #1a2e1a;
  --color-error: #ef5350;
  --color-error-bg: #2e1a1a;
  --color-warning: #ffa726;
  --color-warning-bg: #2e2a1a;
  --color-info: #42a5f5;
  --color-info-bg: #1a2a3e;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ─── Layout ─── */

.app-layout {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: 48px 1fr;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  z-index: 100;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--color-primary);
  white-space: nowrap;
}

.app-header .logo svg {
  width: 24px;
  height: 24px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.app-sidebar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  z-index: 90;
}

.sidebar-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: all var(--transition);
  position: relative;
}

.sidebar-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.sidebar-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.sidebar-btn svg {
  width: 20px;
  height: 20px;
}

.sidebar-btn .tooltip {
  position: absolute;
  left: 52px;
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 200;
}

.sidebar-btn:hover .tooltip {
  opacity: 1;
}

.app-main {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  overflow: hidden;
}

/* ─── Left Panel ─── */

.panel-left {
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel-section {
  border-bottom: 1px solid var(--color-divider);
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.panel-section-header:hover {
  background: var(--color-surface-offset);
}

.panel-section-header .chevron {
  width: 14px;
  height: 14px;
  transition: transform var(--transition);
}

.panel-section-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.panel-section-content {
  padding: 0 16px 12px;
}

.panel-section-content.collapsed {
  display: none;
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

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

.btn-secondary {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-divider);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.btn-icon:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-success {
  background: var(--color-success);
  color: white;
}

/* ─── Canvas Area ─── */

.canvas-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  min-height: 40px;
}

.canvas-toolbar .toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  border-right: 1px solid var(--color-divider);
}

.canvas-toolbar .toolbar-group:last-child {
  border-right: none;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.toolbar-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.toolbar-btn.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.toolbar-btn svg {
  width: 18px;
  height: 18px;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

#canvas2d {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.view-indicator {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.view-indicator .btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

.view-indicator .btn.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

.canvas-overlay-info {
  position: absolute;
  top: 12px;
  left: 12px;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  font-size: 12px;
  color: var(--color-text-muted);
  z-index: 10;
}

/* ─── HVAC Diagram ─── */

.hvac-canvas {
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  background-image:
    radial-gradient(circle, var(--color-divider) 1px, transparent 1px);
  background-size: 20px 20px;
}

.hvac-node {
  position: absolute;
  padding: 8px 14px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  z-index: 5;
}

.hvac-node:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.hvac-node.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.hvac-node .node-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.hvac-node .node-icon {
  width: 28px;
  height: 28px;
  margin: 4px auto;
}

.hvac-node.type-rtu { border-left: 4px solid var(--color-info); }
.hvac-node.type-ahu { border-left: 4px solid var(--color-primary); }
.hvac-node.type-boiler { border-left: 4px solid var(--color-error); }
.hvac-node.type-chiller { border-left: 4px solid var(--color-info); }
.hvac-node.type-heatpump { border-left: 4px solid var(--color-success); }
.hvac-node.type-vrf { border-left: 4px solid #7b1fa2; }
.hvac-node.type-zone { border-left: 4px solid var(--color-warning); }

/* ─── Compliance Panel ─── */

.compliance-panel {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.compliance-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.summary-card {
  padding: 14px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  text-align: center;
}

.summary-card .value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.summary-card .label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.summary-card.pass .value { color: var(--color-success); }
.summary-card.fail .value { color: var(--color-error); }
.summary-card.warn .value { color: var(--color-warning); }

.compliance-table {
  width: 100%;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  overflow: hidden;
}

.compliance-table th {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
}

.compliance-table td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-divider);
  vertical-align: top;
}

.compliance-table tr:last-child td {
  border-bottom: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.pass { background: var(--color-success-bg); color: var(--color-success); }
.status-badge.fail { background: var(--color-error-bg); color: var(--color-error); }
.status-badge.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.status-badge.info { background: var(--color-info-bg); color: var(--color-info); }

/* ─── Tabs ─── */

.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
}

.tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ─── Story/Space Tree ─── */

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

.tree-item:hover {
  background: var(--color-surface-offset);
}

.tree-item.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.tree-item .tree-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.tree-item .tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children {
  padding-left: 20px;
}

.tree-item .tree-actions {
  display: none;
  gap: 2px;
}

.tree-item:hover .tree-actions {
  display: flex;
}

/* ─── Empty State ─── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.empty-state .desc {
  font-size: 13px;
  margin-bottom: 16px;
  max-width: 280px;
}

/* ─── Scrollbar ─── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-divider); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border); }

/* ─── Modal ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-divider);
}

/* ─── Tag/Chip ─── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border: 1px solid var(--color-divider);
}

/* ─── Project info in header ─── */

.project-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-left: 1px solid var(--color-divider);
  font-size: 13px;
}

.project-info .sep {
  color: var(--color-text-faint);
}

/* ─── Footer ─── */

.app-footer {
  position: fixed;
  bottom: 0;
  right: 0;
  padding: 4px 12px;
  font-size: 10px;
  color: var(--color-text-faint);
  z-index: 50;
}

.app-footer a {
  color: var(--color-text-faint);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--color-text-muted);
}

/* ─── Animations ─── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 200ms ease-out;
}

/* ─── AI Chat Panel ─── */

.panel-right {
  width: 380px;
  min-width: 320px;
  background: var(--color-surface);
  border-left: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 200ms ease, opacity 200ms ease;
}

.panel-right.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 12px 16px;
  gap: 8px;
}

.chat-welcome-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .chat-welcome-icon {
  background: rgba(77, 182, 172, 0.12);
}

.chat-welcome-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.chat-welcome-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: 280px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  justify-content: center;
}

.chat-suggestion {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.chat-suggestion:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

[data-theme="dark"] .chat-suggestion:hover {
  background: rgba(77, 182, 172, 0.1);
}

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 200ms ease-out;
}

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

.chat-msg.assistant {
  align-items: flex-start;
}

.chat-msg-bubble {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant .chat-msg-bubble {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-divider);
}

.chat-msg-bubble p { margin: 0 0 8px 0; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble strong { font-weight: 600; }
.chat-msg-bubble code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 3px;
}
[data-theme="dark"] .chat-msg-bubble code {
  background: rgba(255,255,255,0.08);
}
.chat-msg-bubble ul, .chat-msg-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}
.chat-msg-bubble li {
  margin-bottom: 2px;
}

/* Tool call indicators */
.chat-tool-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
  padding: 4px 10px;
  background: var(--color-surface-offset);
  border-radius: 8px;
  margin: 2px 0;
}

.chat-tool-indicator svg {
  flex-shrink: 0;
}

.chat-tool-indicator.editing { color: var(--color-warning); }
.chat-tool-indicator.simulating { color: var(--color-info); }
.chat-tool-indicator.comparing { color: var(--color-primary); }
.chat-tool-indicator.code { color: var(--color-success); }

/* Simulation result card in chat */
.chat-sim-result {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  margin-top: 6px;
  max-width: 92%;
}

.chat-sim-result .sim-eui {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.chat-sim-result .sim-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-sim-result .sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.chat-sim-result .sim-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid var(--color-divider);
}

.chat-sim-result .sim-row:last-child { border-bottom: none; }

/* Comparison card */
.chat-comparison {
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  margin-top: 6px;
  max-width: 92%;
}

.chat-comparison .cmp-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: 8px;
}

.chat-comparison .cmp-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  text-align: center;
  padding: 3px 0;
}

.chat-comparison .cmp-savings {
  color: var(--color-success);
  font-weight: 600;
}

/* Edit notification badges */
.chat-edit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-weight: 500;
  margin: 2px 0;
}

[data-theme="dark"] .chat-edit-badge {
  background: rgba(230, 81, 0, 0.12);
}

/* Loading dots */
.chat-loading {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.chat-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: chatBounce 1.4s infinite ease-in-out both;
}

.chat-loading-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-loading-dot:nth-child(2) { animation-delay: -0.16s; }
.chat-loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-input-area textarea {
  flex: 1;
  border: 1px solid var(--color-divider);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font-body);
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition);
}

.chat-input-area textarea:focus {
  border-color: var(--color-primary);
}

.chat-input-area textarea::placeholder {
  color: var(--color-text-faint);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--color-primary-hover); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Chat toggle button */
.chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: all var(--transition);
}

.chat-toggle-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.chat-toggle-btn.hidden {
  display: none;
}



/* ─── Responsive ─── */

@media (max-width: 1200px) {
  .panel-right {
    width: 320px;
    min-width: 280px;
  }
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
  .panel-left {
    display: none;
  }
  .panel-right {
    position: fixed;
    right: 0;
    top: 48px;
    bottom: 0;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .panel-right.collapsed {
    transform: translateX(100%);
  }
}
