/* ==========================================================
   FavMarks Design System & Stylesheet
   Micro-interactions, Modern Glassmorphism & High Productivity
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Light Theme Palette */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --color-primary: #D97706;
  --color-primary-hover: #B45309;
  --color-primary-soft: rgba(217, 119, 6, 0.12);
  --color-secondary: #F59E0B;
  --color-accent: #2563EB;
  --color-accent-soft: rgba(37, 99, 235, 0.1);
  --color-destructive: #DC2626;
  --color-success: #10B981;

  --bg-page: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #F1F5F9;
  --bg-surface-hover: #E2E8F0;
  --bg-sidebar: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --border-light: #E2E8F0;
  --border-subtle: #F1F5F9;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 8px -2px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 12px 20px -4px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(217, 119, 6, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Palette */
[data-theme="dark"] {
  --bg-page: #0B0F19;
  --bg-surface: #131A2B;
  --bg-surface-secondary: #1E283D;
  --bg-surface-hover: #26334D;
  --bg-sidebar: #0E1424;
  --bg-glass: rgba(19, 26, 43, 0.88);

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-subtle: #64748B;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);

  --shadow-card: 0 2px 8px -2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-card-hover: 0 12px 24px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(245, 158, 11, 0.35);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
}

/* Layout App Container */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 50;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.35);
}

.logo-badge svg {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-title span {
  color: var(--color-primary);
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  overflow-y: auto;
  flex: 1;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.nav-item:hover {
  background-color: var(--bg-surface-secondary);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-left svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item-count {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-secondary);
  color: var(--text-muted);
  font-weight: 600;
}

.nav-item.active .nav-item-count {
  background-color: var(--color-primary);
  color: #FFFFFF;
}

.cat-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
}

.tag-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tag-pill:hover, .tag-pill.active {
  background-color: var(--color-accent);
  color: #FFFFFF;
  border-color: var(--color-accent);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-sidebar);
}

.cf-free-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cf-free-badge svg {
  width: 16px;
  height: 16px;
  color: #F59E0B;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Top App Header */
.app-header {
  height: 64px;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  max-width: 540px;
}

.mobile-menu-btn {
  display: none;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
}

.search-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  padding: 0.55rem 2.4rem 0.55rem 2.4rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.search-input:focus {
  background-color: var(--bg-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.search-shortcut {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-subtle);
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  background-color: var(--bg-surface);
  transition: all var(--transition-fast);
}

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

.btn-primary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(217, 119, 6, 0.4);
}

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

/* Main Body View */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Control Bar (Title, Stats, Filter/Sort, View Mode) */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.current-filter-info h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.current-filter-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.select-control {
  padding: 0.45rem 1.8rem 0.45rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}

.view-mode-toggle {
  display: flex;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  overflow: hidden;
}

.view-btn {
  padding: 0.45rem 0.6rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.view-btn.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
}

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

/* Bookmarks Grid / List Layout */
.bookmarks-container.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
}

.bookmarks-container.list-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Bookmark Card (Grid) */
.bookmark-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-light);
}

.bookmark-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(217, 119, 6, 0.4);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.site-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.site-icon-wrapper img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.card-title-box {
  flex: 1;
  min-width: 0;
}

.site-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.site-url-domain {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin-top: 0.1rem;
}

.pin-indicator {
  color: var(--color-primary);
  display: none;
}

.bookmark-card.pinned .pin-indicator {
  display: block;
}

.card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5rem;
}

.card-meta {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.card-tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-secondary);
  color: var(--text-muted);
  font-weight: 500;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.cat-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.click-stat {
  font-size: 0.75rem;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Quick Actions on Hover */
.card-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  opacity: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.15rem;
  box-shadow: var(--shadow-md);
  transition: opacity var(--transition-fast);
}

.bookmark-card:hover .card-actions {
  opacity: 1;
}

.card-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

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

.card-action-btn.delete:hover {
  color: var(--color-destructive);
}

.card-action-btn.pin.active {
  color: var(--color-primary);
}

.card-action-btn svg {
  width: 15px;
  height: 15px;
}

/* Bookmark Card (List View) */
.bookmarks-container.list-view .bookmark-card {
  flex-direction: row;
  align-items: center;
  padding: 0.85rem 1.25rem;
  gap: 1rem;
}

