/* ===== mape Design System — Light Theme ===== */
/* Official Brand: Slate Indigo #4A556D, Sage #9DBCB0, Sand #E4CFA1, Coral #FF5757 */
/* Logo SVG colors: Blue-gray #6D7A96, Sage #9DBCB0, Gold #E4CFA1 */
/* Font: Montserrat + JetBrains Mono */

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

:root {
  /* Brand Colors — Official Slate Indigo palette */
  --brand-primary: #4A556D;
  --brand-primary-light: #5D6A85;
  --brand-secondary: #9DBCB0;
  --brand-accent: #E4CFA1;
  --brand-dark: #3E415A;
  --brand-black: #2B2F42;
  --logo-blue-gray: #6D7A96;

  /* Coral Accent — CTAs and interactive highlights */
  --accent-coral: #FF5757;
  --accent-coral-light: rgba(255, 87, 87, 0.15);
  --accent-coral-dark: #E04A4A;

  /* Light Theme — Warm Beige / White */
  --bg-light: #F6F3EA;
  --bg-white: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F0EDE4;
  --bg-dark: #3E415A;
  --bg-hover: rgba(74, 85, 109, 0.06);
  --bg-active: rgba(74, 85, 109, 0.10);

  /* Text — Dark on Light */
  --text-primary: #2B2F42;
  --text-secondary: #4A4F66;
  --text-muted: #7A7F95;
  --text-inverse: #FFFFFF;
  --text-accent: var(--brand-primary-light);
  --text-link: var(--brand-primary-light);

  /* Borders — Solid Beige */
  --border-color: #D8D5CC;
  --border-light: #E8E5DC;
  --border-dark: #C5C2B9;

  /* Shadows — Light */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-primary: 0 4px 14px rgba(74, 85, 109, 0.2);
  --shadow-secondary: 0 4px 14px rgba(157, 188, 176, 0.25);

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  --gradient-warm: linear-gradient(135deg, var(--brand-accent), var(--brand-secondary));

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius — Aligned to clinton (smaller) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions — Smooth */
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Layout */
  --sidebar-width: 260px;
  --detail-panel-width: 380px;
  --header-height: 52px;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg-light);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.01em;
}

