/* ============================================================
   VibePDF — Shared Design System (Fira Code)
   Used by: app.html (desktop) & embed.html (mobile/embed)
   ============================================================ */

/* ----- Custom Properties ----- */
:root {
  /* Surfaces */
  --bg-base: #070818;
  --bg-surface: #0f1128;
  --bg-elevated: #16182a;
  --bg-overlay: rgba(12, 14, 32, 0.72);
  --bg-input: rgba(18, 22, 48, 0.55);

  /* App shell — spaced glass columns (desktop) */
  --app-shell-gap: 12px;
  --app-panel-radius: 14px;

  /* Glass (frosted panels — matches logo gradient accents) */
  --glass-blur: 32px;
  --glass-saturate: 1.45;
  --glass-bg: rgba(16, 20, 48, 0.38);
  --glass-bg-raised: rgba(22, 26, 58, 0.48);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-soft: rgba(129, 140, 248, 0.14);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);

  /* Ambient mesh (indigo → sky → teal, same family as .app-title) */
  --mesh-a: radial-gradient(ellipse 90% 55% at 8% -5%, rgba(129, 140, 248, 0.38), transparent 58%);
  --mesh-b: radial-gradient(ellipse 70% 45% at 92% 8%, rgba(56, 189, 248, 0.26), transparent 52%);
  --mesh-c: radial-gradient(ellipse 55% 40% at 48% 105%, rgba(45, 212, 191, 0.14), transparent 50%);
  --mesh-d: radial-gradient(ellipse 40% 30% at 75% 45%, rgba(99, 102, 241, 0.12), transparent 45%);
  --mesh-e: radial-gradient(ellipse 45% 35% at 25% 55%, rgba(168, 85, 247, 0.12), transparent 50%);
  --mesh-f: radial-gradient(ellipse 35% 30% at 60% 20%, rgba(251, 191, 36, 0.06), transparent 45%);

  /* Borders */
  --border-subtle: rgba(91, 181, 255, 0.1);
  --border-default: #2a2d3d;
  --border-strong: #3b3f5c;
  --border-accent: rgba(96, 165, 250, 0.35);

  /* Text */
  --text-primary: #e2e4ef;
  --text-secondary: #a1a5c0;
  --text-muted: #6b6f8d;
  --text-faint: #4a4e6a;

  /* Accent */
  --accent-blue: #60a5fa;
  --accent-indigo: #818cf8;
  --accent-cyan: #38bdf8;
  --accent-teal: #2dd4bf;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #818cf8 0%, #60a5fa 40%, #38bdf8 70%, #2dd4bf 100%);
  --gradient-btn: linear-gradient(135deg, #7c7cff 0%, #5bb5ff 50%, #3dd6e5 100%);
  --gradient-active: linear-gradient(135deg, rgba(129, 140, 248, 0.18) 0%, rgba(56, 189, 248, 0.12) 50%, rgba(45, 212, 191, 0.08) 100%);
  --gradient-glass-shine: linear-gradient(145deg, rgba(255, 255, 255, 0.06) 0%, transparent 42%, rgba(56, 189, 248, 0.04) 100%);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px rgba(96, 165, 250, 0.08);
  --shadow-accent: 0 4px 16px rgba(99, 102, 241, 0.35);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --transition-fast: 0.15s var(--ease-out);
  --transition-base: 0.25s var(--ease-out);
  --transition-slow: 0.35s var(--ease-out);

  /* Typography — Fira Code for UI and monospace contexts */
  --font-sans: 'Fira Code', ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
  --font-mono: 'Fira Code', ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient gradient mesh (desktop app shell + embed WebView) */
body:has(.app-container)::before,
body:has(.embed-container)::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    var(--mesh-f),
    var(--mesh-e),
    var(--mesh-a),
    var(--mesh-b),
    var(--mesh-c),
    var(--mesh-d),
    linear-gradient(145deg, #04061a 0%, #0a0c24 22%, #0d1028 45%, #080a1e 72%, #050514 100%);
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ----- Selection ----- */
::selection {
  background: rgba(96, 165, 250, 0.25);
  color: #fff;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50%      { transform: translate(-50%, -50%) scale(1.3); opacity: 0.7; }
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================================
   APP LAYOUT  (app.html — desktop three-panel)
   ============================================================ */
.app-container {
  display: flex;
  align-items: stretch;
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
  background: transparent;
  padding: var(--app-shell-gap);
  gap: var(--app-shell-gap);
  box-sizing: border-box;
}

/* --- Left Sidebar --- */
.sidebar-left {
  width: 260px;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  border-radius: var(--app-panel-radius);
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow), 0 0 0 1px rgba(129, 140, 248, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 8px rgba(91, 181, 255, 0.3));
  transition: filter var(--transition-base);
}

.logo:hover {
  filter: drop-shadow(0 0 16px rgba(91, 181, 255, 0.55));
}

.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.sidebar-search {
  padding: 8px 16px 0;
  display: none;
}

.sidebar-search.active {
  display: block;
}

.sidebar-search-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sidebar-search-input::placeholder {
  color: var(--text-faint);
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--border-accent);
  background: var(--glass-bg-raised);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12), var(--glass-highlight);
}

