/* ═══════════════════════════════════════════
   PROJECT KEY v3 — Design System
   Knowledge Workspace Theme
   ═══════════════════════════════════════════

   ┌────────────────────────────────────────────────────────────┐
   │ SECTION MAP (Phase 1 markers — for upcoming landing/app split)│
   │   §A SHARED        ~line    1 — :root tokens, reset, btn,  │
   │                              modal, toast, form, util, anim │
   │   §B APP-ONLY      ~line   78 — sidebar, .page, graph,     │
   │                              chat, MCP, file detail panel  │
   │   §C LANDING-ONLY  ~line 2707 — .landing-*, .hero-*,       │
   │                              .feature-*, .pricing-*, .faq-*│
   │ Search markers: "§A SHARED", "§B APP-ONLY", "§C LANDING"   │
   └────────────────────────────────────────────────────────────┘ */

/* §A SHARED — moved to shared.css (Phase 2)
   Tokens, reset, body, .show-landing override now live in shared.css.
   Loaded BEFORE this file so app rules can still cascade as before. */

/* ╔═══════════════════════════════════════════════════════════
   ║ §B APP-ONLY — authenticated workspace shell
   ║   Sidebar, main content, the 8 .page sections, file detail
   ║   panel, graph canvas, chat container, sources panel,
   ║   knowledge tabs, MCP setup, context memory, etc.
   ║   Stays in app.css after Phase 3 split.
   ╚═══════════════════════════════════════════════════════════ */

/* ─── APP LAYOUT ─── */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 24px 32px;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow: hidden;
}

/* v7.3.0 — Mobile hamburger toggle + backdrop. Hidden on desktop. */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9700;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--surface-3); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9700;
  animation: fadeIn 0.2s ease;
}

@media (max-width: 768px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9800;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .app-container.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app-container.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .main-content {
    padding: 60px 16px 16px; /* room for the floating hamburger */
  }
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  color: var(--accent);
}

.logo-text {
  font-weight: 700;
  font-size: 15px;
}

.logo-version {
  font-size: 10px;
  background: var(--accent);
  color: white;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }

.nav-icon {
  display: flex;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
}

.sidebar-stats {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  flex-shrink: 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text-secondary); font-weight: 600; }

.sidebar-footer {
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 8px);
  margin: 0 4px 4px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  letter-spacing: 0.5px;
}
.lang-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.lang-toggle svg {
  color: var(--accent);
  flex-shrink: 0;
}
#lang-label {
  color: var(--accent);
  font-weight: 700;
}
.lang-separator {
  color: var(--text-muted);
  opacity: 0.4;
  font-weight: 300;
}
#lang-alt {
  color: var(--text-muted);
  font-weight: 500;
}

.profile-trigger { position: relative; }

.profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-left: auto;
}

.profile-status-dot.active { background: var(--success); }

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.page {
  display: none;
  padding: 24px 32px;
  min-height: 100vh;
  animation: fadeIn 0.2s ease;
}

.page.active { display: block; }

/* @keyframes fadeIn — moved to shared.css */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── BUTTONS — .btn, .btn-primary moved to shared.css ─── */

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 6px;
  line-height: 1;
}

/* .btn-outline, .btn-danger, .btn-sm moved to shared.css */

.btn-send {
  background: var(--accent);
  color: white;
  padding: 8px;
  border-radius: 8px;
}

/* .btn-close moved to shared.css */

/* Toggle Buttons */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  padding: 6px 14px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--accent);
  color: white;
}

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 12px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
}

/* ─── UPLOAD ZONE ─── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-icon { color: var(--text-muted); margin-bottom: 12px; }
.upload-text { font-size: 14px; color: var(--text-secondary); }
.upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── FILE LIST ─── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-1);
  border-radius: 8px;
  border: 1px solid var(--border);
  gap: 12px;
  transition: all 0.15s;
  cursor: pointer;
}

.file-item:hover { background: var(--surface-2); border-color: var(--border-hover); }

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.file-icon.pdf { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.file-icon.md { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.file-icon.txt { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.file-icon.docx { background: rgba(99, 102, 241, 0.15); color: #6366f1; }

.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; margin-top: 2px; }

.file-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag-chip {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  background: rgba(79, 195, 247, 0.1);
  color: var(--color-tag);
  border: 1px solid rgba(79, 195, 247, 0.2);
}

.freshness-badge, .sensitivity-badge, .sot-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
}

.freshness-badge.current { color: var(--success); background: rgba(34, 197, 94, 0.1); }
.freshness-badge.aging { color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.freshness-badge.stale { color: var(--error); background: rgba(239, 68, 68, 0.1); }
.sensitivity-badge.sensitive { color: var(--warning); }
.sensitivity-badge.confidential { color: var(--error); }
.sot-badge { color: var(--accent); background: rgba(99, 102, 241, 0.1); }

/* v7.0.1 — Storage location badges (BYOS Drive vs server) */
.storage-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-block;
  text-decoration: none;
  white-space: nowrap;
}
.storage-badge.storage-drive {
  color: #1a73e8;
  background: rgba(26, 115, 232, 0.1);
  cursor: pointer;
}
.storage-badge.storage-drive:hover {
  background: rgba(26, 115, 232, 0.2);
  text-decoration: underline;
}
.storage-badge.storage-server {
  color: var(--text-muted, #888);
  background: rgba(128, 128, 128, 0.1);
}

/* v5.9.3 — Locked file styles */
.file-item.file-locked {
  opacity: 0.6;
  position: relative;
  border-style: dashed;
  border-color: rgba(239, 68, 68, 0.3);
}
.file-item.file-locked:hover {
  opacity: 0.75;
  border-color: rgba(239, 68, 68, 0.5);
}
.locked-badge {
  font-size: 12px;
  position: absolute;
  top: -2px;
  right: -2px;
}
.locked-label {
  font-size: 10px;
  font-weight: 600;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  letter-spacing: 0.3px;
}

/* v5.9.3 — Sensitive data warning */
.upload-sensitive-warning {
  font-size: 11px;
  color: #f59e0b;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  text-align: center;
}

/* v7.4.0 — Mobile card layout for file rows + show/hide kebab vs inline.
   `.file-actions { position: relative }` lives in the original rule
   below so the dropdown anchor works on both desktop and mobile. */
.file-action-mobile { display: none; }

@media (max-width: 768px) {
  .file-item {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 10px;
    position: relative;
  }
  .file-item .file-icon {
    width: 44px;
    height: 44px;
    align-self: flex-start;
  }
  .file-item .file-name {
    white-space: normal;
    font-size: 15px;
    line-height: 1.35;
  }
  .file-item .file-meta { flex-wrap: wrap; font-size: 12px; }
  .file-item .file-actions {
    position: absolute;
    top: 10px;
    right: 10px;
  }
  .file-action-desktop { display: none; }
  .file-action-mobile { display: inline-flex; }
}

.file-actions {
  display: flex;
  gap: 4px;
  position: relative; /* anchor for the kebab dropdown menu */
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.ready { background: var(--success); }
.status-dot.processing { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot.uploaded { background: var(--color-tag); }
.status-dot.error { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { font-size: 14px; }
.empty-state .hint { font-size: 12px; margin-top: 4px; }

/* ─── KNOWLEDGE VIEW ─── */
.knowledge-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn:hover { color: var(--text-primary); }

.knowledge-content {
  min-height: 300px;
}

.cluster-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.15s;
}

.cluster-card:hover { border-color: var(--border-hover); }

.cluster-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cluster-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.cluster-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cluster-file-chip {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.cluster-file-chip:hover { background: var(--surface-3); }

/* Relation Sidebar */
.relation-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: var(--detail-panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  z-index: 50;
  overflow-y: auto;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.relation-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.relation-sidebar-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.relation-section {
  margin-bottom: 16px;
}

.relation-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.relation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.relation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-1);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.relation-item:hover { background: var(--surface-2); }

.relation-type-label {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}

.suggestion-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 12px;
}

.suggestion-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

/* ─── GRAPH ─── */
#page-graph {
  padding: 16px;
  display: none;
  flex-direction: column;
  height: 100vh;
}

#page-graph.active {
  display: flex;
}

.graph-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.graph-search {
  flex: 0 0 200px;
}

.search-input {
  width: 100%;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.graph-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  user-select: none;
  transition: all 0.15s;
}

.filter-chip.active {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--surface-2);
}

