:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1c211e;
  --muted: #6b736e;
  --line: #e3e6e3;
  --accent: #3f8f5b;
  --accent-soft: #e6f2ea;
  --danger: #c2453d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --card: #1a1e1b;
    --text: #e6eae7;
    --muted: #8b948e;
    --line: #2a302c;
    --accent: #5bb27a;
    --accent-soft: #1f3327;
    --danger: #e0645b;
    --shadow: none;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: progress; }

.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; margin: 0; font-size: 14px; }

/* Lock screen */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.lock-card {
  width: 100%; max-width: 360px;
  display: grid; gap: 12px;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-logo { width: 48px; height: 48px; margin: 0 auto; }
.lock-card h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.lock-card p.muted { margin: 0 0 8px; font-size: 14px; }
.google-btn { display: flex; justify-content: center; min-height: 44px; }

.account { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Vault */
.vault { max-width: 720px; margin: 0 auto; padding: 24px 20px 64px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }
.brand img { width: 28px; height: 28px; }

.controls { display: flex; gap: 10px; }

.add-form {
  display: grid; gap: 10px;
  margin-top: 12px; padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pw-field { position: relative; }
.pw-field input { padding-right: 124px; }
.pw-tools { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 14px; }
.chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit; font-size: 13px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list:empty { display: none; }

.row {
  /* Site and tag on the first line; username, password and actions share the line below. */
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.site { min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meta { display: flex; align-items: center; gap: 16px; min-width: 0; }
.tag { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; line-height: 1.6; }

.field { display: flex; align-items: center; gap: 2px; min-width: 0; }
/* Username and password split the line equally, so both columns line up across rows. */
.field.user, .field.pass { flex: 1 1 0; }

.name, .secret {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 14px; cursor: pointer;
}
.name:hover, .secret:hover { color: var(--text); }
.secret { flex: 0 1 auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.icon-btn {
  flex: none;
  display: grid; place-items: center;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 6px;
  background: none; color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Wide enough for Edit plus "Confirm", so arming Del doesn't shift the columns. */
.actions { flex: none; display: flex; justify-content: flex-end; gap: 2px; min-width: 7.5rem; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn.confirm, .btn.confirm:hover { background: var(--danger); color: #fff; }

.empty { text-align: center; padding: 48px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text); color: var(--bg);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

@media (max-width: 560px) {
  .meta { flex-wrap: wrap; row-gap: 2px; }
  .field.user { flex-basis: 100%; }
}