/* Nav Items */
.sidebar-nav {
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item,
.sidebar-footer-item {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: transparent;
  color: #c4c7db;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition-fast);
}

.sidebar-nav-item:hover,
.sidebar-footer-item:hover {
  background: rgba(129, 140, 248, 0.1);
  border-color: var(--glass-border-soft);
  color: var(--text-primary);
}

.sidebar-nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.sidebar-nav-item:hover .sidebar-nav-icon {
  color: var(--accent-blue);
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  padding: 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-base);
}

.chat-item:hover {
  background: rgba(129, 140, 248, 0.08);
  border-color: var(--glass-border-soft);
}

.chat-item.active {
  background: var(--gradient-active);
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.chat-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.chat-preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-date {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

.sidebar-footer {
  border-top: 1px solid var(--glass-border);
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* --- Main Editor (center) --- */
.main-editor {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--app-panel-radius);
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow), 0 0 0 1px rgba(129, 140, 248, 0.04);
  overflow: hidden;
}

.editor-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  z-index: 30;
  overflow: visible;
}

.editor-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-actions button {
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: #c4c7db;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.editor-actions button:hover {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.15) 0%, rgba(56, 189, 248, 0.1) 100%);
  border-color: var(--glass-border-soft);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.editor-actions input[type="file"] {
  display: none;
}

.file-name {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* Export Dropdown */
.export-dropdown {
  position: relative;
  display: inline-block;
  z-index: 40;
}

.export-dropdown .export-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--glass-bg-raised);
  background-image: var(--gradient-glass-shine);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  min-width: 210px;
  z-index: 50;
  box-shadow: var(--shadow-lg), var(--glass-highlight), 0 0 40px rgba(99, 102, 241, 0.08);
  padding: 6px;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

.export-dropdown .export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #c4c7db;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.export-dropdown .export-menu button:hover {
  background: rgba(96, 165, 250, 0.08);
  color: var(--text-primary);
}

/* --- Tabs (shared concept — both pages) --- */

/* app.html tab variant */
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 20px 0;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tab-button {
  padding: 9px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.tab-button:hover {
  color: var(--text-secondary);
}

.tab-button.active {
  color: var(--text-primary);
  border-bottom-color: transparent;
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--gradient-brand);
  box-shadow: 0 -2px 12px rgba(129, 140, 248, 0.45);
}

/* embed.html tab variant (matches desktop tab gradient underline) */
.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 14px 12px;
  background: transparent;
  border: none;
  border-bottom: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-base), background var(--transition-base);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.tab-btn.active {
  color: var(--accent-blue);
  background: rgba(96, 165, 250, 0.06);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--gradient-brand);
  box-shadow: 0 -2px 12px rgba(129, 140, 248, 0.45);
}

.tab-btn:active {
  background: rgba(96, 165, 250, 0.1);
}

.tab-btn.active:active {
  background: rgba(96, 165, 250, 0.12);
}

.tab-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Panels --- */

/* app.html panel variant */
.panels {
  flex: 1;
  min-height: 0;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  height: 100%;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

/* embed.html panel variant */
.panel {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.panel.active {
  display: flex;
  flex-direction: column;
}

/* Editor areas */
#editor {
  height: 100%;
}

#monacoEditor {
  width: 100%;
  height: 100%;
}

#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: rgba(11, 13, 26, 0.5);
  color: #fff;
}

#visualEditor {
  width: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.cke_editable {
  padding: 16px !important;
  background: #fff !important;
  min-height: 100% !important;
}