body.theme-dark {
  --brand-primary: #A5B0C7;
  --brand-primary-light: #C1C8D9;
  --brand-secondary: #87AFA0;
  --brand-accent: #D8BE8E;
  --brand-dark: #111827;
  --brand-black: #0F172A;

  --accent-coral: #FF7A72;
  --accent-coral-light: rgba(255, 122, 114, 0.18);
  --accent-coral-dark: #FF5F57;

  --bg-light: #1B2230;
  --bg-white: #141B26;
  --bg-card: #141B26;
  --bg-card-hover: #1F2A3A;
  --bg-dark: #0B111A;
  --bg-hover: rgba(165, 176, 199, 0.16);
  --bg-active: rgba(165, 176, 199, 0.22);

  --text-primary: #E6ECF7;
  --text-secondary: #C2CDE0;
  --text-muted: #8E9AB1;
  --text-inverse: #0B111A;
  --text-accent: #C1C8D9;
  --text-link: #B9C7E8;

  --border-color: #2D3A4F;
  --border-light: #36455D;
  --border-dark: #455672;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 10px 18px -10px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 28px -10px rgba(0, 0, 0, 0.55);
  --shadow-primary: 0 6px 18px rgba(165, 176, 199, 0.24);
  --shadow-secondary: 0 6px 18px rgba(135, 175, 160, 0.24);
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

/* ===== App Layout ===== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--duration-normal) var(--ease-out);
  z-index: 100;
}

.sidebar:not(.open) {
  width: 0;
  border-right-color: transparent;
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  width: 148px;
}

.sidebar-logo .logo-icon {
  width: 100%;
  height: auto;
  display: block;
}

.sidebar-logo .logo-light {
  display: none;
}

body.theme-dark .sidebar-logo .logo-dark,
html[data-mode="dark"] .sidebar-logo .logo-dark {
  display: none;
}

body.theme-dark .sidebar-logo .logo-light,
html[data-mode="dark"] .sidebar-logo .logo-light {
  display: block;
}

.sidebar-logo .logo-text {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.sidebar-logo .logo-dot-accent {
  color: var(--brand-secondary);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: calc(100% - var(--space-lg) * 2);
  margin: var(--space-md) var(--space-lg);
  padding: var(--space-md);
  background: var(--accent-coral-light);
  color: var(--accent-coral);
  border: 1px solid rgba(255, 87, 87, 0.25);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--duration-fast) var(--ease-out);
}

.new-chat-btn:hover {
  background: rgba(255, 87, 87, 0.22);
  border-color: rgba(255, 87, 87, 0.35);
  transform: translateY(-1px);
}

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

.sidebar-section-title {
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-sm);
}

.chat-history-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin: 2px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: 13px;
  color: var(--text-secondary);
}

.chat-history-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.chat-history-item.active {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.chat-mode-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  margin-top: 2px;
}

.chat-history-content {
  flex: 1;
  min-width: 0;
}

.chat-history-main-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-history-item .chat-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.chat-history-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.chat-history-item.active .chat-history-meta-row {
  color: rgba(255, 255, 255, 0.7);
}

.chat-mode-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  flex-shrink: 0;
}

.market-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 16px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: rgba(74, 85, 109, 0.08);
  color: var(--brand-primary);
  border: 1px solid rgba(74, 85, 109, 0.15);
}

.chat-history-item.active .market-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.48);
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-md);
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-controls-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 32px;
}

.sidebar-theme-btn {
  width: auto;
  min-width: 0;
  width: 32px;
  height: 32px;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0;
  gap: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg-light);
}

.sidebar-theme-btn:hover {
  border-color: var(--border-dark);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.theme-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.85;
}

.theme-icon-dark {
  display: none;
}

body.theme-dark .theme-icon-light {
  display: none;
}

body.theme-dark .theme-icon-dark {
  display: inline-flex;
}

.theme-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.market-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 32px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--brand-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  transition: all var(--duration-fast);
}

.market-pill:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-dark);
}

.market-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  flex-shrink: 0;
}

.market-dot[data-market="DE"] {
  background: var(--brand-primary);
}

.market-dot[data-market="PL"] {
  background: var(--brand-secondary);
}

.market-dot[data-market="ES"] {
  background: var(--accent-coral);
}

.market-label {
  line-height: 1;
  letter-spacing: 0.02em;
}

.market-profile-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.market-profile-dot[data-market="PL"] {
  background: var(--brand-secondary);
}

.market-profile-dot[data-market="ES"] {
  background: var(--accent-coral);
}

.sidebar-settings-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.sidebar-settings-btn:hover {
  border-color: var(--border-dark);
  color: var(--text-primary);
}

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

.sidebar-auth-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.sidebar-auth-btn:hover {
  border-color: var(--border-dark);
  color: var(--text-primary);
}

.sidebar-auth-btn.hidden {
  display: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-inverse);
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-image.hidden {
  display: none;
}

.user-info {
  flex: 1;
  min-width: 0;
}

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

.user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.main-content.panel-open {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.main-content.panel-open.panel-fullview {
  grid-template-columns: 1fr;
}

/* ===== Top Bar ===== */
.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-white);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-title[data-mode="demo"]::after {
  content: "Demo";
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.08);
  border: 1px solid rgba(74, 85, 109, 0.15);
  border-radius: 999px;
  padding: 2px 6px;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: rgba(74, 85, 109, 0.08);
  color: var(--brand-primary);
  border: 1px solid rgba(74, 85, 109, 0.15);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
  color: var(--text-muted);
}

.topbar-nav-btn {
  width: auto;
  min-width: 36px;
  padding: 0 10px;
  gap: 6px;
  border: 1px solid transparent;
}

.topbar-btn-label {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

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

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

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

.menu-toggle {
  display: flex;
}

/* ===== Chat Area ===== */
.chat-area {
  grid-column: 1;
  grid-row: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-light);
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl) 0;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

/* Messages */
.message-wrapper {
  padding: var(--space-md) var(--space-xl);
  max-width: 850px;
  margin: 0 auto;
  width: 100%;
  animation: messageIn var(--duration-normal) var(--ease-out);
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-wrapper.user-message {
  display: flex;
  justify-content: flex-end;
}

.message-wrapper.user-message .message-content {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  max-width: 75%;
  font-size: 14px;
}

.message-wrapper.ai-message {
  display: flex;
  gap: var(--space-md);
}

.ai-side-control {
  width: 32px;
  height: 32px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-side-control svg {
  width: 18px;
  height: 18px;
  color: var(--brand-primary);
}

.ai-copy-btn {
  cursor: pointer;
}

.ai-copy-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
}

.ai-message-body {
  flex: 1;
  min-width: 0;
}

.ai-message-body .message-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
}

