/* Cloakd — base styles: reset, scrollbars, focus rings, layout, nav rail,
   main panel, account cards, empty state, auth, modal. Extracted from index.html. */

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

:root {
  --bg:       #0d0f14;
  --surface:  #161a23;
  --surface2: #1e2330;
  --border:   #2a3045;
  --accent:   #5b7cfa;
  --accent2:  #8b5cf6;
  --text:     #e8eaf0;
  --muted:    #6b7490;
  --danger:   #f05252;
  --success:  #34d399;
  --warn:     #fbbf24;
  --mono:     'DM Mono', monospace;
  --sans:     'DM Sans', sans-serif;
  --radius:   10px;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Themed scrollbars (Firefox + WebKit) ── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar          { width: 8px; height: 8px; }
*::-webkit-scrollbar-track    { background: transparent; }
*::-webkit-scrollbar-thumb    { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #3a4262; }
*::-webkit-scrollbar-corner   { background: transparent; }
/* Slim variant for inner panels where vertical space is at a premium */
.scroll-slim::-webkit-scrollbar { width: 4px; height: 4px; }
.scroll-slim::-webkit-scrollbar-thumb { border: none; }

/* ── Keyboard focus rings ──────────────────────────────────────────
   :focus-visible matches keyboard / programmatic focus but NOT a mouse
   click, so pointer users never see a ring while keyboard users always
   get a clear one. Fixes the prior state where 13 elements killed the
   outline with no replacement — keyboard focus was completely invisible. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Text fields already shift their border to accent on focus; give them a
   soft glow ring instead of the hard outline so it reads as one piece. */
.form-input:focus-visible,
.search-input:focus-visible,
.gen-input:focus-visible,
.inline-edit-input:focus-visible,
.setting-select:focus-visible,
.sort-select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,124,250,0.22);
}
/* Custom toggle switch: the real <input> is visually hidden, so surface
   its keyboard focus on the track instead. */
.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(91,124,250,0.3);
}

/* ── Respect reduced-motion preferences ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Layout ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Nav rail (far-left, vertical icon tabs) ── */
.nav-rail {
  width: 78px; min-width: 78px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 8px;
  flex-shrink: 0;
}
.nav-rail-logo {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
}
.nav-rail-logo img { width: 100%; height: 100%; object-fit: contain; }
.nav-rail-tabs { display: flex; flex-direction: column; gap: 4px; }
.nav-tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 9px 4px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-family: var(--sans); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.02em; line-height: 1;
  border-radius: 10px;
  transition: color 0.12s, background 0.12s;
}
.nav-tab svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-tab:hover { color: var(--text); background: var(--surface2); }
.nav-tab.active { color: var(--accent); background: rgba(91,124,250,0.13); }
.nav-tab.active::before {
  content: ''; position: absolute; left: -8px; top: 14px; bottom: 14px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-tab .tab-breach-badge {
  position: absolute; top: 4px; right: 8px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 8px; line-height: 1;
  pointer-events: none;
}

.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; overflow: hidden; flex-shrink: 0;
}
.logo-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-text { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.logo-sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }
/* Wordmarks: bump brightness so they pop against the dark background */