.bookmarks-container.list-view .card-top {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.bookmarks-container.list-view .card-desc {
  display: none;
}

.bookmarks-container.list-view .card-meta {
  margin-top: 0;
  flex-direction: row;
  align-items: center;
  gap: 1.25rem;
}

.bookmarks-container.list-view .card-footer {
  padding-top: 0;
  border-top: none;
  gap: 1rem;
}

.bookmarks-container.list-view .card-actions {
  position: static;
  opacity: 1;
  box-shadow: none;
  border: none;
  background: transparent;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  max-width: 420px;
  margin: 0 auto;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.empty-icon svg {
  width: 32px;
  height: 32px;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.empty-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  padding: 1rem;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--border-light);
  transform: scale(0.95);
  transition: transform var(--transition-fast);
  overflow: hidden;
}

.modal-backdrop.open .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  color: var(--text-subtle);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background-color: var(--bg-surface-secondary);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-surface-secondary);
}

/* Forms */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-input-box {
  position: relative;
  display: flex;
  gap: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

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

.form-helper {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.btn-secondary {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

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

.btn-submit {
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
}

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

.btn-auto-fetch {
  padding: 0 0.85rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

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

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  background-color: var(--bg-surface);
  color: var(--text-main);
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideInRight 0.25s ease-out;
}

.toast.success {
  border-left: 4px solid var(--color-success);
}

.toast.error {
  border-left: 4px solid var(--color-destructive);
}

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

/* Responsive */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .bookmarks-container.grid-view {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   Nhóm 1: UX & Productivity Styles
   Command Palette, Bookmarklet, Bulk Open & Live Preview
   ========================================================== */

/* Search Shortcut Badge */
.search-shortcut {
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.search-shortcut:hover {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Toolbar Action Tool Button */
.btn-action-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action-tool:hover {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: rgba(217, 119, 6, 0.4);
  transform: translateY(-1px);
}

.btn-action-tool svg {
  color: var(--color-secondary);
}

/* Card Action Preview */
.card-action-btn.preview:hover {
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
}

/* ==========================================================
   Command Palette (Raycast / Spotlight style)
   ========================================================== */
.palette-backdrop {
  z-index: 150;
  align-items: flex-start;
  padding-top: 10vh;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
}

.palette-container {
  background: var(--bg-surface);
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border-light);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(-10px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-backdrop.open .palette-container {
  transform: translateY(0) scale(1);
}

.palette-search-bar {
  display: flex;
  align-items: center;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  gap: 0.85rem;
}

.palette-search-icon {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.palette-input {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-main);
  outline: none;
}

.palette-input::placeholder {
  color: var(--text-subtle);
  font-size: 1rem;
}

.palette-esc-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.palette-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1.4rem;
  background-color: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-light);
}

.palette-tab {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.palette-tab:hover {
  color: var(--text-main);
}

.palette-tab.active {
  background-color: var(--color-primary);
  color: #FFFFFF;
}

.palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.palette-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  padding: 0.5rem 0.75rem 0.25rem;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  color: var(--text-main);
  border: 1px solid transparent;
}

.palette-item:hover,
.palette-item.active {
  background-color: var(--color-primary-soft);
  border-color: rgba(217, 119, 6, 0.25);
}

.palette-item-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.palette-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.palette-item-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.palette-item-icon svg {
  width: 16px;
  height: 16px;
  color: var(--color-primary);
}

.palette-item-text {
  min-width: 0;
  flex: 1;
}

.palette-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.palette-item-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin-top: 0.05rem;
}

.palette-item-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.palette-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-secondary);
  color: var(--text-muted);
}

.palette-footer {
  padding: 0.65rem 1.25rem;
  background-color: var(--bg-surface-secondary);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.palette-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.palette-shortcuts span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.palette-shortcuts kbd {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.palette-brand {
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

.palette-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================
   Bookmarklet Modal Styles
   ========================================================== */
.bookmarklet-drag-zone {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.14) 100%);
  border: 2px dashed rgba(217, 119, 6, 0.4);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.drag-hint-arrow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary);
}

.drag-hint-arrow svg {
  animation: bounceUp 1.5s infinite;
}

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

.bookmarklet-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF !important;
  font-weight: 700;
  font-size: 0.96rem;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px -2px rgba(217, 119, 6, 0.4);
  cursor: grab;
  transition: all var(--transition-fast);
  user-select: none;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.bookmarklet-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 20px -2px rgba(217, 119, 6, 0.5);
}

.bookmarklet-btn:active {
  cursor: grabbing;
}

.bookmarklet-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.b-step {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem;
  background-color: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  line-height: 1.45;
}

.b-step code {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.step-badge {
  width: 22px;
  height: 22px;
  background-color: var(--color-primary);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ==========================================================
   Live Website Preview Modal Styles
   ========================================================== */
.preview-backdrop {
  z-index: 120;
}

.preview-modal-content {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 95vw;
  max-width: 1080px;
  height: 88vh;
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform var(--transition-fast);
}

.preview-backdrop.open .preview-modal-content {
  transform: scale(1);
}

.preview-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-surface-secondary);
  gap: 1rem;
}

.preview-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.preview-favicon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  object-fit: contain;
  padding: 2px;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.preview-title-box {
  min-width: 0;
  flex: 1;
}

.preview-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-url {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.preview-header-center {
  display: flex;
  align-items: center;
}

.preview-tabs {
  display: flex;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.preview-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-tab:hover {
  color: var(--text-main);
}

.preview-tab.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-preview-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-preview-action.icon-only {
  padding: 0.4rem;
}

.btn-preview-action:hover {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: rgba(217, 119, 6, 0.4);
}

.preview-view-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background-color: var(--bg-page);
}

.preview-iframe-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: rgba(245, 158, 11, 0.1);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--text-main);
  font-size: 0.78rem;
}

