/* ========== RESET & VARIABLES ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #7c3aed;
  --primary-light: #8b5cf6;
  --primary-dark: #6d28d9;
  --secondary: #06b6d4;
  --bg: #09090b;
  --bg-2: #111115;
  --bg-3: #18181c;
  --surface: #1c1c22;
  --surface-2: #252530;
  --border: #2a2a35;
  --border-light: #3a3a48;
  --text: #f4f4f8;
  --text-2: #a1a1b5;
  --text-3: #6b6b80;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-lg: 20px;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; color: var(--text); }

/* UTIL */
.g-text {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
}
.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}
.logo-text { overflow: hidden; white-space: nowrap; }
.sidebar-toggle {
  color: var(--text-3);
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: var(--surface); color: var(--text); }
.sidebar-new {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
}
.btn-new-chat:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 8px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.nav-item i { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }
.nav-item span:not(.nav-badge) { overflow: hidden; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: rgba(124,58,237,0.15); color: var(--primary-light); font-weight: 600; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  background: rgba(124,58,237,0.2);
  color: var(--primary-light);
  flex-shrink: 0;
}
.nav-badge.new { background: rgba(34,197,94,0.2); color: #22c55e; }
.sidebar-recent {
  padding: 0 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.recent-list { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.recent-item {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-3);
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-item:hover { background: var(--surface); color: var(--text-2); }
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.2s;
  cursor: pointer;
}
.user-profile:hover { background: var(--surface); }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { display: block; font-size: 11px; color: var(--text-3); }
.user-menu-btn { color: var(--text-3); padding: 4px; flex-shrink: 0; }

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ========== TOP BAR ========== */
.top-bar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 50;
  gap: 16px;
}
.top-bar-left { display: flex; align-items: center; gap: 14px; }
.mobile-sidebar-btn { display: none; color: var(--text-2); padding: 8px; }
.tool-breadcrumb { display: flex; align-items: center; gap: 10px; }
.breadcrumb-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
}
.breadcrumb-title { font-size: 15px; font-weight: 700; }
.top-bar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  font-size: 14px;
  transition: all 0.2s;
}
.top-btn:hover { color: var(--text); border-color: var(--border-light); }
.btn-upgrade {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--warning), #f97316);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
}
.btn-upgrade:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(245,158,11,0.4); }

