/* ══════════════════════════════════════════════════════════════════
   Data Source Selector & Read-Only Mode
   ══════════════════════════════════════════════════════════════════ */

/* Data source control group — container for pills */
.data-source-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Local collection pill */
.ds-local-pill {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 3px 3px 3px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}

.ds-local-label {
  font-size: 13px;
  font-weight: 500;
  color: white;
  white-space: nowrap;
  padding-right: 4px;
}

/* Remote sources pill — same base style as local pill */
.ds-remote-pill {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 3px 3px 3px 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}

#dataSourceSelect {
  max-width: 200px;
  font-size: 13px;
  padding: 6px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-overflow: ellipsis;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.7)' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

#dataSourceSelect:focus {
  outline: none;
}

#dataSourceSelect option {
  background: #2d2d4a;
  color: #e5e7eb;
}

/* Empty state label (when no remote collections) */
.ds-empty-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.ds-empty-label:hover {
  color: white;
}

.ds-readonly-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  margin-right: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Icon buttons inside the pills */
.ds-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  color: rgba(255, 255, 255, 0.8);
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.ds-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* Sync button — dot states */
.ds-sync-btn .sync-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9ca3af;
}

.ds-sync-btn.synced .sync-status-dot {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.ds-sync-btn.dirty .sync-status-dot {
  background: #fbbf24;
  animation: sync-pulse 1.5s infinite;
}

.ds-sync-btn.checking .sync-status-dot {
  background: #9ca3af;
  animation: sync-pulse 1.5s infinite;
}

/* Sync status wrapper with label */
.sync-status-wrapper {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.sync-status-wrapper:hover .ds-sync-btn {
  background: rgba(255, 255, 255, 0.15);
}

.sync-status-wrapper .ds-sync-btn {
  width: auto;
}

.sync-status-wrapper .sync-status-dot {
  margin-left: 5px;
}

.header-sync-label {
  margin-left: 5px;
  font-size: 9px;
  font-weight: 600;
  color: #4ade80;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.header-sync-label.dirty {
  color: #fbbf24;
}

.header-sync-label.checking {
  color: #9ca3af;
}

/* Remote-newer state: another device pushed data */
.ds-sync-btn.remote-newer .sync-status-dot {
  background: #60a5fa;
  box-shadow: 0 0 6px rgba(96, 165, 250, 0.5);
  animation: sync-pulse 1.5s infinite;
}

.header-sync-label.remote-newer {
  color: #60a5fa;
}

/* Quick sync button (shown when dirty) */
.ds-quick-sync-btn {
  font-size: 14px;
  color: #fbbf24;
}

.ds-quick-sync-btn:hover {
  color: white;
  background: rgba(251, 191, 36, 0.3);
}

/* Gear button */
.ds-gear-btn {
  font-size: 16px;
}

/* Close button for remote pill */
.ds-close-btn {
  font-size: 18px;
  font-weight: 300;
}

/* Add source button — inside remote pill */
.ds-add-btn {
  font-size: 16px;
  font-weight: 500;
}

/* Pill active state — same for both local and remote */
.ds-local-pill.ds-active,
.ds-remote-pill.ds-active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Pill inactive state — same for both */
.ds-local-pill:not(.ds-active),
.ds-remote-pill:not(.ds-active) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.ds-local-pill:not(.ds-active):hover,
.ds-remote-pill:not(.ds-active):hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.ds-local-pill:not(.ds-active) .ds-local-label {
  opacity: 0.8;
}

/* When local pill is inactive (viewing remote), make entire pill clickable */
.ds-local-pill:not(.ds-active) .sync-status-wrapper,
.ds-local-pill:not(.ds-active) .ds-icon-btn {
  pointer-events: none;
}

.ds-remote-pill:not(.ds-active) #dataSourceSelect {
  color: rgba(255, 255, 255, 0.6);
}

.ds-remote-pill:not(.ds-active) .ds-readonly-tag {
  display: none !important;
}

/* Language switch — see src/styles/themes.css for pill-switch rules */

.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  transition: all 0.2s;
  color: #666;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  background: #f0f0f0;
  border-color: #999;
}

/* Read-only badge in header */
.readonly-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* Read-only mode: disable all mutation controls */
body.readonly-mode .owned-edit-btn,
body.readonly-mode .wishlist-btn,
body.readonly-mode .ordered-btn,
body.readonly-mode .quick-status-actions,
body.readonly-mode .batch-selection-controls,
body.readonly-mode .batch-toolbar,
body.readonly-mode .binder-create-btn,
body.readonly-mode .binder-edit-btn,
body.readonly-mode .binder-delete-btn,
body.readonly-mode .pocket--empty,
body.readonly-mode #addAnotherCopyBtn,
body.readonly-mode .instance-delete-btn,
body.readonly-mode .owned-edit-form .btn-primary,
body.readonly-mode .owned-edit-form .btn-danger,
body.readonly-mode .collection-section {
  pointer-events: none;
  opacity: 0.35;
}

body.readonly-mode .collection-section,
body.readonly-mode .card-modal-actions {
  display: none;
}

/* Hide remaining mutation affordances in read-only mode.
 *
 * Card modal: .instance-edit-btn covers owned-instance edit, ordered
 * edit, and the receive (✅) button — all mutating. The "view order"
 * link uses the same class but no data-action / no /edit href, so we
 * keep it visible by targeting only the mutating variants.
 *
 * Orders view: hide quick-advance + the whole detail-modal footer
 * (Edit / Mark delivered / Delete) and the status dropdown.
 *
 * Binders view: hide the kebab menu (Duplicate / Delete), the "Pages"
 * entry button (page manager is mutation-only), the pocket overlay's
 * action row (move / send-to-tray / remove), the assign-owned button,
 * and every page-manager button if the user reaches it some other way.
 */
body.readonly-mode .instance-edit-btn[data-action],
body.readonly-mode .instance-edit-btn[href*="/edit"],
body.readonly-mode .order-quick-action,
body.readonly-mode .order-detail-actions,
body.readonly-mode #orderStatusSelect,
body.readonly-mode .binder-card-menu-toggle,
body.readonly-mode .binder-card--create,
body.readonly-mode .binder-empty-state [data-action="openBinderSettingsModal"],
body.readonly-mode #binderEditBtn,
body.readonly-mode #binderTrayPill,
body.readonly-mode [data-action="toggleTrayExpanded"],
body.readonly-mode [data-action="openPageManagerForBinder"],
body.readonly-mode [data-action="openPageManagerModal"],
body.readonly-mode .pocket-overlay-actions,
body.readonly-mode .pocket-assign-btn,
body.readonly-mode .pm-action-bar,
body.readonly-mode .pm-btn-move,
body.readonly-mode .pm-btn-move-binder,
body.readonly-mode .pm-btn-delete,
body.readonly-mode .pm-view-toggle,
body.readonly-mode [data-action="pmDeleteSpread"],
body.readonly-mode [data-action="pmMoveSpread"] {
  display: none !important;
}

/* Drag affordance: even though setup* short-circuits in RO, defensive
 * cursor + draggable-attribute neutering avoids any visual hint that
 * the user could move a pocket / page. */
