/* =====================================================================
   Baúl · estilos
   Diseño profesional, modo oscuro fijo, responsivo (PC + móviles).
   ===================================================================== */

:root {
  /* Paleta oscura (base). Negro más suave y contornos más visibles. */
  --bg: #161922;
  --bg-glow: rgba(108, 140, 255, 0.12);
  --surface: #1f2430;
  --surface-2: #272d3b;
  --surface-3: #313849;
  --border: #3a4256;
  --border-strong: #4c5670;
  --text: #eef1f7;
  --muted: #a6aec2;
  --topbar-bg: rgba(22, 25, 34, 0.80);
  --primary: #6c8cff;
  --primary-hover: #7f9bff;
  --primary-press: #5677f0;
  --on-primary: #0b1020;
  --danger: #ff6b6b;
  --ok: #46d17f;
  --warn: #ffcc4d;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  /* Escala de espaciado */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Insets de dispositivos con notch */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

/* ---------------------------------------------------------------------
   Tema CLARO (día).
   Lo activa data-theme="light" (JS según la hora). Si el JS no corre,
   se respeta la preferencia del sistema como respaldo.
   El tema OSCURO (noche) es el :root de arriba, y data-theme="dark" lo
   fuerza también como respaldo del media query.
   --------------------------------------------------------------------- */
:root[data-theme="light"] {
  --bg: #eef1f6;
  --bg-glow: rgba(79, 107, 240, 0.08);
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e7ebf3;
  --border: #dee2ec;
  --border-strong: #c6cdda;
  --text: #171a22;
  --muted: #5b6376;
  --primary: #4f6bf0;
  --primary-hover: #4560e6;
  --primary-press: #3a54d8;
  --on-primary: #ffffff;
  --danger: #d6453f;
  --ok: #1f9d57;
  --warn: #9a6a00;
  --topbar-bg: rgba(255, 255, 255, 0.88);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);

  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f6;
    --bg-glow: rgba(79, 107, 240, 0.08);
    --surface: #ffffff;
    --surface-2: #f2f4f9;
    --surface-3: #e7ebf3;
    --border: #dee2ec;
    --border-strong: #c6cdda;
    --text: #171a22;
    --muted: #5b6376;
    --primary: #4f6bf0;
    --primary-hover: #4560e6;
    --primary-press: #3a54d8;
    --on-primary: #ffffff;
    --danger: #d6453f;
    --ok: #1f9d57;
    --warn: #9a6a00;
    --topbar-bg: rgba(255, 255, 255, 0.88);

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 10px 30px rgba(16, 24, 40, 0.10);
    --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);

    color-scheme: light;
  }
}

* { box-sizing: border-box; }

/* El atributo hidden SIEMPRE oculta, aunque otra regla defina display. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 50% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(108, 140, 255, 0.35); }

.screen { min-height: 100dvh; }

/* Scrollbar sutil (WebKit) */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   Pantalla de acceso
   ===================================================================== */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--sp-5) + var(--safe-t))
    calc(var(--sp-4) + var(--safe-r))
    calc(var(--sp-5) + var(--safe-b))
    calc(var(--sp-4) + var(--safe-l));
}
.lock-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.logo {
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(108, 140, 255, 0.35));
}
.lock-card h1 {
  margin: 8px 0 2px;
  font-size: clamp(23px, 5.5vw, 28px);
  letter-spacing: -0.02em;
}
.subtitle { color: var(--muted); margin: 0 0 var(--sp-4); font-size: 14.5px; }

.card {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(22, 25, 34, 0.92) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 4vw, 26px);
  box-shadow: var(--shadow-lg);
}

/* Formulario de acceso más compacto */
#auth-form .field { margin-bottom: 12px; }
#auth-form .field > span { margin-bottom: 4px; }

/* =====================================================================
   Campos de formulario
   ===================================================================== */
.field { display: block; text-align: left; margin-bottom: var(--sp-4); }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px; /* >=16px evita el zoom automático en iOS */
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #6c7488; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.22);
}
input[type="search"] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; min-height: 76px; }