.preview-iframe-notice svg {
  color: var(--color-secondary);
  flex-shrink: 0;
}

.iframe-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background-color: #FFFFFF;
}

.iframe-loading {
  position: absolute;
  inset: 0;
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  z-index: 10;
  transition: opacity 0.2s ease;
}

.iframe-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* OpenGraph Card Preview View */
.og-card-container {
  max-width: 720px;
  margin: 2.5rem auto;
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.og-cover-wrapper {
  width: 100%;
  height: 320px;
  background-color: var(--bg-surface-secondary);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.og-cover-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.og-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-subtle);
  font-size: 0.88rem;
}

.og-card-details {
  padding: 1.75rem;
}

.og-badge-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.og-domain-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-surface-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.og-title {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.og-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.og-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.og-footer-info {
  font-size: 0.8rem;
  color: var(--text-subtle);
  border-top: 1px solid var(--border-light);
  padding-top: 0.85rem;
  margin-top: 0.5rem;
}

/* ==========================================================
   Workspace Selector & Dropdown
   ========================================================== */
.workspace-selector-container {
  position: relative;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.workspace-current {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.workspace-current:hover {
  background: var(--bg-surface-hover);
  border-color: var(--color-primary);
}

.ws-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.ws-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ws-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  line-height: 1;
  margin-bottom: 2px;
}

.ws-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.ws-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.workspace-selector-container.open .ws-chevron {
  transform: rotate(180deg);
}

.workspace-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 1rem;
  right: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  display: none;
  animation: fadeIn 0.15s ease-out;
  overflow: hidden;
}

.workspace-selector-container.open .workspace-dropdown {
  display: block;
}

.ws-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface-secondary);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.ws-dropdown-header button {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary);
  cursor: pointer;
}

.ws-dropdown-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 0.35rem;
}

.ws-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  transition: background var(--transition-fast);
}

.ws-dropdown-item:hover {
  background: var(--bg-surface-secondary);
}

.ws-dropdown-item.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.ws-item-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* Badges in Sidebar Nav */
.read-later-badge {
  background-color: rgba(245, 158, 11, 0.15) !important;
  color: #D97706 !important;
  font-weight: 700;
}

[data-theme="dark"] .read-later-badge {
  background-color: rgba(245, 158, 11, 0.25) !important;
  color: #FBBF24 !important;
}

.broken-badge {
  background-color: rgba(220, 38, 38, 0.15) !important;
  color: #DC2626 !important;
  font-weight: 700;
}

[data-theme="dark"] .broken-badge {
  background-color: rgba(220, 38, 38, 0.25) !important;
  color: #F87171 !important;
}