/* --- Right Sidebar (Chat) --- */
.sidebar-right {
  width: 40%;
  flex-shrink: 0;
  min-width: 260px;
  min-height: 0;
  border-radius: var(--app-panel-radius);
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow), 0 0 0 1px rgba(129, 140, 248, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
}

.chat-header-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Model Select */
.model-select-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.model-select {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.model-select:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.12);
}

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

.message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.3s ease-out;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0;
  color: transparent;
  flex-shrink: 0;
  background-image: url('https://i.scdn.co/image/ab6761610000e5eb8a3dd5854574c440b83e42c6');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.15);
}

.message.user .message-avatar {
  background-image: url('https://static.wikia.nocookie.net/joke-battles/images/d/df/Gigachad.png') !important;
  font-size: 0;
  color: transparent;
}

.message.assistant .message-avatar {
  background-image: url('https://i.scdn.co/image/ab6761610000e5eb8a3dd5854574c440b83e42c6');
}

.message-content {
  flex: 1;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.message-images img {
  max-width: 120px;
  max-height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-base);
}

.message-role {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}

.message-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
}

.message-actions {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all var(--transition-base);
}

.reset-btn:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  background: rgba(96, 165, 250, 0.06);
}

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

/* Thought blocks */
.thought-block {
  background: rgba(22, 26, 58, 0.35);
  border: 1px dashed rgba(129, 140, 248, 0.22);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  color: #c4c7db;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.thought-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}

.thought-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: inline-block;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
}

.thought-time {
  color: var(--text-primary);
  font-weight: 500;
}

.thought-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text-primary);
}

.thought-block.collapsed .thought-body {
  display: none;
}

/* --- Chat Input --- */
.chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(12, 14, 32, 0.35);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(22, 26, 58, 0.45);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 150px;
  min-height: 60px;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 20px rgba(0, 0, 0, 0.15);
}

.chat-input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.45);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.chat-input::placeholder {
  color: #52525b;
}

.chat-input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.chat-input-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.chat-input-toolbar .model-select-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.chat-input-toolbar .model-select {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Attachment Previews */
.attachment-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: #0f1222;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
}

.attachment-previews::-webkit-scrollbar { width: 6px; }
.attachment-previews::-webkit-scrollbar-track { background: #0c051f; }
.attachment-previews::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.attachment-previews::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.attachment-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #0c051f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  animation: slideIn 0.2s ease-out;
}

.attachment-item:hover {
  border-color: var(--accent-blue);
  background: #1e2139;
}

.attachment-item.template {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.1) 0%, rgba(91, 181, 255, 0.1) 100%);
}

.attachment-item.image {
  padding: 6px;
  padding-right: 12px;
}

.attachment-thumbnail {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #0b0c14;
  border: 1px solid var(--border-default);
}

.attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  font-size: 11px;
  color: var(--text-muted);
}

