/* ============================================
   CardVault Elite — components.css
   Reusable component styles
   ============================================ */

/* ===== Sidebar Navigation ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--s-4) 0;
}
.sidebar__brand {
  padding: var(--s-2) var(--s-5) var(--s-5);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-primary);
}
.sidebar__brand-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--text-on-accent);
  font-size: 1rem;
}
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  cursor: pointer;
}
@media (hover: hover) {
  .sidebar__link:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
  }
}
.sidebar__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.sidebar__link-icon {
  width: 20px;
  display: inline-flex;
  justify-content: center;
  font-size: 1rem;
}
.sidebar__group-label {
  padding: var(--s-3) 12px 6px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar__footer {
  padding: var(--s-4) var(--s-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* ===== Bottom Navigation (mobile) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}
.bottom-nav__inner {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: var(--bottom-nav-h);
  align-items: stretch;
}
.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color var(--dur-fast) var(--ease);
  min-height: 44px;
}
.bottom-nav__item span.icon {
  font-size: 1.25rem;
  line-height: 1;
}
.bottom-nav__item[aria-current="page"] {
  color: var(--accent-text);
}
.bottom-nav__add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.bottom-nav__add-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  display: grid; place-items: center;
  font-size: 1.625rem;
  font-weight: 300;
  box-shadow: 0 6px 16px rgba(126, 146, 127, 0.35);
  margin-top: -22px;
  transition: transform var(--dur) var(--ease);
}
.bottom-nav__add-btn:active { transform: scale(0.92); }
.bottom-nav__add-btn.fab-pulse {
  animation: pulse-ring 2.5s ease-out infinite;
}

/* The bottom bar shows on phones, tablets and any touch screen (an iPad in
   landscape is wider than 1023px). Every rule that keeps clear of the bar
   uses this same query. */
@media (max-width: 1023px), (hover: none), (pointer: coarse) {
  .bottom-nav { display: block; }
}

/* ===== Mobile Drawer (More menu) ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 50;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  padding: var(--s-5) var(--s-4) calc(var(--s-6) + env(safe-area-inset-bottom));
}
.drawer.open { transform: translateY(0); }
.drawer__handle {
  width: 40px; height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  margin: 0 auto var(--s-5);
}
.drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin-bottom: var(--s-4);
}
.drawer__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.drawer__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--s-4) var(--s-2);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  min-height: 80px;
}
@media (hover: hover) {
  .drawer__item:hover { background: var(--accent-soft); }
}
.drawer__item .icon { font-size: 1.375rem; line-height: 1; }

/* ===== Top bar (mobile) ===== */
.topbar__brand {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
}
.topbar__actions { display: flex; gap: var(--s-1); }

/* ===== Collection switcher (only shown with 2+ collections) ===== */
.vault-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 var(--s-5) var(--s-4);
}
.vault-switcher__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.vault-switcher__select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--text-primary);
}
.vault-switcher__select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.vault-switcher--compact { padding: 0; min-width: 0; flex: 1 1 auto; max-width: 190px; }
.vault-switcher--compact .vault-switcher__select { padding: 6px 8px; }

/* ===== Stat Widget ===== */
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.stat__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-3xl);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.stat__sub--up { color: var(--success); }
.stat__sub--down { color: var(--error); }
.stat__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
  font-size: 1rem;
  margin-bottom: var(--s-2);
}

/* ===== Progress Bar ===== */
.progress {
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
  position: relative;
}
.progress__bar {
  height: 100%;
  /* Its own token: the pastel accents were too faint against the track
     (needs 3:1 as a graphic). */
  background: var(--progress-fill, var(--accent));
  border-radius: var(--radius-pill);
  transition: width 600ms var(--ease-out);
}
.progress__bar--complete { background: var(--success); }

/* Progress ring */
.ring {
  position: relative;
  width: 80px; height: 80px;
}
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--bg-subtle); }
.ring__fill { stroke: var(--progress-fill, var(--accent)); transition: stroke-dashoffset 600ms var(--ease-out); }
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  animation: fade-in var(--dur) var(--ease-out);
}
/* A dialog opened on top of another (e.g. a confirm over a form): the one
   underneath is already dimmed, so don't darken or blur twice. */