.filter-chip:not(.active) { opacity: 0.4; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-file { background: var(--color-file); }
.dot-entity { background: var(--color-entity); }
.dot-tag { background: var(--color-tag); }
.dot-project { background: var(--color-project); }
.dot-pack { background: var(--color-pack); }
.dot-person { background: var(--color-person); }

.local-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.local-controls input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}

/* ─── GRAPH CANVAS (Obsidian-style) ─── */
.graph-area {
  flex: 1;
  display: flex;
  gap: 0;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 70%),
    radial-gradient(circle at 20% 80%, rgba(79, 195, 247, 0.02) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 138, 101, 0.02) 0%, transparent 50%),
    var(--bg-primary);
}

.graph-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-svg:active { cursor: grabbing; }

.graph-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
}

/* ─── NODE STYLES (Obsidian-style glow) ─── */
.graph-node { cursor: pointer; }

.graph-node .node-glow {
  opacity: 0.15;
  transition: opacity 0.3s ease;
}

.graph-node .node-core {
  transition: r 0.2s ease, opacity 0.3s ease;
}

.graph-node text {
  font-size: 10px;
  fill: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  text-anchor: middle;
  transition: opacity 0.3s ease, fill 0.3s ease;
  font-weight: 400;
}

/* Hover: brightens the hovered node */
.graph-node:hover .node-glow { opacity: 0.45; }
.graph-node:hover .node-core { filter: brightness(1.4); }
.graph-node:hover text { fill: rgba(255, 255, 255, 0.95); font-weight: 500; }

/* Selected: pulsing ring */
.graph-node.selected .node-core {
  stroke: white;
  stroke-width: 2.5;
  stroke-opacity: 1;
}

.graph-node.selected .node-glow {
  opacity: 0.5;
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.65; }
}

/* Dimmed state (when hovering another node — Obsidian behavior) */
.graph-node.dimmed .node-core { opacity: 0.08; }
.graph-node.dimmed .node-glow { opacity: 0; }
.graph-node.dimmed text { opacity: 0; }

/* Neighbor highlight (bright during hover) */
.graph-node.neighbor .node-glow { opacity: 0.35; }
.graph-node.neighbor text { fill: rgba(255, 255, 255, 0.8); opacity: 1; }

/* Label visibility classes (zoom-level based) */
.graph-node.hide-label text { opacity: 0; }

/* ─── EDGE STYLES ─── */
.graph-edge-line {
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 0.8;
  transition: stroke-opacity 0.3s ease, stroke 0.3s ease;
}

/* Dimmed edge (during hover) */
.graph-edge-line.dimmed {
  stroke-opacity: 0.02;
}

/* Highlighted edge (neighbor connection) */
.graph-edge-line.highlighted {
  stroke-opacity: 0.5;
  stroke-width: 1.5;
}

/* ─── TOOLTIP (Obsidian-style glass) ─── */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 30;
  transition: opacity 0.15s ease;
  max-width: 240px;
}

.graph-tooltip.hidden { opacity: 0; pointer-events: none; }

.tooltip-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  word-break: break-word;
}

.tooltip-type {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── ZOOM CONTROLS ─── */
.graph-zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}

.zoom-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ─── INFO OVERLAY ─── */
.graph-info-overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: var(--text-muted);
  z-index: 20;
  user-select: none;
}