.attachment-remove {
  width: 22px;
  height: 22px;
  background: var(--border-default);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.attachment-remove:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

.attachment-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */

/* Primary action button (Send) */
.send-btn {
  width: 40px;
  height: 40px;
  background: var(--gradient-btn);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}

.send-btn:active {
  transform: translateY(0) scale(0.97);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Attach button */
.attach-btn {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  position: relative;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.attach-btn:hover {
  background: rgba(129, 140, 248, 0.12);
  border-color: var(--glass-border-soft);
  color: var(--text-primary);
}

/* Attach Menu */
.attach-menu-wrapper {
  position: relative;
  display: inline-block;
}

.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--glass-bg-raised);
  background-image: var(--gradient-glass-shine);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 200px;
  box-shadow: var(--shadow-md), var(--glass-highlight), 0 0 32px rgba(99, 102, 241, 0.1);
  z-index: 100;
  display: none;
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

.attach-menu.active {
  display: block;
  animation: slideUpFade 0.2s ease-out;
}

.attach-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.attach-menu button:hover {
  background: rgba(129, 140, 248, 0.12);
}

.attach-menu button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Generic .btn */
.btn {
  padding: 8px 16px;
  background: var(--border-default);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: inherit;
}

.btn:hover {
  background: var(--border-strong);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--gradient-btn);
  border: none;
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn.primary:hover {
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
}

/* Icon buttons (embed.html — glass toolbar) */
.icon-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(129, 140, 248, 0.12);
  border-color: var(--glass-border-soft);
  color: var(--text-primary);
}

.icon-btn:active {
  background: rgba(129, 140, 248, 0.16);
  transform: scale(0.95);
}

.icon-btn.primary {
  background: var(--gradient-btn);
  border: none;
  color: white;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

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

/* ============================================================
   EMBED LAYOUT  (embed.html — single panel)
   ============================================================ */
.embed-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: transparent;
}

/* Frosted chrome + tab strip (matches sidebar / marketing glass) */
.embed-header {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  padding-bottom: 12px;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 8px 32px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}

.embed-container .tabs {
  padding: 0;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.embed-container .tabs::-webkit-scrollbar {
  display: none;
}

/* Main editor / preview sits in a glass card; mesh shows in outer margins */
.embed-container .panels {
  flex: 1;
  min-height: 0;
  margin: 8px calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
  border-radius: var(--app-panel-radius);
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow), 0 0 0 1px rgba(129, 140, 248, 0.05);
  overflow: hidden;
  position: relative;
}

.embed-header .file-select {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a5c0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.embed-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* File selector dropdown (shared) */
.file-select {
  background: var(--border-default);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  max-width: 150px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a5c0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color var(--transition-base);
}

.file-select:focus {
  outline: none;
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

/* ============================================================
   LOADING OVERLAYS
   ============================================================ */

/* embed.html loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 100;
}

.loading-overlay.active {
  display: flex;
}

.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #7c7cff;
  border-right-color: #5bb5ff;
  border-bottom-color: #3dd6e5;
  animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.loader-text {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

/* app.html AI generating overlay */
.ai-generating-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(160deg, rgba(12, 14, 32, 0.78) 0%, rgba(8, 10, 28, 0.65) 100%);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}

.ai-generating-overlay.active {
  display: flex;
}

.ai-loader {
  position: relative;
  width: 80px;
  height: 80px;
}

.ai-loader-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #7c7cff;
  border-right-color: #5bb5ff;
  border-bottom-color: #3dd6e5;
  animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.ai-loader-circle:nth-child(2) {
  width: 60px;
  height: 60px;
  top: 10px;
  left: 10px;
  border-top-color: #3dd6e5;
  border-right-color: #7c7cff;
  border-bottom-color: #5bb5ff;
  animation-duration: 1.2s;
  animation-direction: reverse;
}

.ai-loader-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: var(--gradient-btn);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

.ai-loader-text {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  animation: fadeInOut 2s ease-in-out infinite;
}

.ai-loader-subtext {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: -10px;
}

/* ============================================================
   BOTTOM SHEET (embed.html export)
   ============================================================ */
.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.bottom-sheet-backdrop.active {
  display: block;
  opacity: 1;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass-bg);
  background-image: var(--gradient-glass-shine);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-top: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--glass-highlight), var(--shadow-lg), 0 0 0 1px rgba(129, 140, 248, 0.06);
  z-index: 201;
  transform: translateY(100%);
  transition: transform var(--transition-slow) var(--ease-spring);
  max-height: 70vh;
  overflow: hidden;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 12px auto;
}

.bottom-sheet-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  padding: 8px 20px 16px;
  text-align: center;
}

.bottom-sheet-options {
  padding: 0 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
  width: 100%;
}

.sheet-option:hover {
  background: rgba(129, 140, 248, 0.08);
}

.sheet-option:active {
  background: var(--gradient-active);
  box-shadow: var(--shadow-glow);
}

.sheet-option svg {
  width: 22px;
  height: 22px;
  color: var(--accent-blue);
  flex-shrink: 0;
}

.sheet-option-text {
  flex: 1;
}

.sheet-option-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-sheet-options {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: transform var(--transition-slow) var(--ease-spring), opacity var(--transition-slow) var(--ease-spring);
  box-shadow: var(--shadow-md);
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

/* ============================================================
   RESIZE HANDLES (app.html)
   ============================================================ */
.resize-handle {
  position: relative;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  margin-right: -4px;
  height: 100%;
  background: transparent;
  cursor: col-resize;
  transition: background var(--transition-fast);
  z-index: 20;
}

.resize-handle:hover::after {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.35), rgba(129, 140, 248, 0.35));
  border-radius: 2px;
}

.resize-handle-left::after {
  right: auto;
  left: 0;
  margin-right: 0;
  margin-left: -4px;
}

/* ============================================================
   MODAL / TEMPLATE SELECTION
   ============================================================ */
.template-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.template-modal-backdrop.active {
  display: flex;
}