.modal-backdrop--stacked {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.modal-backdrop--stacked .modal { max-width: 440px; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 92dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: scale-in var(--dur) var(--ease-out);
}
.modal__header {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
}
.modal__close {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--text-secondary);
  font-size: 1.25rem;
  transition: background var(--dur-fast) var(--ease);
}
@media (hover: hover) {
  .modal__close:hover { background: var(--bg-subtle); }
}
.modal__body {
  padding: var(--s-6);
  overflow-y: auto;
  flex: 1;
}
.modal__footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--divider);
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slide-up var(--dur-slow) var(--ease-out);
  }
  .modal__footer {
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom));
  }
}

/* ===== Toast ===== */
.toast-stack {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  /* Above the modal backdrop (99) and drawer (50) so errors raised
     from inside a modal remain readable. */
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
  max-width: calc(100vw - var(--s-8));
}
@media (max-width: 1023px), (hover: none), (pointer: coarse) {
  .toast-stack {
    bottom: calc(var(--bottom-nav-h) + var(--s-4) + env(safe-area-inset-bottom));
    left: var(--s-4);
    right: var(--s-4);
  }
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--text-sm);
  color: var(--text-primary);
  pointer-events: auto;
  animation: toast-in 300ms var(--ease-out);
  min-width: 240px;
}
.toast.leaving { animation: slide-out-right 200ms var(--ease) forwards; }
.toast__icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.8125rem;
  flex-shrink: 0;
}
.toast--success .toast__icon { background: var(--success-bg); color: var(--success); }
.toast--error .toast__icon { background: var(--error-bg); color: var(--error); }
.toast--info .toast__icon { background: var(--info-bg); color: var(--info); }
.toast--warning .toast__icon { background: var(--warning-bg); color: var(--warning); }

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-4);
  max-width: 420px;
  margin: 0 auto;
}
.empty__art {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--s-5);
  opacity: 0.85;
}
.empty__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin-bottom: var(--s-2);
}
.empty__body {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--s-5);
}

/* ===== Install Banner ===== */
.install-banner {
  position: fixed;
  bottom: var(--s-4);
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  z-index: 70;
  max-width: 480px;
  width: calc(100vw - var(--s-8));
  transition: transform 500ms var(--ease-out);
}
.install-banner.visible {
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 1023px), (hover: none), (pointer: coarse) {
  .install-banner {
    bottom: calc(var(--bottom-nav-h) + var(--s-3) + env(safe-area-inset-bottom));
  }
}
.install-banner__icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.install-banner__content { flex: 1; min-width: 0; }
.install-banner__title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.install-banner__sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.install-banner__close {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
@media (hover: hover) {
  .install-banner__close:hover { background: var(--bg-subtle); }
}

/* ===== Onboarding ===== */
.onboarding-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--s-4);
}
.onboarding {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: var(--s-8) var(--s-6);
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: scale-in var(--dur-slow) var(--ease-out);
}
.onboarding__art {
  width: 88px; height: 88px;
  margin: 0 auto var(--s-5);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid; place-items: center;
  font-size: 2.5rem;
}
.onboarding__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  margin-bottom: var(--s-2);
}
.onboarding__sub {
  color: var(--text-secondary);
  margin-bottom: var(--s-6);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}
.onboarding__dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--s-6);
}
.onboarding__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background var(--dur) var(--ease), width var(--dur) var(--ease);
}
.onboarding__dot.active {
  background: var(--accent);
  width: 22px;
  border-radius: var(--radius-pill);
}
.onboarding__form { text-align: left; margin-bottom: var(--s-4); }
.onboarding__themes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.onboarding__theme {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  background: var(--bg-card);
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: center;
}
@media (hover: hover) {
  .onboarding__theme:hover { border-color: var(--accent); }
}
.onboarding__theme.active {
  border-color: var(--accent-hover);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.onboarding__theme-swatch {
  display: flex;
  gap: 2px;
  height: 24px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 6px;
}
.onboarding__theme-swatch span { flex: 1; }

/* ===== Card Item (collection) ===== */
.card-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  cursor: pointer;
}
@media (hover: hover) {
  .card-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}