body.readonly-mode .pocket--filled[draggable="true"],
body.readonly-mode .page-number-btn[draggable="true"] {
  cursor: default;
}

/* Hide sync/share buttons in read-only mode */
body.readonly-mode #syncStatusBtn,
body.readonly-mode .btn-compact[onclick='openImportExportModal()'],
body.readonly-mode #shareCollectionBtn {
  pointer-events: none;
  opacity: 0.35;
}

/* Subtle border indicator on header */
body.readonly-mode .compact-header {
  border-bottom: 2px solid #f59e0b;
}

/* ── Shared Collection Welcome Banner ── */

.shared-collection-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #1e40af;
}

.shared-banner-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.shared-banner-text {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.shared-banner-text strong {
  color: #1e3a8a;
}

.shared-banner-cta {
  flex-shrink: 0;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.shared-banner-cta:hover {
  background: #2563eb;
}

.shared-banner-dismiss {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.shared-banner-dismiss:hover {
  color: #1e40af;
}

body.dark-mode .shared-collection-banner {
  background: linear-gradient(135deg, #1e293b 0%, #1e3a5f 100%);
  border-color: #3b82f6;
  color: #93c5fd;
}

body.dark-mode .shared-banner-text strong {
  color: #bfdbfe;
}

body.dark-mode .shared-banner-cta {
  background: #2563eb;
}

body.dark-mode .shared-banner-cta:hover {
  background: #1d4ed8;
}

body.dark-mode .shared-banner-dismiss {
  color: #6b7280;
}

body.dark-mode .shared-banner-dismiss:hover {
  color: #93c5fd;
}

/* ── Manage Remote Collections Modal ── */

.manage-collections-modal {
  background: white;
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.manage-collections-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.manage-collections-modal .modal-header h2 {
  font-size: 18px;
  margin: 0;
  color: #333;
}

.manage-collections-modal .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}

.manage-collections-modal .modal-close:hover {
  color: #333;
}

.manage-collections-modal .modal-body {
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

.manage-collections-desc {
  margin-bottom: 20px;
}

.remote-collections-section {
  margin-bottom: 24px;
}

.remote-collections-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
}

.add-remote-section {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Add remote form */
.add-remote-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.add-remote-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.add-remote-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  min-width: 36px;
  flex-shrink: 0;
}

.add-remote-form .form-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  min-width: 0;
  box-sizing: border-box;
}

.add-remote-form .form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.add-remote-form .btn-primary {
  white-space: nowrap;
  padding: 9px 20px;
  flex-shrink: 0;
}

/* Remote collections list */
.remote-collections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.remote-collection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.remote-collection-info {
  flex: 1;
  min-width: 0;
}

.remote-collection-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  margin-bottom: 2px;
}

.remote-collection-url {
  font-size: 12px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: monospace;
}

.remote-collection-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.remote-collection-actions .btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
}

.remote-collection-actions .btn-sm:hover {
  background: #f0f0f0;
}

.remote-collection-actions .btn-danger {
  color: #dc2626;
  border-color: #fecaca;
}

.remote-collection-actions .btn-danger:hover {
  background: #fef2f2;
}

/* Help View styles moved to styles/help.css */

/* ── Site Footer ── */

.site-footer {
  max-width: 1400px;
  margin: 24px auto 0;
  padding: 0 20px 40px;
}

.footer-inner {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 32px 36px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.1);
}

.footer-brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.footer-logo {
  font-size: 1.4em;
  font-weight: 400;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.footer-tagline {
  font-size: 13px;
  color: #888;
  font-style: italic;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  justify-content: space-around;
}

.footer-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  text-decoration: none;
  background: rgba(102, 126, 234, 0.06);
  border: 1px solid rgba(102, 126, 234, 0.1);
  transition: all 0.2s ease;
}

.footer-nav-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
}

.footer-nav-link:hover {
  background: rgba(102, 126, 234, 0.12);
  border-color: rgba(102, 126, 234, 0.25);
  color: var(--color-primary);
}

.footer-nav-link:hover svg {
  opacity: 1;
}

.footer-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 28px;
  margin-bottom: 24px;
}

.footer-col h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-primary);
  margin: 0 0 10px 0;
}

.footer-col p {
  font-size: 12.5px;
  color: #666;
  line-height: 1.6;
  margin: 0;
}

.footer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-list li {
  font-size: 12.5px;
  color: #666;
  padding: 3px 0;
  line-height: 1.5;
}

.footer-list li::before {
  content: '·';
  color: var(--color-primary);
  font-weight: 700;
  margin-right: 6px;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  text-align: center;
  font-size: 11px;
  color: #999;
  line-height: 1.7;
}

.footer-sep {
  margin: 0 6px;
}

/* ── Footer Pages (About, Privacy, Credits) ── */

.footer-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.footer-page-wide {
  max-width: 1200px;
}

/* Open Data — stats hero */
.od-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 4px 0 28px;
}

.od-stat {
  background: linear-gradient(135deg,
    rgba(102, 126, 234, 0.08) 0%,
    rgba(118, 75, 162, 0.08) 100%);
  border: 1px solid rgba(102, 126, 234, 0.18);
  border-radius: 12px;
  padding: 16px 18px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.od-stat:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.12);
}

.od-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.od-stat-label {
  font-size: 12px;
  color: #777;
  margin-top: 4px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* Open Data tabs */
.od-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.15);
}

.od-tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.od-tab-btn:hover {
  color: #555;
}

.od-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* Download bar */
.od-download-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: rgba(102, 126, 234, 0.06);
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 10px;
}

.od-download-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--color-primary, #667eea);
  color: #fff !important;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  text-decoration: none !important;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.od-download-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.od-download-link svg {
  flex-shrink: 0;
}

.od-download-desc {
  font-size: 12.5px;
  color: #666;
}

.od-download-sep {
  color: #ccc;
  font-size: 14px;
}

/* Sample JSON blocks */
.od-sample {
  margin: 10px 0 14px;
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.od-sample summary {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(102, 126, 234, 0.05);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.od-sample summary::before {
  content: '▸ ';
}

.od-sample[open] summary::before {
  content: '▾ ';
}

.od-sample summary:hover {
  background: rgba(102, 126, 234, 0.1);
}

.od-sample pre {
  margin: 0;
  padding: 12px 16px;
  background: #f8f9fb;
  font-size: 11.5px;
  line-height: 1.5;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #444;
  overflow-x: auto;
  border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.footer-page-inner {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 40px 44px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.1);
}

.footer-page-title {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.15);
}

.fp-section {
  margin-bottom: 28px;
}

.fp-section:last-child {
  margin-bottom: 0;
}

.fp-section h2 {
  font-size: 1em;
  font-weight: 600;
  color: #333;
  margin: 0 0 10px;
}

.fp-section p {
  font-size: 14px;
  color: #555;
  line-height: 1.7;
  margin: 0;
}

.fp-section a {
  color: var(--color-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(102, 126, 234, 0.3);
  transition: border-color 0.2s;
}

.fp-section a:hover {
  border-bottom-color: var(--color-primary);
}

.fp-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.fp-list li {
  font-size: 14px;
  color: #555;
  line-height: 1.7;
  padding: 3px 0 3px 20px;
  position: relative;
}

.fp-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0.5;
}

.fp-disclaimer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.fp-disclaimer p {
  font-size: 12px;
  color: #999;
  font-style: italic;
}

.fp-code-block {
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.8;
  color: #444;
}

.fp-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.fp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fp-table th {
  text-align: left;
  padding: 8px 10px;
  background: rgba(102, 126, 234, 0.08);
  border-bottom: 2px solid rgba(102, 126, 234, 0.2);
  font-weight: 600;
  font-size: 12px;
  color: var(--color-primary);
  white-space: nowrap;
}

.fp-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  color: #555;
  line-height: 1.5;
}

