:root {
  --bg-0: #030712;
  --bg-1: #050b1f;
  --bg-2: #0a1636;
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --cyan-300: #67e8f9;
  --cyan-400: #22d3ee;
  --ink: #e8f1ff;
  --ink-dim: #9cb3d9;
  --ink-mute: #5a6f94;
  --glass: rgba(16, 33, 68, 0.55);
  --glass-strong: rgba(22, 44, 88, 0.75);
  --border: rgba(147, 197, 253, 0.14);
  --border-strong: rgba(147, 197, 253, 0.28);
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --shadow-lg: 0 20px 60px -10px rgba(2, 6, 23, 0.7), 0 4px 20px -6px rgba(59, 130, 246, 0.15);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 40%, var(--bg-2) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Animated sky (aurora gradients) ---------- */
.sky {
  position: fixed; inset: 0; z-index: -3;
  overflow: hidden;
  pointer-events: none;
}
.aurora {
  position: absolute;
  width: 70vmax; height: 70vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  mix-blend-mode: screen;
  animation: float 30s ease-in-out infinite;
}
.aurora-1 {
  background: radial-gradient(circle, #1e40af 0%, transparent 60%);
  top: -20%; left: -10%;
}
.aurora-2 {
  background: radial-gradient(circle, #0891b2 0%, transparent 60%);
  top: 30%; right: -20%;
  animation-duration: 40s;
  animation-delay: -10s;
}
.aurora-3 {
  background: radial-gradient(circle, #6366f1 0%, transparent 60%);
  bottom: -20%; left: 20%;
  animation-duration: 50s;
  animation-delay: -20s;
  opacity: 0.25;
}
@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(5%, -8%) scale(1.08); }
  66% { transform: translate(-6%, 4%) scale(0.95); }
}

/* ---------- Leaves ---------- */
.leaves, .particles {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: -2;
  overflow: hidden;
}
.leaf {
  position: absolute;
  width: 26px; height: 26px;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(96, 165, 250, 0.9), rgba(59, 130, 246, 0.3) 60%, transparent 75%),
    linear-gradient(135deg, rgba(147, 197, 253, 0.6), rgba(30, 64, 175, 0.1));
  border-radius: 0 100% 0 100%;
  box-shadow: inset 0 0 8px rgba(147, 197, 253, 0.3);
  opacity: 0.75;
  transform-origin: center;
  animation: leafFall linear infinite;
  filter: blur(0.2px);
}
.leaf::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
}
.leaf.variant-2 {
  background: radial-gradient(ellipse at 40% 30%, rgba(34, 211, 238, 0.8), rgba(8, 145, 178, 0.25) 60%, transparent 75%);
  border-radius: 100% 0 100% 0;
}
.leaf.variant-3 {
  background: radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.8), rgba(67, 56, 202, 0.2) 60%, transparent 75%);
  border-radius: 50% 0 50% 0;
}
@keyframes leafFall {
  0%   { transform: translate(0,-10vh) rotate(0deg) scale(var(--s, 1)); opacity: 0; }
  10%  { opacity: var(--o, 0.75); }
  50%  { transform: translate(var(--dx, 20vw), 50vh) rotate(360deg) scale(var(--s, 1)); }
  90%  { opacity: var(--o, 0.75); }
  100% { transform: translate(var(--dx2, -10vw), 110vh) rotate(720deg) scale(var(--s, 1)); opacity: 0; }
}

/* Small floating particles */
.particle {
  position: absolute;
  width: 3px; height: 3px;
  background: rgba(147, 197, 253, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(147, 197, 253, 0.6);
  animation: particleDrift linear infinite;
  opacity: 0;
}
@keyframes particleDrift {
  0%   { transform: translate(0, 100vh); opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.9; }
  100% { transform: translate(var(--dx, 10vw), -10vh); opacity: 0; }
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  background: linear-gradient(180deg, rgba(3, 7, 18, 0.75), rgba(3, 7, 18, 0.45));
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  font-weight: 600;
}
.brand-logo {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
}
.brand-text { font-size: 17px; letter-spacing: 0.02em; }
.brand-accent { color: var(--blue-300); font-weight: 700; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
  pointer-events: none;
}
.search {
  width: 260px;
  padding: 9px 12px 9px 36px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}
.search::placeholder { color: var(--ink-mute); }
.search:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5); }
.btn-ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--glass); color: var(--ink); border-color: var(--border-strong); }
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 0.18s;
}
.icon-btn:hover { background: var(--glass-strong); color: var(--ink); border-color: var(--border-strong); }