.pw-input { display: flex; gap: var(--sp-2); align-items: stretch; }
.pw-input input { flex: 1; min-width: 0; }

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-2) 0;
  font-size: 14px;
  color: var(--muted);
}
.checkbox input { width: auto; accent-color: var(--primary); }

/* =====================================================================
   Botones
   ===================================================================== */
button {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: 11px 15px;
  min-height: 44px; /* objetivo táctil cómodo */
  line-height: 1;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.primary {
  background: var(--primary);
  color: var(--on-primary);
  width: 100%;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(108, 140, 255, 0.28);
}
.primary:hover { background: var(--primary-hover); }
.primary:active { background: var(--primary-press); }
.primary:disabled { opacity: .55; cursor: default; box-shadow: none; }

.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  padding: 10px 12px;
}
.ghost:hover { border-color: var(--border-strong); background: var(--surface-3); }
.ghost.danger:hover { border-color: var(--danger); color: var(--danger); }

/* =====================================================================
   Medidor de fortaleza
   ===================================================================== */
.strength { margin: -2px 0 var(--sp-3); text-align: left; }
.strength-bar {
  height: 7px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}
.strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 6px;
  transition: width .25s ease;
  background: var(--danger);
}
.strength-bar span[data-score="2"] { background: var(--warn); }
.strength-bar span[data-score="3"] { background: #7ac943; }
.strength-bar span[data-score="4"] { background: var(--ok); }
.strength small { color: var(--muted); font-size: 12px; display: inline-block; margin-top: 5px; }

/* =====================================================================
   Mensajes
   ===================================================================== */
.error { color: var(--danger); font-size: 14px; margin: var(--sp-2) 0; }
.ok-msg { color: var(--ok); font-size: 14px; margin: var(--sp-2) 0; }

/* Enlaces de texto (cambiar entre iniciar sesión / crear cuenta) */
.switch-line { color: var(--muted); font-size: 14px; margin: var(--sp-4) 0 0; }
.link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  padding: 4px 4px;
  min-height: auto;
  font-size: 14px;
}
.link:hover { text-decoration: underline; }

/* Aviso de cifrado: chip translúcido oscuro con texto claro.
   Va sobre la parte oscura del degradado de la tarjeta, así se lee en ambos temas. */
.secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--sp-3) 0 0;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.35;
  color: #eaf2ee;
  text-align: center;
  background: rgba(10, 14, 20, 0.45);
  border: 1px solid rgba(70, 209, 127, 0.45);
  border-radius: var(--radius-sm);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.secure-note .lock { font-size: 14px; flex-shrink: 0; }

input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  color: var(--muted);
}

/* Banner momentáneo de instalar app (PWA) y aviso iOS.
   Aparecen fijos arriba, centrados, y la app los oculta a los 5s. */
.install-btn,
.ios-hint {
  position: fixed;
  top: calc(14px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100vw - 28px);
  box-shadow: var(--shadow-lg);
  animation: banner-in .28s ease;
}
.install-btn {
  width: auto;
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
  font-weight: 600;
  padding: 12px 22px;
}
.install-btn:hover { background: var(--primary-hover); }
.ios-hint {
  margin: 0;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  text-align: center;
  line-height: 1.45;
}
@keyframes banner-in {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.warn {
  color: var(--warn);
  font-size: 13px;
  background: rgba(255, 204, 77, 0.10);
  border: 1px solid rgba(255, 204, 77, 0.28);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-top: var(--sp-4);
  text-align: left;
  line-height: 1.45;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 var(--sp-3); line-height: 1.45; }
.hint.small { font-size: 12px; }

/* =====================================================================
   App principal · barra superior
   ===================================================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding:
    calc(var(--sp-3) + var(--safe-t))
    calc(var(--sp-4) + var(--safe-r))
    var(--sp-3)
    calc(var(--sp-4) + var(--safe-l));
  background: rgba(22, 25, 34, 0.80);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: #ffffff; /* siempre blanco sobre la barra oscura */
}
.toolbar {
  display: flex;
  gap: var(--sp-2);
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar #search {
  width: 200px;
  padding: 9px 12px;
  min-height: 40px;
}
.toolbar .ghost, .toolbar .primary { min-height: 40px; }
.toolbar .primary { width: auto; padding: 9px 14px; }
#search-btn { display: none; } /* solo aparece en móvil */