.fp-table tr:hover td {
  background: rgba(102, 126, 234, 0.03);
}

.fp-field-values {
  font-size: 11px;
  color: #999;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.fp-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin: 18px 0 6px;
}

.fp-code-block code {
  background: rgba(102, 126, 234, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--color-primary);
}

@media (max-width: 768px) {
  .footer-page-inner {
    padding: 28px 20px;
  }

  .od-tab-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .od-download-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .od-download-sep {
    display: none;
  }

  .footer-nav {
    flex-direction: column;
    gap: 6px;
  }

  .footer-nav-link {
    width: 100%;
    justify-content: flex-start;
  }

  .footer-columns {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .footer-brand {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .footer-inner {
    padding: 24px 20px 18px;
  }

  /* Help view responsive rules moved to styles/help.css */

  .brand-tagline {
    font-size: 0.6em;
  }

  .brand-mascot {
    height: 65px;
    left: -15px;
    top: -25px;
  }

  .brand {
    margin-left: 75px;
  }
}

/* ── Share Collection Modal ── */

.share-modal {
  background: white;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.share-modal .modal-header h2 {
  font-size: 18px;
  margin: 0;
  color: #333;
}

.share-modal .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}

.share-modal .modal-close:hover {
  color: #333;
}

.share-modal .modal-body {
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

.share-desc {
  margin-bottom: 16px;
}

.share-stats {
  font-size: 13px;
  color: #555;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-weight: 500;
}

.share-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.share-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  min-width: 80px;
  flex-shrink: 0;
}

.share-name-row .form-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  min-width: 0;
  box-sizing: border-box;
}

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

.share-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.share-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.share-url-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  min-width: 0;
  box-sizing: border-box;
  background: #f8f9fa;
  color: #333;
}

.share-url-row .btn-primary {
  white-space: nowrap;
  padding: 9px 20px;
  flex-shrink: 0;
}

/* ── Collection Manager Modal ── */

.cm-modal {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 900px;
  width: 100%;
  height: 800px; /* Fixed height to prevent resize on panel switch */
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.cm-layout {
  display: flex;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.cm-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #f7f8fa;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-self: stretch; /* Ensure sidebar takes full height */
}

.cm-sidebar-header {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cm-sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: #333;
  letter-spacing: 0.02em;
}

.cm-close-mobile {
  display: none;
}

.cm-nav {
  display: flex;
  flex-direction: column;
  padding: 0 10px 12px;
  gap: 4px;
}

/* Codex: status pill pinned to the bottom of the CM rail. */
.cm-rail-status {
  margin: auto 12px 14px;
  padding: 10px 12px;
  background: var(--surface, #13171f);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
}
.cm-rail-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-mute, #6b7280);
  flex-shrink: 0;
}
.cm-rail-status-dot--synced { background: var(--pos, #2c9c5a); }
.cm-rail-status-dot--dirty { background: var(--warm, #c97f1a); }
.cm-rail-status-dot--local { background: var(--text-mute, #6b7280); }
.cm-rail-status-text {
  color: var(--text, #e7eaef);
}
.cm-rail-status-age {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim, #8a929e);
}

.cm-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 12px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  text-align: left;
  white-space: nowrap;
}

.cm-nav-item:hover {
  background: #eef0f4;
  color: #333;
}

.cm-nav-item.active {
  background: var(--color-primary);
  color: white;
}

.cm-nav-icon {
  font-size: 14px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
}

.cm-nav-label {
  flex: 1;
  min-width: 0;
}

.cm-nav-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: #e6a700;
  color: white;
  font-weight: 600;
}

/* Content area */
.cm-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.cm-close-desktop {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
  z-index: 1;
}

.cm-close-desktop:hover {
  color: #333;
}

/* Panels */
.cm-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.cm-panel-header {
  padding: 22px 26px 0;
  flex-shrink: 0;
}

.cm-panel-header h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 2px;
  color: #333;
  padding-right: 30px;
}

.cm-panel-desc {
  font-size: 13px;
  color: #888;
  margin: 4px 0 0;
  line-height: 1.5;
  padding-right: 30px;
}

.cm-panel-body {
  padding: 18px 26px 26px;
  overflow-y: auto;
  flex: 1;
}

/* Shared component styles */
.cm-hint {
  font-size: 13px;
  color: #888;
  margin: 0 0 14px;
  line-height: 1.55;
}

.cm-hint-warning {
  color: #b45309;
  background: #fffbeb;
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 3px solid #f59e0b;
}

/* How It Works sections */
.cm-hiw-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 8px;
}

.cm-hiw-section {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  gap: 4px 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(102, 126, 234, 0.045);
  border: 1px solid rgba(102, 126, 234, 0.10);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.cm-hiw-section:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.20);
}

.cm-hiw-icon {
  grid-row: 1 / 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  align-self: start;
  margin-top: 1px;
}

.cm-hiw-section h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: #2c2c3e;
  align-self: end;
}

.cm-hiw-section p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary, #5e5e74);
  line-height: 1.6;
}

/* ── New 3-step flow at the top of How It Works ──────────── */
.cm-hiw-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 8px;
  margin: 4px 0 22px;
}

.cm-hiw-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 14px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--step-color, #667eea) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--step-color, #667eea) 25%, transparent);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cm-hiw-step:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--step-color, #667eea) 18%, transparent);
}

.cm-hiw-step-num {
  position: absolute;
  top: -10px;
  left: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--step-color, #667eea);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.cm-hiw-step-icon {
  font-size: 32px;
  margin-bottom: 6px;
  line-height: 1;
}

.cm-hiw-step h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--step-color, #667eea);
}

.cm-hiw-step p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary, #5e5e74);
  line-height: 1.5;
}

.cm-hiw-arrow {
  align-self: center;
  font-size: 22px;
  color: var(--text-tertiary, #9ca3af);
  user-select: none;
}

@media (max-width: 720px) {
  .cm-hiw-flow {
    grid-template-columns: 1fr;
  }
  .cm-hiw-arrow {
    transform: rotate(90deg);
    margin: 4px 0;
  }
}

/* ── Details accordion below the flow ─────────────────────── */
.cm-hiw-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cm-hiw-detail {
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.04);
  border: 1px solid rgba(102, 126, 234, 0.08);
  transition: background 0.15s ease;
}

.cm-hiw-detail:hover {
  background: rgba(102, 126, 234, 0.08);
}

