/* ManPazz — a calm, dark, mobile-first password manager UI.
   No framework, no web fonts (system stack keeps it instant and offline). */

:root {
  --bg: #0e1116;
  --bg-2: #161b22;
  --bg-3: #1c232d;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #4c8dff;
  --accent-ink: #ffffff;
  --danger: #ff5c67;
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen[hidden] { display: none; }

/* ---------- Lock / onboarding ---------- */
#lock-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 18px;
}
.lock-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
.lead { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }
.lock-form { display: flex; flex-direction: column; gap: 14px; }
.lock-foot { color: var(--muted); font-size: 12px; text-align: center; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], input[type="file"], textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 16px; /* >=16px stops iOS zoom-on-focus */
  min-height: var(--tap);
}
textarea { min-height: 72px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.meter { height: 6px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.meter-label { font-size: 12px; color: var(--muted); margin-top: -6px; min-height: 14px; }

.or { text-align: center; color: var(--muted); font-size: 12px; }
.filepick span { display: block; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); }
.btn.link { background: none; border: none; color: var(--accent); padding: 6px 0; min-height: auto; font-weight: 500; text-align: left; }
.icon-btn {
  appearance: none; border: none; background: transparent; color: var(--text);
  width: var(--tap); height: var(--tap); border-radius: 10px; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-3); }
.mini-btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-3); color: var(--muted);
  border-radius: 8px; padding: 0 10px; height: 40px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.error[hidden] { display: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-brand strong { letter-spacing: -0.02em; }
.topbar-brand strong { display: none; }
@media (min-width: 560px) { .topbar-brand strong { display: inline; } }
.search-wrap { flex: 1; }
#search { min-height: 40px; padding: 8px 12px; }
.topbar-actions { display: flex; gap: 2px; }

/* ---------- Entry list ---------- */
.entry-list { max-width: 720px; margin: 0 auto; padding: 8px 12px 96px; }
.entry {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid transparent;
}
.entry:hover { background: var(--bg-2); border-color: var(--line); }
.entry .avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 16px;
}
.entry .meta { min-width: 0; flex: 1; }
.entry .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .star { color: var(--warn); font-size: 14px; }
.entry .quick { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.entry:hover .quick, .entry:focus-within .quick { opacity: 1; }
@media (hover: none) { .entry .quick { opacity: 1; } }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty[hidden] { display: none; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: none;
  font-size: 28px; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}
.fab:hover { filter: brightness(1.08); }

/* ---------- Dialogs ---------- */
.dialog {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.dialog > form, .dialog { }
.dialog form, .dialog > .dialog-head, .dialog > section, .dialog > .gen-output, .dialog > .gen-controls, .dialog > .dialog-actions { padding: 0 20px; }
.dialog form { padding: 0; }
.dialog form > * { margin: 0 20px; }
.dialog form > .dialog-head, .dialog form > .dialog-actions { margin: 0; padding: 0 20px; }
.dialog form label, .dialog form .checkline { margin-bottom: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-actions { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); margin-top: 16px; }
.dialog-actions .spacer, .spacer { flex: 1; }
.field-row { display: flex; gap: 6px; align-items: stretch; }
.field-row input { flex: 1; }
.checkline { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.checkline input { width: 20px; height: 20px; min-height: 20px; accent-color: var(--accent); }

/* ---------- Generator ---------- */
.gen-output { padding: 18px 20px; }
.gen-value {
  display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px; word-break: break-all; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-height: 56px;
}
.gen-entropy { font-size: 12px; color: var(--muted); margin-top: 8px; }
.gen-controls { padding: 0 20px 8px; display: flex; flex-direction: column; gap: 14px; }
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 3px; align-self: flex-start; }
.seg-btn { appearance: none; border: none; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.rangeline { flex-direction: row; align-items: center; gap: 12px; color: var(--text); font-size: 14px; }
.rangeline input[type="range"] { flex: 1; accent-color: var(--accent); }
.rangeline output { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; }

/* ---------- Settings ---------- */
.settings-section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: none; }
.settings-section h3 { margin: 0 0 8px; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.filepick.inline { display: inline-flex; }
.filepick.inline span { margin: 0; }
.danger-zone h3 { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); font-size: 14px; z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