/* Estado de sincronización */
.sync-status {
  padding: 9px calc(var(--sp-4) + var(--safe-r)) 9px calc(var(--sp-4) + var(--safe-l));
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.sync-status.ok { color: var(--ok); }
.sync-status.err { color: var(--danger); }

/* =====================================================================
   Lista de entradas
   ===================================================================== */
.entries {
  max-width: 760px;
  margin: 0 auto;
  padding:
    var(--sp-4)
    calc(var(--sp-4) + var(--safe-r))
    calc(var(--sp-6) + var(--safe-b))
    calc(var(--sp-4) + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: var(--sp-2); /* grupos más juntos (sobre todo plegados) */
}

/* Grupos por categoría: un solo panel redondeado con filas separadas */
.group { }
.group-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 10px 0;
}
/* Plegado: el encabezado no deja hueco debajo → más juntos */
.group.collapsed .group-head { margin-bottom: 0; }
/* Agarre para mover la categoría entera */
.cat-grip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  cursor: grab;
  touch-action: none;
  color: var(--muted);
  padding: 6px 2px;
  -webkit-user-select: none;
  user-select: none;
}
.cat-grip svg { display: block; fill: currentColor; opacity: 0.45; }
.cat-grip:hover svg { opacity: 0.9; }
.cat-grip:active { cursor: grabbing; }
.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 6px 4px;
  min-height: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.group-title:hover { color: var(--text); }
.group-chevron {
  margin-left: auto;               /* a la derecha */
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  transition: transform .18s ease;
  display: inline-block;
}
/* Abierto: la flecha apunta hacia abajo. Cerrado (colapsado): a la derecha. */
.group:not(.collapsed) .group-chevron { transform: rotate(90deg); }
.group-name { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}
.group-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 8px;
}

/* Fila (dentro del panel del grupo) */
.entry {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 11px 14px;
  transition: background .12s;
}
.entry + .entry { border-top: 1px solid var(--border); }
.entry:hover { background: var(--surface-2); }

/* Número (discreto) */
.entry-num {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* Agarre de 6 puntos para arrastrar (discreto) */
.entry-grip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  color: var(--muted);
  padding: 6px 0;
  margin: 0 -2px 0 -4px;
  user-select: none;
  -webkit-user-select: none;
}
.entry-grip svg { display: block; fill: currentColor; opacity: 0.4; }
.entry-grip:hover svg { opacity: 0.9; }
.entry-grip:active { cursor: grabbing; }

/* Avatar en cuadro redondeado con la inicial (color pastel) */
.entry-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
}

/* Estados de arrastre (SortableJS) */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { background: var(--surface-2); }
.sortable-drag { opacity: 0.95; }

