/* ════════════════════════════════════════════════
   LNKER — styles.css
════════════════════════════════════════════════ */

:root {
  --bg:          #F5F7FA;
  --bg-2:        #FFFFFF;
  --card:        #FFFFFF;
  --card-2:      #F1F5F9;
  --border:      #E2E8F0;
  --border-2:    #CBD5E1;
  --text:        #0F172A;
  --text-2:      #475569;
  --text-3:      #94A3B8;
  --accent:      #2563EB;
  --accent-2:    #1D4ED8;
  --accent-rgb:  37,99,235;
  --danger:      #DC2626;
  --danger-rgb:  220,38,38;
  --warn:        #D97706;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow:      0 8px 24px rgba(15,23,42,.08);
  --shadow-sm:   0 2px 6px rgba(15,23,42,.05);
  --topbar-h:    56px;
  --addbar-h:    64px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; cursor: pointer; border: 0; background: 0; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* The HTML `hidden` attr defaults to `display: none`, but every layer
   in this app sets its own `display: flex/block`, which wins the
   cascade and leaves "hidden" elements visible. Force hidden to
   actually hide. */
[hidden] { display: none !important; }

/* ═══════════ LANDING LAYER ═══════════ */
.landing-layer {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(var(--accent-rgb),.10), transparent 70%),
    radial-gradient(800px 500px at -10% 110%, rgba(var(--accent-rgb),.06), transparent 70%),
    var(--bg);
  /* Bottom padding leaves room for .app-footer (~36px) so the centered
     card never sits flush against the legal links. */
  padding: 24px 24px 56px;
  overflow-y: auto;
}
.landing-card {
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column; align-items: stretch;
  gap: 18px;
  text-align: center;
}
.landing-tagline {
  color: var(--text-2);
  font-size: 17px;
  margin-top: -4px;
}
.landing-blurb {
  color: var(--text-3);
  font-size: 15px;
  line-height: 1.55;
  max-width: 380px;
  margin: 0 auto;
}
.landing-features {
  display: flex; flex-direction: column; gap: 10px;
  margin: 8px auto 4px;
  text-align: left;
  width: 100%;
  max-width: 360px;
}
.landing-feature {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 14px;
}
.lf-icon { font-size: 20px; flex: 0 0 auto; }
.landing-actions {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 8px;
}
.landing-cta { padding: 14px 18px; font-size: 16px; font-weight: 600; }
.landing-secondary { padding: 12px 18px; font-size: 15px; }

/* "← Back" link inside auth card */
.auth-back {
  align-self: flex-start;
  color: var(--text-3);
  font-size: 14px;
  padding: 4px 0;
  margin-bottom: -4px;
}
.auth-back:hover { color: var(--text-2); }

/* ═══════════ AUTH LAYER ═══════════ */
.auth-layer {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(var(--accent-rgb),.10), transparent 70%),
    radial-gradient(800px 500px at -10% 110%, rgba(var(--accent-rgb),.06), transparent 70%),
    var(--bg);
  /* Same as .landing-layer — leave room for the fixed app-footer. */
  padding: 24px 24px 56px;
  overflow-y: auto;
}
.auth-card {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: stretch;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; align-self: center; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; }
.brand-name { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.brand-tagline { color: var(--text-3); text-align: center; margin-bottom: 8px; }

.auth-tabs {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
}
.auth-tab {
  flex: 1; padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--card-2); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color .15s;
}
.auth-form input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  transition: transform .05s, background .15s, opacity .15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.primary:active { transform: translateY(1px); }
.btn.ghost { background: var(--card); border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--card-2); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: var(--r-sm); }

.google-btn { gap: 10px; }
.google-g {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: #333; font-weight: 700; font-size: 14px;
}

.text-link {
  color: var(--text-3); text-align: center; font-size: 14px; padding: 4px;
}
.text-link:hover { color: var(--accent); }

.auth-error {
  background: rgba(var(--danger-rgb),.08);
  border: 1px solid rgba(var(--danger-rgb),.25);
  color: var(--danger);
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 14px;
}

