:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark Theme Palette (Default) */
  --bg-app: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-glass: rgba(26, 34, 52, 0.7);
  --bg-surface-hover: #222d42;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-primary-subtle: rgba(99, 102, 241, 0.15);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --gemini-gradient: linear-gradient(135deg, #4285F4 0%, #9B72CB 50%, #D96570 100%);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

[data-theme="light"] {
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --bg-surface-hover: #eef2f6;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --accent-primary-subtle: rgba(99, 102, 241, 0.1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.4);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* -------------------------------------------------------------
   TOP HEADER
   ------------------------------------------------------------- */
.top-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.logo-icon {
  font-size: 20px;
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.logo-title {
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  color: var(--text-main);
  margin-left: 4px;
}

.notebook-selector-wrapper {
  position: relative;
}

.current-notebook-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  max-width: 260px;
}

.current-notebook-pill:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.nb-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Notebooks Dropdown */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px;
  display: none;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.dropdown-menu.open {
  display: block;
  animation: fadeInDown 0.15s ease-out;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.notebooks-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nb-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  color: var(--text-main);
  text-decoration: none;
}

.nb-dropdown-item:hover, .nb-dropdown-item.active {
  background: var(--bg-surface-hover);
}

.nb-dropdown-item.active {
  border-left: 3px solid var(--accent-primary);
}

.nb-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.nb-item-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-item-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.btn-docs-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-primary-subtle);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-full);
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-docs-link:hover {
  background: var(--accent-primary);
  color: #fff;
  transform: translateY(-1px);
}

.docs-icon {
  font-size: 14px;
}

.btn-ghost-header:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Notebooks Library Modal Grid */
.library-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.library-search {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 13.5px;
  outline: none;
}

.library-search:focus {
  border-color: var(--accent-primary);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.library-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  transition: all 0.2s ease;
  position: relative;
}

.library-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.library-card.active-nb {
  border-color: var(--accent-primary);
  background: var(--bg-surface-hover);
}

.library-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.library-card-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.library-card-title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  word-break: break-word;
}

.library-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-card-bottom {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-faint);
}

.library-card-actions {
  display: flex;
  gap: 6px;
}

.library-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
}

.library-delete-btn:hover {
  color: var(--danger);
}

/* Mobile Tabs */
.mobile-tabs {
  display: none;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 4px;
  border-radius: var(--radius-full);
}

.mobile-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

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

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.btn-settings:hover {
  background: var(--bg-surface-hover);
}

.api-status-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--danger);
}

.api-status-badge.connected {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* -------------------------------------------------------------
   MAIN 3-PANEL WORKSPACE
   ------------------------------------------------------------- */
.main-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 320px minmax(400px, 1fr) 360px;
  height: calc(100vh - 64px);
  overflow: hidden;
  background-color: var(--bg-app);
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.panel:last-child {
  border-right: none;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header-title h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* -------------------------------------------------------------
   PANEL 1: SOURCES
   ------------------------------------------------------------- */
.sources-filter-bar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-container input {
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.sources-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.source-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.source-card.deselected {
  opacity: 0.5;
}

.source-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.source-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

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

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

.source-card-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-card-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
}

.source-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.source-delete-btn:hover {
  color: var(--danger);
}

/* -------------------------------------------------------------
   PANEL 2: CHAT & GROUNDED Q&A
   ------------------------------------------------------------- */
.panel-chat {
  background-color: var(--bg-app);
}

.chat-header {
  background: var(--bg-surface);
}

.chat-grounding-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.sparkle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gemini-gradient);
  display: inline-block;
  animation: pulseGlow 2s infinite ease-in-out;
}

.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chat-welcome-state {
  margin: auto;
  text-align: center;
  max-width: 580px;
  padding: 20px;
}

.welcome-icon {
  font-size: 42px;
  margin-bottom: 12px;
  animation: floatAnim 3s infinite ease-in-out;
}

.chat-welcome-state h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.chat-welcome-state p {
  color: var(--text-muted);
  font-size: 14.5px;
  margin-bottom: 24px;
}