.cm-hiw-detail summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #2c2c3e;
  user-select: none;
}
.cm-hiw-detail summary::-webkit-details-marker { display: none; }
.cm-hiw-detail summary::after {
  content: '▸';
  margin-left: auto;
  color: var(--text-tertiary, #9ca3af);
  transition: transform 0.15s ease;
}
.cm-hiw-detail[open] summary::after { transform: rotate(90deg); }

.cm-hiw-detail-icon {
  font-size: 16px;
  line-height: 1;
}

.cm-hiw-detail p {
  margin: 0;
  padding: 0 14px 12px 40px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary, #5e5e74);
}

/* ── Backup-first banner on the Reset panel ────────────── */
.cm-backup-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 22px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(99, 102, 241, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: 12px;
}

.cm-backup-banner-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.cm-backup-banner-body {
  flex: 1;
  min-width: 0;
}

.cm-backup-banner-body h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: #047857;
}

.cm-backup-banner-body p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary, #5e5e74);
  line-height: 1.5;
}

.cm-backup-banner-cta {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Remote-sources export/import tools row ─────────────── */
.cm-remote-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 18px;
}

.cm-remote-tools .btn-ghost {
  background: transparent;
  border: 1px solid rgba(102, 126, 234, 0.20);
  color: var(--color-primary, #667eea);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cm-remote-tools .btn-ghost:hover {
  background: rgba(102, 126, 234, 0.10);
  border-color: rgba(102, 126, 234, 0.40);
}

/* Dark mode */
body.dark-mode .cm-hiw-step h4 { color: color-mix(in srgb, var(--step-color, #818cf8) 80%, white); }
body.dark-mode .cm-hiw-step p,
body.dark-mode .cm-hiw-detail p {
  color: var(--text-secondary, #cbd5e1);
}
body.dark-mode .cm-hiw-detail {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}
body.dark-mode .cm-hiw-detail summary {
  color: #f1f5f9;
}
body.dark-mode .cm-hiw-detail:hover {
  background: rgba(255, 255, 255, 0.08);
}
body.dark-mode .cm-backup-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.10) 0%, rgba(99, 102, 241, 0.10) 100%);
  border-color: rgba(16, 185, 129, 0.30);
}
body.dark-mode .cm-backup-banner-body h4 { color: #6ee7b7; }
body.dark-mode .cm-backup-banner-body p { color: #cbd5e1; }
body.dark-mode .cm-remote-tools .btn-ghost {
  border-color: rgba(129, 140, 248, 0.25);
  color: #c4b5fd;
}
body.dark-mode .cm-remote-tools .btn-ghost:hover {
  background: rgba(129, 140, 248, 0.12);
}

/* ── Cloud panel: power-user "Avancé" accordion ─────────── */
.cm-sync-advanced {
  margin-top: 14px;
  padding: 0;
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.04);
}
.cm-sync-advanced > summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary, #667eea);
  list-style: none;
}
.cm-sync-advanced > summary::-webkit-details-marker { display: none; }
.cm-sync-advanced > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}
.cm-sync-advanced[open] > summary::before { transform: rotate(90deg); }
.cm-sync-advanced-body {
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cm-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cm-test-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
}
.cm-test-status.cm-test-pending { color: var(--text-secondary, #64748b); }
.cm-test-status.cm-test-ok { color: #10b981; }
.cm-test-status.cm-test-fail { color: #ef4444; }

.cm-secret-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed rgba(102, 126, 234, 0.18);
}
.cm-secret-reveal {
  display: none;
}
.cm-secret-reveal.shown {
  display: block;
}

body.dark-mode .cm-sync-advanced {
  background: rgba(129, 140, 248, 0.06);
  border-color: rgba(129, 140, 248, 0.18);
}
body.dark-mode .cm-sync-advanced > summary { color: #c4b5fd; }
body.dark-mode .cm-secret-section { border-top-color: rgba(129, 140, 248, 0.18); }
body.dark-mode .cm-test-status.cm-test-ok { color: #6ee7b7; }
body.dark-mode .cm-test-status.cm-test-fail { color: #fca5a5; }

/* ── Sources panel: bulk-add accordion ──────────────────── */
.cm-bulk-sources {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed rgba(102, 126, 234, 0.20);
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.03);
}
.cm-bulk-sources > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary, #667eea);
  list-style: none;
  padding: 2px 0;
}
.cm-bulk-sources > summary::-webkit-details-marker { display: none; }
.cm-bulk-sources > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s ease;
}
.cm-bulk-sources[open] > summary::before { transform: rotate(90deg); }
.cm-bulk-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 10px 0;
  width: 100%;
  resize: vertical;
}
body.dark-mode .cm-bulk-sources {
  background: rgba(129, 140, 248, 0.05);
  border-color: rgba(129, 140, 248, 0.22);
}
body.dark-mode .cm-bulk-sources > summary { color: #c4b5fd; }

.cm-empty-state {
  text-align: center;
  padding: 32px 20px;
}

.cm-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.cm-empty-state p {
  font-size: 13.5px;
  color: #666;
  margin: 0 0 20px;
  line-height: 1.5;
}

.cm-notice {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.cm-notice p {
  font-size: 13px;
  color: #666;
  margin: 0 0 14px;
  line-height: 1.55;
}

.cm-action-btn {
  width: 100%;
  padding: 11px 18px;
  font-size: 13.5px;
}

.cm-section {
  margin-bottom: 22px;
}

.cm-section h4 {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 10px;
  color: #444;
}

.cm-section-bordered {
  padding-top: 22px;
  border-top: 1px solid var(--border-color);
}

.cm-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cm-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #888;
  min-width: 64px;
  flex-shrink: 0;
}

.cm-field-row .form-input,
.cm-select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  min-width: 0;
  box-sizing: border-box;
  background: white;
}

.cm-field-row .form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* URL row */
.cm-url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.cm-url-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 11px;
  font-family: monospace;
  background: #f8f9fa;
  color: #333;
  min-width: 0;
  box-sizing: border-box;
}

/* QR scan button */
.cm-qr-scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.cm-qr-scan-btn svg {
  flex-shrink: 0;
}

/* Transfer import row */
.cm-import-row {
  display: flex;
  gap: 8px;
}

.cm-import-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  min-width: 0;
  box-sizing: border-box;
}

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

.cm-import-input::placeholder {
  color: #bbb;
}

/* QR container */
.cm-qr-container {
  display: flex;
  justify-content: center;
  padding: 16px;
  margin-bottom: 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.cm-qr-container .qr-canvas {
  border-radius: 4px;
  image-rendering: pixelated;
}

.cm-qr-container .qr-fallback {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 12px;
}

/* Sync status rows */
.cm-sync-status {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.cm-sync-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.cm-sync-row + .cm-sync-row {
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
  padding-top: 8px;
}

.cm-sync-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: #888;
}

.cm-sync-value {
  font-size: 12px;
  font-weight: 500;
  color: #333;
}

code.cm-sync-value {
  font-family: monospace;
  font-size: 11px;
  background: #eef0f4;
  padding: 2px 6px;
  border-radius: 3px;
}

/* localStorage usage indicator */
.cm-storage-indicator {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
}

.cm-storage-indicator.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.cm-storage-indicator.critical {
  border-color: #ef4444;
  background: #fef2f2;
}

.cm-storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.cm-storage-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: #888;
}

.cm-storage-value {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  font-variant-numeric: tabular-nums;
}

.cm-storage-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.cm-storage-bar-fill {
  height: 100%;
  background: var(--color-primary, #667eea);
  border-radius: 3px;
  transition: width 0.3s ease;
  min-width: 0;
}

.cm-storage-bar-fill.warning {
  background: #f59e0b;
}

.cm-storage-bar-fill.critical {
  background: #ef4444;
}

.cm-storage-hint {
  font-size: 11px;
  color: #999;
  margin: 0;
  line-height: 1.4;
}

.cm-storage-indicator.warning .cm-storage-hint {
  color: #92400e;
}

.cm-storage-indicator.critical .cm-storage-hint {
  color: #991b1b;
}

.cm-sync-dirty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: #fff8e6;
  border: 1px solid #f0d060;
  border-radius: 6px;
  font-size: 12.5px;
  color: #8a6d00;
}

.cm-sync-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.cm-sync-actions .btn {
  flex: 1;
  padding: 11px 18px;
  font-size: 13.5px;
}

.cm-sync-footer {
  text-align: center;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

/* Sync comparison section */
.cm-sync-comparison {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.cm-sync-comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: #888;
}

.cm-sync-refresh-btn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #666;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}

.cm-sync-refresh-btn:hover {
  background: #e5e7eb;
  color: #333;
}

.cm-sync-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cm-sync-comparison-col {
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
}

.cm-sync-col-title {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: #666;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.cm-sync-col-local .cm-sync-col-title {
  color: #6b7280;
}

.cm-sync-col-remote .cm-sync-col-title {
  color: #3b82f6;
}

.cm-sync-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 12px;
}

.cm-sync-stat-label {
  color: #888;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Inline SVG stat icons — colors baked in per icon */
.stat-icon {
  flex-shrink: 0;
  vertical-align: -1px;
}

.cm-sync-stat-value {
  font-weight: 600;
  color: #333;
}

.cm-sync-stat-sub {
  padding-left: 8px;
}

.cm-sync-stat-sub .cm-sync-stat-label {
  font-size: 11px;
  color: #aaa;
}

.cm-sync-stat-sub .cm-sync-stat-value {
  font-size: 11px;
  font-weight: 500;
}

.cm-sync-stat-value .stat-higher {
  color: #16a34a;
}

.cm-sync-stat-value .stat-lower {
  color: #dc2626;
}

.cm-sync-comparison-loading,
.cm-sync-comparison-error {
  text-align: center;
  font-size: 12px;
  padding: 8px 0;
  color: #888;
}

.cm-sync-comparison-error {
  color: #dc2626;
}

/* Detailed diff section */
#syncDetailedDiff {
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}

.cm-sync-diff-title {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: #888;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.cm-sync-diff-fallback {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  font-style: italic;
  padding: 4px 0;
}

.cm-sync-diff-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.cm-sync-diff-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  margin-top: 8px;
  margin-bottom: 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid #e5e7eb;
}