/* ═══════════ SSO ═══════════ */
.sso-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 4px;
}
.sso-line { flex: 1; height: 1px; background: var(--border); }
.sso-divider-label {
  color: var(--text-3); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sso-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.sso-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.sso-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.sso-google {
  background: #FFFFFF; color: #3c4043;
  border: 1px solid #dadce0;
}
.sso-google:hover:not(:disabled) { background: #F8FAFC; }
.sso-microsoft {
  background: #FFFFFF; color: #3c4043;
  border: 1px solid #dadce0;
}
.sso-microsoft:hover:not(:disabled) { background: #F8FAFC; }
.sso-apple {
  background: #000000; color: #FFFFFF;
  border: 1px solid #000000;
}
.sso-apple:hover:not(:disabled) { background: #1a1a1a; }
.sso-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
}
.sso-mark-google { color: #4285F4; font-weight: 900; font-size: 14px; }
.sso-mark-ms {
  display: inline-grid; grid-template-columns: 8px 8px; grid-template-rows: 8px 8px; gap: 1px;
  width: 17px; height: 17px;
}
.sso-mark-ms span:nth-child(1) { background: #F25022; }
.sso-mark-ms span:nth-child(2) { background: #7FBA00; }
.sso-mark-ms span:nth-child(3) { background: #00A4EF; }
.sso-mark-ms span:nth-child(4) { background: #FFB900; }
.sso-mark-apple::before {
  content: ''; font-size: 18px; line-height: 1;
}

/* ═══════════ APP SHELL ═══════════ */
.app {
  display: flex; flex-direction: column;
  height: 100%;
}
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-mark { width: 28px; height: 28px; border-radius: 6px; }
.topbar-name { font-weight: 700; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  font-size: 16px;
}
.icon-btn:hover { background: var(--card); color: var(--text); }

/* "+" button in the topbar that opens the slide-down add overlay. */
.add-toggle-btn {
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
  color: var(--accent);
}
.add-toggle-btn:hover { background: rgba(var(--accent-rgb),.10); color: var(--accent-2); }

/* Full-screen overlay: blurred backdrop + slide-down add bar. */
.add-overlay {
  position: fixed; inset: 0;
  z-index: 250;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; flex-direction: column;
  animation: add-overlay-fade .18s ease-out;
}
@keyframes add-overlay-fade {
  from { background: rgba(15,23,42,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
  to   { background: rgba(15,23,42,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
}

.add-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(15,23,42,.25);
}
.add-bar input {
  flex: 1;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  font-size: 15px;
  transition: border-color .15s;
}
.add-bar input:focus { border-color: var(--accent); }
.add-bar .btn { padding: 14px 22px; }
.add-bar-close { color: var(--text-3); }
.add-bar-close:hover { color: var(--text); background: var(--card-2); }

/* Slide-from-top animation. */
.add-bar-sliding {
  animation: add-bar-slide .22s cubic-bezier(.4,0,.2,1);
}
@keyframes add-bar-slide {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

.filter-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-2);
}
.filter-bar input {
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
}

/* ═══════════ LINK LIST ═══════════ */
.link-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  align-content: start;
}
/* Empty-state spans the full grid so it centers properly. */
.link-list .empty-state { grid-column: 1 / -1; }

.link-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  /* Don't clip the card — the kebab dropdown needs to escape the bottom
     edge. We round just the thumbnail's top corners instead. */
  transition: border-color .15s, transform .05s, box-shadow .15s;
  cursor: pointer;
}
.link-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
}
.link-card:active { transform: scale(0.99); }
.link-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--card-2) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 36px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  border-top-left-radius:  var(--r-md);
  border-top-right-radius: var(--r-md);
}
/* Favicon-only fallback: subtle gradient backdrop so the small icon
   doesn't look lost in a flat box. */
.link-thumb.favicon-only {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(var(--accent-rgb),.06), transparent 70%),
    var(--card-2);
}
.link-favicon {
  width: 48px; height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(15,23,42,.10));
}
.link-fallback-emoji { font-size: 36px; opacity: .6; }

.link-info {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px 12px;
}
.link-title {
  font-weight: 600; font-size: 14px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-meta {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-size: 11px; color: var(--text-3);
  margin-top: 2px;
}
.link-host {
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.link-meta .vis-pill {
  padding: 1px 7px; border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 10px;
  white-space: nowrap;
}
.link-meta .vis-pill.public { color: var(--accent); border-color: rgba(var(--accent-rgb),.35); }
.link-meta .vis-pill.shared { color: var(--warn);   border-color: rgba(217,119,6,.35); }

.link-actions {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 5;
}
.kebab-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  font-size: 18px; line-height: 1;
  letter-spacing: 1px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: var(--shadow-sm);
  transition: background .12s, transform .08s;
}
.kebab-btn:hover  { background: #fff; }
.kebab-btn:active { transform: scale(0.92); }
.kebab-btn[aria-expanded="true"] { background: #fff; }

.kebab-menu {
  position: absolute; right: 0; top: 36px;
  z-index: 50;
  min-width: 180px;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  gap: 2px;
}
.kebab-menu button {
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 14px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  transition: background .12s, color .12s;
}
.kebab-menu button:hover { background: var(--card-2); }
.kebab-menu button.danger { color: var(--danger); }
.kebab-menu button.danger:hover { background: rgba(var(--danger-rgb),.08); }

.vis-pill.clicks {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb),.35);
  background: rgba(var(--accent-rgb),.06);
}
.link-host { font-weight: 500; }

.empty-state {
  text-align: center; padding: 56px 24px; color: var(--text-3);
}
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state h2 { color: var(--text); margin-bottom: 6px; font-size: 18px; }

/* ═══════════ SORT BAR ═══════════ */
.sort-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sort-label {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.sort-select {
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.sort-select:focus { border-color: var(--accent); }
.sort-bar .text-link { font-size: 12px; }
.sort-bar .spacer { flex: 1; }
.sort-count { font-size: 12px; color: var(--text-3); }
.sort-search {
  flex: 1; min-width: 140px;
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.sort-search:focus { border-color: var(--accent); }

/* Two-state pill that toggles whether search is scoped to the
   current view (stash + filter chain) or the whole library. */
.search-scope-btn {
  padding: 5px 11px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.search-scope-btn:hover { color: var(--text); border-color: var(--border-2); }
.search-scope-btn.all-mode {
  background: rgba(var(--accent-rgb),.12);
  border-color: var(--accent);
  color: var(--accent);
}

/* Drag-and-drop card states (custom sort) */
.link-list.sortable .link-card { cursor: grab; }
.link-list.sortable .link-card:active { cursor: grabbing; }
.link-card.dragging { opacity: 0.5; transform: scale(0.97); }
.link-card.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}

/* ═══════════ CONNECTED DEVICES (settings) ═══════════ */
.pair-actions { display: flex; gap: 8px; }
.pair-code-box {
  margin-top: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 8px;
}
.pair-code-box.expired .pair-code { color: var(--text-3); text-decoration: line-through; }
.pair-code-row {
  display: flex; align-items: center; gap: 10px;
}
.pair-code {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  padding: 8px 12px;
  background: rgba(var(--accent-rgb),.08);
  border-radius: var(--r-sm);
  flex: 1; text-align: center;
  user-select: all;
}
.pair-code-hint { font-size: 12px; color: var(--text-3); text-align: center; }

.device-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.device-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.device-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.device-name { font-size: 13px; font-weight: 600; }
.device-when { font-size: 11px; color: var(--text-3); }

/* ═══════════ INBOX (CSV import + pending queue) ═══════════ */
.inbox-btn {
  position: relative;
}
.inbox-icon { font-size: 16px; line-height: 1; }
.inbox-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
  border: 2px solid var(--bg-2);
}

.inbox-sheet { max-width: 560px; }
.inbox-tabs {
  display: flex; gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
}
.inbox-tab {
  padding: 8px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.inbox-tab:hover { color: var(--text); }
.inbox-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.inbox-tab-count {
  font-size: 10px;
  padding: 1px 7px;
  background: var(--card-2);
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 700;
}
.inbox-tab.active .inbox-tab-count {
  background: rgba(var(--accent-rgb),.15);
  color: var(--accent);
}
.inbox-pane {
  display: flex; flex-direction: column; gap: 10px;
}

.inbox-import {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.inbox-import-head { display: flex; flex-direction: column; gap: 2px; }
.inbox-import-status {
  font-size: 12px; color: var(--text-2);
  padding: 6px 10px;
  background: var(--card-2);
  border-radius: var(--r-sm);
}
.inbox-import-status.error { color: var(--danger); background: rgba(var(--danger-rgb),.08); }
.inbox-import-status.ok    { color: var(--accent); background: rgba(var(--accent-rgb),.08); }

.inbox-pending { display: flex; flex-direction: column; gap: 8px; }
.inbox-pending-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.inbox-pending-head .spacer { flex: 1; }
.inbox-pending-count {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--card-2); color: var(--text-2);
  text-transform: none; letter-spacing: 0;
}
.inbox-list { display: flex; flex-direction: column; gap: 6px; }
.inbox-empty {
  text-align: center; padding: 32px 16px;
  color: var(--text-3); font-size: 13px;
}
.inbox-empty-icon { font-size: 36px; margin-bottom: 8px; }
.inbox-row {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.inbox-row-fav {
  width: 24px; height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
}
.inbox-row-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.inbox-row-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-row-url {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-row-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.inbox-row-tag {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--card-2);
  border-radius: 999px;
  color: var(--text-2);
}
.inbox-row-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* ═══════════ STASHES DROPDOWN (topbar) ═══════════ */
.stashes-wrap { position: relative; }
.stashes-menu {
  position: absolute; top: 42px; right: 0;
  z-index: 60;
  width: 260px;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.stashes-menu-head {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  padding: 6px 8px;
}
.stashes-menu-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 6px;
}
.stashes-menu-empty {
  padding: 12px 8px;
  font-size: 13px; color: var(--text-3); text-align: center;
}
.stashes-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 14px; color: var(--text);
  text-align: left;
  transition: background .12s;
}
.stashes-menu-item:hover { background: var(--card-2); }
.stashes-menu-item.active {
  background: rgba(var(--accent-rgb),.08);
  color: var(--accent);
  font-weight: 600;
}
.stashes-menu-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stashes-menu-count {
  font-size: 11px; color: var(--text-3);
  background: var(--card-2);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 8px;
}
.stashes-menu-foot {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.stashes-menu-foot .btn { width: 100%; }

/* ═══════════ STASH BANNER (when viewing a stash) ═══════════ */
.stash-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(var(--accent-rgb),.08);
  border-bottom: 1px solid rgba(var(--accent-rgb),.25);
  flex-wrap: wrap;
}
.stash-banner-label {
  font-size: 11px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.stash-banner-icon { width: 18px; height: 18px; object-fit: contain; }
.stashes-btn { padding: 0; }
.stashes-btn-icon {
  width: 22px; height: 22px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.kebab-icon {
  width: 14px; height: 14px;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 2px;
}
.stash-banner-name {
  font-size: 16px; font-weight: 600; color: var(--text);
  flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stash-banner .spacer { flex: 1; }
.stash-banner .text-link { font-size: 13px; padding: 2px 6px; }
.stash-banner .text-link.danger { color: var(--danger); }
.stash-banner .text-link.danger:hover { color: var(--danger); opacity: .8; }

.stash-banner-menu-wrap { position: relative; }
.stash-banner-kebab {
  font-size: 18px; line-height: 1; letter-spacing: 1px;
  color: var(--text-2);
}
.stash-banner-kebab:hover { background: var(--card); color: var(--text); }
.stash-kebab-menu {
  position: absolute;
  right: 0; top: 36px;
  z-index: 60;
  min-width: 180px;
}

.stash-banner-url {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(var(--accent-rgb),.12);
  border: 1px solid rgba(var(--accent-rgb),.4);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px; font-weight: 500;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  cursor: pointer;
  transition: background .15s;
  max-width: 100%;
  overflow: hidden;
}
.stash-banner-url:hover { background: rgba(var(--accent-rgb),.20); }
.stash-banner-url-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 280px;
}
.stash-banner-url-copy { font-size: 13px; opacity: .8; }

/* ═══════════ "+ STASH" BUTTON IN BREADCRUMBS ═══════════ */
.stash-add-chain-btn {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.stash-add-chain-btn:hover {
  background: rgba(var(--accent-rgb),.10);
}

/* ═══════════ SAVE-TO-STASH MODAL ═══════════ */
.stash-sheet { max-width: 460px; }
.stash-pick-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px;
}
.stash-pick-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--card);
  border-radius: var(--r-sm);
  font-size: 14px; color: var(--text);
  text-align: left;
  transition: background .12s;
}
.stash-pick-row:hover { background: var(--card-2); }
.stash-pick-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stash-pick-add { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ═══════════ TAG DRAWER (left-hand vertical) ═══════════ */
.tag-drawer {
  position: fixed;
  top: var(--topbar-h);
  bottom: 30px; /* clear the app footer */
  left: 0;
  width: 240px;
  z-index: 80;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 16px rgba(15,23,42,0.06);
  display: flex; flex-direction: column;
  transform: translateX(0);
  transition: transform .24s cubic-bezier(.4,0,.2,1);
}
.tag-drawer.closed { transform: translateX(-240px); }

.tag-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.tag-drawer-title { color: var(--text-2); }
.tag-drawer-count {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--card-2);
  border-radius: 999px;
  color: var(--text-2);
  text-transform: none; letter-spacing: 0;
}

.tag-drawer-search-wrap {
  padding: 8px 12px 0;
}
.tag-drawer-search {
  width: 100%;
  padding: 7px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  transition: border-color .12s;
}
.tag-drawer-search:focus { border-color: var(--accent); }

.tag-pile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px 14px;
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.tag-pile .tag-chip,
.tag-pile .pile-chip {
  /* In drawer mode, chips stack vertically. */
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

/* Handle pinned to the drawer's right edge — slides with the drawer
   so it's visible at left:0 when closed and at left:240 when open. */
.tag-drawer-handle {
  position: absolute;
  left: 100%;
  top: 80px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  box-shadow: 4px 2px 10px rgba(15,23,42,0.06);
  cursor: pointer;
  color: var(--text-2);
  font-size: 11px; font-weight: 600;
  transition: color .12s, background .12s;
}
.tag-drawer-handle:hover { background: var(--card); color: var(--accent); }
.tag-drawer-handle-icon { font-size: 12px; line-height: 1; }
.tag-drawer-handle-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* When the drawer is open AND we're on a wide enough viewport, the
   link grid + sort bar shift right so cards aren't hidden behind it.
   On narrow viewports the drawer overlays content (no shift). */
@media (min-width: 700px) {
  .app.drawer-open .sort-bar,
  .app.drawer-open .filter-crumbs,
  .app.drawer-open .stash-banner,
  .app.drawer-open .link-list {
    padding-left: 256px;
    transition: padding-left .24s cubic-bezier(.4,0,.2,1);
  }
}
.pile-chip {
  font-weight: 500;
  /* anchor for the entry/leave WAAPI animations */
  will-change: transform, opacity;
}
.pile-chip:hover {
  background: rgba(var(--accent-rgb),.08);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════ FILTER BREADCRUMBS ═══════════ */
.filter-crumbs {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  overflow: hidden; /* let .crumbs-row do the scrolling, not the parent */
}
.crumbs-label {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  flex-shrink: 0;
}
/* Single horizontally-scrollable row of crumbs. Keeps narrow viewports
   from growing the bar to two/three lines of pills. */
.crumbs-row {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: nowrap;
  flex: 1; min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* Compact scrollbar so the row doesn't look chunky */
  scrollbar-width: thin;
  padding-bottom: 2px; /* room for the thin scrollbar */
}
.crumbs-row::-webkit-scrollbar { height: 4px; }
.crumbs-row::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
.crumbs-row::-webkit-scrollbar-track { background: transparent; }
.crumbs-row .crumb-chip,
.crumbs-row .crumb-sep,
.crumbs-row .stash-add-chain-btn { flex-shrink: 0; }
.crumbs-clear { flex-shrink: 0; }
.crumb-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 10px;
  background: rgba(var(--accent-rgb),.10);
  border: 1px solid rgba(var(--accent-rgb),.4);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  will-change: transform, opacity;
}
.crumb-chip:hover { background: rgba(var(--accent-rgb),.18); }
.crumb-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.crumb-chip .x {
  font-size: 11px; color: var(--accent);
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-left: 2px;
  transition: background .12s;
}
.crumb-chip:hover .x { background: rgba(var(--accent-rgb),.20); }
.crumb-sep {
  color: var(--text-3); font-size: 14px;
  margin: 0 2px;
  user-select: none;
}
.crumbs-clear {
  font-size: 12px;
  white-space: nowrap;
}

/* ═══════════ TAGS ═══════════ */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.tag-chip:hover { border-color: var(--border-2); color: var(--text); }
.tag-chip.selected { background: rgba(var(--accent-rgb),.10); border-color: var(--accent); color: var(--accent); }
.tag-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tag-chip .x { color: var(--text-3); font-size: 14px; line-height: 1; }
.tag-chip .x:hover { color: var(--danger); }
.tag-chip.suggested {
  background: transparent;
  border-style: dashed;
}
.tag-chip.suggested::before { content: "+ "; color: var(--text-3); }

/* ═══════════ SHEET ═══════════ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.sheet {
  width: 100%; max-width: 540px;
  max-height: 92vh;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: sheet-up .2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-lg); border: 1px solid var(--border); max-height: 84vh; }
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { font-size: 16px; font-weight: 600; }
.sheet-body {
  flex: 1; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.sheet-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sheet-foot .spacer { flex: 1; }

/* Duplicate-link warning banner inside the save sheet. */
.dup-warn {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  background: rgba(217,119,6,.08);
  border: 1px solid rgba(217,119,6,.35);
  border-radius: var(--r-md);
  color: var(--text);
}
.dup-warn.similar {
  background: rgba(var(--accent-rgb),.08);
  border-color: rgba(var(--accent-rgb),.35);
}
.dup-warn-head { display: flex; align-items: center; gap: 8px; }
.dup-warn-icon { font-size: 16px; line-height: 1; }
.dup-warn-title { font-size: 14px; }
.dup-warn-body { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.dup-warn-url {
  font-size: 11px; color: var(--text-3);
  word-break: break-all;
}
.dup-warn-actions { display: flex; gap: 6px; }
.dup-warn.domain-only {
  background: var(--card-2);
  border-color: var(--border);
}
.dup-warn.domain-only .dup-warn-title { font-weight: 600; font-size: 13px; }

.dup-warn-siblings {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.dup-warn-siblings-head {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.dup-warn-siblings-list { display: flex; flex-direction: column; gap: 4px; }
.dup-sibling {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.dup-sibling-fav { width: 18px; height: 18px; border-radius: 3px; flex-shrink: 0; }
.dup-sibling-meta { flex: 1; min-width: 0; }
.dup-sibling-title {
  font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dup-sibling-url {
  font-size: 10px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dup-sibling-clicks {
  font-size: 10px; color: var(--accent);
  padding: 1px 6px;
  background: rgba(var(--accent-rgb),.08);
  border: 1px solid rgba(var(--accent-rgb),.25);
  border-radius: 999px;
  flex-shrink: 0;
}
.dup-sibling-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dup-sibling-actions .btn { padding: 4px 8px; font-size: 11px; }

.preview-card {
  display: grid; grid-template-columns: 100px 1fr; gap: 12px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.preview-image {
  width: 100px; height: 76px;
  background: var(--card-2) center/cover no-repeat;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 24px;
  overflow: hidden;
}
.preview-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.preview-site  { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.preview-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-url   { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}
.field input, .field textarea {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  resize: vertical;
  transition: border-color .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }

.tag-suggest-row { display: flex; gap: 6px; align-items: stretch; }
.tag-suggest-row .tag-input-wrap { flex: 1; position: relative; min-width: 0; }
.tag-suggest-row .tag-input-wrap input { width: 100%; }

/* Autocomplete dropdown — matches existing tag names as the user types. */
.tag-autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  display: flex; flex-direction: column;
  gap: 1px;
}
.tag-ac-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: transparent; border: 0;
  transition: background .12s;
}
.tag-ac-item:hover, .tag-ac-item.active { background: var(--card-2); }
.tag-ac-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-ac-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.visibility-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.vis-btn {
  padding: 8px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-weight: 500;
  font-size: 13px;
}
.vis-btn.active { background: var(--card-2); color: var(--text); }
.visibility-hint { font-size: 12px; color: var(--text-3); padding-left: 4px; }

.share-row { display: flex; gap: 6px; }
.share-row input { flex: 1; padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm); outline: none; }
.share-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.share-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
}
.share-pill .x { color: var(--text-3); cursor: pointer; }
.share-pill .x:hover { color: var(--danger); }

/* ═══════════ 2FA CHALLENGE ═══════════ */
.totp-hint {
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
  margin-top: -4px;
}
#totpChallengeCode,
#totpEnrollCode,
#smsEnrollCode,
#emailEnrollCode {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.totp-method-picker {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.totp-method-picker .method-btn {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  text-align: left;
}
.totp-method-picker .method-btn:hover { border-color: var(--border-2); }
.totp-method-picker .method-btn.active {
  background: rgba(var(--accent-rgb),.08);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════ 2FA SETTINGS — per-method blocks ═══════════ */
.tfa-method {
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 10px;
}
.tfa-method-head {
  display: flex; align-items: center; justify-content: space-between;
}
.tfa-method-label {
  font-weight: 600; font-size: 14px; color: var(--text);
}
.tfa-method-status {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.tfa-method-status.on {
  background: rgba(var(--accent-rgb),.10);
  border-color: rgba(var(--accent-rgb),.4);
  color: var(--accent);
}

/* ═══════════ DESCRIPTION POPOVER ═══════════ */
.desc-sheet { max-width: 480px; }
.desc-body {
  font-size: 14px; color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.desc-stats {
  font-size: 12px; color: var(--text-3);
  text-align: center;
  padding: 4px 0;
}

/* ═══════════ SETTINGS ═══════════ */
.settings-sheet { max-width: 460px; }
.settings-section {
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: 0; }
.settings-row-head {
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
}
.settings-label { color: var(--text-3); font-size: 13px; }
.settings-value { color: var(--text); font-size: 14px; }
.settings-blurb {
  font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.totp-qr {
  display: block; margin: 8px auto;
  width: 200px; height: 200px;
  border-radius: var(--r-md);
  background: #fff;
  border: 1px solid var(--border);
}
.totp-key {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  text-align: center;
  letter-spacing: 0.1em;
  font-size: 13px;
  color: var(--text);
  user-select: all;
}
.totp-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ═══════════ FREEMIUM — plan + upsell ═══════════ */
.plan-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.plan-name {
  font-size: 16px; font-weight: 700;
  color: var(--text);
}
.plan-name.paid { color: var(--accent); }
.plan-usage { display: flex; flex-direction: column; gap: 8px; padding: 6px 4px; }
.plan-usage-row { display: flex; flex-direction: column; gap: 4px; }
.plan-usage-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px;
}
.plan-usage-label { color: var(--text-2); }
.plan-usage-num { color: var(--text); font-weight: 600; }
.plan-usage-of  { color: var(--text-3); font-weight: 400; }
.plan-usage-bar {
  height: 6px; border-radius: 999px;
  background: var(--card-2);
  overflow: hidden;
}
.plan-usage-fill {
  height: 100%; background: var(--accent);
  transition: width .3s ease-out;
}
.plan-usage-fill.overflow { background: var(--danger); }

.upsell-sheet { max-width: 540px; }
.upsell-reason {
  padding: 10px 12px;
  background: rgba(217,119,6,.08);
  border: 1px solid rgba(217,119,6,.3);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 13px;
}
.upsell-tiers { display: flex; flex-direction: column; gap: 10px; }
.upsell-tier {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 8px;
}
.upsell-tier.upgrade {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb),.3);
}
.upsell-tier-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.upsell-tier-name { font-weight: 700; font-size: 15px; }
.upsell-tier-price { font-weight: 700; font-size: 16px; color: var(--accent); }
.upsell-tier-desc { font-size: 13px; color: var(--text-2); }
.upsell-tier-features {
  list-style: none; padding: 0; margin: 4px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.upsell-tier-features li {
  font-size: 13px; color: var(--text-2);
  padding-left: 18px; position: relative;
}
.upsell-tier-features li::before {
  content: '✓'; color: var(--accent);
  position: absolute; left: 0; font-weight: 700;
}
.upsell-tier-btn { width: 100%; }

/* ═══════════ APP AUTH CONTROLS — custom message banner ═══════════ */
.aac-custom-message {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 105;
  padding: 18px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  overflow-y: auto;
  max-height: 100vh;
}
.aac-custom-message a { color: var(--accent); }

/* ═══════════ APP FOOTER ═══════════ */
.app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  /* Above .landing-layer / .auth-layer (both z-index: 100) so the
     copyright + legal links stay visible on the signed-out screens. */
  z-index: 110;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 6px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
  /* Don't intercept clicks on the link grid above when the footer is
     just decorative — but the inner buttons/links re-enable it. */
  pointer-events: none;
}
.app-footer > * { pointer-events: auto; }
.app-footer-sep { color: var(--text-3); opacity: .6; }
.app-footer-link {
  color: var(--text-3);
  text-decoration: none;
  background: transparent; border: 0;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  transition: color .12s;
}
.app-footer-link:hover { color: var(--accent); }
.app-footer-legal { font-weight: 500; }
.app-footer-install {
  color: var(--accent);
  font-weight: 600;
}

/* Push the link grid up so cards aren't hidden behind the footer.
   Topbar (56) + addbar dropped + footer (~30) — give the scroller
   bottom-padding instead of the body so it pads the inner content. */
.link-list { padding-bottom: 56px; }

/* ═══════════ LEGAL MODAL ═══════════ */
.legal-sheet { max-width: 600px; max-height: 86vh; }
.legal-doc-nav {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.legal-doc-tab {
  padding: 6px 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.legal-doc-tab:hover { color: var(--text); }
.legal-doc-tab.active {
  background: rgba(var(--accent-rgb),.10);
  border-color: var(--accent);
  color: var(--accent);
}
.legal-doc-meta {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 0;
}
.legal-doc-body {
  font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.legal-doc-body h1, .legal-doc-body h2, .legal-doc-body h3 {
  margin: 14px 0 6px;
  font-weight: 700;
}
.legal-doc-body h1 { font-size: 18px; }
.legal-doc-body h2 { font-size: 16px; }
.legal-doc-body h3 { font-size: 14px; }
.legal-doc-body p, .legal-doc-body ul, .legal-doc-body ol { margin: 6px 0; }
.legal-doc-body ul, .legal-doc-body ol { padding-left: 22px; }
.legal-doc-body a { color: var(--accent); }

/* ═══════════ TOAST ═══════════ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--card-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  z-index: 300;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast.error { border-color: rgba(var(--danger-rgb),.4); color: var(--danger); }

/* ═══════════ SCROLLBAR ═══════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ PASSKEY ═══════════ */
.passkey-signin-btn {
  width: 100%;
  margin: 4px 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600;
  padding: 11px 14px;
}
.passkey-signin-btn.is-loading { opacity: 0.85; cursor: progress; }
.passkey-glyph { font-size: 16px; }
.passkey-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  animation: passkey-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes passkey-spin { to { transform: rotate(360deg); } }
.passkey-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.passkey-list:empty { display: none; }
.passkey-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.passkey-item-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.passkey-item-label { font-size: 14px; font-weight: 600; color: var(--text); }
.passkey-item-sub   { font-size: 12px; color: var(--text-3); }
.passkey-item-del {
  background: transparent; border: 0; color: var(--danger);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.passkey-item-del:hover { background: rgba(var(--danger-rgb),.08); }

/* ═══════════ STANDALONE LEGAL / HELP PAGES ═══════════ */
/* /privacy.html, /terms.html, /help.html share these styles. They
   reuse the variables + Inter font defined at the top of this file
   but layout themselves as a single-column document instead of the
   app shell. The base `body { overflow: hidden }` rule at the top
   exists for the SPA (which uses internal scrollers); standalone
   docs need the document to scroll naturally, so we explicitly
   restore overflow and let the body grow past viewport height. */
body.legal-page,
body.help-page {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  height: auto;
  overflow: visible;
  display: flex; flex-direction: column;
  padding-bottom: 56px; /* room for the fixed footer */
}
.legal-page-head {
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.legal-page-back {
  display: inline-flex; align-items: center; gap: 10px;
  max-width: 760px; margin: 0 auto;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--text);
}
.legal-page-back:hover { color: var(--accent); }
.legal-page-back .brand-mark { width: 28px; height: 28px; border-radius: 6px; }
.legal-page-back .brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.legal-page-back-mark { color: var(--text-3); font-size: 16px; }

.legal-page-main {
  flex: 1;
  width: 100%; max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.legal-page-article h1 {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.legal-page-meta {
  font-size: 12px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 24px;
}
.legal-page-body {
  font-size: 15px; line-height: 1.6; color: var(--text);
}
.legal-page-body h2 { font-size: 20px; font-weight: 700; margin: 28px 0 8px; }
.legal-page-body h3 { font-size: 16px; font-weight: 600; margin: 20px 0 6px; }
.legal-page-body p { margin: 0 0 14px; }
.legal-page-body ul, .legal-page-body ol { margin: 0 0 14px 24px; }
.legal-page-body li { margin-bottom: 6px; }
.legal-page-body a { color: var(--accent); }
.legal-page-body code {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--card-2);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px;
}
.legal-empty { color: var(--text-3); }

.legal-page-footer, /* same .app-footer base — just confirms position */
.help-page-footer {
  position: fixed;
}

/* ── /help.html specifics ── */
.help-page-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 24px;
}
.help-page-search input {
  flex: 1;
  background: transparent; border: 0; outline: 0;
  font-size: 14px; color: var(--text);
}
.help-page-search input::placeholder { color: var(--text-3); }

.help-page-empty {
  padding: 18px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  text-align: center;
  font-size: 14px;
}

.help-category {
  margin-bottom: 28px;
}
.help-category-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 10px;
}
.help-category-title {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.01em;
}
.help-category-desc {
  font-size: 13px; color: var(--text-3);
}

.help-faq {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  overflow: hidden;
}
.help-faq[open] { border-color: rgba(var(--accent-rgb),.4); }
.help-faq-summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 14px; font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.help-faq-summary::-webkit-details-marker { display: none; }
.help-faq-summary::after {
  content: '+';
  color: var(--text-3);
  font-size: 18px; font-weight: 400; line-height: 1;
  transition: transform .15s;
}
.help-faq[open] .help-faq-summary::after { content: '–'; }
.help-faq-summary:hover { color: var(--accent); }

.help-faq-body {
  padding: 0 14px 14px;
  font-size: 14px; line-height: 1.6; color: var(--text-2);
}
.help-faq-body p { margin: 0 0 10px; }
.help-faq-body ul, .help-faq-body ol { margin: 0 0 10px 22px; }
.help-faq-body a { color: var(--accent); }
.help-faq-body code {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--card-2);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px;
}

.help-page-contact {
  margin-top: 36px;
  padding: 20px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
}
.help-page-contact-head {
  font-size: 15px; font-weight: 700;
  margin-bottom: 4px;
}
.help-page-contact-body {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 10px;
}
.help-page-contact-mail {
  display: inline-block;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff !important;
  font-weight: 600; font-size: 13px;
  border-radius: var(--r-sm);
  text-decoration: none;
}
.help-page-contact-mail:hover { background: var(--accent-2, #1D4ED8); }
