/* =============================================
   Tryll engine RAG Database Constructor
   Color Palette & Design Tokens
   ============================================= */

:root {
  /* Palette */
  --bg-main: #12161F;
  --bg-sidebar: #1A202C;
  --bg-card: #232E41;
  --bg-input: #161C28;
  --bg-hover: #2A3650;
  --text-primary: #FFFFFF;
  --text-secondary: #8B95A5;
  --text-muted: #5A6577;
  --accent: #2367DA;
  --accent-hover: #1B52B5;
  --accent-soft: rgba(35, 103, 218, 0.15);
  --accent-glow: rgba(35, 103, 218, 0.4);
  --danger: #E53E3E;
  --danger-hover: #C53030;
  --danger-soft: rgba(229, 62, 62, 0.15);
  --success: #38A169;
  --success-soft: rgba(56, 161, 105, 0.15);
  --warning: #D69E2E;
  --border: #2D3748;
  --border-light: #3D4A5C;

  /* Typography */
  --font-body: 'Inter', system-ui, sans-serif;
  --font-heading: 'Inter', system-ui, sans-serif;

  /* Spacing & sizing */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --sidebar-width: 300px;
  --topbar-height: 56px;
  --transition: 180ms ease;
}

/* =============================================
   RESET & BASE
   ============================================= */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* =============================================
   TOPBAR
   ============================================= */

.topbar {
  height: var(--topbar-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  z-index: 100;
  position: relative;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-logo {
  height: 30px;
  width: 30px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.brand-text {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.brand-accent {
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-left: 4px;
  align-self: flex-end;
  margin-bottom: 2px;
}

.topbar-project {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 400px;
}

.project-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  flex: 1;
  height: 36px;
  transition: border-color var(--transition);
}

.project-select-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.project-select-wrap i {
  color: var(--text-muted);
  font-size: 14px;
}

.project-select-wrap select {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
}

.project-select-wrap select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Session badge */
.session-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  letter-spacing: 1.5px;
  font-family: 'Courier New', monospace;
  user-select: all;
}

.session-badge i {
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0;
}

.mcp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 300ms ease;
}

.mcp-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px var(--success), 0 0 12px rgba(56, 161, 105, 0.3);
  animation: mcpPulse 2s ease-in-out infinite;
}

@keyframes mcpPulse {
  0%, 100% { box-shadow: 0 0 6px var(--success), 0 0 12px rgba(56, 161, 105, 0.3); }
  50%      { box-shadow: 0 0 8px var(--success), 0 0 20px rgba(56, 161, 105, 0.5); }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-accent:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

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

.btn-icon--accent {
  color: var(--accent);
}

.btn-icon--accent:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-icon--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* =============================================
   LAYOUT
   ============================================= */

.app-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title i {
  color: var(--accent);
}

.sidebar-header-actions {
  display: flex;
  gap: 4px;
}

/* Chunk search */
.chunk-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}

.chunk-search-icon {
  color: var(--text-muted);
  font-size: 12px;
}

.chunk-search input {
  flex: 1;
  height: 28px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 0 8px;
  outline: none;
  transition: border-color var(--transition);
}

.chunk-search input:focus {
  border-color: var(--accent);
}

/* New category input */
.new-category-input {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
}

.new-category-input input {
  flex: 1;
  height: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color var(--transition);
}

.new-category-input input:focus {
  border-color: var(--accent);
}