.ai-message-body .message-content p {
  margin-bottom: var(--space-md);
}

.ai-message-body .message-content p:last-child {
  margin-bottom: 0;
}

.ai-message-body .message-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.ai-message-body .message-content code {
  background: var(--bg-card-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
}

.ai-message-body .message-content pre {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
}

.ai-message-body .message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

/* Message Actions */
.message-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.message-wrapper:hover .message-actions {
  opacity: 1;
}

.msg-action-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all var(--duration-fast);
}

.msg-action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
}

.msg-action-btn svg {
  width: 14px;
  height: 14px;
}

/* Welcome Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2xl);
  animation: fadeIn var(--duration-slow) var(--ease-out);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.welcome-logo {
  width: 56px;
  height: 56px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.welcome-logo svg {
  width: 32px;
  height: 32px;
  color: var(--brand-primary);
}

.welcome-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.logo-unfold img,
.logo-unfold svg {
  animation: mape-unfold 1.6s cubic-bezier(0.22, 1, 0.36, 1) 1 forwards;
}

@keyframes mape-unfold {
  0% {
    clip-path: circle(16px at center);
    transform: scale(0.5);
    opacity: 0.3;
  }
  60% {
    clip-path: circle(48px at center);
    transform: scale(1.05);
    opacity: 1;
  }
  80% {
    clip-path: none;
    transform: scale(0.98);
    opacity: 1;
  }
  100% {
    clip-path: none;
    transform: scale(1);
    opacity: 1;
  }
}

.welcome-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.welcome-title span {
  color: var(--accent-coral);
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 480px;
  margin-bottom: var(--space-2xl);
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  max-width: 700px;
  width: 100%;
}

.welcome-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: left;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.welcome-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.welcome-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.welcome-card-icon svg {
  width: 20px;
  height: 20px;
  color: var(--brand-primary);
}

.welcome-card-icon.newsletter {
  background: var(--accent-coral-light);
}

.welcome-card-icon.segment {
  background: rgba(157, 188, 176, 0.15);
}

.welcome-card-icon.consultant {
  background: rgba(228, 207, 161, 0.15);
}

.welcome-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.welcome-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== Input Area ===== */
.input-area {
  padding: var(--space-md) var(--space-xl) var(--space-lg);
  max-width: 850px;
  margin: 0 auto;
  width: 100%;
}

.mode-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mode-selector-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.mode-selector {
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 0 10px;
}

.mode-selector:focus {
  border-color: var(--brand-primary);
}

.input-container {
  position: relative;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: all var(--duration-fast);
  overflow: hidden;
}

.input-container:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(74, 85, 109, 0.1);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-md);
}

#chat-input {
  flex: 1;
  min-height: 24px;
  max-height: 150px;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  padding: var(--space-sm) 0;
  color: var(--text-primary);
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-coral);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
  flex-shrink: 0;
  opacity: 0.3;
}

.send-btn.active {
  opacity: 1;
}

.send-btn:hover.active {
  transform: scale(1.05);
  background: var(--accent-coral-dark);
}

.send-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-sm);
}

/* ===== Detail Panel ===== */
.detail-panel {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  background: var(--bg-white);
  border-left: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  position: relative;
  z-index: 90;
  min-width: 0;
  opacity: 0;
}

.main-content.panel-open .detail-panel {
  display: flex;
  opacity: 1;
}

.detail-panel[data-view="email"] .detail-panel-body {
  padding: 0;
  overflow: hidden;
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-white);
  min-height: var(--header-height);
}

.detail-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-panel-title {
  font-size: 14px;
  font-weight: 600;
}

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

.detail-panel-expand {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--duration-fast);
}

.detail-panel-expand:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.detail-panel-expand .panel-expand-close {
  display: none;
}

.main-content.panel-fullview .detail-panel-expand {
  background: var(--bg-hover);
  color: var(--brand-primary);
}

.main-content.panel-fullview .detail-panel-expand .panel-expand-open {
  display: none;
}

