:root {
  --bg: #0b1120;
  --panel: #131c30;
  --panel-2: #1b2740;
  --line: #26334d;
  --text: #e7edf8;
  --muted: #93a2bd;
  --accent: #4f9cf9;
  --ok: #3ddc97;
  --warn: #f5b544;
  --danger: #ff6b6b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; min-height: 100dvh; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #16233c 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 760px; margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  overflow-x: hidden;
}
.boot { color: var(--muted); text-align: center; padding-top: 40dvh; }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p.sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #101a2c 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); color: #04101f; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
button.danger { background: transparent; border: 1px solid #5b2a2a; color: var(--danger); }
button.wide { width: 100%; }
button:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.items { display: grid; gap: 10px; }
.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: grid;
  gap: 8px;
}
.item .name { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12px; white-space: normal; overflow-wrap: break-word; }
.item .meta .email { word-break: break-all; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.item .actions button { padding: 7px 10px; font-size: 12px; }
.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.totp { font-size: 22px; letter-spacing: 0.12em; font-family: ui-monospace, monospace; color: var(--ok); }
.totp-bar { height: 3px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.totp-bar > i { display: block; height: 100%; background: var(--ok); width: 100%; transition: width 1s linear; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 8px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.notice {
  border: 1px solid #3a3320;
  background: #221d10;
  color: #f0d798;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.recovery-key {
  font-family: ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  word-break: break-all;
  margin: 10px 0;
}
.modal {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: rgba(3, 7, 15, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  z-index: 50;
}
.modal .sheet {
  width: 100%;
  max-width: 760px;
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--panel);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid var(--line);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal .sheet form > button.primary.wide {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  /* não trocar o fundo do .primary: texto escuro sobre fundo escuro ficaria ilegível */
  box-shadow: 0 -12px 16px -12px rgba(0, 0, 0, 0.9);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #0e2a22;
  border: 1px solid #1f5c47;
  color: #b7f3d9;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 99;
  /* crítico: o aviso não pode capturar toque — ele flutua sobre os botões do rodapé */
  pointer-events: none;
  max-width: min(92vw, 520px);
  text-align: center;
}
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #04101f;
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(79, 156, 249, 0.38);
  z-index: 40;
}
.empty { text-align: center; color: var(--muted); padding: 34px 12px; }
.pill { background: var(--panel-2); border-radius: 999px; padding: 3px 9px; font-size: 11px; color: var(--muted); }
@media (min-width: 620px) { .app { padding-top: 34px; } }

body:has(.fab) .app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

@media (max-height: 720px) {
  .app { padding-top: 10px; }
  .cover { height: 200mm; }
  .card { padding: 13px; margin-bottom: 10px; }
  h1 { font-size: 18px; }
}

/* contenção de largura: sem isto, textos longos (URL/usuário) empurram os cards
   para fora da tela — o conteúdo ficava mais largo que o display e era cortado */
.app, .items, .item, .item .row, .item .actions, .topbar { min-width: 0; }
.item > *, .item .row > *, .topbar > div { min-width: 0; }
.item .meta, .topbar .sub { max-width: 100%; }
.topbar h1 { white-space: normal; overflow-wrap: anywhere; }
.topbar .sub { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.item .actions button { white-space: nowrap; }
input, textarea, select { min-width: 0; max-width: 100%; }

/* cabeçalho: em tela estreita os botões (convite/ajustes/trancar) descem de linha
   em vez de esticar a página além da largura do display */
.topbar { flex-wrap: wrap; row-gap: 8px; }
.topbar > div:first-child { flex: 1 1 160px; min-width: 0; }
.topbar > .row { flex: 0 0 auto; }

/* abas Meus itens / Compartilhados */
.tabs { display: flex; gap: 8px; margin: 12px 0 10px; }
.tabs button {
  flex: 1 1 0; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 12.5px; padding: 9px 8px; border-radius: 10px; white-space: normal;
  line-height: 1.15; overflow-wrap: break-word;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #04101f; font-weight: 600; }

/* conteúdo de nota dentro do card */
.notes { margin-top: 2px; }
.notes summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.notes-body {
  margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 12px; color: var(--text);
  white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto;
}

/* ---------- layout dos cards (v3.4) ---------- */
.item { gap: 7px; padding: 14px 14px 12px; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.item-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.item-title .name { font-size: 15px; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; }
.item .tag { flex: 0 0 auto; }
.tag-share { color: #9fc4f5; border-color: #2c4a72; background: #131f33; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* etiqueta do tipo do item — cor própria por tipo */
.tag-login { color: #8fc0ff; border-color: #2b4d78; background: #12233a; }
.tag-note { color: #f0cf8a; border-color: #574526; background: #241d10; }
.tag-card { color: #c9aaff; border-color: #453468; background: #1d1730; }
.tag-ident { color: #ffb3c7; border-color: #5e3247; background: #2a1620; }
.tag-2fa { color: #8ee6a1; border-color: #2a5433; background: #102415; }
.tag-invite { color: #ffc48a; border-color: #5b3f22; background: #261a0e; }
.item .meta { margin-top: 1px; }
.totp-row { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.totp-row .totp { font-size: 20px; letter-spacing: .10em; }
.totp-row .totp-bar { flex: 1 1 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-main { margin-top: 4px; }
.actions-sub { margin-top: 2px; }
.chip {
  padding: 8px 12px; font-size: 12.5px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap;
}
.chip.ghost { background: transparent; color: var(--muted); }
.chip.danger { color: var(--danger); border-color: #5b2a2a; }
.actions-sub .pill { margin-left: auto; }

/* ---------- tela de entrada ---------- */
.login-wrap { min-height: calc(100dvh - 46px); display: grid; align-content: center; }
.login-brand { text-align: center; padding: 22px 10px 24px; }
.brand-mark {
  width: 54px; height: 54px; margin: 0 auto 12px;
  display: grid; place-items: center; color: #cfe3ff;
  border-radius: 16px; border: 1px solid #2b3f5f;
  background: linear-gradient(160deg, #1d2f4d 0%, #15233a 100%);
  box-shadow: 0 10px 24px -12px rgba(79, 156, 249, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.login-brand h1 { font-size: 27px; margin: 0 0 6px; letter-spacing: -0.02em; }
.login-brand p.sub { margin: 0 auto; max-width: 310px; line-height: 1.45; text-wrap: balance; }

.login-card { padding: 18px; }
.login-card form > label:first-child { margin-top: 0; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 6px; }
.label-row label { margin: 0; }
a.link-inline {
  color: var(--accent); font-size: 12.5px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-height: 44px; padding: 0 1px;
}
input::placeholder { color: var(--muted); opacity: 1; }
.link-inline:hover { text-decoration: underline; }

button.btn-lg {
  height: 48px; padding: 0 16px; font-size: 15px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.login-card form button.primary { margin-top: 10px; }
.login-card .error:empty { min-height: 0; margin-top: 6px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.btn-google { color: #cfdcee; border-color: #22314a; }
.btn-google .gicon { flex: 0 0 auto; }

/* "Ainda não tem conta? Criar conta" — ação terciária, sem peso de botão */
.signup-row { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.signup-row a.link-inline { font-size: 13px; font-weight: 600; min-height: 44px; padding: 0 2px; }

.login-foot { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 18px 14px 0; text-align: center; text-wrap: balance; }
.login-foot b { color: #cdd9ea; font-weight: 600; white-space: nowrap; }
.login-hint { color: var(--muted); font-size: 11.5px; text-align: center; margin: 8px 0 0; }
