:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #5f6b7a; --border: #e1e5ea;
  --primary: #1a73e8; --primary-text: #fff; --danger: #d93025; --warn: #e37400; --ok: #188038;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --text: #e8eaed; --muted: #9aa4b2; --border: #2a313a; --primary: #8ab4f8; --primary-text: #0b1a33; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
main.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 12px; }
h1 { font-size: 1.6rem; margin: .2em 0; } h2 { font-size: 1.1rem; margin: 0 0 .4em; } h3 { font-size: .95rem; margin: 1em 0 .4em; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
p { margin: .4em 0; } a { color: var(--primary); word-break: break-all; }
code { font-family: var(--mono); font-size: .9em; background: var(--border); padding: 0 .3em; border-radius: 4px; }
.logo { font-size: 3.5rem; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .mono { font-family: var(--mono); font-size: .92em; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; font-size: 1.05rem; } .actions { display: flex; gap: 6px; align-items: center; }

button { font: inherit; cursor: pointer; }
.btn { border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 10px 16px; border-radius: 10px; }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); } .btn.big { padding: 14px 24px; font-size: 1.05rem; } .btn.small { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.icon { border: 0; background: transparent; color: var(--text); font-size: 1.15rem; padding: 6px 8px; border-radius: 8px; line-height: 1; }
.icon:active, .btn:active { filter: brightness(.92); }
.link { border: 0; background: none; color: var(--primary); padding: 4px; }
.chip { border: 1px solid var(--border); background: var(--card); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: .78rem; font-family: var(--mono); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-text); font-size: 2rem; line-height: 1; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 6; }

.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input[type=search] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin: 8px 0; flex: 1; }
label > input, label > select, label > textarea { color: var(--text); font-size: 1rem; }
label.check { flex: 0 0 auto; flex-direction: row; align-items: center; margin: 0; } label.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; } .row > * { flex: 1; } .row > .icon, .row > .btn, .row > .check { flex: 0 0 auto; }
.row.between { justify-content: space-between; } .row.gap { gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.item:last-child { border-bottom: 0; } .item:active { background: var(--bg); }
.ico { font-size: 1.5rem; width: 36px; text-align: center; flex: 0 0 auto; } .ico.big { font-size: 2rem; width: 44px; }
.body { flex: 1; min-width: 0; } .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .sub { color: var(--muted); font-size: .82rem; }
.chev { color: var(--muted); font-size: 1.4rem; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--border); color: var(--text); }
.badge.warn { background: var(--warn); color: #fff; } .badge.danger { background: var(--danger); color: #fff; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.meter { margin: 8px 0; } .bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.fill { height: 100%; background: var(--ok); } .fill.warn { background: var(--warn); }

.alert { padding: 10px 12px; border-radius: 10px; margin: 8px 0; display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.alert.danger { background: rgba(217,48,37,.1); color: var(--danger); border: 1px solid rgba(217,48,37,.3); }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .9rem; z-index: 30; max-width: 90vw; text-align: center; }
.busy { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.15); }
.spinner { width: 36px; height: 36px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); z-index: 20; box-shadow: 0 -8px 30px rgba(0,0,0,.25); max-width: 720px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; } .sheet-head > div:not(.ico) { flex: 1; } .sheet-head h2 { margin: 0; }
.fields { margin: 0; } .field { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.field dt { grid-column: 1; font-size: .78rem; color: var(--muted); } .field dd { grid-column: 1; margin: 0; overflow-wrap: anywhere; }
.field-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 2px; }
.field pre { margin: 0; white-space: pre-wrap; max-height: 200px; overflow: auto; }
.totp { font-size: 1.3rem; letter-spacing: .05em; }
.notes { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 10px; font: inherit; }
.kv { background: var(--bg); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.kv-key { font-family: var(--mono); }
.kv select { flex: 0 0 auto; max-width: 42%; }
