:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e8e8f0;
  background: #0f1117;
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #1a1d27;
  --surface: #11141d;
  --border: #2d3148;
  --accent: #6c63ff;
  --accent-soft: #6c63ff22;
  --success: #00d4aa;
  --warning: #ffb454;
  --danger: #ff4f70;
  --muted: #9ba0ba;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .58; }
button, article, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, article:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #8f89ff88;
  outline-offset: 2px;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.material-icon { width: 21px; height: 21px; fill: currentColor; pointer-events: none; }

main {
  width: min(100%, 660px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
}

header { display: flex; align-items: center; gap: 12px; padding: 10px 0 22px; }
.network-status { margin-left: auto; color: var(--success); font-size: 11px; font-weight: 700; }
.network-status.offline { color: var(--warning); }
.lock { color: var(--accent); font-size: 28px; }
h1 { margin: 0; font-size: 24px; }
h2, h3 { text-wrap: balance; }

.card, dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 18px 50px #0005;
}
.card h2 { margin-top: 0; }
.card p, dialog p { color: var(--muted); line-height: 1.5; }

label { display: block; margin: 14px 0; color: #b9bdd0; font-size: 13px; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 13px;
  border: 1px solid #343952;
  border-radius: 10px;
  background: var(--surface);
  color: #fff;
}
input::placeholder, textarea::placeholder { color: #737990; }
input:invalid:not(:placeholder-shown) { border-color: #b64a62; }
textarea { min-height: 88px; resize: vertical; }

button {
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
.card > button { width: 100%; }
.secondary { margin-top: 9px; background: #292d41; }
.compact { width: 100%; padding: 9px; }
.hidden { display: none !important; }

.status-message { min-height: 20px; margin-bottom: 0; color: var(--warning) !important; }
.status-message:empty { min-height: 0; margin: 0; }
.badge { display: inline-block; padding: 8px 11px; border-radius: 99px; background: #00d4aa22; color: var(--success); font-size: 13px; }

.vault { padding: 16px; }
.vault-head, .toolbar, .dialog-head, .actions { display: flex; align-items: center; gap: 8px; }
.vault-head { justify-content: space-between; align-items: flex-start; }
.vault-head h2 { margin: 0; }
.vault-head span { color: var(--success); font-size: 11px; }
.vault-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; }
.vault-actions button { width: auto; }
.icon-button { padding: 9px 11px; background: #292d41; }
#update-button { background: #725d24; }
.toolbar { margin: 16px 0; }
.toolbar input { margin: 0; min-width: 0; }
.toolbar button { flex: 0 0 auto; padding: 9px 15px; font-size: 22px; }

.conflicts { margin-bottom: 14px; padding: 14px; border: 1px solid #8b672d; border-radius: 12px; background: #2b2419; }
.conflicts h3 { margin: 0 0 4px; color: #ffd18a; font-size: 15px; }
.conflicts > p { margin: 0 0 10px; font-size: 12px; }
#conflict-list { display: grid; gap: 8px; }
.conflict-row { display: grid; gap: 9px; padding: 10px; border-radius: 9px; background: #191712; }
.conflict-row > div:first-child { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.conflict-row small { color: var(--muted); }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.compact-action { width: auto; margin: 0; padding: 8px 10px; }
.text-action { padding: 8px 10px; background: transparent; color: #d7d4ff; }

#vault-list { display: grid; gap: 8px; }
article { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
article:hover { border-color: #4a4f74; }
article > b { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: #342e83; color: #bcb7ff; }
article > span { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
article strong, article small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
article small { color: var(--muted); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

dialog { width: min(92vw, 480px); max-height: min(88vh, 760px); overflow: auto; color: #e8e8f0; }
dialog::backdrop { background: #05060bcc; backdrop-filter: blur(2px); }
.dialog-head { justify-content: space-between; }
.dialog-head h3 { margin: 0; }
.close { padding: 7px 10px; background: transparent; font-size: 22px; }
.field { display: flex; flex-direction: column; margin-top: 10px; padding: 12px; border-radius: 9px; background: var(--surface); }
.field small { margin-bottom: 5px; color: #8b8fa8; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 50px; }
.password-toggle, .field-eye { display: grid; position: absolute; right: 5px; bottom: 5px; place-items: center; width: 40px; height: 40px; padding: 0; background: transparent; color: var(--muted); }
.password-toggle:hover, .field-eye:hover { background: var(--accent-soft); color: #d6d3ff; }
.eye-slash { display: none; position: absolute; width: 24px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.password-toggle.showing .eye-slash, .field-eye.showing .eye-slash { display: block; }
.password-detail { position: relative; padding-right: 54px; }
.field-eye { right: 7px; bottom: 7px; }
.hold-copy { position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.hold-copy::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.hold-copy.pressing::after { transform: scaleX(1); transition: transform 550ms linear; }
.detail-actions { display: flex; align-items: center; gap: 4px; }
.mini-action { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: transparent; color: var(--muted); }
.mini-action:hover { background: var(--accent-soft); color: #d6d3ff; }
.mini-action.danger, .mini-action.danger:hover { background: transparent; color: var(--danger); }
.confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.actions { flex-wrap: wrap; }
.actions button { flex: 1; min-width: 120px; }
.danger { background: #b83451; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); width: min(90vw, 480px); padding: 11px 16px; transform: translateX(-50%); border-radius: 9px; background: var(--success); color: #07110e; font-weight: 700; text-align: center; box-shadow: 0 10px 30px #0007; }
.toast[data-kind="error"] { background: var(--danger); color: #fff; }
footer { width: min(100%, 660px); margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); text-align: center; }
.text-button { padding: 8px; background: transparent; color: #8b8fa8; font-weight: 500; }

@media (max-width: 560px) {
  main { padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left)); }
  .card { padding: 16px; }
  .vault-head { display: grid; gap: 12px; }
  .vault-actions { justify-content: flex-start; }
  .icon-button { padding: 9px; font-size: 12px; }
  .conflict-actions { display: grid; }
  .compact-action, .text-action { width: 100%; }
}

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