/* ---------- Main layout ---------- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 28px 80px;
  position: relative;
  z-index: 1;
}
.hero { margin-bottom: 36px; }
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.accent {
  background: linear-gradient(120deg, var(--blue-300), var(--cyan-300));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle {
  font-size: 16px;
  color: var(--ink-dim);
  max-width: 520px;
  margin: 0;
  line-height: 1.6;
}

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 28px;
}
.chip {
  padding: 7px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  border-radius: 100px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.chip:hover { color: var(--ink); border-color: var(--border-strong); }
.chip.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(14, 165, 233, 0.2));
  color: var(--blue-100);
  border-color: var(--blue-500);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* Grid of cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  padding: 20px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  transition: all 0.25s ease;
  cursor: pointer;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), transparent 40%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card:hover::before { opacity: 1; }

.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.card-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.15));
  border: 1px solid var(--border-strong);
  color: var(--blue-200);
  flex-shrink: 0;
}
.card-title {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.card-label {
  font-size: 15px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-issuer {
  font-size: 12px; color: var(--ink-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kind-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--blue-200);
  border-radius: 6px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}

.card-preview {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  letter-spacing: 0.2em;
  color: var(--blue-100);
  padding: 10px 0;
  min-height: 44px;
  display: flex; align-items: center;
}
.card-preview.muted { color: var(--ink-mute); font-size: 14px; letter-spacing: 0.05em; }

.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-mute);
}

.timer-bar {
  height: 3px;
  background: rgba(147, 197, 253, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-400), var(--cyan-300));
  transition: width 0.3s linear;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-dim);
}
.empty-icon { color: var(--ink-mute); margin-bottom: 16px; }

/* ---------- Detail view ---------- */
.detail-hero { max-width: 640px; margin: 0 auto; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 24px;
  font-family: inherit; font-size: 14px;
  transition: all 0.18s;
}
.back:hover { color: var(--ink); border-color: var(--border-strong); }

.detail-card {
  padding: 32px;
  background: var(--glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: var(--shadow-lg);
}

.detail-head {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.detail-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: white;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}
.detail-title h2 {
  font-size: 22px; font-weight: 600; margin: 0;
  color: var(--ink);
}
.detail-title p {
  font-size: 13px; color: var(--ink-mute); margin: 4px 0 0;
}

/* TOTP display */
.totp-stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 36px 20px;
  margin-bottom: 24px;
}
.totp-ring {
  position: relative;
  width: 180px; height: 180px;
  display: grid; place-items: center;
}
.totp-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.totp-ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.totp-ring .ring-bg { stroke: rgba(147, 197, 253, 0.1); }
.totp-ring .ring-fg {
  stroke: url(#grad-ring);
  transition: stroke-dashoffset 0.3s linear;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.6));
}
.totp-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 42px; font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--blue-100);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  z-index: 1;
}
.totp-code:hover { color: white; text-shadow: 0 0 16px rgba(147, 197, 253, 0.8); }
.totp-code.copied { color: var(--ok); transform: scale(1.05); }
.totp-sub {
  margin-top: 14px;
  font-size: 13px; color: var(--ink-mute);
}

.detail-rows { display: grid; gap: 14px; }
.detail-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(3, 7, 18, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.detail-row-label { font-size: 12px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.08em; }
.detail-row-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--ink);
  word-break: break-all;
  flex: 1; min-width: 0;
  text-align: right;
}
.detail-row-actions { display: flex; gap: 6px; }

.detail-foot {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.share-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(3, 7, 18, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 16px;
}
.share-link code {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--blue-200);
  word-break: break-all;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(520px, 100%);
  background: linear-gradient(180deg, rgba(10, 22, 54, 0.95), rgba(5, 11, 31, 0.95));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 90vh;
  overflow: auto;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 10px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px; color: var(--ink-dim);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  background: rgba(3, 7, 18, 0.5);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit; font-size: 14px;
  outline: none;
  transition: all 0.18s;
  resize: vertical;
}
.field textarea { font-family: 'JetBrains Mono', monospace; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.field small { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-mute); }
.field code {
  padding: 1px 5px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 4px;
  font-size: 11px;
  color: var(--blue-200);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.payload-wrap { position: relative; }
.payload-wrap textarea { padding-right: 40px; }
.payload-toggle {
  position: absolute; right: 8px; top: 8px;
  width: 28px; height: 28px;
  background: rgba(3, 7, 18, 0.6);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  padding: 12px 16px;
  background: var(--glass-strong);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; align-items: center; gap: 10px;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--err); }
.toast.info { border-left: 3px solid var(--blue-400); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
}

/* ---------- Footer ---------- */
.foot {
  position: relative;
  text-align: center;
  padding: 24px;
  color: var(--ink-mute);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  z-index: 1;
}
.foot .dot { margin: 0 8px; opacity: 0.5; }
.muted { color: var(--ink-mute); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .search { width: 100%; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .main { padding: 24px 16px 60px; }
  .row-2 { grid-template-columns: 1fr; }
  .totp-code { font-size: 32px; }
  .totp-ring { width: 150px; height: 150px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--blue-700), var(--blue-900, #1e3a8a));
  border-radius: 10px;
  border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--blue-500); }