/* Category tree */
.category-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.category-item {
  user-select: none;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.category-header:hover {
  background: var(--bg-hover);
}

.category-header.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.category-chevron {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform var(--transition);
  width: 16px;
  text-align: center;
}

.category-chevron.expanded {
  transform: rotate(90deg);
}

.category-icon {
  font-size: 14px;
  color: var(--warning);
}

.category-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.category-actions {
  display: flex;
  gap: 2px;
}

.category-actions .btn-icon {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

/* Chunk list inside category */
.chunk-list {
  overflow: hidden;
  transition: max-height 250ms ease;
}

.chunk-list.collapsed {
  max-height: 0 !important;
}

.chunk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 44px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.chunk-item:hover {
  background: var(--bg-hover);
}

.chunk-item.selected {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.chunk-item-icon {
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

.chunk-item-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chunk-item.selected .chunk-item-name {
  color: var(--text-primary);
}

.chunk-item-delete {
  opacity: 0;
  transition: opacity var(--transition);
}

.chunk-item:hover .chunk-item-delete {
  opacity: 1;
}

/* Add chunk button inside category */
.add-chunk-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 44px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-body);
}

.add-chunk-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.add-chunk-btn i {
  font-size: 11px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.sidebar-links a {
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
}

.sidebar-links a:hover {
  color: var(--accent);
}

/* =============================================
   MAIN CONTENT
   ============================================= */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  opacity: 0;
  animation: fadeIn 400ms ease forwards;
}

.empty-state-icon {
  font-size: 64px;
  color: var(--border-light);
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.empty-state-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.6;
}

/* =============================================
   CHUNK EDITOR
   ============================================= */

.chunk-editor {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  opacity: 0;
  animation: fadeIn 300ms ease forwards;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.editor-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-title i {
  color: var(--accent);
  font-size: 18px;
}

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

.editor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.editor-card:hover {
  border-color: var(--border-light);
}

.editor-card-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-card-title i {
  color: var(--accent);
}

/* Form fields */
.field-group {
  margin-bottom: 16px;
}

.field-group:last-child {
  margin-bottom: 0;
}

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

.field-input {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 0 12px;
  outline: none;
  transition: all var(--transition);
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.field-textarea {
  width: 100%;
  min-height: 160px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  line-height: 1.6;
  transition: all var(--transition);
}

.field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-textarea::placeholder {
  color: var(--text-muted);
}

/* ID duplicate warning */
.id-warning {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.id-warning.hidden {
  display: none;
}

/* Character counter */
.char-counter {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.char-counter--warn {
  color: var(--warning);
}
.char-counter--limit {
  color: var(--danger);
  font-weight: 600;
}

/* Custom fields */
.custom-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.custom-field-row .field-input {
  flex: 1;
}

.custom-field-key {
  max-width: 180px;
}

.add-field-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

.add-field-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.editor-save-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* =============================================
   MODAL
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  animation: fadeIn 200ms ease forwards;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 380px;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title i {
  color: var(--accent);
}

.modal-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 0 14px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color var(--transition);
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

/* FAQ modal */
.modal--faq {
  max-width: 560px;
}

.faq-list {
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 12px;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: color var(--transition);
}

.faq-question:hover {
  color: var(--accent);
}

.faq-question i {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.faq-item.open .faq-question i {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  padding: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-answer code {
  background: var(--bg-sidebar);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--accent);
}

/* Wiki import */
.wiki-import-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0 0;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
}

.wiki-import-status.hidden { display: none; }

.wiki-import-error {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.input-error { border-color: var(--danger) !important; }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(40px);
  animation: toastIn 300ms ease forwards;
}

.toast.leaving {
  animation: toastOut 300ms ease forwards;
}

.toast--success {
  background: var(--bg-card);
  border: 1px solid var(--success);
  color: var(--success);
}

.toast--error {
  background: var(--bg-card);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.toast--info {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* =============================================
   UTILITY
   ============================================= */

.hidden {
  display: none !important;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* =============================================
   ANIMATIONS
   ============================================= */

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

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

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

/* =============================================
   WELCOME / NO PROJECT STATE
   ============================================= */

.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  opacity: 0;
  animation: fadeIn 400ms ease forwards;
}

.welcome-logo {
  animation: float 3s ease-in-out infinite;
}

.welcome-logo i {
  font-size: 72px;
  color: var(--accent);
  filter: drop-shadow(0 0 30px var(--accent-glow));
}

.welcome-logo-img {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  object-fit: cover;
  filter: drop-shadow(0 0 30px var(--accent-glow));
}

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

.welcome-title {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.welcome-title .accent {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

.welcome-desc {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 460px;
  line-height: 1.7;
}

.welcome-btn {
  margin-top: 8px;
}

/* =============================================
   ONBOARDING
   ============================================= */

.onboarding-tip {
  position: fixed;
  z-index: 3000;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(35, 103, 218, 0.25);
  animation: fadeIn 300ms ease forwards;
}

.onboarding-tip-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.onboarding-step-badge {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-tip-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
}

.onboarding-skip {
  display: block;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color var(--transition);
}

.onboarding-skip:hover {
  color: var(--text-secondary);
}

/* Pulse effect on target element */
@keyframes onboardingPulse {
  0%   { box-shadow: 0 0 0 0 rgba(35, 103, 218, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(35, 103, 218, 0); }
  100% { box-shadow: 0 0 0 0 rgba(35, 103, 218, 0); }
}

.onboarding-pulse {
  animation: onboardingPulse 1.5s ease infinite !important;
  transition: none !important;
  border-radius: var(--radius-sm);
}

/* =============================================
   BATCH WIKI IMPORT
   ============================================= */

/* Wider modal for category selection */
.modal--batch { max-width: 640px; min-width: 480px; }

/* Category selection */
.batch-category-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.batch-category-controls .btn { font-size: 12px; padding: 4px 10px; }

.batch-category-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.batch-category-search {
  width: 100%;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0 10px;
  font-size: 13px;
  margin-bottom: 10px;
  transition: border-color var(--transition);
}

.batch-category-search:focus {
  border-color: var(--accent);
  outline: none;
}

.batch-category-scroll {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 16px;
}

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

.batch-category-item:hover { background: rgba(255,255,255,0.03); }
.batch-category-item.filtered { opacity: 0.35; }
.batch-category-item input[type="checkbox"] { accent-color: var(--accent); }

.batch-category-item .cat-size {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* Floating Control Center */
.batch-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-height: 55vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: fadeIn 300ms ease forwards;
}

.batch-panel--collapsed .batch-panel-body { display: none; }
.batch-panel--done { border-color: #34d399; }
.batch-panel--cancelled { border-color: var(--danger); }

/* Panel header */
.batch-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.batch-panel-header i.bi-globe2 { font-size: 18px; color: var(--accent); }

.batch-panel-title {
  flex: 1;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-panel-title small {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 6px;
}

.batch-panel-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.batch-panel-toggle:hover { color: var(--text-primary); }

/* Panel body */
.batch-panel-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}

/* Compact stats row */
.batch-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.batch-stat {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.batch-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.batch-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

/* Progress bar */
.batch-progress-bar {
  height: 3px;
  background: var(--bg-card);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.batch-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 300ms ease;
  width: 0%;
}

/* Current operation */
.batch-current-op {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Timing */
.batch-timing {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding: 0 2px;
}

/* Activity log */
.batch-log {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  max-height: 150px;
  overflow-y: auto;
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.batch-log-entry { padding: 1px 0; }
.batch-log-entry--error { color: var(--danger); }
.batch-log-entry--success { color: #34d399; }
.batch-log-entry--dim { color: var(--text-secondary); opacity: 0.6; }

/* Batch actions */
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.batch-actions .btn {
  font-size: 13px;
  padding: 6px 14px;
  white-space: nowrap;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #dc2626; }

/* Report modal */
.report-reasons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.report-reason {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: background 150ms;
}

.report-reason:hover { background: var(--bg-input); }

.report-reason input[type="radio"] {
  accent-color: var(--accent);
}

/* =============================================
   RESPONSIVE (basic)
   ============================================= */

@media (max-width: 768px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
  }

  .brand-sub {
    display: none;
  }

  .content {
    padding: 16px;
  }
}

/* =============================================
   HISTORY DRAWER
   ============================================= */

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  z-index: 900;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}

.history-drawer.visible {
  transform: translateX(0);
}

.history-drawer.hidden {
  pointer-events: none;
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.history-drawer-header i {
  margin-right: 8px;
  color: var(--accent);
}

.history-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Empty state */
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.history-empty i {
  font-size: 48px;
  opacity: .4;
}

.history-empty p {
  font-size: 13px;
  line-height: 1.5;
}

/* Timeline */
.history-timeline {
  position: relative;
  padding-left: 24px;
}

.history-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}

/* Commit item */
.history-commit {
  position: relative;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.history-commit-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.history-commit-header:hover {
  background: var(--bg-hover);
}

/* Source dot on timeline */
.history-source-dot {
  position: absolute;
  left: -20px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
  flex-shrink: 0;
}

.history-source-dot--browser {
  background: var(--accent);
}

.history-source-dot--mcp {
  background: var(--success);
}

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

.history-commit-summary {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.history-commit-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.history-commit-source {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.history-commit-source--browser {
  background: var(--accent-soft);
  color: var(--accent);
}

.history-commit-source--mcp {
  background: var(--success-soft);
  color: var(--success);
}

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

.history-commit-expand {
  color: var(--text-muted);
  font-size: 14px;
  transition: transform 200ms ease;
  flex-shrink: 0;
  margin-top: 2px;
}

.history-commit.expanded .history-commit-expand {
  transform: rotate(180deg);
}

/* Diff panel */
.history-diff-panel {
  display: none;
  padding: 0 12px 12px;
}

.history-commit.expanded .history-diff-panel {
  display: block;
}

.history-diff-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 12px;
  gap: 8px;
}

.history-diff-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Diff entries */
.history-diff {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  border-left: 3px solid transparent;
}

.history-diff--added {
  background: rgba(56, 161, 105, 0.08);
  border-left-color: var(--success);
  color: #68D391;
}

.history-diff--deleted {
  background: rgba(229, 62, 62, 0.08);
  border-left-color: var(--danger);
  color: #FC8181;
}

.history-diff--modified {
  background: rgba(214, 158, 46, 0.08);
  border-left-color: var(--warning);
  color: #F6E05E;
}

.history-diff-icon {
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 1px;
}

.history-diff-text {
  flex: 1;
  word-break: break-word;
}

/* Rollback button */
.history-rollback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.history-rollback-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.history-rollback-btn i {
  font-size: 13px;
}

/* Spinner */
.spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .history-drawer {
    width: 100vw;
  }
}