/* ─── DETAIL PANEL (refined) ─── */
.detail-panel {
  width: var(--detail-panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.detail-type-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-header h3 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.detail-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
}

.detail-meta-grid .meta-key { color: var(--text-muted); }
.detail-meta-grid .meta-value { color: var(--text-secondary); }

.detail-relations {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

/* ─── AI CHAT ─── */
#page-chat {
  padding: 0;
  height: 100vh;
}

#page-chat.active { display: block; }

.chat-container {
  display: flex;
  height: 100%;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.profile-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.profile-dot.active { background: var(--success); }

/* v7.2.0 — AI Typing Indicator (chat header) */
.chat-typing-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 9999px;
  background: var(--accent-glow);
  margin-left: 12px;
}
.chat-typing-status.hidden { display: none; }

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.welcome-message {
  text-align: center;
  padding: 48px 24px;
}

.welcome-message h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.welcome-message p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.context-layers {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.layer-chip {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.layer-profile { border-color: rgba(179, 157, 219, 0.3); color: var(--color-profile); }
.layer-pack { border-color: rgba(79, 195, 247, 0.3); color: var(--color-packs); }
.layer-collection { border-color: rgba(129, 199, 132, 0.3); color: var(--color-collection); }
.layer-file { border-color: rgba(255, 213, 79, 0.3); color: var(--color-files); }
.layer-graph { border-color: rgba(255, 138, 101, 0.3); color: var(--color-graph); }

.message {
  margin-bottom: 16px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

.message.user {
  margin-left: auto;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.injection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-wrapper textarea {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
}

.chat-input-wrapper textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Sources Panel */
.sources-panel {
  width: var(--sources-panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sources-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sources-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.sources-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.source-section {
  margin-bottom: 14px;
}

.source-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.source-content {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  margin: 2px;
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.evidence-graph-container {
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* §A SHARED moved to shared.css:
   .modal-overlay, .modal, .modal-header, .modal-body, .modal-footer,
   .form-group, .form-group label, .form-group textarea,
   #toast-container, .toast (+ .success/.error/.info),
   @keyframes slideUp, @keyframes spin */

/* ─── LOADING ─── */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ═══ LOADING OVERLAY — v5.1 Premium ═══ */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10800; /* v7.3.0 — was 10000; sits above modal-overlay (10500) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.loading-overlay.visible { opacity: 1; }
.loading-overlay.fade-out { opacity: 0; transition: opacity 0.3s ease; }

.loading-overlay-card {
  background: linear-gradient(135deg, rgba(30, 32, 44, 0.95), rgba(20, 22, 34, 0.98));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 20px;
  padding: 40px 48px;
  text-align: center;
  min-width: 320px;
  max-width: 420px;
  box-shadow: 
    0 0 60px rgba(139, 92, 246, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.4);
  animation: cardFloat 2s ease-in-out infinite;
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Upload icon */
.loading-icon.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--accent, #a78bfa);
  animation: uploadBounce 1.2s ease-in-out infinite;
}

@keyframes uploadBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* AI brain icon */
.loading-icon.ai-brain {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--accent, #a78bfa);
  animation: aiPulse 1.5s ease-in-out infinite;
}
.loading-icon.ai-brain svg {
  width: 100%;
  height: 100%;
}

@keyframes aiPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.3)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.6)); }
}

/* Default spinner */
.loading-icon.default-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent, #a78bfa);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-message {
  font-size: 16px;
  font-weight: 500;
  color: #e2e8f0;
  line-height: 1.6;
  margin-bottom: 20px;
}

.loading-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(139, 92, 246, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.loading-progress-fill {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent, #a78bfa), #c084fc, var(--accent, #a78bfa));
  background-size: 200% 100%;
  border-radius: 2px;
  animation: progressShimmer 1.5s ease-in-out infinite;
}

@keyframes progressShimmer {
  0% { width: 10%; background-position: -200% 0; }
  50% { width: 70%; }
  100% { width: 10%; background-position: 200% 0; }
}

.loading-elapsed {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.7);
  font-variant-numeric: tabular-nums;
}

/* §A SHARED moved to shared.css: .hidden + ::-webkit-scrollbar */


/* ═══════════════════════════════════════════
   MVP v4 — PDB Connector Layer Styles
   ═══════════════════════════════════════════ */

:root {
  --color-mcp: #a78bfa;
  --color-mcp-glow: rgba(167, 139, 250, 0.15);
  --color-mcp-border: rgba(167, 139, 250, 0.25);
}

/* ─── NAV DIVIDER & SECTION LABEL ─── */
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 12px;
}

.nav-section-label {
  display: block;
  padding: 4px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ─── MCP SETUP PAGE ─── */

.mcp-status-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mcp-status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mcp-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
  transition: all 0.3s;
}

.mcp-status-dot.active {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15), 0 0 12px rgba(34, 197, 94, 0.3);
}

.mcp-status-text {
  font-size: 14px;
  font-weight: 600;
}

.mcp-status-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Setup Grid */
.mcp-setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .mcp-setup-grid { grid-template-columns: 1fr; }
}

.mcp-step-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  gap: 16px;
  transition: border-color 0.2s;
}

.mcp-step-card:hover {
  border-color: var(--border-hover);
}

.mcp-step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-mcp-glow);
  border: 1px solid var(--color-mcp-border);
  color: var(--color-mcp);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.mcp-step-content {
  flex: 1;
  min-width: 0;
}

.mcp-step-content h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.mcp-step-content p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Platform Tabs (v5.3) */
.mcp-platform-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.mcp-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.mcp-tab:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

.mcp-tab.active {
  color: var(--color-mcp);
  border-bottom-color: var(--color-mcp);
}

.mcp-tab-content {
  display: none;
}

.mcp-tab-content.active {
  display: block;
}

/* Code Block */
.code-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--color-mcp);
  word-break: break-all;
}

.code-block code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-block-multi {
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

.code-block-multi pre {
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  font-family: inherit;
  margin: 0;
}

.code-block-multi .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

.code-block-token {
  border-color: var(--color-mcp-border);
  background: rgba(167, 139, 250, 0.05);
}

/* Copy Button */
.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--color-mcp);
}

/* Token Area */
.mcp-token-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mcp-token-input-row {
  display: flex;
  gap: 8px;
}

.mcp-token-input-row .search-input {
  flex: 1;
}

.mcp-token-display {
  animation: fadeIn 0.3s ease;
}

.mcp-token-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--warning);
  margin-bottom: 8px;
}

/* Test Result */
.mcp-test-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 10px;
  animation: fadeIn 0.3s ease;
}

.mcp-test-result.success {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.mcp-test-result.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.mcp-test-result.warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.test-icon { font-size: 16px; }

/* Available Tools Grid */
.mcp-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.mcp-tool-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  transition: border-color 0.15s;
}

.mcp-tool-card:hover {
  border-color: var(--color-mcp-border);
}

.mcp-tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mcp-tool-icon { font-size: 16px; }

.mcp-tool-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-mcp);
  background: var(--color-mcp-glow);
  padding: 2px 8px;
  border-radius: 4px;
}

.mcp-tool-scope {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}

.mcp-tool-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}

.mcp-tool-params {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mcp-param-chip {
  font-size: 10px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}


/* ─── TOKEN MANAGEMENT PAGE ─── */

.token-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.token-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.15s;
}

.token-card:hover { border-color: var(--border-hover); }

.token-card.revoked { opacity: 0.55; }

.token-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.token-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.token-card-label svg { color: var(--color-mcp); }

.token-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.token-status-pill.active {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.token-status-pill.revoked {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.token-card-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.token-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.token-meta-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.token-meta-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.token-card-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-size: 11px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  color: var(--error);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

.token-revoked-info {
  font-size: 11px;
  color: var(--text-muted);
}


/* ─── MCP LOGS PAGE ─── */

.log-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.log-filter-select {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  min-width: 140px;
}

.log-filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

.log-filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.log-table-wrapper {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.log-table thead {
  background: var(--surface-1);
}

.log-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.log-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.log-table tbody tr:hover {
  background: var(--bg-hover);
}

.log-table tbody tr:last-child td {
  border-bottom: none;
}

.log-row-error {
  background: rgba(239, 68, 68, 0.03);
}

.log-time {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.log-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--color-mcp);
  background: var(--color-mcp-glow);
  padding: 2px 8px;
  border-radius: 4px;
}

.log-status-pill {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}

.log-status-pill.success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.log-status-pill.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.log-latency {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.log-details {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-muted);
}

.log-empty-row td {
  border-bottom: none;
}

/* ═══════════════════════════════════════════
   FILE DETAIL SLIDE PANEL
   ═══════════════════════════════════════════ */

.file-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 90vw);
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}
.file-detail-panel.visible {
  transform: translateX(0);
}