.main-content.panel-fullview .detail-panel-expand .panel-expand-close {
  display: inline-flex;
}

.detail-panel-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

@media (min-width: 1025px) {
  .main-content.panel-open.panel-fullview .chat-area {
    display: none;
  }

  .main-content.panel-open.panel-fullview .detail-panel {
    grid-column: 1;
    border-left: none;
  }
}

/* Feature styles moved to app.css */

/* ===== Asset Cards (Campaign Overview) ===== */
.asset-grid {
  display: grid;
  gap: var(--space-md);
}

.asset-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.asset-card:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-sm);
}

.asset-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.asset-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.asset-type-badge.email {
  background: rgba(74, 85, 109, 0.10);
  color: var(--brand-primary);
}

.asset-type-badge.segment {
  background: rgba(74, 85, 109, 0.10);
  color: var(--brand-primary);
}

.asset-type-badge.draft {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
}

.asset-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
}

.asset-status-dot.draft {
  background: var(--text-muted);
}

.asset-card h4 {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.asset-card p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Code Block / SQL Preview ===== */
.code-block {
  position: relative;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-md) 0;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.code-block-header .lang-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-muted);
  transition: all var(--duration-fast);
}

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

.code-block pre {
  padding: var(--space-md);
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  margin: 0;
  background: none;
  border: none;
}

.code-block pre code {
  background: none;
  padding: 0;
}

/* SQL Keywords */
.sql-keyword {
  color: var(--brand-primary);
  font-weight: 600;
}

.sql-string {
  color: var(--brand-primary);
}

.sql-number {
  color: var(--brand-secondary);
}

.sql-comment {
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Collapsible Section ===== */
.collapsible {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card-hover);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.collapsible-header:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.collapsible-header svg {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast);
}

.collapsible.open .collapsible-header svg {
  transform: rotate(90deg);
}

.collapsible-body {
  display: none;
  padding: var(--space-md);
}

.collapsible.open .collapsible-body {
  display: block;
}

/* ===== Info Banner ===== */
.info-banner {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  margin: var(--space-md) 0;
}

.info-banner.blue {
  background: rgba(74, 85, 109, 0.06);
  border: 1px solid rgba(74, 85, 109, 0.15);
  color: var(--brand-primary);
}

.info-banner.orange {
  background: rgba(228, 207, 161, 0.12);
  border: 1px solid rgba(228, 207, 161, 0.3);
  color: var(--brand-dark);
}

.info-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== Progress Stepper ===== */
.stepper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  margin: var(--space-md) 0;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.stepper-step.active {
  color: var(--brand-primary);
}

.stepper-step.completed {
  color: var(--brand-primary);
}

.stepper-dot {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.stepper-step.active .stepper-dot {
  border-color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.1);
  color: var(--brand-primary);
}