.card-item__image {
  aspect-ratio: 3 / 4;
  background: var(--bg-subtle);
  display: grid; place-items: center;
  color: var(--text-muted);
  font-size: 2.25rem;
  position: relative;
  overflow: hidden;
}
.card-item__image img { width: 100%; height: 100%; object-fit: cover; }
.card-item__badges {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  right: var(--s-2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.card-item__body { padding: var(--s-3); }
.card-item__name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-item__meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--s-2);
}
.card-item__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent-text);
}

/* Compact list row */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
@media (hover: hover) {
  .list-row:hover { background: var(--bg-subtle); }
}
.list-row:last-child { border-bottom: none; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.toolbar__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.toolbar__search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 14px 10px 38px;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.toolbar__search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toolbar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* View toggle */
.view-toggle {
  display: flex;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 3px;
}
.view-toggle__btn {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  display: grid; place-items: center;
  transition: all var(--dur-fast) var(--ease);
}
.view-toggle__btn[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Quick add row (dashboard) */
.quick-add-row {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.quick-add-row .btn {
  flex: 1;
  min-width: 140px;
}

/* Saved indicator (forms) */
.saved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--success);
  font-weight: 500;
  animation: saved-flash 1800ms ease-out forwards;
}
.saved-indicator::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* Theme toggle button (header) */
.theme-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.theme-toggle__btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  transition: all var(--dur-fast) var(--ease);
}
.theme-toggle__btn[aria-pressed="true"] {
  background: var(--bg-card);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

/* Filter panel */
.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s-5);
  margin-bottom: var(--s-4);
  animation: slide-down var(--dur) var(--ease-out);
}

/* Tab nav */
/* Tabs wrap onto a second line on narrow screens. They used to scroll behind a
   hidden scrollbar, so on a phone the last tabs (Vault: Backup & export) were
   out of sight with nothing hinting they existed. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-1);
  border-bottom: 1px solid var(--divider);
  margin-bottom: var(--s-5);
}
.tab {
  padding: 10px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
}
.tab[aria-selected="true"] {
  color: var(--accent-text);
  border-bottom-color: var(--accent-hover);
}
@media (hover: hover) {
  .tab:hover { color: var(--text-primary); }
}
.tab:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Swipe-to-reveal action row */
.list-row {
  position: relative;
  touch-action: pan-y;
}
.list-row__actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  background: var(--error);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
}
.list-row__actions button {
  background: transparent;
  color: white;
  padding: 0 var(--s-5);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.list-row.swiped .list-row__actions { transform: translateX(0); }

/* Update banner (toggled by SW registration in index.html) */
#update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  /* The primary-button pair: readable in every theme (white on the hover
     accent was 2.3:1 in Night Vault). */
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg); font-size: var(--text-sm); font-family: var(--font-body);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#update-banner button {
  flex-shrink: 0; padding: 6px 14px;
  border: 2px solid currentColor; border-radius: var(--radius-sm);
  background: transparent; color: inherit; font-size: var(--text-xs);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  font-family: var(--font-body);
}
@media (hover: hover) {
  #update-banner button:hover { background: rgba(255,255,255,0.15); }
}

/* Skip link (a11y) */
.skip-link {
  position: absolute;
  top: -40px;
  left: var(--s-3);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  padding: 8px 14px;
  border-radius: var(--radius);
  z-index: 1000;
  font-weight: 500;
  font-size: var(--text-sm);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus {
  top: var(--s-3);
}

/* Improved button focus (a11y) */
.btn:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

/* Card item — keyboard activation */
.card-item:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* High-contrast focus on inputs */
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none; /* using box-shadow instead */
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
}
.section-header h2 {
  font-size: var(--text-xl);
}
.section-header__action {
  color: var(--accent-text);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Activity item */
.activity-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--divider);
}
.activity-row:last-child { border-bottom: none; }
.activity-row__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.activity-row__body { flex: 1; min-width: 0; }
.activity-row__title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}
.activity-row__sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.activity-row__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-primary);
}