.cm-sync-diff-item {
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 0;
}

.cm-sync-diff-badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.cm-sync-diff-added > .cm-sync-diff-badge {
  background: #dcfce7;
  color: #16a34a;
}

.cm-sync-diff-removed > .cm-sync-diff-badge {
  background: #fee2e2;
  color: #dc2626;
}

.cm-sync-diff-modified > .cm-sync-diff-badge {
  background: #fef3c7;
  color: #d97706;
}

.cm-sync-diff-card {
  font-weight: 600;
  color: #333;
}

.cm-sync-diff-detail {
  color: #888;
  font-size: 11px;
  margin-left: 4px;
}

.cm-sync-diff-changes {
  margin-left: 26px;
  margin-top: 2px;
  font-size: 11px;
  color: #666;
}

.cm-sync-diff-change {
  padding: 1px 0;
}

.cm-sync-diff-old {
  color: #dc2626;
  text-decoration: line-through;
}

.cm-sync-diff-new {
  color: #16a34a;
  font-weight: 600;
}

span.cm-sync-diff-added {
  color: #16a34a;
  font-weight: 600;
}

span.cm-sync-diff-removed {
  color: #dc2626;
  font-weight: 600;
}

/* ─── Cloud History Panel ─── */

.cm-history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 0;
  color: #888;
  font-size: 13px;
}

.cm-history-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e0e0e0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: cm-spin 0.6s linear infinite;
}

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

.cm-history-error {
  text-align: center;
  padding: 24px 0;
  color: #dc2626;
  font-size: 13px;
}

.cm-history-error-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.cm-history-error .btn {
  margin-top: 12px;
}

.cm-history-empty {
  text-align: center;
  padding: 32px 0;
  color: #888;
}

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

/* Current version card */
.cm-history-current {
  background: #f0f9ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.cm-history-current-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cm-history-current-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3b82f6;
  background: #dbeafe;
  padding: 3px 8px;
  border-radius: 4px;
}

.cm-history-current-date {
  font-size: 12px;
  color: #6b7280;
}

.cm-history-current-stats {
  font-size: 13px;
}

/* Version list */
.cm-history-list-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 10px;
}

.cm-history-version-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.cm-history-version-card:hover {
  border-color: #93c5fd;
}

.cm-history-version-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cm-history-version-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cm-history-version-num {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
}

.cm-history-version-date {
  font-size: 12px;
  color: #6b7280;
}

.cm-history-version-size {
  font-size: 11px;
  color: #9ca3af;
}

.cm-history-version-stats {
  margin-bottom: 10px;
}

.cm-history-version-actions {
  display: flex;
  gap: 8px;
}

.cm-history-version-actions .btn {
  flex: 1;
  font-size: 12px;
  padding: 5px 10px;
}

/* Stats grid (compact) */
.cm-history-stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.cm-history-stat {
  font-size: 12px;
  color: #6b7280;
}

.cm-history-stat-val {
  font-weight: 600;
  color: #374151;
}

.cm-history-stat-lbl {
  font-weight: 400;
  color: #9ca3af;
}

/* Compare panel */
.cm-history-compare {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-top: 16px;
  overflow: hidden;
}

.cm-history-compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9fafb;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.cm-history-compare-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.cm-history-compare-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.cm-history-compare-close:hover {
  color: #374151;
}

.cm-history-compare-summary {
  padding: 14px 16px;
}

.cm-history-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cm-history-compare-col {
  font-size: 13px;
}

.cm-history-compare-col-title {
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cm-history-compare-stat {
  padding: 2px 0;
  color: #6b7280;
}

.cm-history-compare-stat strong {
  color: #374151;
}

.cm-history-diff-plus {
  color: #16a34a;
  font-weight: 600;
  font-size: 12px;
}

.cm-history-diff-minus {
  color: #dc2626;
  font-weight: 600;
  font-size: 12px;
}

.cm-history-compare-detail {
  padding: 0 16px 14px;
}

.cm-history-diff-hint {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
  margin: 4px 0 10px;
  line-height: 1.4;
}

.cm-history-no-diff {
  text-align: center;
  padding: 16px 0;
  color: #16a34a;
  font-size: 13px;
  font-weight: 500;
}

/* Pull confirmation modal */
#pullConfirmModal {
  z-index: var(--z-pull-confirm);
  background: rgba(0, 0, 0, 0.9);
}