/* ========== MODEL SELECTOR ========== */
.model-selector { position: relative; }
.model-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.model-current:hover { border-color: var(--primary-light); }
.model-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: blink 1.5s ease infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.model-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-width: 240px;
  display: none;
  box-shadow: var(--shadow);
  z-index: 200;
}
.model-menu.open { display: block; }
.model-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.model-option:hover { background: var(--surface-2); }
.model-option.locked { opacity: 0.5; cursor: not-allowed; }
.mo-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}
.mo-icon.standard { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.mo-icon.pro { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.mo-icon.vision { background: linear-gradient(135deg, var(--secondary), #3b82f6); }
.mo-icon.ultra { background: linear-gradient(135deg, #a855f7, #ec4899); }
.mo-info { display: flex; flex-direction: column; }
.mo-name { font-size: 13px; font-weight: 700; }
.mo-desc { font-size: 12px; color: var(--text-3); }
.lock-badge { background: linear-gradient(135deg,#f59e0b,#ef4444); color:#fff; font-size:10px; padding:1px 6px; border-radius:100px; }

/* ========== TOOL PANELS ========== */
.tool-panel { display: none; flex: 1; overflow: hidden; }
.tool-panel.active { display: flex; flex-direction: column; }

/* ========== CHAT PANEL ========== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.welcome-logo { text-align: center; margin-bottom: 40px; }
.welcome-icon {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  color: #fff;
  margin: 0 auto 20px;
  box-shadow: 0 8px 30px rgba(124,58,237,0.4);
}
.welcome-logo h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }
.welcome-logo p { color: var(--text-2); font-size: 15px; }
.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 700px;
}
.ws-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.ws-card:hover { border-color: rgba(124,58,237,0.3); transform: translateY(-2px); }
.ws-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.ws-text { display: flex; flex-direction: column; }
.ws-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.ws-sub { font-size: 12px; color: var(--text-3); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-messages:empty + .chat-input-area { margin-top: auto; }
.chat-message {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: msgFadeIn 0.3s ease;
}
@keyframes msgFadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.chat-message.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.msg-avatar.ai {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}
.msg-avatar.user {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.msg-content { max-width: 80%; display: flex; flex-direction: column; gap: 6px; }
.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.chat-message.ai .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
}
.chat-message.user .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: 16px 4px 16px 16px;
  text-align: right;
}
.msg-bubble code {
  background: rgba(255,255,255,0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}
.msg-bubble pre {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
}
.msg-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
}
.chat-message.user .msg-meta { justify-content: flex-end; }
.msg-action-btns { display: flex; gap: 6px; }
.msg-btn {
  padding: 3px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-3);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.msg-btn:hover { color: var(--text); }
/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  width: fit-content;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--text-3);
  border-radius: 50%;
  animation: typingBounce 1.4s ease infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,100%{transform:translateY(0);opacity:.4} 50%{transform:translateY(-5px);opacity:1} }

/* Chat Input */
.chat-input-area {
  padding: 16px 24px 20px;
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.chat-input-container { max-width: 100%; }
.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}
.chat-input-box:focus-within { border-color: var(--primary-light); }
.attach-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.attach-btn:hover { background: var(--surface-2); color: var(--text); }
.attach-preview {
  max-width: 80px;
  position: relative;
  flex-shrink: 0;
}
.attach-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.attach-preview .remove-attach {
  position: absolute;
  top: -5px; right: -5px;
  width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  cursor: pointer;
}
#chatInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
  min-height: 24px;
}
#chatInput::placeholder { color: var(--text-3); }
.chat-input-actions { display: flex; gap: 6px; align-items: center; }
.input-action-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
}
.input-action-btn:hover { background: var(--surface-2); color: var(--text); }
.send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(124,58,237,0.4);
}
.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.input-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 8px;
}

/* ========== EDITOR PANEL ========== */
.editor-layout {
  display: grid;
  grid-template-columns: auto 1fr 280px;
  grid-template-rows: auto 1fr;
  height: 100%;
  overflow: hidden;
}
.editor-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.toolbar-group { display: flex; gap: 4px; }
.toolbar-sep { width: 1px; height: 28px; background: var(--border); margin: 0 6px; }
.tb-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  font-size: 15px;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.tb-btn:hover { background: var(--surface); color: var(--text); }
.tb-btn.active { background: rgba(124,58,237,0.2); color: var(--primary-light); border-color: rgba(124,58,237,0.3); }
.download-btn { color: var(--secondary); }
.editor-canvas-area {
  background: #060608;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.editor-canvas-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.editor-drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  min-height: 320px;
  cursor: pointer;
  transition: all 0.3s;
}
.editor-drop-zone:hover, .editor-drop-zone.drag-over {
  border-color: var(--primary-light);
  background: rgba(124,58,237,0.05);
}
.drop-zone-inner { text-align: center; padding: 40px 24px; }
.dz-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  color: var(--text-3);
  margin: 0 auto 16px;
}
.drop-zone-inner h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.drop-zone-inner p { color: var(--text-3); font-size: 14px; margin-bottom: 20px; }
.btn-upload-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-upload-main:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-3);
  font-size: 13px;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.sample-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sample-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.2s;
}
.sample-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.editor-right-panel {
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.ep-section { border-bottom: 1px solid var(--border); }
.ep-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.ep-section-header:hover { background: var(--surface); }
.ep-section-header i { color: var(--primary-light); }
.ep-section-header .fa-chevron-down { color: var(--text-3); transition: transform 0.2s; font-size: 12px; }
.ep-section-header.collapsed .fa-chevron-down { transform: rotate(-90deg); }
.ep-section-body { padding: 12px 16px 16px; }
.ep-section-body.hidden { display: none; }
.slider-row {
  display: grid;
  grid-template-columns: 80px 1fr 30px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.slider-row label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.slider-row input[type=range] { width: 100%; accent-color: var(--primary); }
.slider-row span { font-size: 12px; color: var(--text-3); text-align: right; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-chip.active, .filter-chip:hover { background: rgba(124,58,237,0.2); color: var(--primary-light); border-color: rgba(124,58,237,0.4); }
#aiEditPrompt {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  resize: none;
  outline: none;
  margin-bottom: 10px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
#aiEditPrompt:focus { border-color: var(--primary); }
.btn-ai-apply {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
  margin-bottom: 10px;
}
.btn-ai-apply:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.ai-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-preset-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-2);
  transition: all 0.2s;
}
.ai-preset-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
#aiEditStatus { font-size: 13px; color: var(--primary-light); margin-top: 8px; }

/* ========== FACE PANEL ========== */
.face-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.face-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.face-upload-drop {
  flex: 1;
  background: #060608;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.face-dz-inner { text-align: center; padding: 40px; }
.face-compare-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  justify-content: center;
}
.compare-btn {
  padding: 7px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
}
.compare-btn.active { background: rgba(124,58,237,0.2); color: var(--primary-light); border-color: rgba(124,58,237,0.3); }
.compare-btn:hover { border-color: var(--border-light); color: var(--text); }
.face-tools-panel {
  width: 300px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ========== BACKGROUND PANEL ========== */
.bg-layout { display: flex; height: 100%; overflow: hidden; }
.bg-main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.bg-canvas-area {
  flex: 1;
  background: repeating-conic-gradient(#111 0% 25%, #1a1a1a 0% 50%) 0 0 / 24px 24px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.bg-drop-zone {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  width: calc(100% - 40px);
  min-height: 320px;
  max-width: 500px;
  cursor: pointer;
  transition: all 0.3s;
}
.bg-drop-zone:hover { border-color: var(--primary-light); background: rgba(124,58,237,0.05); }
.bg-dz-inner { text-align: center; padding: 40px 24px; }
.bg-action-bar {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  justify-content: center;
  flex-wrap: wrap;
}
.bg-action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: all 0.2s;
}
.bg-action-btn:hover { border-color: var(--border-light); color: var(--text); }
.bg-action-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-color: transparent;
}
.bg-action-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.bg-tools-panel {
  width: 300px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

/* ========== GENERATE PANEL ========== */
.generate-layout { display: flex; height: 100%; overflow: hidden; }
.generate-main {
  flex: 1;
  background: #060608;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.generate-result-area { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.generate-placeholder { text-align: center; color: var(--text-3); padding: 40px; }
.gp-icon {
  width: 80px; height: 80px;
  border-radius: 22px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  color: var(--text-3);
  margin: 0 auto 20px;
}
.generate-placeholder h3 { font-size: 20px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.generate-placeholder p { color: var(--text-3); font-size: 14px; }
.generate-sidebar {
  width: 320px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#generatePrompt {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: border-color 0.2s;
}
#generatePrompt:focus { border-color: var(--primary); }
.prompt-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ps-btn {
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 11px;
  color: var(--text-3);
  transition: all 0.15s;
}
.ps-btn:hover { color: var(--primary-light); border-color: rgba(124,58,237,0.3); }
.style-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.style-chip {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.style-chip.active, .style-chip:hover { background: rgba(124,58,237,0.2); color: var(--primary-light); border-color: rgba(124,58,237,0.4); }
.ratio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ratio-btn {
  padding: 10px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}
.ratio-btn small { display: block; font-size: 10px; color: var(--text-3); }
.ratio-btn.active, .ratio-btn:hover { background: rgba(124,58,237,0.2); color: var(--primary-light); border-color: rgba(124,58,237,0.4); }
.btn-generate {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all 0.2s;
  margin-top: 8px;
}
.btn-generate:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(124,58,237,0.5); }

/* ========== SHARED PANEL STYLES ========== */
.fp-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.fp-title i { color: var(--primary-light); }
.fp-section { margin-bottom: 20px; }
.fp-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.age-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.age-btn {
  padding: 8px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  transition: all 0.2s;
  text-align: center;
}
.age-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.expression-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.expr-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.2s;
}
.expr-btn:hover { border-color: var(--primary-light); color: var(--primary-light); }
.appearance-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.appear-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.appear-btn:hover { border-color: var(--primary-light); }
.ab-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 15px;
}
.face-swap-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.face-swap-upload:hover { border-color: var(--primary-light); color: var(--primary-light); }
.bg-template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.bg-template {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 4px;
  border: 2px solid transparent;
  transition: all 0.2s;
  overflow: hidden;
}
.bg-template:hover, .bg-template.active { border-color: var(--primary-light); }
.bg-template span {
  font-size: 9px;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.5);
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.custom-bg-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface) !important;
  border: 2px dashed var(--border) !important;
  gap: 4px;
}
.custom-bg-btn i { color: var(--text-3); }
.custom-bg-btn span { color: var(--text-3); }
.custom-bg-btn:hover i, .custom-bg-btn:hover span { color: var(--primary-light); }
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-picker-row input[type=color] {
  width: 44px; height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
}
.color-picker-row span { font-size: 13px; color: var(--text-2); }
.tool-status {
  padding: 10px 14px;
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--primary-light);
  margin-top: 8px;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== MOBILE OVERLAY ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .mobile-sidebar-btn { display: flex; align-items: center; justify-content: center; }
  .model-current span { display: none; }
  .btn-upgrade span { display: none; }
  .welcome-suggestions { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: auto 1fr; }
  .editor-right-panel { display: none; }
  .face-tools-panel, .bg-tools-panel, .generate-sidebar { width: 250px; }
}
@media (max-width: 600px) {
  .face-layout, .bg-layout, .generate-layout { flex-direction: column; }
  .face-tools-panel, .bg-tools-panel, .generate-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 250px; }
}