/* Toolbar Read Later Filter Bar */
.read-filter-bar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.filter-chip {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-surface-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.filter-chip.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

/* Duplicate Alert Banner */
.duplicate-alert-banner {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  animation: fadeIn 0.2s ease;
}

.dup-alert-icon {
  color: #D97706;
  flex-shrink: 0;
  margin-top: 2px;
}

.dup-alert-content {
  flex: 1;
}

.dup-alert-content strong {
  display: block;
  font-size: 0.88rem;
  color: #B45309;
  margin-bottom: 0.2rem;
}

[data-theme="dark"] .dup-alert-content strong {
  color: #FBBF24;
}

.dup-alert-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.dup-alert-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-xs {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: #D97706;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-xs:hover {
  opacity: 0.9;
}

.btn-xs.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

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

.url-clean-notice {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-success);
}

/* Modal sizing & form rows */
.modal-lg {
  max-width: 680px !important;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 580px) {
  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* Markdown Editor Box */
.markdown-editor-box {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: var(--bg-surface-secondary);
}

.md-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.md-editor-toolbar {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.md-tool-btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.md-tool-btn.tab-btn {
  margin-left: 0.3rem;
  background: var(--bg-surface-secondary);
  color: var(--color-primary);
  font-weight: 700;
}

.md-textarea {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-surface);
}

.notes-preview-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  min-height: 90px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Accordion Markdown Drawer on Bookmark Card */
.card-notes-drawer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-light);
  display: none;
  animation: fadeIn 0.2s ease;
}

.card-notes-drawer.open {
  display: block;
}

.notes-drawer-content {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-main);
  max-height: 240px;
  overflow-y: auto;
}

.notes-drawer-content h1, .notes-drawer-content h2, .notes-drawer-content h3 {
  margin-top: 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  color: var(--text-main);
}

.notes-drawer-content p {
  margin-bottom: 0.4rem;
}

.notes-drawer-content ul, .notes-drawer-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.4rem;
}

.notes-drawer-content code {
  font-family: 'Consolas', monospace;
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--color-primary);
}

[data-theme="dark"] .notes-drawer-content code {
  background: rgba(255, 255, 255, 0.1);
  color: #FBBF24;
}

.notes-code-block {
  position: relative;
  margin: 0.5rem 0;
  background: #1E293B;
  color: #F8FAFC;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

[data-theme="dark"] .notes-code-block {
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.notes-code-block pre {
  padding: 0.75rem;
  margin: 0;
  overflow-x: auto;
  font-family: 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.45;
}

.notes-code-block pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
}

.btn-copy-code {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  color: #E2E8F0;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Card badges & buttons */
.reading-time-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-surface-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.broken-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #DC2626;
  background: rgba(220, 38, 38, 0.1);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.card-action-btn.notes.active {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.card-action-btn.read-toggle.read {
  color: var(--color-success);
}

.card-action-btn.read-toggle.unread {
  color: #D97706;
}

/* Broken links modal & progress */
.scan-progress-box {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-success));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.broken-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  gap: 0.75rem;
}

.broken-item-left {
  min-width: 0;
  flex: 1;
}

.broken-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.broken-item-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.broken-status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.broken-status-badge.error {
  background: rgba(220, 38, 38, 0.12);
  color: #DC2626;
}

.broken-status-badge.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
}

.broken-item-actions {
  display: flex;
  gap: 0.35rem;
}

/* ==========================================================
   AI & Vectorize Features Styling (Workers AI & Vectorize)
   ========================================================== */

.ai-sparkle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.4));
  animation: ai-pulse 2.5s infinite ease-in-out;
}

@keyframes ai-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 7px rgba(168, 85, 247, 0.7)); }
}

/* 1. Header AI Semantic Search Toggle */
.btn-ai-search-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface-secondary);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-ai-search-toggle:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
  border-color: #8B5CF6;
}

.btn-ai-search-toggle.active {
  background: linear-gradient(135deg, #8B5CF6 0%, #3B82F6 100%);
  color: #FFFFFF;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.35);
}

.search-container.ai-active {
  border-color: #8B5CF6 !important;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18) !important;
}

/* 2. Modal AI Analyze Button */
.btn-ai-analyze {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.25);
  white-space: nowrap;
}

.btn-ai-analyze:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
  filter: brightness(1.06);
}

.btn-ai-analyze:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 3. AI Status Notice Banner */
.ai-analysis-notice {
  margin-top: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  animation: fadeIn 0.25s ease-out;
}

.ai-pill-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
  color: #8B5CF6;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
}

