/* ═══ Design Tokens ═══ */
:root {
  --z-primary: #10b981;
  --z-accent: #06b6d4;
  --z-gradient: linear-gradient(150deg, #10b981, #06b6d4);
  --z-gradient-rev: linear-gradient(150deg, #06b6d4, #10b981);
  --z-bg: #060d0b;
  --z-bg-card: #0e1a16;
  --z-bg-elevated: #142820;
  --z-bg-hover: #1a3428;
  --z-text: #e0f0ec;
  --z-text-secondary: #68aa99;
  --z-text-disabled: #3d6656;
  --z-border: #1a3428;
  --z-error: #ef4444;
  --z-glow: rgba(16, 185, 129, 0.15);
  --z-glow-strong: rgba(16, 185, 129, 0.3);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--z-bg);
  color: var(--z-text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══ Utility ═══ */
.hidden {
  display: none !important;
}

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

/* ═══ Nav ═══ */
.z-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 18px 0;
  background: rgba(6, 13, 11, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(26, 52, 40, 0.5);
  transition: background 0.3s;
}

.z-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.z-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.z-logo svg {
  height: 32px;
  width: auto;
}

.z-nav-wordmark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--z-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══ Buttons ═══ */
.btn-primary {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 8px;
  background: var(--z-gradient);
  color: #060d0b;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--z-glow-strong);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 8px;
  background: transparent;
  color: var(--z-text);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--z-border);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

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

.btn-lg {
  padding: 14px 32px;
  font-size: 17px;
  border-radius: 10px;
}

/* ═══ Hero ═══ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 800px;
  height: 800px;
  background: radial-gradient(ellipse, rgba(16, 185, 129, 0.08) 0%, rgba(6, 182, 212, 0.04) 40%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.hero-content h1 {
  font-size: clamp(40px, 7vw, 72px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -1.5px;
  margin-bottom: 24px;
}

.hero-subtitle {
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--z-text-secondary);
  line-height: 1.6;
  max-width: 520px;
  margin: 0 auto 40px;
}

/* ═══ Features ═══ */
.features {
  padding: 80px 24px 80px;
  max-width: 1100px;
  margin: 0 auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.feature-card {
  position: relative;
  padding: 32px 28px;
  border-radius: 16px;
  border: 1px solid var(--z-border);
  background: var(--z-bg-card);
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--z-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 8px 32px rgba(6, 13, 11, 0.5), 0 0 40px var(--z-glow);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.feature-card p {
  font-size: 14px;
  color: var(--z-text-secondary);
  line-height: 1.7;
}

/* ═══ Footer ═══ */
.z-footer {
  padding: 40px 0;
  border-top: 1px solid var(--z-border);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.5px;
  background: var(--z-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 13px;
  color: var(--z-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--z-primary);
}

/* ═══ Waitlist Confirm ═══ */
.waitlist-confirm {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  gap: 20px;
}

.waitlist-icon {
  font-size: 56px;
  line-height: 1;
}

.waitlist-confirm h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -1px;
}

.waitlist-confirm p {
  font-size: 17px;
  color: var(--z-text-secondary);
  max-width: 480px;
}

.waitlist-email-display {
  font-size: 15px;
  color: var(--z-primary) !important;
  font-weight: 500;
}

/* ═══ Waitlist Confirm Page (standalone /waitlist) ═══ */
.waitlist-confirm-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 24px;
  text-align: center;
}

.waitlist-confirm-page h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -1px;
}

.waitlist-confirm-page p {
  font-size: 17px;
  color: var(--z-text-secondary);
  max-width: 480px;
}

/* ═══ Privacy Page ═══ */
.privacy-page {
  max-width: 700px;
  margin: 80px auto 60px;
  padding: 0 24px;
  line-height: 1.7;
}

.privacy-page h1 {
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.privacy-date {
  font-size: 14px;
  color: var(--z-text-secondary);
  margin-bottom: 32px;
}

.privacy-page h2 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 8px;
}

.privacy-page p,
.privacy-page ul {
  font-size: 15px;
  color: var(--z-text-secondary);
}

.privacy-page ul {
  padding-left: 20px;
}

.privacy-page a {
  color: var(--z-primary);
  text-decoration: none;
}

.privacy-page a:hover {
  text-decoration: underline;
}

.privacy-page code {
  background: var(--z-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* ═══ Responsive ═══ */
@media (max-width: 600px) {
  .hero {
    padding: 100px 20px 60px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* ── App Shell ─────────────────────────────────────────────────────────────── */
#app-section {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 48px;
  background: var(--z-bg);
  border-bottom: 1px solid var(--z-border);
  flex-shrink: 0;
  gap: 8px;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-header {
  background: none;
  border: 1px solid transparent;
  color: var(--z-text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.btn-header:hover {
  background: var(--z-bg-hover);
  color: var(--z-text);
}

.btn-header-panel {
  background: none;
  border: 1px solid transparent;
  color: var(--z-text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.btn-header-panel:hover {
  background: var(--z-bg-hover);
  color: var(--z-text);
}

.btn-header-panel.active {
  background: var(--z-bg-elevated);
  color: var(--z-primary);
  border-color: var(--z-border);
}

.btn-header-panel.ext-unavailable {
  opacity: 0.4;
}

.page-tabs {
  display: flex;
  gap: 2px;
  max-width: 400px;
  overflow-x: auto;
}

.page-tab-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--z-text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.page-tab-btn:hover {
  background: var(--z-bg-hover);
  color: var(--z-text);
}

.page-tab-btn.active {
  background: var(--z-bg-elevated);
  color: var(--z-primary);
  border-color: var(--z-border);
}

.avatar-wrap {
  position: relative;
}

.btn-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--z-bg-elevated);
  border: 1px solid var(--z-border);
  color: var(--z-text);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-dropdown {
  position: absolute;
  right: 0;
  top: 36px;
  background: var(--z-bg-elevated);
  border: 1px solid var(--z-border);
  border-radius: 8px;
  padding: 8px;
  min-width: 180px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-email {
  font-size: 12px;
  color: var(--z-text-secondary);
  padding: 2px 4px;
}

.btn-signout {
  background: none;
  border: 1px solid var(--z-border);
  color: var(--z-text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}

.btn-signout:hover {
  background: var(--z-bg-hover);
}

.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.canvas-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
  position: relative;
}

.ext-panel {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}

.pages-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: var(--z-bg-elevated);
  border-right: 1px solid var(--z-border);
  z-index: 201;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--z-text-secondary);
}

/* ── Widget card (ported from tabs-page) ───────────────────────────────────── */
.widget-canvas {
  position: relative;
  min-height: calc(100vh - 48px);
  padding: 16px;
}

.canvas-empty-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.widget-card {
  position: absolute;
  width: 220px;
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}

.widget-card.dragging {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0.85;
  z-index: 500;
}

.widget-card.drag-over {
  border-color: var(--z-primary);
}

.widget-card.cols-2 { width: 460px; }
.widget-card.cols-3 { width: 700px; }

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--z-border);
  cursor: grab;
  user-select: none;
}

.widget-header:active { cursor: grabbing; }

.widget-name {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-name-input {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  background: var(--z-bg-hover);
  border: 1px solid var(--z-primary);
  border-radius: 4px;
  color: var(--z-text);
  font-family: inherit;
  padding: 2px 6px;
}

.btn-widget-menu {
  background: none;
  border: none;
  color: var(--z-text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}

.btn-widget-menu:hover {
  background: var(--z-bg-hover);
  color: var(--z-text);
}

/* Widget dropdown menu */
.widget-menu-dropdown {
  position: absolute;
  right: 8px;
  top: 40px;
  z-index: 600;
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 180px;
  overflow: hidden;
}

.widget-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--z-text);
}

.widget-menu-item:hover { background: var(--z-bg-hover); }
.widget-menu-item.danger { color: var(--z-error); }

/* Bookmark list */
.bookmark-list { list-style: none; }

.bookmark-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(26,52,40,0.5);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

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

.bookmark-item:hover {
  background: #1a3528;
  box-shadow: 0 2px 12px rgba(16,185,129,0.15), inset 0 0 0 1px rgba(16,185,129,0.12);
  transform: translateX(3px);
}

.bookmark-favicon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 2px;
}

.bookmark-title {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-delete-bookmark {
  display: none;
  background: none;
  border: none;
  color: var(--z-error);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  flex-shrink: 0;
}

.bookmark-item:hover .btn-delete-bookmark,
.widget-card.edit-mode .btn-delete-bookmark { display: block; }

/* Bookmark add form */
.add-bookmark-form {
  padding: 8px 12px;
  border-top: 1px solid rgba(26,52,40,0.5);
}

.add-bookmark-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.input-bm {
  background: var(--z-bg-hover);
  border: 1px solid var(--z-border);
  border-radius: 4px;
  color: var(--z-text);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  width: 100%;
}

.input-bm:focus {
  outline: none;
  border-color: var(--z-primary);
}

.btn-add-bookmark {
  width: 100%;
  padding: 7px 12px;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid rgba(26,52,40,0.5);
  color: var(--z-text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.btn-add-bookmark:hover {
  background: var(--z-bg-hover);
  color: var(--z-primary);
}

/* ── Modals (ported from tabs-page) ────────────────────────────────────────── */
.modal {
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 16px;
  padding: 24px;
  color: var(--z-text);
  max-width: 360px;
  width: 100%;
}

.modal-wide { max-width: 520px; }
.modal::backdrop { background: rgba(0,0,0,0.5); }
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.modal p { font-size: 13px; color: var(--z-text-secondary); margin-bottom: 16px; }
.modal-hint { font-size: 12px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

.input-name {
  width: 100%;
  background: var(--z-bg-hover);
  border: 1px solid var(--z-border);
  border-radius: 8px;
  color: var(--z-text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.input-name:focus {
  outline: none;
  border-color: var(--z-primary);
}

.btn-danger {
  padding: 8px 20px;
  border: none;
  border-radius: 20px;
  background: var(--z-error);
  color: white;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

/* ── Import tree ───────────────────────────────────────────────────────────── */
.import-tree {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.import-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.import-node.indent-1 { padding-left: 20px; }
.import-node.indent-2 { padding-left: 40px; }

.import-node input[type=checkbox] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--z-primary);
}

.import-node-label {
  font-size: 13px;
  cursor: pointer;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--z-bg-elevated);
  color: var(--z-text);
  border: 1px solid var(--z-border);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 999;
  transition: opacity 0.3s ease;
}

.toast.hidden { display: none; }

.toast-undo-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: inherit;
  cursor: pointer;
  font-size: 10px;
  margin-left: 10px;
  padding: 2px 8px;
}

/* ── Display settings popover ──────────────────────────────────────────────── */
.ds-popover {
  position: absolute;
  z-index: 700;
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  width: 240px;
  overflow: hidden;
}

.ds-popover-header {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--z-border);
}

.ds-popover-body { padding: 8px 14px; }

.ds-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
}

.ds-label {
  color: var(--z-text-secondary);
  white-space: nowrap;
  min-width: 60px;
}

.ds-select {
  flex: 1;
  background: var(--z-bg-hover);
  border: 1px solid var(--z-border);
  border-radius: 4px;
  color: var(--z-text);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 6px;
  cursor: pointer;
}

.ds-divider {
  border-top: 1px solid rgba(26,52,40,0.5);
  margin: 6px 0;
}

.ds-segmented { display: flex; gap: 2px; }

.ds-seg-btn {
  padding: 4px 10px;
  border: 1px solid var(--z-border);
  border-radius: 4px;
  background: none;
  color: var(--z-text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.ds-seg-btn.active {
  background: rgba(16,185,129,0.1);
  color: var(--z-primary);
  border-color: var(--z-primary);
}

.ds-color {
  width: 28px;
  height: 24px;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 4px;
}

.ds-reset {
  background: none;
  border: none;
  color: var(--z-text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.ds-reset:hover { color: var(--z-text); }

.ds-range {
  flex: 1;
  accent-color: var(--z-primary);
}

.ds-range-label {
  font-size: 12px;
  color: var(--z-text-secondary);
  min-width: 32px;
  text-align: right;
}

.ds-apply-all { cursor: pointer; }
.ds-apply-all input { accent-color: var(--z-primary); }

/* ── Bookmark context menu ─────────────────────────────────────────────────── */
.bm-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #1a2e28;
  border: 1px solid #243d30;
  border-radius: 8px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 4px 0;
  animation: bm-ctx-pop 0.15s cubic-bezier(.34,1.4,.64,1);
  transform-origin: top left;
}

@keyframes bm-ctx-pop {
  from { opacity: 0; transform: scale(0.92) translateY(-6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.bm-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 16px;
  font-size: 11px;
  color: var(--z-text);
  background: none;
  border: none;
  cursor: pointer;
  gap: 8px;
  text-align: left;
  font-family: inherit;
}

.bm-ctx-item:hover { background: #243d30; }
.bm-ctx-danger { color: #e05555; }
.bm-ctx-danger:hover { background: #3d1a1a; }

.bm-ctx-sep {
  height: 1px;
  background: #243d30;
  margin: 4px 0;
}

.bm-ctx-has-sub {
  position: relative;
  cursor: pointer;
}

.bm-ctx-arrow { color: #4a9e78; font-size: 9px; }

.bm-ctx-submenu {
  position: absolute;
  left: 100%;
  top: -4px;
  background: #1a2e28;
  border: 1px solid #243d30;
  border-radius: 8px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 10000;
  animation: bm-ctx-pop 0.15s cubic-bezier(.34,1.4,.64,1);
}

.bm-ctx-sub-section { padding: 4px 0; }

.bm-ctx-sub-label {
  padding: 6px 12px;
  font-size: 9px;
  color: #4a9e78;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #243d30;
}

.bm-ctx-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 11px;
  color: var(--z-text);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.bm-ctx-sub-item:hover { background: #243d30; }

.bm-more-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(16,185,129,0.15);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 4px;
  color: #4a9e78;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 5px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 3;
}

.bookmark-item:hover .bm-more-btn,
.bookmark-grid-item:hover .bm-more-btn { opacity: 1; }

/* ── Change icon modal ─────────────────────────────────────────────────────── */
.bm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bm-modal {
  background: #1a2e28;
  border: 1px solid #243d30;
  border-radius: 10px;
  width: 320px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  overflow: hidden;
}

.bm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #243d30;
}

.bm-modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--z-text);
}

.bm-modal-close {
  background: none;
  border: none;
  color: #4a9e78;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

.bm-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bm-icon-current {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bm-icon-preview {
  width: 48px;
  height: 48px;
  background: rgba(13,158,114,0.12);
  border: 2px solid #0d9e72;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.bm-icon-source {
  font-size: 10px;
  color: #4a9e78;
}

.bm-icon-dropzone {
  border: 2px dashed #243d30;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.bm-icon-dropzone:hover,
.bm-icon-dropzone.drag-over {
  border-color: #0d9e72;
  background: rgba(13,158,114,0.05);
}

.bm-icon-dropzone-icon { font-size: 20px; margin-bottom: 4px; }
.bm-icon-dropzone-text { font-size: 11px; font-weight: 600; color: var(--z-text); }
.bm-icon-dropzone-hint { font-size: 9px; color: #4a7a63; margin-top: 2px; }

.bm-icon-reset-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid #243d30;
  border-radius: 6px;
  color: #4a9e78;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}

.bm-icon-reset-btn:hover { background: #243d30; }

/* ── Icons view (grid) ─────────────────────────────────────────────────────── */
.bookmark-grid {
  display: grid;
  padding: 8px;
  gap: 6px;
  justify-items: center;
}

.bookmark-grid.icon-sm { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.bookmark-grid.icon-md { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.bookmark-grid.icon-lg { grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); }

.bookmark-grid-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  width: 100%;
  overflow: visible;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.18s ease,
              background 0.15s ease;
}

.bookmark-grid-item:hover {
  transform: scale(1.08) translateY(-2px);
  background: #1e3d2e;
  box-shadow:
    0 0 0 1px rgba(16,185,129,0.25),
    0 4px 20px rgba(16,185,129,0.2),
    0 8px 32px rgba(0,0,0,0.4);
  z-index: 2;
}

/* ── Detailed view ─────────────────────────────────────────────────────────── */
.bookmark-item-detailed {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(26,52,40,0.5);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

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

.bookmark-item-detailed:hover {
  background: #1a3528;
  box-shadow: 0 2px 12px rgba(16,185,129,0.15), inset 0 0 0 1px rgba(16,185,129,0.12);
  transform: translateX(3px);
}

.bookmark-item-detailed .bookmark-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bookmark-domain {
  font-size: 11px;
  color: var(--z-text-secondary);
  padding-left: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Bookmark drag-to-reorder ──────────────────────────────────────────────── */
.bookmark-drag-handle {
  display: none;
  cursor: grab;
  color: var(--z-text-secondary);
  font-size: 12px;
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
}

.bookmark-item:hover .bookmark-drag-handle,
.bookmark-item-detailed:hover .bookmark-drag-handle { display: block; }

.bookmark-drag-handle:active { cursor: grabbing; }

.bookmark-item.bm-dragging,
.bookmark-item-detailed.bm-dragging { opacity: 0.4; }

.bookmark-drop-indicator {
  height: 2px;
  background: var(--z-primary);
  margin: 0 12px;
  border-radius: 1px;
  pointer-events: none;
}

/* "... and X more" link */
.bookmark-show-more {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--z-text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  border-top: 1px solid rgba(26,52,40,0.5);
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.bookmark-show-more:hover {
  color: var(--z-primary);
  background: var(--z-bg-hover);
}

/* ── Letter icon fallback ──────────────────────────────────────────────────── */
.bm-letter-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Title line clamping ───────────────────────────────────────────────────── */
.bookmark-title.lines-0 { display: none; }
.bookmark-title.lines-1 { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.bookmark-title.lines-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal;
}

.bookmark-grid-item .bookmark-title.lines-0 { display: none; }
.bookmark-grid-item .bookmark-title.lines-1 {
  white-space: nowrap; text-overflow: ellipsis;
}
.bookmark-grid-item .bookmark-title.lines-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ── Widget empty state ────────────────────────────────────────────────────── */
.widget-no-bookmarks {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--z-text-secondary);
}

/* ── Detailed view delete button positioning ───────────────────────────────── */
.bookmark-item-detailed .btn-delete-bookmark { position: absolute; right: 8px; top: 8px; }
.bookmark-item-detailed:hover .btn-delete-bookmark,
.widget-card.edit-mode .bookmark-item-detailed .btn-delete-bookmark { display: block; }

/* ── Icons view delete button positioning ──────────────────────────────────── */
.bookmark-grid-item .btn-delete-bookmark {
  position: absolute; top: 2px; right: 2px;
}
.bookmark-grid-item:hover .btn-delete-bookmark,
.widget-card.edit-mode .bookmark-grid-item .btn-delete-bookmark { display: block; }

/* ── Icons view hover effects ──────────────────────────────────────────────── */
.bookmark-grid.icon-lg .bm-icon-wrap img,
.bookmark-grid.icon-lg .bm-icon-wrap .bm-letter-icon {
  width: 96px !important;
  height: 96px !important;
}

.bookmark-grid-item:hover .bm-icon-wrap img,
.bookmark-grid-item:hover .bm-icon-wrap .bm-letter-icon {
  filter: drop-shadow(0 0 8px rgba(16,185,129,0.5));
}

/* ── Extension Required ─────────────────────────────────────────────────────── */
.ext-required-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
}

.ext-lock-icon {
  font-size: 48px;
  line-height: 1;
}

.ext-required-wrap h3 {
  color: var(--z-text);
  font-size: 18px;
  font-weight: 600;
}

.ext-required-wrap p {
  color: var(--z-text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.ext-shortcuts {
  font-family: monospace;
  background: var(--z-bg-elevated);
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--z-text);
  font-size: 13px;
}

.ext-required-wrap .btn-primary {
  text-decoration: none;
}

/* ── Tab Loops Panel ─────────────────────────────────────────────────────────── */
.loops-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 6px;
}

.loop-name {
  font-weight: 500;
  color: var(--z-text);
}

.loop-meta {
  font-size: 12px;
  color: var(--z-text-secondary);
}

.loops-empty {
  text-align: center;
  color: var(--z-text-secondary);
  padding: 40px 24px;
}

.shortcuts-legend {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--z-bg-card);
  border: 1px solid var(--z-border);
  border-radius: 8px;
}

.shortcuts-legend h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--z-text-secondary);
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--z-text);
  padding: 3px 0;
}

kbd {
  background: var(--z-bg-elevated);
  border: 1px solid var(--z-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 12px;
  color: var(--z-text);
}

.panel-error {
  color: var(--z-error);
  text-align: center;
  padding: 24px;
}

/* ── Settings Panels ─────────────────────────────────────────────────────────── */
.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--z-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--z-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--z-text);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--z-text);
}

.setting-row select {
  background: var(--z-bg-elevated);
  border: 1px solid var(--z-border);
  color: var(--z-text);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}

.setting-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--z-text);
  cursor: pointer;
}

.setting-options input[type="radio"]:disabled + * {
  opacity: 0.4;
}

.ext-note {
  font-size: 12px;
  color: var(--z-text-secondary);
  font-style: italic;
}

.setting-desc {
  font-size: 13px;
  color: var(--z-text-secondary);
}

.setting-email {
  font-size: 13px;
  color: var(--z-text-secondary);
}

.ext-install-link {
  display: inline-block;
  text-decoration: none;
}