.search-wrap { padding: 12px 14px 10px; position: relative; }
.search-wrap .search-icon {
  position: absolute; left: 24px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; display: flex; align-items: center;
}
.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 7px 12px 7px 30px;
  outline: none;
  transition: background 0.12s, border-color 0.12s;
}
.search-input:hover  { background: #232939; }
.search-input:focus  { background: var(--bg); border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }
.search-input::-webkit-search-cancel-button { display: none; }

.vault-list { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }

.vault-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  margin-bottom: 2px;
  border: 1px solid transparent;
  position: relative;
}
.vault-item:hover { background: var(--surface2); }
.vault-item.active {
  background: rgba(91,124,250,0.10);
  border-color: rgba(91,124,250,0.22);
}
.vault-item.active::before {
  content: ''; position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 2px;
}
.vault-item-site  { font-size: 14px; font-weight: 500; }
.vault-item-count { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.favicon {
  width: 34px; height: 34px;
  background: var(--surface2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent); /* overridden per-item by faviconColor() */
  flex-shrink: 0;
  font-family: var(--mono);
}
.vault-item-info { flex: 1; min-width: 0; }
.vault-item-site { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vault-item-count { font-size: 11px; color: var(--muted); }
.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 20px;
  font-family: var(--mono);
}
.badge-pwned { background: rgba(240,82,82,0.15); color: var(--danger); }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-info { font-size: 12px; color: var(--muted); }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; padding: 4px;
  border-radius: 5px; transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* ── Main panel ── */
.main { flex: 1; overflow-y: auto; padding: 32px 40px; }

.main-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 28px;
}
.site-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.site-url { font-size: 13px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.94; box-shadow: 0 4px 16px rgba(91,124,250,0.35); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); background: var(--surface3, #252b3d); }
.btn-danger { background: rgba(240,82,82,0.15); color: var(--danger); border: 1px solid rgba(240,82,82,0.3); }
.btn-danger:hover { background: rgba(240,82,82,0.25); }

/* ── Account cards ── */
.accounts-grid { display: flex; flex-direction: column; gap: 14px; }

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.account-card.is-default { border-color: var(--accent); }
.account-card:hover { border-color: var(--muted); box-shadow: 0 2px 12px rgba(0,0,0,0.2); }

.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.default-pill {
  font-size: 10px; font-family: var(--mono);
  padding: 2px 8px; border-radius: 20px;
  background: rgba(91,124,250,0.15); color: var(--accent);
}
.card-label { font-size: 13px; font-weight: 600; }
.fav-star {
  background: none; border: none; cursor: pointer;
  color: var(--muted2, #4a5168); font-size: 18px; line-height: 1;
  padding: 2px 4px; border-radius: 5px;
  transition: color 0.12s, transform 0.12s, background 0.12s;
}
.fav-star:hover { color: #fbbf24; background: rgba(251,191,36,0.08); transform: scale(1.1); }
.fav-star.active { color: #fbbf24; text-shadow: 0 0 6px rgba(251,191,36,0.35); }
.fav-star-sm {
  color: #fbbf24; font-size: 11px;
  vertical-align: middle; margin-right: 2px;
}

.field-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.field-label { font-size: 11px; color: var(--muted); width: 72px; flex-shrink: 0; font-family: var(--mono); }
.field-value {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
}
.field-value.pw { letter-spacing: 0.15em; }
.field-value.editable {
  cursor: text;
  transition: border-color 0.12s, background 0.12s;
}
.field-value.editable:hover {
  border-color: rgba(91,124,250,0.45);
  background: var(--surface2);
}
.field-value.placeholder { color: var(--muted2); font-style: italic; }
.inline-edit-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.inline-edit-input.label-input {
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  padding: 2px 7px;
  width: auto; min-width: 140px;
  border-radius: 6px;
}
.card-label.editable {
  cursor: text; padding: 2px 7px; margin-left: -7px;
  border-radius: 6px; transition: background 0.12s;
  display: inline-block;
}
.card-label.editable:hover { background: var(--surface2); }
.field-actions { display: flex; gap: 4px; }
.field-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px;
  cursor: pointer; font-size: 12px; color: var(--muted);
  font-family: var(--sans);
  transition: color 0.1s, border-color 0.1s;
}
.field-btn:hover { color: var(--text); border-color: var(--accent); }

.strength-bar {
  height: 3px; border-radius: 2px;
  background: var(--border); overflow: hidden;
  margin-top: 6px;
}
.strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; }
.strength-label { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }

.pwned-warning {
  display: flex; align-items: center; gap: 8px;
  background: rgba(240,82,82,0.08);
  border: 1px solid rgba(240,82,82,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 12px; color: var(--danger);
}

.card-actions { display: flex; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Empty state ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; gap: 12px; color: var(--muted); text-align: center;
}
.empty-icon { opacity: 0.4; display: flex; align-items: center; justify-content: center; }
.note-icon { color: var(--accent); }
.empty-title { font-size: 16px; font-weight: 500; color: var(--text); }
.empty-sub { font-size: 13px; max-width: 280px; line-height: 1.6; }

/* ── Auth screen ── */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.45);
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; margin-bottom: 36px; text-align: center;
}
.auth-logo .logo-icon { width: 80px; height: 80px; border-radius: 20px; }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }

.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: block; font-family: var(--mono); }
.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }

.auth-note {
  font-size: 11px; color: var(--muted);
  line-height: 1.6; margin-top: 20px;
  padding: 12px; background: rgba(91,124,250,0.06);
  border-radius: 8px; border: 1px solid rgba(91,124,250,0.15);
}
.auth-switch { font-size: 13px; color: var(--muted); margin-top: 18px; text-align: center; }
.auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* Password show/hide toggle */
.input-wrap { position: relative; }
.input-wrap .form-input { padding-right: 42px; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 4px; display: flex; align-items: center; line-height: 1;
  border-radius: 4px; transition: color 0.1s;
}
.eye-btn:hover { color: var(--text); }

/* Check-email screen */
.check-email-icon {
  width: 54px; height: 54px; border-radius: 14px;
  background: rgba(91,124,250,0.1); border: 1px solid rgba(91,124,250,0.25);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px; color: var(--accent);
}
.confirm-info {
  background: rgba(52,211,153,0.06); border: 1px solid rgba(52,211,153,0.2);
  border-radius: 8px; padding: 12px 14px;
  font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 20px;
}
.auth-forgot { font-size: 11px; color: var(--muted); text-align: right; margin-top: 5px; }
.auth-forgot a { color: var(--accent); cursor: pointer; text-decoration: none; }
.auth-forgot a:hover { text-decoration: underline; }

.error-msg { font-size: 12px; color: var(--danger); margin-top: 8px; }
.success-msg { font-size: 12px; color: var(--success); margin-top: 8px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  /* Darker plain backdrop instead of backdrop-filter:blur(4px) — the
     blur was forcing a GPU re-rasterise of the entire underlying
     viewport on every layout change inside the modal (typing,
     toggling a custom-field row, expanding gen history), making
     interactions feel sticky on lower-end hardware. */
  background: rgba(0,0,0,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.16s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  /* Settle-in curve (ease-out-expo-ish) so the dialog feels like it lands
     rather than snapping. */
  animation: modalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn  { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.gen-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.gen-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.checkbox-row input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  z-index: 200;
  animation: slideUp 0.2s ease;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } }

.divider { height: 1px; background: var(--border); margin: 28px 0 20px; }