.stepper-step.completed .stepper-dot {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.stepper-line {
  width: 32px;
  height: 2px;
  background: var(--border-color);
}

.stepper-line.completed {
  background: var(--brand-primary);
}

/* ===== Email Preview ===== */
.email-preview-frame {
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: var(--space-md) 0;
}

.email-preview-frame iframe {
  width: 100%;
  height: 400px;
  border: none;
}

/* ===== Data Table ===== */
.data-table-wrapper {
  overflow-x: auto;
  margin: var(--space-md) 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card-hover);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.data-table .editable {
  cursor: pointer;
  position: relative;
}

.data-table .editable:hover {
  background: var(--bg-card-hover);
}

/* ===== Toast Notification ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--duration-normal) var(--ease-out);
  max-width: 360px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.success {
  border-left: 3px solid var(--brand-secondary);
}

.toast.error {
  border-left: 3px solid var(--accent-coral);
}

.toast.info {
  border-left: 3px solid var(--brand-primary);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ===== Onboarding Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--duration-fast);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--duration-normal) var(--ease-out);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-body {
  padding: var(--space-2xl);
  text-align: center;
}

.onboarding-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: var(--radius-md);
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-icon svg {
  width: 26px;
  height: 26px;
  color: var(--brand-primary);
}

.modal-body h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.modal-body p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-2xl) var(--space-lg);
}

.modal-dots {
  display: flex;
  gap: var(--space-sm);
}

.modal-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border-color);
  transition: all var(--duration-fast);
}

.modal-dot.active {
  background: var(--brand-primary);
  width: 24px;
}

.auth-overlay {
  z-index: 650;
}

.auth-modal {
  width: 420px;
}

.auth-modal .modal-body {
  padding: 30px 26px;
  text-align: center;
}

.auth-brand {
  width: 156px;
  margin: 0 auto 16px;
}

.auth-brand-logo {
  width: 100%;
  height: auto;
  display: block;
}

.auth-brand-logo-light {
  display: none;
}

body.theme-dark .auth-brand-logo-dark,
html[data-mode="dark"] .auth-brand-logo-dark {
  display: none;
}

body.theme-dark .auth-brand-logo-light,
html[data-mode="dark"] .auth-brand-logo-light {
  display: block;
}

.auth-modal .modal-body h2 {
  margin-bottom: 8px;
}

.google-signin-button {
  min-height: 40px;
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.auth-hint {
  font-size: 12px;
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--text-muted);
}

/* ===== Auth Lock Mode ===== */
body.auth-locked .new-chat-btn,
body.auth-locked .chat-history,
body.auth-locked .sidebar-controls-row,
body.auth-locked .topbar-right,
body.auth-locked #menu-toggle,
body.auth-locked .mode-selector-row,
body.auth-locked .input-container,
body.auth-locked .detail-panel,
body.auth-locked .welcome-cards {
  pointer-events: none;
  opacity: 0.38;
}

body.auth-locked .chat-messages {
  opacity: 1;
}

.btn {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--duration-fast);
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn-primary {
  background: var(--accent-coral);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-coral-dark);
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--text-secondary);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-md);
}

.mape-loader {
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  border: 2px solid rgba(74, 85, 109, 0.18);
  border-top-color: var(--brand-primary);
  border-right-color: var(--brand-secondary);
  animation: mapeSpin 0.85s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.mape-loader-sm {
  width: 13px;
  height: 13px;
  border-width: 2px;
}

@keyframes mapeSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.brand-loader {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 243, 234, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
}

.brand-loader.active {
  opacity: 1;
}

.brand-loader.hidden {
  display: none;
}

.brand-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  min-width: 240px;
}

.loading-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-loader-icon {
  width: 72px;
  height: 72px;
  background-image: url('../img/mape-icon.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.brand-loader.active .mape-icon-unfold {
  animation: mape-unfold 1.6s cubic-bezier(0.22, 1, 0.36, 1) 1 forwards;
}

.loading-drops {
  display: flex;
  gap: var(--space-sm);
}

.loading-drop {
  width: 12px;
  height: 14px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: dropPulse 1.4s infinite ease-in-out;
}

.loading-drop:nth-child(1) {
  background: var(--brand-primary);
}

.loading-drop:nth-child(2) {
  background: var(--brand-secondary);
  animation-delay: 0.2s;
}

.loading-drop:nth-child(3) {
  background: var(--accent-coral);
  animation-delay: 0.4s;
}

@keyframes dropPulse {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.8) translateY(0);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) translateY(-4px);
  }
}

