:root {
  color-scheme: light;
  --ink: #17211d;
  --ink-soft: #52605a;
  --paper: #f6f5ef;
  --card: rgba(255, 255, 255, 0.92);
  --line: #dfe4df;
  --accent: #1f7a5a;
  --accent-dark: #155b43;
  --accent-soft: #e1f1e9;
  --danger: #b33b32;
  --shadow: 0 18px 55px rgba(34, 54, 45, 0.11);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(circle at 7% 12%, rgba(31, 122, 90, 0.13), transparent 28rem),
    radial-gradient(circle at 92% 82%, rgba(229, 171, 94, 0.15), transparent 25rem),
    var(--paper);
}

.background::before,
.background::after {
  content: "";
  position: absolute;
  width: 17rem;
  height: 17rem;
  border: 1px solid rgba(31, 122, 90, 0.12);
  border-radius: 50%;
}

.background::before { left: -8rem; bottom: 8%; }
.background::after { right: -7rem; top: 8%; }

.shell {
  width: min(100% - 28px, 920px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 max(36px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: clamp(28px, 7vw, 58px);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  color: #fff;
  border-radius: 16px;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(23, 33, 29, 0.18);
}

.brand-mark svg { width: 30px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.brand h1 { margin: 1px 0 0; font-size: 1.18rem; letter-spacing: -0.02em; }
.install-button { margin-left: auto; padding-inline: 15px; }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h2, h3 { letter-spacing: -0.035em; }
h2 { margin: 5px 0 9px; font-size: clamp(1.75rem, 6vw, 2.5rem); line-height: 1.04; }
h3 { margin: 0 0 6px; font-size: 1.1rem; }
.muted { color: var(--ink-soft); line-height: 1.55; }

.card {
  border: 1px solid rgba(206, 215, 209, 0.78);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(100%, 485px);
  margin: 0 auto;
  padding: clamp(26px, 6vw, 42px);
}

.card-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  color: var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 1.4rem;
}

.form-stack { display: grid; gap: 18px; margin-top: 25px; }
label { display: grid; gap: 7px; color: #384640; font-size: 0.88rem; font-weight: 700; }
label small { color: var(--ink-soft); font-weight: 500; }

input, textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid #cfd7d2;
  border-radius: 13px;
  outline: none;
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input { min-height: 52px; padding: 0 14px; }
textarea { resize: vertical; padding: 13px 14px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(31, 122, 90, 0.13); }

.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-field .icon-button { position: absolute; right: 6px; top: 6px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--ink-soft);
  border: 0;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
  font-size: 1.35rem;
}

.icon-button:hover { background: #eff3f0; color: var(--ink); }

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 9px 22px rgba(31, 122, 90, 0.22); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { color: var(--ink); border-color: var(--line); background: rgba(255,255,255,.78); }
.button-secondary:hover { background: #fff; }
.button-dark { color: #fff; background: var(--ink); }
.button-danger { color: #fff; background: var(--danger); }

.text-button {
  display: block;
  margin: 20px auto 0;
  padding: 6px;
  color: var(--accent-dark);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.form-error { min-height: 1.2em; margin: -4px 0; color: var(--danger); font-size: 0.86rem; font-weight: 650; }

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.toolbar h2 { margin-bottom: 0; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }

.security-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -6px 0 22px;
  padding: 17px 18px;
  color: #33280f;
  border: 1px solid #e1c77c;
  border-radius: 16px;
  background: #fff5d7;
  box-shadow: 0 10px 30px rgba(95, 71, 14, .08);
}

.security-notice p { margin: 4px 0 0; font-size: .88rem; line-height: 1.45; }
.security-notice .button { flex: 0 0 auto; }

.entries-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.entry-card {
  position: relative;
  min-width: 0;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 11px 32px rgba(36, 56, 47, 0.08);
}

.entry-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--accent);
}

.entry-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.entry-name { margin: 0; overflow-wrap: anywhere; font-size: 1rem; }
.entry-actions { display: flex; margin: -8px -8px 0 0; }
.pin-value { margin: 20px 0 8px; color: var(--ink); font: 750 clamp(1.65rem, 6vw, 2.1rem)/1 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; overflow-wrap: anywhere; }
.entry-note { margin: 12px 0 0; color: var(--ink-soft); font-size: .88rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-state { padding: 48px 24px; text-align: center; }
.empty-state .muted { max-width: 430px; margin: 8px auto 22px; }
.empty-illustration { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; color: var(--accent); border: 1px solid #b9d6c9; border-radius: 21px; background: var(--accent-soft); font-size: 2rem; }

.fab {
  position: fixed;
  z-index: 5;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  color: #fff;
  border: 0;
  border-radius: 19px;
  background: var(--accent);
  box-shadow: 0 14px 32px rgba(31, 122, 90, .35);
  cursor: pointer;
  font-size: 2rem;
}

.settings-card { margin-top: 22px; box-shadow: 0 10px 34px rgba(36,56,47,.06); }
.settings-card summary { padding: 20px 22px; cursor: pointer; font-weight: 800; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 0 22px 18px; }
.fine-print { margin: 0; padding: 0 22px 22px; color: var(--ink-soft); font-size: .8rem; }

.dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100dvh - 30px);
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 23px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(20, 30, 26, .28);
}

.dialog::backdrop { background: rgba(14, 23, 19, .52); backdrop-filter: blur(5px); }
.dialog-body { display: grid; gap: 17px; padding: clamp(22px, 5vw, 32px); }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; }
.dialog-header h2 { margin-top: 4px; font-size: 1.7rem; }
.dialog-hint { margin: -5px 0 0; font-size: .88rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.dialog-small { width: min(calc(100% - 24px), 420px); }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(25px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 36px);
  padding: 12px 17px;
  color: #fff;
  border-radius: 12px;
  background: var(--ink);
  box-shadow: 0 12px 35px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
  font-size: .88rem;
  font-weight: 700;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 660px) {
  .brand { margin-bottom: 28px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; justify-content: flex-start; }
  .toolbar-actions .button { flex: 1; padding-inline: 12px; }
  .security-notice { align-items: stretch; flex-direction: column; }
  .entries-grid { grid-template-columns: 1fr; }
  .entry-card { padding: 20px; }
  .settings-actions { flex-direction: column; }
  .settings-actions .button { width: 100%; }
  .install-button { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
