:root {
  color-scheme: light;

  /* text */
  --text: #1f2a44;
  --text-dim: #5b6b8c;
  --text-faint: #94a3b8;

  /* glass surfaces */
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-soft: rgba(255, 255, 255, 0.42);
  --stroke: rgba(23, 37, 84, 0.09);
  --stroke-strong: rgba(23, 37, 84, 0.16);
  --highlight: rgba(255, 255, 255, 0.85);

  /* accents (iOS-ish, vivid but soft) */
  --accent: #6d5efc;
  --accent-2: #9b5cf6;
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c05ce0 100%);
  --grad-primary-hover: linear-gradient(135deg, #5b53f0 0%, #7e4ef0 55%, #b64fda 100%);
  --danger: #ff453a;
  --success: #23c65a;
  --warn: #ff9f0a;

  /* shape + depth */
  --radius: 20px;
  --radius-sm: 13px;
  --radius-xs: 10px;
  --shadow: 0 10px 30px rgba(30, 41, 90, 0.10), 0 2px 8px rgba(30, 41, 90, 0.05);
  --shadow-lg: 0 24px 60px rgba(30, 41, 90, 0.18);
  --glow: 0 8px 24px rgba(109, 94, 252, 0.34);

  --blur: saturate(180%) blur(20px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body {
  background-color: #eef2fe;
  /* small grid on top of a soft, colorful multi-blob gradient */
  background-image:
    linear-gradient(rgba(72, 94, 168, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(72, 94, 168, 0.06) 1px, transparent 1px),
    radial-gradient(900px 680px at 6% -8%, rgba(139, 92, 246, 0.30), transparent 55%),
    radial-gradient(820px 600px at 100% 2%, rgba(236, 72, 153, 0.22), transparent 52%),
    radial-gradient(760px 620px at 78% 108%, rgba(56, 189, 248, 0.26), transparent 55%),
    radial-gradient(700px 560px at 12% 112%, rgba(45, 212, 191, 0.22), transparent 55%);
  background-size: 26px 26px, 26px 26px, auto, auto, auto, auto;
  background-attachment: fixed;
  background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat, no-repeat;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); }

.boot { padding: 25vh 0; text-align: center; color: var(--text-dim); }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--highlight);
  outline: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-logo { font-size: 36px; text-align: center; margin-bottom: 4px; }
.auth-card h1 { font-size: 1.4rem; text-align: center; margin: 6px 0 4px; letter-spacing: -0.02em; }
.auth-card .sub { text-align: center; color: var(--text-dim); font-size: 0.9rem; margin-bottom: 24px; line-height: 1.55; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.78rem; color: var(--text-dim); margin-bottom: 7px; font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 14px;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(109, 94, 252, 0.18);
}
.textarea { resize: vertical; min-height: 74px; }

/* Custom dropdown chevron, inset from the edge (native one sits flush right). */
.select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6b8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}

.input-group { position: relative; display: flex; }
.input-group .input { flex: 1; padding-right: 150px; }

.ghost-btn {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--stroke);
  color: var(--text-dim);
  border-radius: 9px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); background: #fff; }

.btn {
  width: 100%;
  background: var(--grad-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: var(--glow);
  transition: filter 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { background: var(--grad-primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn.secondary {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow);
}
.btn.secondary:hover { background: #fff; }
.btn.danger { background: linear-gradient(135deg, #ff6b6b, #ff453a); box-shadow: 0 8px 24px rgba(255, 69, 58, 0.32); }

.form-error { color: var(--danger); font-size: 0.85rem; margin: -4px 0 14px; min-height: 1.1em; }
.hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 7px; line-height: 1.5; }

.strength { height: 6px; border-radius: 4px; background: rgba(23, 37, 84, 0.08); margin-top: 10px; overflow: hidden; }
.strength > span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.2s, background 0.2s; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 22px;
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--highlight);
  box-shadow: 0 1px 0 var(--stroke), 0 8px 24px rgba(30, 41, 90, 0.06);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.08rem; white-space: nowrap; letter-spacing: -0.02em; }
.brand .dot { font-size: 1.15rem; }
.topbar .spacer { flex: 1; }
.search-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; }
.search-inner { width: 100%; max-width: 460px; }
.badge svg { display: block; }

.icon-btn {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--stroke);
  color: var(--text-dim);
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(30, 41, 90, 0.06);
  transition: color 0.15s, border-color 0.15s, transform 0.05s, background 0.15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: #fff; }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg { width: 18px; height: 18px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 22px 60px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--stroke);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: #fff; }
.chip.active { background: var(--grad-primary); border-color: transparent; color: #fff; box-shadow: var(--glow); }
.chip .count { opacity: 0.75; font-variant-numeric: tabular-nums; }

/* ---------- Account grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--highlight);
  outline: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow);
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.card-head { display: flex; align-items: center; gap: 12px; }
.badge {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 6px 16px rgba(30, 41, 90, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.card-title { min-width: 0; flex: 1; }
.card-title .name { font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title .meta { font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 4px; }
.mini-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-faint);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.mini-btn:hover { color: var(--accent); background: rgba(255, 255, 255, 0.85); }
.mini-btn.danger:hover { color: var(--danger); }
.mini-btn svg { width: 16px; height: 16px; }

.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-height: 42px;
}
.row .k { font-size: 0.68rem; color: var(--text-faint); width: 62px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.row .v { flex: 1; min-width: 0; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .v.mono { font-family: var(--mono); }
.row .v.secret { letter-spacing: 0.14em; color: var(--text-faint); }
.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 5px;
  border-radius: 8px;
  display: inline-flex;
  transition: all 0.15s;
}
.copy-btn:hover { color: var(--accent); background: rgba(255, 255, 255, 0.9); }
.copy-btn svg { width: 15px; height: 15px; }

/* TOTP */
.totp { display: flex; align-items: center; gap: 10px; }
.totp .code { font-family: var(--mono); font-size: 1.18rem; letter-spacing: 0.16em; font-weight: 700; color: var(--success); }
.totp .code.stale { color: var(--warn); }
.ring { width: 28px; height: 28px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: rgba(23, 37, 84, 0.12); }
.ring .prog { stroke: var(--success); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.ring.low .prog { stroke: var(--warn); }

.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-faint);
  background: var(--glass-soft);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--highlight);
  outline: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty .big { font-size: 2.6rem; margin-bottom: 10px; }

.list-status { padding: 8px 0 4px; }
.list-msg {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.list-msg.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--stroke-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sentinel { height: 1px; width: 100%; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 37, 84, 0.22);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--highlight);
  outline: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 26px;
}
.modal h2 { margin: 0 0 18px; font-size: 1.2rem; letter-spacing: -0.02em; }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--highlight);
  outline: 1px solid var(--stroke);
  color: var(--text);
  padding: 11px 17px;
  border-radius: 13px;
  font-size: 0.87rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.success { outline-color: rgba(35, 198, 90, 0.5); }
.toast.error { outline-color: rgba(255, 69, 58, 0.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

@media (max-width: 560px) {
  /* two-row header: [brand ........ + key lock] then [search full width] */
  .topbar { flex-wrap: wrap; column-gap: 8px; row-gap: 10px; padding: 12px 16px; }
  .brand { margin-right: auto; }
  .icon-btn { width: 40px; height: 40px; }
  .search-wrap { order: 3; flex-basis: 100%; }
  .search-inner { max-width: 100%; }
  .container { padding: 18px 16px 56px; }
  .filters { gap: 7px; margin-bottom: 18px; }
  .modal-row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .input-group .input { padding-right: 150px; }
}