#pullConfirmModal .modal {
  max-width: 540px;
  width: calc(100% - 40px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  position: relative;
}

#pullConfirmModal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

#pullConfirmModal .modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
}

#pullConfirmModal .modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #333;
}

#pullConfirmModal .modal-body {
  display: block;
  padding: 16px 20px 20px;
}

#pullConfirmModal .share-desc {
  font-size: 13px;
  margin-bottom: 16px;
  color: #666;
}

.pull-confirm-comparison {
  display: grid;
  grid-template-columns: 1fr 32px 1fr;
  gap: 0;
  align-items: stretch;
  margin: 0 0 20px;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 12px;
}

.pull-confirm-col {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  min-width: 0; /* Allow shrinking */
}

.pull-confirm-local {
  border-color: #f87171;
  background: linear-gradient(135deg, #fef2f2 0%, #fff 100%);
}

.pull-confirm-remote {
  border-color: #4ade80;
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
}

.pull-confirm-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
}

.pull-confirm-col-header span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pull-confirm-local .pull-confirm-col-header {
  color: #b91c1c;
  border-bottom-color: #fecaca;
}

.pull-confirm-remote .pull-confirm-col-header {
  color: #15803d;
  border-bottom-color: #bbf7d0;
}

.pull-confirm-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.pull-confirm-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.pull-confirm-arrow svg {
  width: 18px;
  height: 18px;
}

.pull-confirm-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pull-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #666;
  padding: 2px 0;
}

.pull-stat span:first-child {
  color: #6b7280;
  font-size: 11px;
}

.pull-stat strong {
  font-weight: 600;
  color: #1f2937;
  font-size: 12px;
  text-align: right;
}

.pull-stat-higher {
  color: #16a34a !important;
}

.pull-stat-lower {
  color: #dc2626 !important;
}

.pull-stat-diff {
  font-size: 11px;
  opacity: 0.8;
}

/* "What's actually changing" mini-list inside the pull modal */
.pull-diff-detail {
  margin: 16px 0 12px;
  padding: 12px 14px;
  background: rgba(102, 126, 234, 0.04);
  border: 1px solid rgba(102, 126, 234, 0.10);
  border-radius: 8px;
}

.pull-diff-detail h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary, #888);
}

.pull-diff-block {
  font-size: 12.5px;
  line-height: 1.55;
  margin: 4px 0;
  color: var(--text-secondary, #4b5563);
}
.pull-diff-added strong   { color: #10b981; }
.pull-diff-removed strong { color: #dc2626; }

body.dark-mode .pull-diff-detail {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}
body.dark-mode .pull-diff-block { color: #cbd5e1; }
body.dark-mode .pull-diff-added strong   { color: #6ee7b7; }
body.dark-mode .pull-diff-removed strong { color: #fca5a5; }

.pull-confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 0;
}

.pull-confirm-actions .btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
}

/* Share stats */
.cm-share-stats {
  font-size: 12.5px;
  color: #555;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* Share success box */
.cm-success-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.cm-success-box p {
  font-size: 13px;
  color: #16a34a;
  margin: 0 0 12px;
}

/* Privacy settings toggles */
.cm-privacy-settings {
  margin-top: 16px;
  margin-bottom: 18px;
}

.cm-privacy-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: #444;
  user-select: none;
}

.cm-privacy-toggle input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.cm-privacy-toggle span {
  line-height: 1.3;
}

.cm-privacy-sync-hint {
  margin-top: 10px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #b45309;
}
.cm-privacy-sync-hint p {
  flex: 1 1 auto;
  margin: 0;
  font-style: italic;
}
.cm-privacy-sync-hint .cm-privacy-sync-btn {
  flex-shrink: 0;
}

/* Import preview */
.cm-import-preview {
  margin-top: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 16px;
}

.cm-import-preview h5 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #92400e;
}

.cm-import-preview-content {
  font-size: 12px;
  margin-bottom: 10px;
}

.cm-import-preview-meta {
  font-size: 11px;
  color: #92400e;
  margin-bottom: 10px;
  opacity: 0.85;
}

.cm-import-preview .import-comparison {
  margin-bottom: 12px;
}

.cm-import-preview .pull-confirm-col {
  padding: 10px 12px;
}

.cm-import-preview-actions {
  display: flex;
  gap: 8px;
}

/* Remote collections list */
.cm-remote-list {
  margin-bottom: 18px;
}

.cm-remote-list:empty::after {
  content: attr(data-empty-text);
  display: block;
  text-align: center;
  padding: 16px;
  color: #999;
  font-size: 12px;
}

/* Export options */
.cm-export-options {
  margin-bottom: 14px;
}

/* Export summary — single column variant of the sync comparison grid */
.cm-export-summary {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.cm-export-summary .cm-sync-comparison-col.cm-sync-col-local {
  width: 50%;
  margin: auto;
}

/* Header sync status button */
.sync-status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: background 0.15s;
}

.sync-status-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.sync-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.sync-status-btn.synced .sync-status-dot {
  background: #22c55e;
}

.sync-status-btn.dirty .sync-status-dot {
  background: #f59e0b;
  animation: sync-pulse 1.5s infinite;
}

/* Responsive: Collection Manager */
@media (max-width: 640px) {
  .cm-modal {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }

  .cm-layout {
    flex-direction: column;
  }

  .cm-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .cm-sidebar-header {
    padding: 12px 16px 8px;
  }

  .cm-close-mobile {
    display: block;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
    line-height: 1;
  }

  .cm-close-desktop {
    display: none;
  }

  .cm-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 8px 8px;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .cm-nav::-webkit-scrollbar {
    display: none;
  }

  .cm-nav-item {
    padding: 8px 12px;
    font-size: 12px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .cm-nav-icon {
    font-size: 14px;
  }

  .cm-nav-label {
    display: inline;
  }

  .cm-nav-separator {
    width: 1px;
    height: auto;
    margin: 2px 4px;
    flex-shrink: 0;
  }

  .cm-panel-header {
    padding: 14px 16px 0;
  }

  .cm-panel-desc {
    font-size: 12px;
  }

  .cm-panel-body {
    padding: 14px 16px 18px;
  }

  .cm-sync-status {
    padding: 12px;
  }

  .cm-field-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .cm-field-label {
    min-width: unset;
  }

  .cm-import-row {
    flex-direction: column;
    gap: 8px;
  }

  .cm-import-row .btn {
    width: 100%;
  }
}

/* ── Share & Sync Modal (tabbed) — LEGACY, kept for compat ── */

.share-sync-modal {
  background: white;
  border-radius: 12px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.share-sync-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: none;
}

.share-sync-modal .modal-header h2 {
  font-size: 18px;
  margin: 0;
  color: #333;
}

.share-sync-modal .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}

.share-sync-modal .modal-close:hover {
  color: #333;
}

.share-sync-modal .modal-body {
  display: flex;
  flex-direction: column;
  padding: 20px 24px 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Tab navigation bar */
.share-sync-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 0;
}

.share-sync-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition:
    color 0.2s,
    border-color 0.2s;
  white-space: nowrap;
}

.share-sync-tab:hover {
  color: #555;
}

.share-sync-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.share-sync-tab .tab-icon {
  font-size: 15px;
  line-height: 1;
}

/* ── Sync tab styles ── */

.sync-intro {
  text-align: center;
  padding: 16px 0;
}

.sync-intro-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.sync-first-push-btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
}

.sync-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.sync-status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.sync-status-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.5px;
}