.brand-loader-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-loader-text {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

@media (prefers-reduced-motion: reduce) {
  .brand-loader.active .mape-icon-unfold,
  .loading-drop {
    animation: none;
  }
}

.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ===== Sample Data Badge ===== */
.sample-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(74, 85, 109, 0.08);
  color: var(--brand-primary);
  border: 1px solid rgba(74, 85, 109, 0.15);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .main-content {
    display: flex;
    flex-direction: column;
  }

  .main-content.panel-open {
    grid-template-columns: 1fr;
  }

  .chat-area {
    flex: 1;
  }

  .detail-panel {
    display: flex;
    position: absolute;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 100%;
    transform: translateX(100%);
    opacity: 1;
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .main-content.panel-open .detail-panel {
    transform: translateX(0);
  }

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

  .topbar-nav-btn {
    width: 36px;
    padding: 0;
  }

  .detail-panel-expand {
    display: none;
  }
}

@media (max-width: 1360px) {
  .topbar-btn-label {
    display: none;
  }

  .topbar-nav-btn {
    width: 36px;
    padding: 0;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar:not(.open) {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .welcome-cards {
    grid-template-columns: 1fr;
  }

  .message-wrapper {
    padding: var(--space-md);
  }

  .input-area {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  :root {
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 32px;
  }

  .welcome-title {
    font-size: 22px;
  }
}

/* ===== Tooltip ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: var(--bg-dark);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-inverse);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
  z-index: 50;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ===== Refinement Prompt ===== */
.refine-prompt {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(74, 85, 109, 0.04);
  border: 1px solid rgba(74, 85, 109, 0.12);
  border-radius: var(--radius-md);
  margin-top: var(--space-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: 13px;
  color: var(--brand-primary);
}

.refine-prompt:hover {
  background: rgba(74, 85, 109, 0.08);
  border-color: rgba(74, 85, 109, 0.2);
}

.refine-prompt svg {
  width: 16px;
  height: 16px;
}

/* ===== Content Block Editor ===== */

/* SFMC badge */
.sfmc-badge {
  background: rgba(74, 85, 109, 0.06);
  border: 1px solid rgba(74, 85, 109, 0.15);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--brand-primary);
  text-align: center;
  margin-bottom: var(--space-md);
  font-weight: 500;
}

/* Block Canvas */
.block-canvas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-md);
}

/* Block Card */
.block-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
  animation: blockIn var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

@keyframes blockIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.block-card:hover {
  border-color: var(--border-dark);
}

.block-card.expanded {
  border-color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.02);
  box-shadow: 0 0 0 1px rgba(74, 85, 109, 0.08);
}

.block-card.locked {
  opacity: 0.65;
}

/* Block Card Header */
.block-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 36px;
  gap: 8px;
}

.block-card.locked .block-card-header {
  cursor: default;
}

.block-card-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.block-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.block-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}

.block-lock {
  font-size: 10px;
  opacity: 0.6;
}

.block-ai-tag {
  font-size: 10px;
  background: rgba(167, 139, 250, 0.12);
  color: #7C3AED;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Block Card Actions */
.block-card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast);
  flex-shrink: 0;
}

.block-card:hover .block-card-actions {
  opacity: 1;
}

.block-action-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  transition: all var(--duration-fast);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

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

.block-action-btn.delete:hover {
  background: rgba(255, 87, 87, 0.12);
  color: var(--accent-coral);
}

/* ===== Config Panel ===== */
.block-config-panel {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: blockIn var(--duration-fast) var(--ease-out);
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.config-input,
.config-textarea,
.config-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--duration-fast);
  box-sizing: border-box;
}

.config-input:focus,
.config-textarea:focus,
.config-select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(74, 85, 109, 0.08);
}

.config-textarea {
  resize: vertical;
  min-height: 56px;
  line-height: 1.5;
}

.config-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%234A556D'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* Color picker */
.config-color-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-color-preview {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  cursor: pointer;
}

.config-color-input {
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  visibility: hidden;
  position: absolute;
}

.config-hex-input {
  width: 80px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.config-hex-input:focus {
  outline: none;
  border-color: var(--brand-primary);
}

/* Toggle */
.config-toggle-wrap {
  display: flex;
  align-items: center;
}

.config-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border-color);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background var(--duration-fast);
  padding: 0;
}

.config-toggle.on {
  background: var(--brand-primary);
}

.config-toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--duration-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.config-toggle.on .config-toggle-thumb {
  left: 18px;
}

/* ===== Block Palette ===== */
.add-block-toggle {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.add-block-toggle:hover,
.add-block-toggle.active {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.04);
}

.block-palette {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.block-palette.open {
  display: grid;
}

.palette-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-align: center;
}

.palette-block:hover {
  border-color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.04);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.palette-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.palette-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.palette-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ===== AI Creator ===== */
.ai-creator {
  margin-bottom: var(--space-md);
}

.ai-creator-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ai-creator-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  line-height: 1.4;
}

.ai-creator-input-row {
  display: flex;
  gap: 6px;
}

.ai-creator-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
}

.ai-creator-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(74, 85, 109, 0.08);
}

.ai-creator-input::placeholder {
  color: var(--text-muted);
}

.ai-creator-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
}

/* ===== Panel Utilities ===== */
.panel-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-md) 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  margin: var(--space-md) 0;
}

/* Token bar */
.token-bar {
  margin-top: var(--space-sm);
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.token-chip {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.token-chip:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(74, 85, 109, 0.06);
}

/* Feature styles moved to app.css */