.template-modal {
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.template-modal-title {
  font-weight: 600;
  font-size: 18px;
  background: var(--gradient-btn);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.template-modal-close {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.template-modal-close:hover {
  background: var(--border-default);
  border-color: var(--accent-blue);
  color: var(--text-primary);
}

.template-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.template-modal-body::-webkit-scrollbar { width: 8px; }
.template-modal-body::-webkit-scrollbar-track { background: #0c051f; }
.template-modal-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.template-modal-body::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.template-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-selected-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.template-selected-info strong {
  color: var(--accent-blue);
}

/* Template Cards */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.template-card {
  background: #0c051f;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.template-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-blue);
  box-shadow: 0 8px 24px rgba(91, 181, 255, 0.15);
}

.template-card.selected {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(91, 181, 255, 0.3);
}

.template-card-thumb {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  display: block;
  background: #0b0c14;
}

.template-card-body {
  padding: 12px;
}

.template-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-empty {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
  font-size: 15px;
}

/* ============================================================
   KNOWLEDGE BASE UI
   ============================================================ */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 4px;
}

.kb-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.kb-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  background: #1e2139;
}

.kb-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(124, 124, 255, 0.1) 0%, rgba(61, 214, 229, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  margin-bottom: 4px;
}

.kb-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.kb-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 16px;
}

.kb-detail-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.kb-upload-area {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all var(--transition-base);
  margin-bottom: 16px;
}

.kb-upload-area:hover {
  border-color: var(--accent-blue);
  background: rgba(91, 181, 255, 0.05);
}

.kb-doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kb-doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.kb-doc-item:hover {
  border-color: var(--border-strong);
  background: #1e2139;
}

.kb-doc-icon {
  width: 36px;
  height: 36px;
  background: #0c051f;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
  border: 1px solid var(--border-default);
}

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

.kb-doc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.kb-doc-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.kb-status-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
  background: rgba(91, 181, 255, 0.1);
  color: var(--accent-blue);
  border: 1px solid rgba(91, 181, 255, 0.2);
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-default);
  transition: 0.4s;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-secondary);
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background: linear-gradient(135deg, #7c7cff 0%, #5bb5ff 100%);
  border-color: transparent;
}

input:checked + .toggle-slider:before {
  transform: translateX(14px);
  background-color: white;
}

.presentation-mode-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  margin-left: 8px;
}

.presentation-mode-wrapper:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.presentation-mode-wrapper:hover .toggle-slider {
  border-color: var(--accent-blue);
}

/* ============================================================
   QUICK EDIT (app.html)
   ============================================================ */
.quick-edit-menu {
  position: absolute;
  z-index: 10000;
  background: #0c051f;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  padding: 4px;
}

.quick-edit-menu button {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 6px 12px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.quick-edit-menu button:hover {
  background: #1e2139;
}

.quick-edit-prompt {
  position: absolute;
  z-index: 10001;
  background: #0c051f;
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: none;
  padding: 10px;
  width: 320px;
}

.quick-edit-prompt textarea {
  width: 100%;
  height: 80px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 8px;
  font-size: 13px;
}

.quick-edit-prompt textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.quick-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.quick-edit-actions button {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}

.btn-cancel:hover {
  background: var(--border-default);
}

.btn-submit {
  background: var(--accent-blue);
  border: none;
  color: #000;
  font-weight: 600;
}

.btn-submit:hover {
  background: #4aa3ff;
}

/* ============================================================
   MARKETING & AUTH PAGES (landing, login — scrollable + app mesh)
   ============================================================ */
body.marketing-page,
body.auth-page {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg-base);
  color: var(--text-primary);
}

body.marketing-page::before,
body.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    var(--mesh-f),
    var(--mesh-e),
    var(--mesh-a),
    var(--mesh-b),
    var(--mesh-c),
    var(--mesh-d),
    linear-gradient(145deg, #04061a 0%, #0a0c24 22%, #0d1028 45%, #080a1e 72%, #050514 100%);
}

/* In-flow sections must stack above the fixed mesh layer; nested z-index alone is not enough. */
body.marketing-page > section,
body.marketing-page > footer {
  position: relative;
  z-index: 1;
}

body.marketing-page > section[id] {
  scroll-margin-top: 96px;
}

/* Let long marketing pages scroll (global html/body use overflow:hidden for /app). */
html:has(body.marketing-page),
html:has(body.auth-page) {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
}