.sync-status-value {
  font-size: 12px;
  font-weight: 500;
  color: #333;
  font-family: monospace;
}

.sync-dirty-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  background: #fff8e6;
  border: 1px solid #f0d060;
  border-radius: 6px;
  font-size: 12px;
  color: #8a6d00;
}

.sync-dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e6a700;
  flex-shrink: 0;
  animation: sync-pulse 1.5s infinite;
}

@keyframes sync-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.sync-action-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.sync-action-buttons .btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
}

.sync-unlink {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.btn-text {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}

.btn-danger-text {
  color: #dc3545;
}

.btn-danger-text:hover {
  color: #a71d2a;
  text-decoration: underline;
}

/* ── Transfer tab styles ── */

.transfer-section {
  margin-bottom: 20px;
}

.transfer-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #333;
}

.transfer-section .share-desc {
  font-size: 12px;
  margin-bottom: 12px;
}

.transfer-qr-container {
  display: flex;
  justify-content: center;
  padding: 16px;
  margin-bottom: 12px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.transfer-qr-container .qr-canvas {
  border-radius: 4px;
  image-rendering: pixelated;
}

.transfer-qr-container .qr-fallback {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 12px;
}

.transfer-import-section {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* ── Sync Conflict Modal ── */

.sync-conflict-modal {
  background: white;
  border-radius: 12px;
  max-width: 460px;
  width: 100%;
  overflow: hidden;
}

.sync-conflict-modal .modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sync-conflict-modal .modal-header h2 {
  font-size: 16px;
  margin: 0;
  color: #333;
}

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

.sync-conflict-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sync-conflict-actions .btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  width: 100%;
  border-radius: 8px;
}

.sync-conflict-actions .btn-text {
  justify-content: center;
  padding: 8px;
  color: #888;
  font-size: 12px;
}

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

.conflict-btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conflict-btn-text strong {
  font-size: 13px;
}

.conflict-btn-text small {
  font-size: 11px;
  opacity: 0.7;
  font-weight: normal;
}

/* ── Responsive: Share & Sync modal ── */

@media (max-width: 768px) {
  .share-sync-modal {
    max-width: 100%;
    margin: 0 12px;
    max-height: 90vh;
  }

  .share-sync-tabs {
    padding: 0 12px;
  }

  .share-sync-tab {
    padding: 8px 12px;
    font-size: 12px;
  }

  .share-sync-modal .modal-body {
    padding: 16px;
  }

  .sync-status-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sync-status-item {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .sync-conflict-modal {
    margin: 0 12px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   OFFLINE STATE — Sync UI adaptations
   ═══════════════════════════════════════════════════════════════════════════ */

/* Offline notice banner inside the Collection Manager */
.cm-offline-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  width: 70%;
  margin: 5px auto;
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border: 1px solid #ffb74d;
  border-radius: 8px;
  color: #e65100;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.cm-offline-notice svg {
  flex-shrink: 0;
  stroke: #e65100;
}

.cm-offline-text {
  flex: 1;
}

.cm-offline-retry {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid #e65100;
  border-radius: 12px;
  background: rgba(230, 81, 0, 0.1);
  color: #e65100;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
  white-space: nowrap;
}

.cm-offline-retry:hover {
  background: rgba(230, 81, 0, 0.2);
}

.cm-offline-retry:active {
  transform: scale(0.96);
}

.cm-offline-retry:disabled {
  opacity: 0.6;
  cursor: wait;
}

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

/* Disabled buttons when offline */
.offline-disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}

/* Header sync wrapper offline state */
.sync-status-wrapper.offline .ds-sync-btn {
  opacity: 0.5;
}

.sync-status-wrapper.offline .sync-status-dot {
  background: #bbb !important;
}

.sync-status-wrapper.offline .header-sync-label {
  color: #999 !important;
}

/* Quick sync button offline */
.ds-quick-sync-btn.offline-disabled {
  opacity: 0.4 !important;
}

/* ── Reset panel ── */

.cm-nav-separator {
  height: 1px;
  background: var(--border-color);
  margin: 6px 8px;
}

.cm-nav-item.cm-nav-item-muted {
  color: #dc2626;
  font-size: 11.5px;
  margin-top: auto;
}

.cm-nav-item.cm-nav-item-muted:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

.cm-nav-item.cm-nav-item-muted.active {
  background: #dc2626;
  color: white;
}

.cm-danger-section h4 {
  color: #666;
  font-size: 13px;
}

/* Unlink button (softer than danger) */
.btn-muted-text {
  color: #999;
}

.btn-muted-text:hover {
  color: #c0392b;
  text-decoration: underline;
}

/* ── Textual confirmation modal ── */

.textual-confirm-title {
  font-size: 20px;
  color: var(--color-danger, #e74c3c);
}

.textual-confirm-body {
  padding: 24px 30px;
}

.textual-confirm-instruction {
  font-size: 13px;
  color: #666;
  margin-bottom: 14px;
  line-height: 1.8;
}

.textual-confirm-phrase {
  display: inline-block;
  background: #fef3f2;
  border: 1px solid #fecdc9;
  color: #c0392b;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 4px;
  margin: 0 3px;
  user-select: none;
  letter-spacing: 0.3px;
}

.textual-confirm-input {
  width: 100%;
  font-size: 15px;
  padding: 10px 12px;
  letter-spacing: 0.3px;
}

.textual-confirm-error {
  color: var(--color-danger, #e74c3c);
  font-size: 13px;
  margin-top: 8px;
  margin-bottom: 0;
}

#textualConfirmOk:disabled {
  background: #ccc;
  color: #888;
  border-color: #bbb;
  cursor: not-allowed;
  opacity: 1;
}

#textualConfirmOk:not(:disabled) {
  transition:
    background 0.2s,
    color 0.2s;
}

/* ── Direction-aware sync banner ─────────────────────────────── */
.cm-sync-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle, rgba(0, 0, 0, 0.04));
  margin-bottom: 12px;
}
.cm-sync-banner[data-verdict="in-sync"]     { border-color: rgba( 22,163, 74, 0.40); background: rgba( 22,163, 74, 0.06); }
.cm-sync-banner[data-verdict="local-newer"] { border-color: rgba(234,179,  8, 0.50); background: rgba(234,179,  8, 0.08); }
.cm-sync-banner[data-verdict="cloud-newer"] { border-color: rgba( 37, 99,235, 0.45); background: rgba( 37, 99,235, 0.06); }
.cm-sync-banner[data-verdict="conflict"]    { border-color: rgba(220, 38, 38, 0.45); background: rgba(220, 38, 38, 0.07); }
.cm-sync-banner[data-verdict="unknown"]     { border-color: rgba(115,115,115, 0.40); }
.cm-sync-banner[data-verdict="offline"]     { border-color: rgba(115,115,115, 0.40); opacity: 0.85; }
.cm-sync-banner-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.cm-sync-banner-text {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.cm-sync-banner-breakdown {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.cm-sync-refresh-btn {
  align-self: flex-end;
  font-size: 11px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
}
.cm-sync-refresh-btn:hover {
  background: var(--surface);
}

/* ── Header verdict dot ──────────────────────────────────────── */
.sync-verdict-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
  background: transparent;
}
.sync-verdict-dot[data-verdict="in-sync"]     { background: #16a34a; }
.sync-verdict-dot[data-verdict="local-newer"] { background: #eab308; }
.sync-verdict-dot[data-verdict="cloud-newer"] { background: #2563eb; }
.sync-verdict-dot[data-verdict="conflict"]    { background: #dc2626; }
.sync-verdict-dot[data-verdict="unknown"]     { background: #737373; }
.sync-verdict-dot[data-verdict="offline"]     { background: #737373; opacity: 0.45; }
.sync-verdict-dot[data-verdict="unconfigured"]{ display: none; }

/* ── Pull dialog verdict header ───────────────────────────────── */
.cm-sync-pull-verdict-header {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--surface-subtle, rgba(0, 0, 0, 0.04));
}
.cm-sync-pull-verdict-header[data-verdict="local-newer"] { background: rgba(234,179,8,0.10); color: #92580a; }
.cm-sync-pull-verdict-header[data-verdict="cloud-newer"] { background: rgba(37,99,235,0.08); color: #1d4ed8; }
.cm-sync-pull-verdict-header[data-verdict="conflict"]    { background: rgba(220,38,38,0.09); color: #b91c1c; }

/* ============================================================
   Collection profile editor (Collection Manager → Scope tab)
   ============================================================ */
#cmProfilePanel.cm-panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cm-profile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cm-profile-name-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
}

.cm-profile-name-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 4px 10px;
  font-size: 13.5px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  background: var(--bg-elevated, #ffffff);
  color: var(--text-primary, #1f2937);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cm-profile-name-input:focus {
  outline: none;
  border-color: var(--border-focus, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.16);
}

.cm-profile-rules-label {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}

.cm-profile-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cm-profile-rule {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background: var(--bg-elevated, #ffffff);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.cm-profile-rule:hover {
  background: var(--bg-secondary, #f8f9fa);
  border-color: var(--border-focus, #c7d2fe);
}

.cm-profile-rule.is-incomplete {
  border-left: 3px solid var(--color-warning, #f59e0b);
  padding-left: 10px;
}

.cm-profile-rule-drag {
  width: 26px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary, #6b7280);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cm-profile-rule-drag:hover {
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text-primary, #1f2937);
}

.cm-profile-rule-drag:first-of-type {
  margin-left: -2px;
}

.cm-profile-rule-kind,
.cm-profile-rule-lang,
.cm-profile-rule-target {
  height: 28px;
  padding: 2px 8px;
  font-size: 12.5px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  background: var(--bg-elevated, #ffffff);
  color: var(--text-primary, #1f2937);
  cursor: pointer;
}

.cm-profile-rule-kind {
  flex: 1 1 160px;
  min-width: 140px;
}

.cm-profile-rule-lang {
  flex: 0 0 auto;
  min-width: 64px;
}

.cm-profile-rule-target {
  flex: 1 1 120px;
  min-width: 100px;
}

.cm-profile-rule-kind:focus,
.cm-profile-rule-lang:focus,
.cm-profile-rule-target:focus {
  outline: none;
  border-color: var(--border-focus, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.16);
}

.cm-profile-rule-arrow {
  color: var(--text-secondary, #6b7280);
  font-size: 12px;
  padding: 0 4px;
  user-select: none;
}

.cm-profile-rule-delete {
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary, #6b7280);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.cm-profile-rule-delete:hover {
  background: rgba(220, 38, 38, 0.10);
  color: var(--color-error, #dc2626);
}

#cmProfileAddRule {
  align-self: flex-start;
  font-size: 13px;
}

.cm-profile-preview {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  font-size: 12.5px;
  color: var(--text-secondary, #6b7280);
  line-height: 1.55;
}

.cm-profile-preview-headline {
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin-bottom: 4px;
}

.cm-profile-preview-breakdown {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  opacity: 0.85;
  word-break: break-word;
}

.cm-profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

body.dark-mode .cm-profile-name-label,
body.dark-mode .cm-profile-rule-arrow,
body.dark-mode .cm-profile-preview {
  color: var(--text-dim, #8a929e);
}

body.dark-mode .cm-profile-rules-label,
body.dark-mode .cm-profile-preview-headline {
  color: var(--text, #e7eaef);
}

body.dark-mode .cm-profile-name-input,
body.dark-mode .cm-profile-rule,
body.dark-mode .cm-profile-rule-kind,
body.dark-mode .cm-profile-rule-lang,
body.dark-mode .cm-profile-rule-target {
  background: var(--surface2, #1a1f29);
  border-color: var(--border-hi, rgba(255, 255, 255, 0.12));
  color: var(--text, #e7eaef);
}

body.dark-mode .cm-profile-rule:hover {
  background: var(--surface3, #222836);
  border-color: var(--accent, #bdb2ff);
}

body.dark-mode .cm-profile-rule-drag {
  color: var(--text-dim, #8a929e);
}

body.dark-mode .cm-profile-rule-drag:hover {
  background: var(--surface3, #222836);
  color: var(--text, #e7eaef);
}

body.dark-mode .cm-profile-rule-delete {
  color: var(--text-dim, #8a929e);
}

body.dark-mode .cm-profile-rule-delete:hover {
  background: rgba(255, 118, 118, 0.14);
  color: var(--neg, #ff7676);
}

body.dark-mode .cm-profile-rule.is-incomplete {
  border-left-color: var(--warm, #fbb454);
}

body.dark-mode .cm-profile-preview,
body.dark-mode .cm-profile-actions {
  border-top-color: var(--border, rgba(255, 255, 255, 0.06));
}

body.dark-mode .cm-profile-name-input:focus,
body.dark-mode .cm-profile-rule-kind:focus,
body.dark-mode .cm-profile-rule-lang:focus,
body.dark-mode .cm-profile-rule-target:focus {
  border-color: var(--accent, #bdb2ff);
  box-shadow: 0 0 0 3px rgba(189, 178, 255, 0.22);
}

@media (max-width: 640px) {
  .cm-profile-meta {
    flex-wrap: wrap;
  }
  .cm-profile-name-input {
    flex: 1 1 100%;
  }
  .cm-profile-rule {
    gap: 5px;
  }
  .cm-profile-rule-kind,
  .cm-profile-rule-target {
    flex: 1 1 100%;
  }
  .cm-profile-rule-arrow {
    display: none;
  }
  .cm-profile-rule-delete {
    margin-left: auto;
  }
  .cm-profile-actions {
    flex-wrap: wrap;
  }
}