.file-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.file-detail-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.file-detail-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.file-detail-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  margin: 0;
}
.fd-meta-row {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}
.file-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.fd-section {
  margin-bottom: 24px;
}
.fd-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.fd-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}
.fd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.fd-chips .chip {
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(109, 78, 255, 0.15);
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 500;
}
.fd-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.fd-list li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 4px 0;
  padding-left: 14px;
  position: relative;
}
.fd-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
}
.fd-content-preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Inter', sans-serif;
}

/* Make file items clickable */
.file-item {
  cursor: pointer;
  transition: background 0.15s;
}
.file-item:hover {
  background: var(--bg-tertiary);
}

/* Backdrop */
.fd-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 199;
  opacity: 0;
  pointer-events: none;  /* ไม่ดักจับ click เมื่อซ่อนอยู่ */
  transition: opacity 0.3s;
}
.fd-backdrop.visible {
  opacity: 1;
  pointer-events: auto;  /* ดักจับ click เฉพาะเมื่อแสดง */
}

/* ═══════════════════════════════════════════
   CONTEXT PACK MODAL + CARDS
   ═══════════════════════════════════════════ */

.pack-modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 10500; /* v7.3.0 — was 300; matches .modal-overlay so layering is consistent */
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}
.pack-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(500px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.pack-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.pack-modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.pack-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.pack-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus {
  border-color: var(--accent-primary);
}
.pack-file-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-tertiary);
}
.pack-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.pack-file-item:last-child { border-bottom: none; }
.pack-file-item:hover { background: rgba(109,78,255,0.08); }
.pack-file-item input[type="checkbox"] {
  accent-color: var(--accent-primary);
  width: 16px; height: 16px;
}
.pack-file-item .pf-name {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pack cards in Knowledge View */
.pack-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.pack-card:hover {
  border-color: var(--accent-primary);
}
.pack-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.pack-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.pack-card-actions {
  display: flex;
  gap: 6px;
}
.pack-card-actions button {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.pack-card-actions button:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.pack-card-actions button.btn-danger:hover {
  border-color: #f44;
  color: #f44;
}
.pack-card-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}
.pack-card-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Create pack button */
.packs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════
   SUMMARY EDIT MODE
   ═══════════════════════════════════════════ */

.fd-edit-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  padding: 8px 0;
  z-index: 5;
}
.fd-edit-actions {
  display: flex;
  gap: 6px;
}
.fd-edit-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--accent-primary);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* Collection card edit */
.cluster-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.btn-icon:hover {
  opacity: 1;
}
.cluster-card:hover .btn-icon {
  opacity: 0.7;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  margin-left: auto;
  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: var(--surface-2);
  border-radius: 20px;
  transition: background 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* MCP Tool Categories */
.mcp-tools-category {
  margin-bottom: 20px;
}
.mcp-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.mcp-tool-card.disabled {
  opacity: 0.4;
}
.mcp-tool-card.disabled .mcp-tool-desc {
  text-decoration: line-through;
}

/* §C LANDING block (hero, features, pricing, FAQ, trust, CTA,
   footer, auth-modal styles, landing responsive @media) was
   extracted to landing.css in Phase 3. */


/* ─── SIDEBAR USER INFO ─── */

.sidebar-user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  margin-top: 2px;
  background: var(--surface-1);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.btn-logout:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* §C LANDING responsive @media queries moved to landing.css */



/* ═══════════════════════════════════════════
   CONTEXT MEMORY — v5.5
   ═══════════════════════════════════════════ */

.ctx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.ctx-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ctx-card:hover {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 4px 24px rgba(99, 102, 241, 0.12);
  transform: translateY(-2px);
}
.ctx-card.pinned {
  border-color: rgba(250, 204, 21, 0.4);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.04), transparent);
}

.ctx-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.ctx-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}
.ctx-pin-badge {
  font-size: 14px;
  flex-shrink: 0;
}

.ctx-card-summary {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ctx-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.ctx-type-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}
.ctx-type-badge.project { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.ctx-type-badge.task { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.ctx-type-badge.note { background: rgba(236, 72, 153, 0.15); color: #f9a8d4; }

.ctx-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.ctx-card-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.ctx-card-actions {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: none;
  gap: 4px;
  z-index: 2;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(6px);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}
.ctx-card:hover .ctx-card-actions { display: flex; }
.ctx-card-actions button {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text-secondary);
}
.ctx-card-actions button:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
}
.ctx-card-actions button svg { stroke: currentColor; }

/* v7.4.0 — Kebab anchor for ctx-card. Position absolute to the card. */
.ctx-card { /* already position: relative */ }
.ctx-kebab {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1; /* above card content */
}

@media (max-width: 768px) {
  .ctx-grid { grid-template-columns: 1fr; }
  /* On mobile the legacy hover-only flyout never appears — kebab handles
     all card-level actions. Hide the legacy DOM if any future render
     re-introduces it. */
  .ctx-card-actions { display: none !important; }
}


/* ═══════════════════════════════════════════
   v7.4.0 — Page Primary FAB (mobile only)
   ═══════════════════════════════════════════
   Sits ABOVE .guide-fab (bottom 24, height ~48) so the two don't overlap.
   Hidden on desktop because the in-flow primary button is enough there. */
.page-fab {
  display: none;
  position: fixed;
  bottom: 88px;
  right: 20px;
  z-index: 9700;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}
.page-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.55);
}
.page-fab:active { transform: scale(0.96); }

@media (max-width: 768px) {
  .page.active .page-fab { display: inline-flex; }
  /* Hide in-flow primary actions where the FAB takes over */
  .page.active #btn-organize-new,
  .page.active #btn-new-context { display: none; }
  /* Leave room above the FAB so the last list item isn't covered */
  .main-content { padding-bottom: 96px; }
}

/* ═══════════════════════════════════════════
   GUIDE SYSTEM — Simple FAB + Drawer
   ═══════════════════════════════════════════ */
.guide-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9998;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; border: none; border-radius: 50px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white; font-size: 0.9rem; font-weight: 600;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
  transition: all 0.3s ease;
}
.guide-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(124,58,237,0.5); }

.guide-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
}