/* Badge (achievement) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.badge--gold { background: #F5ECC8; color: #6B5414; }
.badge--silver { background: #E5E7EA; color: #5C6770; }
.badge--bronze { background: #F0DBC4; color: #7A5524; }

/* Confetti container */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}
.confetti span {
  position: absolute;
  width: 8px; height: 12px;
  top: -20px;
  animation: confetti-fall 1.6s ease-out forwards;
}

/* ===== Binder view (#storage/<id>) ===== */
/* Printable-only blocks (print.css shows them; it only loads for printing). */
.print-only { display: none; }

.binder-grid {
  display: grid;
  gap: var(--s-2);
  max-width: 560px;
  margin: 0 auto;
}
.binder-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 420px; }
.binder-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.binder-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 640px; }
.binder-pocket {
  position: relative;
  aspect-ratio: 63 / 88;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary);
}
.binder-pocket:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.binder-pocket--empty {
  border-style: dashed;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.binder-pocket--empty:disabled { cursor: default; opacity: 0.45; }
.binder-pocket__img { width: 100%; height: 100%; object-fit: cover; }
.binder-pocket__text {
  padding: var(--s-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
}
.binder-pocket__plus { font-size: 1.5rem; line-height: 1; }
.binder-pocket__num {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}
.binder-pocket__grade {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  font-size: 0.625rem;
  font-weight: 600;
  text-align: center;
}

/* ===== Copy photos (front/back) ===== */
.photo-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.photo-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--s-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  min-width: 0;
}
.photo-slot.is-busy { opacity: 0.6; pointer-events: none; }
.photo-slot__img {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 63 / 88;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.photo-slot__empty {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 63 / 88;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.photo-slot__label { font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); }
.storage-meter { height: 10px; border-radius: 999px; background: var(--bg-subtle); overflow: hidden; }
.storage-meter > span { display: block; height: 100%; background: var(--chart-1); }

/* ===== Profit & tax report (#sales/report) ===== */
.tax-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); min-width: 640px; }
.tax-table th { text-align: left; padding: 10px 12px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); background: var(--bg-subtle); }
.tax-table td { padding: 10px 12px; border-top: 1px solid var(--divider); vertical-align: top; }

/* ----- Device sync card (components/sync-card.js, v2.11.0) ----- */
.sync-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.sync-status--ok { background: var(--success-bg); color: var(--text-primary); }
.sync-status--warn { background: var(--warning-bg); color: var(--text-primary); }
.sync-more summary { cursor: pointer; color: var(--text-secondary); padding: 4px 0; }
.sync-code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-2);
  margin-bottom: var(--s-2);
}
.sync-code-input {
  width: 100%;
  font-size: 1.5rem !important;
  letter-spacing: 0.12em;
  text-align: center;
}
.sync-pics {
  display: flex;
  justify-content: center;
  gap: var(--s-5);
  flex-wrap: wrap;
  margin: var(--s-3) 0 var(--s-4);
}
.sync-pics > span { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sync-pic { font-size: 2.5rem; line-height: 1; }
.sync-key {
  display: block;
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  word-break: break-all;
  text-align: left;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-3);
}
textarea.sync-key { resize: vertical; }
button.sync-key { cursor: pointer; }
.sync-key--hidden { color: transparent; text-shadow: 0 0 8px var(--text-secondary); user-select: none; }

/* ===== Dashboard welcome panel (scripts/modules/dashboard.js welcomePanel) =====
   The greeting, a line about the collection, the stat tiles and the picture
   (components/hero-art.js). Colours are the --hero-* and --art-* tokens each
   theme sets. Laid out by the panel's own width (container query): on phones
   the picture sits small beside the greeting so the tiles stay on the first
   screen; wider panels give it a right-hand column. */
