/* PassVault: hand-written styles, light + dark themes via custom properties */

:root {
  --bg: #f5f6fb;
  --bg-accent: radial-gradient(1200px 500px at 85% -10%, #e4e1ff 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --border: #e2e4ef;
  --text: #171a2b;
  --muted: #5d6280;
  --primary: #5b4cf0;
  --primary-hover: #4a3be0;
  --primary-soft: #ecebff;
  --on-primary: #ffffff;
  --danger: #c62f3c;
  --danger-soft: #fdecee;
  --success: #12805c;
  --success-soft: #e5f6ef;
  --ring: rgba(91, 76, 240, 0.35);
  --shadow: 0 1px 2px rgba(20, 22, 50, 0.05), 0 8px 24px rgba(20, 22, 50, 0.06);
  --shadow-lg: 0 20px 50px rgba(20, 22, 50, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f1a;
    --bg-accent: radial-gradient(1200px 500px at 85% -10%, #261f5c 0%, transparent 60%);
    --surface: #161927;
    --surface-2: #1e2233;
    --border: #2a2f45;
    --text: #eceefa;
    --muted: #a0a6c3;
    --primary: #8b7dff;
    --primary-hover: #a094ff;
    --primary-soft: #262150;
    --on-primary: #0d0f1a;
    --danger: #ff7a85;
    --danger-soft: #3a1c24;
    --success: #5ad5a6;
    --success-soft: #133229;
    --ring: rgba(139, 125, 255, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d0f1a;
  --bg-accent: radial-gradient(1200px 500px at 85% -10%, #261f5c 0%, transparent 60%);
  --surface: #161927;
  --surface-2: #1e2233;
  --border: #2a2f45;
  --text: #eceefa;
  --muted: #a0a6c3;
  --primary: #8b7dff;
  --primary-hover: #a094ff;
  --primary-soft: #262150;
  --on-primary: #0d0f1a;
  --danger: #ff7a85;
  --danger-soft: #3a1c24;
  --success: #5ad5a6;
  --success-soft: #133229;
  --ring: rgba(139, 125, 255, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-accent), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 32px; padding-bottom: 48px; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 8px; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; fill: var(--primary); stroke: none; }
.brand-mark .brand-key { fill: var(--surface); }
.nav { display: flex; align-items: center; gap: 8px; }
.nav form { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 38px; padding: 0 12px; font-size: .9rem; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: transparent; }
.btn[disabled] { opacity: .7; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.is-done { color: var(--success); }
.theme-toggle { border-color: var(--border); color: var(--text); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}
.icon-eye-off { display: none; }
[aria-pressed="true"] .icon-eye { display: none; }
[aria-pressed="true"] .icon-eye-off { display: block; }

.link-btn { background: none; border: 0; padding: 0; margin-top: 6px; color: var(--primary); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; align-self: flex-start; }
.link-btn:hover { text-decoration: underline; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Toasts */
.toasts { position: fixed; top: 76px; right: 16px; left: 16px; z-index: 20; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: 420px; width: 100%;
  padding: 12px 12px 12px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease-out;
}
.toast span { flex: 1; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.toast-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; line-height: 1; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* Landing */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding: 24px 0 56px; }
.pill { display: inline-block; padding: 6px 12px; margin-bottom: 18px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .82rem; font-weight: 600; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.4rem); margin-bottom: 18px; }
.accent { color: var(--primary); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 34em; margin-bottom: 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.mock { padding: 8px; transform: rotate(-2deg); box-shadow: var(--shadow-lg); }
.mock-row { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-sm); }
.mock-row + .mock-row { border-top: 1px solid var(--border); border-radius: 0; }
.mock-row div { flex: 1; display: grid; }
.mock-row small { color: var(--muted); }
.mock-dot { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--c); color: #fff; font-weight: 700; }
.mock-pass { color: var(--muted); letter-spacing: 2px; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { padding: 22px; }
.feature svg { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.feature h3 { font-size: 1.05rem; }
.feature p { margin: 0; font-size: .95rem; }

/* Auth / forms */
.auth { max-width: 440px; margin: 16px auto 0; padding: 32px; }
.auth h1 { font-size: 1.7rem; }
.back { display: inline-block; margin-bottom: 16px; font-size: .9rem; }
.form { display: grid; gap: 16px; margin-top: 24px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
.field small { font-weight: 400; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field input {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-weight: 400; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); background: var(--surface); }
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 48px; }
.input-btn { position: absolute; right: 4px; top: 4px; }
.auth-switch { margin: 20px 0 0; text-align: center; font-size: .95rem; }

/* Vault */
.vault-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.vault-head p { margin: 0; }
.search { position: relative; display: flex; align-items: center; width: min(340px, 100%); }
.search svg { position: absolute; left: 14px; color: var(--muted); }
.search input {
  width: 100%; height: 44px; padding: 0 14px 0 42px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; font: inherit;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }

.vault-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.entry { display: flex; flex-direction: column; gap: 14px; padding: 20px; transition: border-color .15s, transform .15s, box-shadow .15s; }
.entry:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow-lg); }
.entry-top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.entry-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); object-fit: contain; padding: 6px; flex-shrink: 0; }
img.entry-logo { background: #fff; }
.entry-logo-fallback { display: none; place-items: center; padding: 0; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.entry-logo.is-broken { display: none; }
.entry-logo.is-broken + .entry-logo-fallback { display: grid; }
.entry-title { min-width: 0; display: grid; }
.entry-title h2 { font-size: 1.05rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-url { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row { display: grid; gap: 4px; }
.field-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field-value { display: flex; align-items: center; gap: 2px; min-height: 42px; padding: 0 4px 0 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.field-value .mono { flex: 1; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.entry-actions form { margin: 0; flex: 1; }
.entry-actions .btn { width: 100%; }

.empty-state { max-width: 480px; margin: 24px auto; padding: 40px 28px; text-align: center; }
.empty-icon { width: 56px; height: 56px; color: var(--primary); margin-bottom: 12px; }
.empty { text-align: center; padding: 32px 0; }

.footer { padding-top: 20px; padding-bottom: 28px; text-align: center; font-size: .85rem; color: var(--muted); }

/* Responsive */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding-top: 8px; }
  .hero-art { max-width: 420px; }
  .features { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .main { padding-top: 20px; }
  .auth { padding: 24px 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .vault-grid { grid-template-columns: 1fr; }
  .hide-xs { display: none; }
  .nav { gap: 6px; }
  .nav .btn-sm { padding: 0 10px; }
  .brand span { font-size: 1rem; }
  .hero-cta .btn { flex: 1 1 100%; }
}
@media (max-width: 359px) {
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