.guide-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 10000;
  width: 420px; max-width: 100vw;
  background: var(--bg-primary, #0f0f23);
  border-left: 1px solid var(--border, #2a2a4a);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.guide-drawer.open { transform: translateX(0); }

.guide-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border, #2a2a4a);
}
.guide-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.guide-close {
  background: none; border: none; color: var(--text-secondary, #9ca3af);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.guide-close:hover { background: var(--bg-hover, #1e1e3a); color: white; }

.guide-search { display: none; }

.guide-tabs {
  display: flex; padding: 0 20px;
  border-bottom: 1px solid var(--border, #2a2a4a);
}
.guide-tab {
  flex: 1; padding: 10px 8px; border: none; background: none;
  color: var(--text-secondary, #9ca3af); font-size: 0.8rem;
  font-family: inherit; cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.guide-tab:hover { color: var(--text-primary, #e5e7eb); }
.guide-tab.active { color: var(--accent, #7c3aed); border-bottom-color: var(--accent, #7c3aed); font-weight: 600; }

.guide-content {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  scrollbar-width: thin;
}

.guide-section {
  margin-bottom: 20px;
}
.guide-section h3 {
  margin: 0 0 12px; font-size: 0.95rem; font-weight: 600;
  padding-bottom: 8px; border-bottom: 1px solid var(--border, #2a2a4a);
  color: var(--text-primary, #e5e7eb);
}
.guide-item {
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border, #2a2a4a);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
}
.guide-item strong {
  display: block; margin-bottom: 4px; font-size: 0.88rem;
  color: var(--text-primary, #e5e7eb);
}
.guide-item p {
  margin: 0 0 6px; font-size: 0.82rem; line-height: 1.5;
  color: var(--text-secondary, #9ca3af);
}
.guide-item code {
  background: var(--bg-hover, #1e1e3a); padding: 2px 6px; border-radius: 4px;
  font-size: 0.8rem; color: #a78bfa;
}

.guide-copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-radius: 8px;
  background: var(--accent, #7c3aed); color: white;
  border: none; font-size: 0.82rem; cursor: pointer; font-family: inherit;
  margin-top: 8px;
}
.guide-copy-btn:hover { opacity: 0.9; }

@media (max-width: 480px) {
  .guide-drawer { width: 100vw; }
  .guide-fab span { display: none; }
  .guide-fab { padding: 14px; border-radius: 50%; }
}

.guide-item img {
  width: 100%; border-radius: 8px; margin: 8px 0 4px;
  border: 1px solid var(--border, #2a2a4a);
}

/* ─── BILLING SECTION (v5.9.2) ─── */
.billing-section { margin-bottom: 4px; }
.billing-plan-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px;
}
.billing-plan-info {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.billing-plan-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.billing-plan-badge.badge-free {
  background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3);
}
.billing-plan-badge.badge-starter {
  background: rgba(129,140,248,0.15); color: #818cf8; border: 1px solid rgba(129,140,248,0.3);
}
.billing-plan-name { font-size: 15px; font-weight: 500; color: #e5e7eb; }
.billing-plan-detail { font-size: 13px; color: #8a8f98; margin-bottom: 12px; }
.billing-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.billing-actions .btn-sm { font-size: 13px; padding: 7px 14px; border-radius: 8px; }
.billing-cancel-note { font-size: 12px; color: #f59e0b; margin-top: 8px; font-style: italic; }

/* ─── PLAN SELECTION MODAL (v5.9.2) ─── */
.plan-modal { max-width: 780px; width: 95%; max-height: 90vh; }
.plan-modal .modal-body { overflow-y: auto; max-height: 72vh; padding-right: 8px; }
.plan-modal-desc { color: #8a8f98; font-size: 14px; margin-bottom: 20px; text-align: center; }
.plan-group { margin-bottom: 8px; }
.plan-group-label { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 2px; }
.plan-group-personal { color: #818cf8; }
.plan-group-exec { color: #d4a853; }
.plan-group-desc { text-align: center; color: #6b7280; font-size: 13px; margin-bottom: 16px; }
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.plan-cards-exec { grid-template-columns: repeat(3, 1fr); }
.plan-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 20px 16px;
  display: flex; flex-direction: column;
  position: relative;
  transition: border-color 0.3s, transform 0.2s;
}
.plan-card:hover { border-color: rgba(255,255,255,0.15); transform: translateY(-2px); }
.plan-card-highlight {
  border-color: rgba(129,140,248,0.3);
  background: rgba(129,140,248,0.04);
}
.plan-card-highlight:hover { border-color: rgba(129,140,248,0.5); box-shadow: 0 0 30px rgba(129,140,248,0.08); }
.plan-card-exec { border-color: rgba(212,168,83,0.12); }
.plan-card-exec:hover { border-color: rgba(212,168,83,0.3); box-shadow: 0 0 20px rgba(212,168,83,0.06); }
.plan-card-exec-highlight { border-color: rgba(212,168,83,0.25); transform: scale(1.02); }
.plan-card-exec-highlight:hover { transform: scale(1.04) translateY(-2px); }
.plan-card-badge {
  position: absolute; top: -10px; right: 16px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 12px; border-radius: 20px;
  letter-spacing: 0.3px;
}
.plan-card-header h3 { font-size: 18px; font-weight: 600; color: #f7f8f8; margin-bottom: 4px; }
.plan-card-price { font-size: 28px; font-weight: 700; color: #e5e7eb; margin-bottom: 4px; }
.plan-card-price span { font-size: 13px; font-weight: 400; color: #6b7280; }
.plan-card-price-accent { color: #818cf8; }
.plan-card-price-gold { color: #d4a853; }
.plan-card-tagline { font-size: 12px; color: #6b7280; margin-bottom: 14px; font-style: italic; }
.plan-card-features { list-style: none; padding: 0; margin-bottom: 16px; flex: 1; }
.plan-card-features li {
  padding: 4px 0; font-size: 12.5px; color: #d0d6e0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.plan-card-features li::before { content: "✓ "; color: #22c55e; font-weight: 600; }
.btn-gold {
  background: linear-gradient(135deg, #d4a853, #b8860b);
  color: #fff; border: none; font-weight: 600;
}
.btn-gold:hover { opacity: 0.9; transform: translateY(-1px); }
@media (max-width: 700px) {
  .plan-cards, .plan-cards-exec { grid-template-columns: 1fr; }
  .plan-modal { max-width: 400px; }
  .plan-card-exec-highlight { transform: none; }
}

/* ═══════════════════════════════════════════
   USAGE BARS — v5.9.3
   ═══════════════════════════════════════════ */
.usage-section {
  background: rgba(129, 140, 248, 0.06);
  border: 1px solid rgba(129, 140, 248, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.usage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.usage-title {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
}
.usage-plan-label {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.15);
  color: #818cf8;
}
.usage-bar-row {
  margin-bottom: 10px;
}
.usage-bar-row:last-child {
  margin-bottom: 0;
}
.usage-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.usage-bar-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.usage-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 2px;
}

/* ═══════════════════════════════════════════
   UPGRADE MODAL — v5.9.3
   ═══════════════════════════════════════════ */
.upgrade-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10500; /* v7.3.0 — was 10000; aligned with .modal-overlay */
  animation: fadeIn 0.2s ease;
}
.upgrade-modal {
  background: linear-gradient(135deg, rgba(30,27,55,0.98), rgba(20,18,40,0.98));
  border: 1px solid rgba(129,140,248,0.25);
  border-radius: 20px;
  padding: 36px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(129,140,248,0.15);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.upgrade-modal-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.upgrade-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0 0 12px;
}
.upgrade-modal-message {
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 24px;
}
.upgrade-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.upgrade-modal-btn {
  background: linear-gradient(135deg, #818cf8, #6366f1) !important;
  border: none !important;
  padding: 12px 24px !important;
  border-radius: 12px !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  cursor: pointer;
  transition: all 0.2s;
}
.upgrade-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99,102,241,0.4);
}
.upgrade-modal-dismiss {
  background: transparent !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #64748b !important;
  padding: 10px 24px !important;
  border-radius: 12px !important;
  cursor: pointer;
  font-size: 13px !important;
}
.upgrade-modal-dismiss:hover {
  border-color: rgba(255,255,255,0.2) !important;
  color: #94a3b8 !important;
}


/* ═══════════════════════════════════════════
   STORAGE MODE — BYOS v7.0.0
   ═══════════════════════════════════════════ */

.storage-mode-section {
  background: rgba(16, 185, 129, 0.04);
  border: 1px solid rgba(16, 185, 129, 0.12);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  transition: border-color 0.3s ease;
}
.storage-mode-section:hover {
  border-color: rgba(16, 185, 129, 0.22);
}

.storage-mode-header {
  margin-bottom: 12px;
}
.storage-mode-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.storage-mode-title-row svg {
  color: #10b981;
  flex-shrink: 0;
}
.storage-mode-title {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1;
}

/* Storage badges */
.storage-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.storage-badge-managed {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.3);
}
.storage-badge-byos {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Storage body */
.storage-mode-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.storage-managed-desc {
  font-size: 13px;
  color: #8a8f98;
  line-height: 1.5;
  margin: 0;
}

/* Connected info */
.storage-connected-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.storage-connected-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #34d399;
}
.storage-email {
  font-size: 12px;
  color: #94a3b8;
  padding-left: 24px;
}
.storage-sync-time {
  font-size: 11px;
  color: #64748b;
  padding-left: 24px;
}
.storage-folder {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #8a8f98;
  padding-left: 24px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Actions */
.storage-mode-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.storage-mode-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Testing mode notice */
.storage-mode-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.06);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.12);
}
.storage-mode-notice svg {
  color: #f59e0b;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════ */
/* v6.0 — Personality Section + History       */
/* ═══════════════════════════════════════════ */

.personality-section {
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 16px;
}

.personality-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  font-weight: 510;
  color: #f7f8f8;
  user-select: none;
}
.personality-section > summary::-webkit-details-marker { display: none; }
.personality-section > summary::before {
  content: '▶';
  display: inline-block;
  font-size: 10px;
  color: #8a8f98;
  transition: transform 0.15s ease;
}
.personality-section[open] > summary::before { transform: rotate(90deg); }
.personality-section > summary:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
}

.personality-section-title { flex: 1; }
.personality-optional {
  font-size: 12px;
  font-weight: 400;
  color: #8a8f98;
}

.personality-pdpa {
  font-size: 12px;
  color: #62666d;
  margin: 12px 0 16px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  border-left: 2px solid rgba(94,106,210,0.35);
  line-height: 1.5;
}

/* ─── Personality blocks (4 systems) ─── */
.personality-block {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.personality-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.personality-block-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 590;
  color: #f7f8f8;
  letter-spacing: -0.182px;
}

.personality-desc {
  font-size: 12px;
  color: #8a8f98;
  line-height: 1.6;
  margin: 0 0 10px 0;
  padding: 8px 10px;
  background: rgba(255,255,255,0.015);
  border-radius: 5px;
  border-left: 2px solid rgba(94,106,210,0.25);
}
.personality-desc strong {
  color: #b0b7c3;
  font-weight: 590;
}

.btn-history {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #d0d6e0;
  font-size: 12px;
  font-weight: 510;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-history:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}
.history-count {
  background: #5e6ad2;
  color: #fff;
  font-size: 10px;
  font-weight: 590;
  padding: 1px 6px;
  border-radius: 9999px;
  line-height: 1.4;
}

.personality-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.personality-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #d0d6e0;
}
.personality-fields select {
  background-color: #161719;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: #f7f8f8;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}
.personality-fields select option {
  background: #1e1f23;
  color: #f7f8f8;
}
.personality-fields select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.personality-fields small {
  font-size: 10px;
  color: #62666d;
  margin-top: -2px;
}

.personality-rank-list {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.personality-rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.personality-rank-label {
  width: 28px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 590;
  color: #8a8f98;
  text-align: right;
}
.personality-rank-row input {
  flex: 1;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: #f7f8f8;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}
.personality-rank-row input:focus {
  outline: none;
  border-color: rgba(113,112,255,0.4);
  background: rgba(255,255,255,0.04);
}

/* ─── External test links (chip style) ─── */
.test-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.test-link-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 9999px;
  color: #d0d6e0;
  font-size: 11px;
  font-weight: 510;
  padding: 3px 10px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.test-link-chip:hover {
  background: rgba(255,255,255,0.08);
  color: #f7f8f8;
}
.test-link-chip.is-free {
  border-color: rgba(39,166,68,0.35);
  color: #5fcc78;
}
.test-link-chip.is-free:hover {
  background: rgba(39,166,68,0.12);
  color: #5fcc78;
}

/* ─── History modal + timeline ─── */
.personality-history-modal {
  max-width: 520px;
  width: 90vw;
}
.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.history-entry {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 10px 12px;
}
.history-date {
  font-size: 12px;
  color: #8a8f98;
  margin-bottom: 4px;
}
.history-value {
  font-size: 14px;
  color: #f7f8f8;
  font-weight: 510;
  margin-bottom: 4px;
}
.history-source {
  font-size: 11px;
  color: #62666d;
}
.history-empty {
  text-align: center;
  color: #62666d;
  font-size: 13px;
  padding: 24px 0;
}

/* Responsive — collapse personality fields ลง 1 column บน mobile */
@media (max-width: 600px) {
  .personality-fields { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   DUPLICATE DETECTION MODAL (v7.1)
   ═══════════════════════════════════════════ */
.dup-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10500; /* v7.3.0 — was 9999; aligned with other modal overlays */
}
.dup-modal-overlay.hidden { display: none; }

.dup-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.dup-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.dup-modal-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
}

.dup-modal-body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
}
.dup-modal-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}
.dup-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dup-row {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.dup-new {
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 8px;
  word-break: break-word;
}
.dup-arrow {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
  word-break: break-word;
}

.dup-bar {
  position: relative;
  background: var(--surface-2);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
  margin-bottom: 6px;
}
.dup-bar-fill {
  /* Gradient เหลือง→แดง — เน้นว่าเป็น "warning" UI ไม่ใช่ success */
  background: linear-gradient(90deg, var(--warning), var(--error));
  height: 100%;
  transition: width 0.3s ease;
}
.dup-bar-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 18px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.dup-topics {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
  font-style: italic;
  word-break: break-word;
}

.dup-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .dup-modal { width: 95%; max-height: 90vh; }
  .dup-modal-footer { flex-direction: column-reverse; }
  .dup-modal-footer .btn { width: 100%; }
}

/* ═══════════════════════════════════════════
   v7.1.5 — Per-file selector + undo toast
   ═══════════════════════════════════════════ */

/* Quick action bar above per-file list */
.dup-quick-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.dup-quick-actions .btn-sm {
  font-size: 12px;
  padding: 4px 10px;
}

/* Per-row radio actions (research-backed: NN/G + Win/macOS Skip/Keep both) */
.dup-actions {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
}
.dup-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
.dup-radio input[type="radio"] {
  cursor: pointer;
  accent-color: #818cf8;
}
.dup-radio:has(input:checked) {
  color: var(--text-primary);
  font-weight: 500;
}

/* Undo toast — 10s countdown + manual X dismiss (Material 3 + WCAG 2.2.1) */
.dup-undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary, #191a1b);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 11000; /* Above modals (10500) per v7.3.0 z-index hierarchy */
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  min-width: 380px;
  max-width: 92vw;
  overflow: hidden;
  animation: dupUndoToastIn 0.25s ease-out;
}
@keyframes dupUndoToastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.dup-undo-text {
  flex: 1;
  min-width: 0;
}
.dup-undo-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 510;
}
.dup-undo-files {
  color: var(--text-secondary);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dup-undo-btn {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 510;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.dup-undo-btn:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
}
.dup-undo-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary, #62666d);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.dup-undo-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #f7f8f8);
}
.dup-undo-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.dup-undo-progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transform-origin: left;
  animation: dupUndoCountdown 10s linear forwards;
}
@keyframes dupUndoCountdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Mobile responsive */
@media (max-width: 600px) {
  .dup-undo-toast {
    min-width: unset;
    width: 92vw;
    flex-wrap: wrap;
  }
  .dup-undo-text { width: 100%; order: 1; }
  .dup-undo-btn { order: 2; }
  .dup-undo-close { order: 3; }
  .dup-actions { flex-direction: column; gap: 8px; }
}

/* ═══════════════════════════════════════════
   v7.5.0 — Upload Result Modal (per-file actionable skip)
   ═══════════════════════════════════════════ */
.upload-result-modal-overlay { z-index: 10500; }
.upload-result-modal { max-width: 540px; width: 92vw; }
.upload-result-modal .modal-body { max-height: 60vh; overflow-y: auto; padding: 16px 20px; }

.upload-result-success {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 16px;
  background: #ecfdf5; border-left: 4px solid #10b981;
  border-radius: 6px;
}
.upload-result-icon-success {
  width: 32px; height: 32px; border-radius: 50%;
  background: #10b981; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.upload-result-success-text { font-weight: 500; color: #064e3b; }

.upload-result-skip-header {
  font-size: 13px; font-weight: 600; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 8px 0 10px;
}
.upload-result-skip-list { display: flex; flex-direction: column; gap: 10px; }
.upload-result-skip-card {
  display: flex; gap: 12px;
  padding: 12px 14px;
  background: #fef2f2; border-left: 4px solid #f87171;
  border-radius: 6px;
}
.upload-result-skip-icon { font-size: 24px; flex-shrink: 0; line-height: 1; }
.upload-result-skip-body { flex: 1; min-width: 0; }
.upload-result-skip-filename {
  font-weight: 600; color: #991b1b; word-break: break-all;
  margin-bottom: 4px;
}
.upload-result-skip-message { color: #7f1d1d; font-size: 14px; margin-bottom: 6px; }
.upload-result-skip-suggestion {
  color: #525252; font-size: 13px; line-height: 1.5;
  padding-top: 6px; border-top: 1px dashed #fca5a5;
}
.upload-result-skip-suggestion strong { color: #1f2937; }

@media (max-width: 768px) {
  .upload-result-modal { width: 96vw; }
  .upload-result-skip-card { padding: 10px 12px; gap: 10px; }
  .upload-result-skip-icon { font-size: 20px; }
}

/* ═══════════════════════════════════════════
   v7.5.0 — Extraction status badges + chunk count + retry button
   ═══════════════════════════════════════════ */
.extraction-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.extraction-empty { background: #fef3c7; color: #92400e; }
.extraction-encrypted { background: #fee2e2; color: #991b1b; }
.extraction-ocr_failed { background: #fed7aa; color: #9a3412; }
.extraction-unsupported { background: #f3f4f6; color: #4b5563; }
.extraction-partial { background: #fef9c3; color: #854d0e; }

.chunk-count-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 6px;
  border-radius: 10px;
  background: #ede9fe; color: #5b21b6;
  font-weight: 500;
  white-space: nowrap;
}

.file-action-retry {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fbbf24;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  margin-right: 6px;
  transition: background 0.15s;
}
.file-action-retry:hover { background: #fde68a; }

@media (max-width: 768px) {
  .extraction-badge, .chunk-count-badge { font-size: 10px; padding: 1px 5px; }
  .file-action-retry { display: none; } /* mobile uses kebab menu */
}

/* ═══════════════════════════════════════════ */
/* v8.0.0 — LINE Bot Section in Profile Modal */
/* ═══════════════════════════════════════════ */
.line-bot-section {
  background: rgba(6, 199, 85, 0.05);  /* LINE brand green tint */
  border: 1px solid rgba(6, 199, 85, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  transition: border-color 0.3s ease;
}
.line-bot-section:hover {
  border-color: rgba(6, 199, 85, 0.28);
}

.line-bot-header { margin-bottom: 12px; }
.line-bot-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.line-bot-title-row svg { color: #06c755; flex-shrink: 0; }  /* LINE green */
.line-bot-title {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1;
}
.line-bot-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.line-bot-badge-disconnected {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}
.line-bot-badge-connected {
  background: rgba(6, 199, 85, 0.18);
  color: #06c755;
}

.line-bot-body { font-size: 13px; }
.line-bot-desc {
  color: #94a3b8;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 12px 0;
}
.line-bot-info {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.line-bot-info-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
}
.line-bot-info-label { color: #94a3b8; }
.line-bot-info-value { color: #e2e8f0; font-weight: 500; }

.line-bot-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.line-bot-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 11.5px;
  color: #fbbf24;
}
.line-bot-notice svg { color: #f59e0b; flex-shrink: 0; }

/* ═══════════════════════════════════════════
   v8.1.0 — Google Sign-In button + auth divider
   ═══════════════════════════════════════════ */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-weight: 500;
  font-size: 14px;
  padding: 11px 16px;
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.btn-google:hover {
  background: #f8f9fa;
  border-color: #c8ccd0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.btn-google:active {
  background: #f1f3f4;
}
.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-google-icon {
  flex-shrink: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted, #888);
  font-size: 12.5px;
  margin: 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, rgba(255, 255, 255, 0.1));
}
.auth-divider span {
  white-space: nowrap;
}

/* ═══════════════════════════════════════════
   ADMIN PANEL — v8.2.0
   หน้า /admin (admin.html) — หน้าแยกจาก /app
   reuse: shared.css ทั้ง .modal-overlay/.modal/.toast/.btn-*/.form-input
   ═══════════════════════════════════════════ */
.admin-loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary); color: var(--text-muted);
}

.admin-shell {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.admin-header {
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary);
  position: sticky; top: 0; z-index: 100;
}
.admin-logo {
  display: flex; align-items: center; gap: 12px;
  font-weight: 600; color: var(--text-primary);
}
.admin-logo-pill {
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
}
.admin-user-info {
  display: flex; gap: 12px; align-items: center;
  font-size: 14px; color: var(--text-secondary);
}

.admin-tabs {
  display: flex; gap: 4px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.admin-tab {
  padding: 12px 20px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  font-family: inherit; font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--text-secondary); }
.admin-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.admin-tab-content { display: none; padding: 32px; }
.admin-tab-content.active { display: block; animation: fadeIn 0.2s ease; }
.admin-main { flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; }

.admin-tab-content h2 {
  font-size: 20px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 20px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.admin-stat-card {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.admin-stat-card .stat-label {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-stat-card .stat-value {
  font-size: 28px; font-weight: 700;
  color: var(--text-primary);
}
.admin-stat-card .stat-detail {
  font-size: 12px; color: var(--text-muted);
  margin-top: 4px;
}
.admin-checked-at {
  color: var(--text-muted); font-size: 12px; margin-top: 24px;
}

.admin-users-controls {
  display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  align-items: center;
}
.admin-users-controls .form-input { flex: 1; max-width: 400px; }
.admin-users-controls select.form-input { max-width: 200px; flex: 0 0 auto; }

.admin-users-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.admin-users-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-users-table th {
  text-align: left; padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-weight: 600;
  background: var(--bg-card);
  font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-users-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.admin-users-table tr:last-child td { border-bottom: none; }
.admin-users-table tbody tr:hover { background: var(--bg-hover); }

.admin-user-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.admin-users-pagination {
  display: flex; gap: 12px;
  align-items: center; justify-content: center;
  margin-top: 24px;
  color: var(--text-secondary); font-size: 13px;
}

/* ─── Badge modifiers (extend .badge in styles.css) ─── */
.badge.badge-free    { background: var(--surface-2); color: var(--text-secondary); }
.badge.badge-starter { background: var(--accent-glow); color: var(--accent-hover); border: 1px solid var(--accent); }
.badge.badge-admin   { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.badge-stripe {
  display: inline-block;
  background: rgba(167, 139, 250, 0.15); color: #c4b5fd;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
}
.badge-active { color: var(--success); font-weight: 600; }
.badge-inactive { color: var(--error); font-weight: 600; }

/* ─── Audit log ─── */
.admin-audit-list {
  display: flex; flex-direction: column; gap: 8px;
}
.admin-audit-row {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 160px 200px 1fr 1fr 200px;
  gap: 12px; font-size: 13px; align-items: center;
}
.admin-audit-row .audit-time { color: var(--text-muted); font-size: 12px; }
.admin-audit-row .audit-event { color: var(--text-primary); }
.admin-audit-row .audit-user { color: var(--text-secondary); }
.admin-audit-row .audit-old { color: var(--text-muted); text-decoration: line-through; }
.admin-audit-row .audit-new { color: var(--text-primary); font-weight: 600; }
.admin-audit-row .audit-by { color: var(--text-muted); font-size: 12px; }

/* ─── Warnings + password display ─── */
.admin-warning-banner {
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  font-size: 13px; margin: 16px 0;
}
.admin-password-display {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 18px; font-weight: 600;
  padding: 16px;
  background: var(--surface-1);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  text-align: center;
  user-select: all;
  margin: 16px 0;
  color: var(--text-primary);
  letter-spacing: 1px;
  word-break: break-all;
}

.text-muted { color: var(--text-muted); }

/* ─── Mobile responsive ─── */
@media (max-width: 768px) {
  .admin-header, .admin-tabs { padding-left: 16px; padding-right: 16px; }
  .admin-tab-content { padding: 16px; }
  .admin-tab { padding: 10px 14px; font-size: 12px; }
  .admin-audit-row { grid-template-columns: 1fr; gap: 4px; }
  .admin-users-table { font-size: 11px; }
  .admin-users-table th, .admin-users-table td { padding: 8px 6px; }
  .admin-stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-user-info { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .admin-user-actions .btn { padding: 4px 8px; font-size: 11px; }
}

/* v8.2.0 — Admin Panel button (เห็นเฉพาะ admin, อยู่ใต้ sidebar logo บนสุด) */
.btn-admin-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 4px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  color: #fbbf24;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.08);
}
.btn-admin-panel:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(245, 158, 11, 0.14));
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.18);
  transform: translateY(-1px);
}
.btn-admin-panel svg {
  flex-shrink: 0;
}
.btn-admin-panel span {
  flex: 1;
}
.btn-admin-panel .btn-admin-arrow {
  opacity: 0.6;
  transition: transform 0.2s;
}
.btn-admin-panel:hover .btn-admin-arrow {
  transform: translateX(3px);
  opacity: 1;
}