.cv-hero {
  container-type: inline-size;
  position: relative;
  overflow: hidden;
  background: var(--hero-bg, var(--bg-card));
  border: 1px solid var(--hero-border, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--s-6);
}
.cv-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  grid-template-areas: "text art" "foot foot";
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-4);
}
.cv-hero__text { grid-area: text; min-width: 0; }
.cv-hero__art { grid-area: art; line-height: 0; min-width: 0; }
.cv-hero__art svg { width: 100%; height: auto; display: block; }
.cv-hero__foot { grid-area: foot; min-width: 0; }
.cv-hero__eyebrow {
  display: inline-block;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--hero-eyebrow-bg, var(--bg-subtle));
  color: var(--hero-eyebrow-text, var(--text-primary));
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cv-hero__title {
  margin-top: var(--s-2);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.15;
  color: var(--text-primary);
}
.cv-hero__line {
  margin-top: var(--s-1);
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text-secondary);
}
/* The stat tiles follow the panel's width too: two across until there's
   room for four without squeezing their labels (at 1024px the window-based
   .grid-4 rule put four in a 700px panel). */
.cv-hero__foot .grid { margin-bottom: 0 !important; }
.cv-hero__foot .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
/* Phones: slimmer tiles so the Portfolio card comes into view sooner. */
.cv-hero__foot .stat { padding: var(--s-3) var(--s-4); }
@container (min-width: 600px) {
  .cv-hero__foot .stat { padding: var(--s-5); }
}
@container (min-width: 820px) {
  .cv-hero__foot .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
}
@container (min-width: 600px) {
  .cv-hero__grid {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 270px);
    gap: var(--s-4) var(--s-5);
    padding: var(--s-5) var(--s-6);
  }
  .cv-hero__title { font-size: var(--text-3xl); }
  .cv-hero__line { font-size: var(--text-base); }
}
@container (min-width: 880px) {
  .cv-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
  .cv-hero__title { font-size: var(--text-4xl); }
}

/* Picture fills (classes, not fill attributes: see hero-art.js) */
.cv-art-glow { fill: var(--art-glow); }
.cv-art-shadow { fill: var(--art-shadow); opacity: 0.08; }
.cv-art-card1 { fill: var(--art-card1); }
.cv-art-card2 { fill: var(--art-card2); }
.cv-art-card3 { fill: var(--art-card3); }
.cv-art-window { fill: var(--art-window); }
.cv-art-line { fill: var(--art-ink); opacity: 0.22; }
.cv-art-star { fill: var(--art-star); }
.cv-art-pack { fill: var(--art-pack); }
.cv-art-pack2 { fill: var(--art-pack2); }
.cv-art-fold { fill: var(--art-ink); opacity: 0.12; }
.cv-art-case { fill: var(--art-case); stroke: var(--art-case-edge); stroke-width: 2; }
.cv-art-label { fill: var(--art-label); }
.cv-art-grade { fill: var(--art-label); }
.cv-art-shine { fill: var(--art-shine); opacity: 0.35; }
.cv-art-spark { fill: var(--art-spark); transform-box: fill-box; transform-origin: center; }
.cv-art-spark--soft { opacity: 0.6; }
/* One gentle loop: the holo sparkles twinkle in turn. */
.cv-art-sparks .cv-art-spark { animation: cvTwinkle 4.8s ease-in-out infinite; }
.cv-art-sparks .cv-art-spark:nth-child(2) { animation-delay: 1.6s; }
.cv-art-sparks .cv-art-spark:nth-child(3) { animation-delay: 3.2s; }
@keyframes cvTwinkle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .cv-art-sparks .cv-art-spark { animation: none; }
}

/* ===== Free demo (only when demo/demo-shim.js ran; see tools/make-demo.py) ===== */
html.is-demo .demo-hide { display: none !important; }
.demo-bar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  padding: 8px var(--s-4);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.demo-bar .btn { padding-top: 4px; padding-bottom: 4px; }
/* Phones: one line ("✨ Free demo" + the button); the rest says it on wider screens. */
@media (max-width: 480px) { .demo-bar__more { display: none; } }
.demo-card { border: 2px solid var(--accent); }
@media print { .demo-bar { display: none !important; } }