/* 4. AI TL;DR Summary Box in Modal */
.ai-summary-box {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.03) 0%, rgba(99, 102, 241, 0.03) 100%);
  border: 1px dashed rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.ai-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.ai-summary-regen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-summary-regen-btn:hover {
  color: #8B5CF6;
  border-color: #8B5CF6;
  background: var(--bg-surface-secondary);
}

.ai-summary-textarea {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  background-color: var(--bg-surface);
}

/* 5. AI Suggested Tag Chips */
.ai-suggested-tags-box {
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ai-suggest-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.ai-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.ai-suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 7px;
  font-size: 0.75rem;
  background: var(--bg-surface-secondary);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #8B5CF6;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-suggest-chip:hover {
  background: #8B5CF6;
  color: #FFFFFF;
  border-color: #8B5CF6;
  transform: translateY(-1px);
}

/* 6. Bookmark Card AI Features */
.similarity-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 7px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
  color: #7C3AED;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

[data-theme="dark"] .similarity-badge {
  color: #A78BFA;
  border-color: rgba(167, 139, 250, 0.4);
}

.card-action-btn.ai-tldr {
  color: #8B5CF6;
}

.card-action-btn.ai-tldr:hover,
.card-action-btn.ai-tldr.active {
  background: rgba(139, 92, 246, 0.12);
  color: #7C3AED;
}

.card-ai-drawer {
  display: none;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.04) 0%, rgba(59, 130, 246, 0.04) 100%);
  border-top: 1px solid rgba(139, 92, 246, 0.15);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-main);
  animation: fadeIn 0.2s ease-out;
}

.card-ai-drawer.open {
  display: block;
}

.ai-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #8B5CF6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-drawer-bullets {
  margin: 0;
  padding-left: 1.1rem;
}

.ai-drawer-bullets li {
  margin-bottom: 0.25rem;
}

/* 7. Live Preview Modal AI Tab */
.preview-ai-card {
  max-width: 800px;
  margin: 2rem auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

.preview-ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

.preview-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #8B5CF6;
  background: rgba(139, 92, 246, 0.1);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.preview-ai-summary-content {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  white-space: pre-line;
  background: var(--bg-surface-secondary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border-left: 4px solid #8B5CF6;
}

.preview-ai-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.ai-meta-box {
  padding: 0.85rem;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.ai-meta-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ai-meta-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.ai-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ==========================================================
   Ecosystem & Cross-device Styling (PWA, Extension, Telegram)
   ========================================================== */

/* Nút Cài đặt PWA trên Header */
.btn-install-app {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all var(--transition-fast);
  animation: pulseGentle 3s infinite;
}

.btn-install-app:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

@keyframes pulseGentle {
  0%, 100% { box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }
  50% { box-shadow: 0 2px 14px rgba(37, 99, 235, 0.55); }
}

/* Tab Header trong Ecosystem Modal */
.eco-tabs-header {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface-secondary);
  overflow-x: auto;
}

.eco-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.eco-tab.active {
  color: var(--color-accent);
  background: var(--bg-surface);
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

/* Hero Cards */
.eco-hero-card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.03) 100%);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.eco-hero-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-accent);
  margin-bottom: 0.5rem;
}

.eco-hero-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.eco-hero-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.pwa-action-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.pwa-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10B981;
  box-shadow: 0 0 6px #10B981;
}

.status-indicator-dot.warning {
  background-color: #F59E0B;
  box-shadow: 0 0 6px #F59E0B;
}

/* Feature Cards & Steps */
.eco-feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.feature-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.eco-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.eco-step-item {
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
}

.step-num {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.eco-step-item strong {
  display: block;
  font-size: 0.86rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.eco-step-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

/* Vertical Steps */
.eco-steps-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.eco-v-step {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.step-circle {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.step-content p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.eco-info-box {
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  border-left: 3px solid #3B82F6;
}

.shortcut-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-main);
}

.shortcut-pill kbd {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-light);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* Telegram Status Grid */
.tele-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.tele-status-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

.tele-status-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.tele-status-value {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tele-config-form {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.tele-btn-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ==========================================================
   Version Badges
   ========================================================== */

.app-version-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.22));
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.35);
  letter-spacing: 0.3px;
  margin-left: 0.35rem;
  vertical-align: middle;
  display: inline-block;
  line-height: 1.3;
}

.footer-version-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: #F59E0B;
  background: rgba(245, 158, 11, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-left: auto;
}

.modal-version-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: #3B82F6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: inline-block;
}