.quick-prompts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.prompt-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-chip:hover {
  border-color: var(--accent-primary);
  background: var(--bg-surface-elevated);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Chat Messages */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message-row {
  display: flex;
  gap: 14px;
  max-width: 85%;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.assistant {
  align-self: flex-start;
  max-width: 92%;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.message-row.user .message-avatar {
  background: var(--accent-primary);
  color: #fff;
}

.message-row.assistant .message-avatar {
  background: var(--gemini-gradient);
  color: #fff;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.6;
  position: relative;
}

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

.message-row.assistant .message-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-citations {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
}

.citation-tag {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* Chat Input Bar */
.chat-input-container {
  padding: 16px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.chat-form {
  display: flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.chat-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14.5px;
  resize: none;
  max-height: 140px;
  line-height: 1.4;
}

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

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

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

.chat-input-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.model-tag {
  background: var(--bg-surface-elevated);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* -------------------------------------------------------------
   PANEL 3: STUDIO & NOTES
   ------------------------------------------------------------- */
.panel-studio {
  background-color: var(--bg-surface);
}

.studio-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.studio-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.studio-tool-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: all 0.2s;
}

.studio-tool-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.studio-tool-card:last-child {
  grid-column: span 2;
}

.tool-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.tool-info strong {
  display: block;
  font-size: 12.5px;
  color: var(--text-main);
}

.tool-info small {
  font-size: 10.5px;
  color: var(--text-muted);
}

.notes-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.note-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.note-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-card-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* -------------------------------------------------------------
   BUTTONS & COMMON UI
   ------------------------------------------------------------- */
.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary-subtle {
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

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

.btn-danger-ghost {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* -------------------------------------------------------------
   MODALS & FORMS
   ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: scaleUp 0.2s ease-out;
}

.modal-card.modal-large {
  max-width: 800px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.input-transparent-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  width: 90%;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px 24px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--accent-primary);
}

.helper-text {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
}

.helper-text a {
  color: var(--accent-primary);
  text-decoration: none;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.modal-tab-btn {
  flex: 1;
  padding: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
}

.modal-tab-btn.active {
  background: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.file-drop-area {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s;
}

.file-drop-area:hover {
  border-color: var(--accent-primary);
}

.file-drop-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}

.selected-file-info {
  margin-top: 8px;
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions.space-between {
  justify-content: space-between;
}

.actions-right {
  display: flex;
  gap: 10px;
}

/* Note Editor Pane */
.note-editor-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 380px;
}

.note-textarea {
  width: 100%;
  height: 100%;
  padding: 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  resize: none;
  outline: none;
}

.note-preview-pane {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
}

/* Emoji Picker */
.emoji-picker-row {
  display: flex;
  gap: 8px;
}

.emoji-btn {
  font-size: 20px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
}

.emoji-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-subtle);
}

/* -------------------------------------------------------------
   MARKDOWN STYLING
   ------------------------------------------------------------- */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-main);
}
.markdown-body p {
  margin-bottom: 10px;
}
.markdown-body ul, .markdown-body ol {
  margin-left: 20px;
  margin-bottom: 10px;
}
.markdown-body li {
  margin-bottom: 4px;
}
.markdown-body code {
  font-family: var(--font-mono);
  background: rgba(125, 125, 125, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.markdown-body pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 12px;
}
.markdown-body blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* -------------------------------------------------------------
   TOAST NOTIFICATIONS
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.2s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent-primary); }

/* -------------------------------------------------------------
   ANIMATIONS & UTILITIES
   ------------------------------------------------------------- */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.6; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.1); filter: drop-shadow(0 0 6px #6366f1); }
}

@keyframes floatAnim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.hidden { display: none !important; }

/* -------------------------------------------------------------
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
  .mobile-tabs {
    display: flex;
  }

  .main-workspace {
    grid-template-columns: 1fr;
  }

  .panel {
    display: none;
  }

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

  .note-editor-wrapper {
    grid-template-columns: 1fr;
    height: auto;
  }

  .note-textarea {
    height: 180px;
  }
}