/* Zona central: se abre al tocarla */
.entry-open {
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  min-height: auto;
}
.entry-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  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-url {
  display: block;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Acciones a la derecha: llave (copiar) + chevron */
.entry-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.entry-key {
  min-height: 40px;
  min-width: 40px;
  padding: 8px 10px;
  font-size: 16px;
  background: var(--surface-2);
  border-color: var(--border);
}
.entry-chevron {
  min-height: 40px;
  min-width: 32px;
  padding: 8px 6px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
}
.entry-chevron:hover { color: var(--primary); background: none; }

/* Acciones dentro del detalle (copiar usuario / contraseña) */
.detail-actions {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.detail-actions .ghost { flex: 1 1 auto; }

/* Vista previa de importación */
.import-preview {
  margin: var(--sp-3) 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.imp-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
}
.imp-row .imp-num { width: 20px; text-align: center; font-weight: 700; color: var(--muted); font-size: 13px; }
.imp-row .imp-main { flex: 1 1 auto; min-width: 0; }
.imp-row .imp-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-row .imp-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-row .imp-del { min-height: 34px; min-width: 34px; padding: 6px 8px; font-size: 14px; }

.empty {
  text-align: center;
  color: var(--muted);
  margin-top: clamp(48px, 12vh, 90px);
  padding: 0 var(--sp-4);
}

/* =====================================================================
   Diálogos (modales)
   ===================================================================== */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: clamp(20px, 4vw, 26px);
  width: min(480px, 100%);
  max-height: 92dvh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: rgba(3, 5, 10, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
dialog h2 { margin: 0 0 var(--sp-4); font-size: 19px; letter-spacing: -0.01em; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
}
legend { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 6px; }
.dialog-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  margin: var(--sp-2) 0 0;
  padding: 0;
}
.dialog-actions button { width: auto; min-width: 96px; }
.row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.row .ghost { flex: 1 1 auto; }

/* Diálogo de entrada más compacto (letra algo más grande, menos espacio) */
#entry-dialog { padding: 18px 18px calc(16px + var(--safe-b)); }
#entry-dialog h2 { margin-bottom: 12px; font-size: 19px; }
#entry-dialog .field { margin-bottom: 9px; }
#entry-dialog .field > span { font-size: 13.5px; margin-bottom: 3px; }
#entry-dialog input,
#entry-dialog select,
#entry-dialog textarea {
  padding: 9px 11px;
  font-size: 16px;   /* legible y sin zoom automático en iOS */
}
#entry-dialog textarea { min-height: 46px; }
#entry-dialog .detail-actions { margin-bottom: 10px; gap: 8px; }
#entry-dialog .detail-actions .ghost { min-height: 38px; padding: 8px 10px; font-size: 13.5px; }
#entry-dialog .pw-input .ghost { min-height: 42px; }
/* Barra de acciones: Eliminar pequeño abajo-izquierda; Guardar/Cancelar a la derecha */
#entry-dialog .dialog-actions.entry-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}
#entry-dialog .actions-right { display: flex; gap: 10px; }
#entry-dialog .actions-right button { min-height: 40px; width: auto; }
#entry-dialog .btn-delete-sm {
  flex: 0 0 auto;
  width: auto;
  min-width: 40px;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 15px;
  opacity: 0.85;
}

/* =====================================================================
   Toast
   ===================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-b));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 14px;
  text-align: center;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* =====================================================================
   Responsivo
   ===================================================================== */

/* Móvil: el buscador se colapsa a una lupa; se expande al tocarla */
@media (max-width: 620px) {
  .topbar { gap: var(--sp-2); }
  .toolbar { width: 100%; margin-left: 0; }
  .toolbar #search { display: none; }                 /* colapsado por defecto */
  #search-btn { display: inline-flex; align-items: center; justify-content: center; }
  .toolbar.searching #search {
    display: block;
    flex: 1 1 100%;
    width: 100%;
    order: -1;                                         /* ocupa su propia fila arriba */
  }
  .toolbar.searching #search-btn { display: none; }   /* al abrir, se oculta la lupa */

  /* Chevron más grandes en celular (categorías y cápsulas) */
  .group-chevron { font-size: 30px; }
  .entry-chevron { font-size: 30px; min-width: 40px; padding: 8px 8px; }
}

/* Móviles (≈ hasta 430px de ancho) */
@media (max-width: 430px) {
  body { font-size: 15px; }
  .brand { font-size: 21px; }
  .entries { gap: var(--sp-2); }
  .entry { padding: 12px 13px; gap: var(--sp-2); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}

/* Móviles pequeños (≈ 360px o menos: iPhone SE, Android compactos) */
@media (max-width: 360px) {
  .toolbar { gap: 6px; }
  .toolbar .primary { flex: 1 1 auto; width: auto; }
  .entry { flex-wrap: wrap; }
  .entry-actions { width: 100%; justify-content: flex-end; }
  .entry-actions .ghost { flex: 1 1 auto; }
  .lock-card h1 { font-size: 24px; }
}

/* Pantallas grandes: un poco más de aire en la lista */
@media (min-width: 1024px) {
  .entries { padding-top: var(--sp-5); }
}

/* Respeta a quien prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
