/* =========================================================
   Mi Tinta — paleta ciruela, malva y crema + liquid glass
   ========================================================= */

@font-face { font-family: "Archivo"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/archivo-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/archivo-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/archivo-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 900; font-style: normal; font-display: swap; src: url("../fonts/archivo-latin-900-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/instrument-serif-latin-400-italic.woff2") format("woff2"); }

:root {
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  /* Paleta (tema oscuro, el principal) */
  --bg: #190019;              /* ciruela casi negro */
  --ink: #FBE4D8;             /* texto claro */
  --moss: #DFB6B2;            /* rosa empolvado (texto secundario) */
  --lime: #DFB6B2;            /* acento */
  --lime-2: #854F6C;          /* malva */
  --deep: #190019;            /* ciruela casi negro */
  --royal: #2B124C;           /* índigo */
  --glass-bg: rgba(43, 18, 76, 0.42);
  --glass-fuerte: rgba(25, 0, 25, 0.8);
  --cabecera-cal: #190019;
  --glass-line: rgba(223, 182, 178, 0.2);
  --campo-bg: rgba(25, 0, 25, 0.5);
  --campo-borde: rgba(223, 182, 178, 0.18);
  --label: #DFB6B2;
  --label-up-bg: #2B124C;
  --linea: rgba(223, 182, 178, 0.08);
  --hover: rgba(223, 182, 178, 0.06);
  --hoy-col: rgba(133, 79, 108, 0.06);
  --hora-actual: rgba(223, 182, 178, 0.12);
  --peligro: #DFB6B2;
  --sombra: 0 12px 40px rgba(25, 0, 25, 0.35);
  --aurora-1: rgba(82, 43, 91, 0.55);
  --aurora-2: rgba(133, 79, 108, 0.32);
  --aurora-3: rgba(43, 18, 76, 0.9);
  --especular: rgba(251, 228, 216, 0.14);
  --acento: linear-gradient(135deg, #FBE4D8, #DFB6B2);   /* botones, día de hoy, elementos activos */
  --acento-texto: #190019;

  --radius: 22px;
  --hh: 48px;                 /* alto de una hora en la vista semanal */
  --ancho-horas: 54px;
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --rebote: cubic-bezier(0.34, 1.56, 0.64, 1);

  color-scheme: dark;
}

/* Tema claro (solo si el usuario lo elige en Ajustes o el sistema está en claro con "automático") */
@media (prefers-color-scheme: light) {
  :root:not([data-tema="oscuro"]) {
    --bg: #FBE4D8; --ink: #190019; --moss: #522B5B; --lime: #522B5B; --lime-2: #854F6C;
    --glass-bg: rgba(251, 228, 216, 0.5); --glass-fuerte: rgba(251, 228, 216, 0.85); --cabecera-cal: #FBE4D8; --glass-line: rgba(82, 43, 91, 0.16);
    --campo-bg: rgba(251, 228, 216, 0.65); --campo-borde: rgba(82, 43, 91, 0.18); --label: #854F6C; --label-up-bg: #FBE4D8;
    --linea: rgba(82, 43, 91, 0.09); --hover: rgba(82, 43, 91, 0.05); --hoy-col: rgba(133, 79, 108, 0.05); --hora-actual: rgba(133, 79, 108, 0.1);
    --peligro: #854F6C; --sombra: 0 12px 40px rgba(25, 0, 25, 0.14);
    --aurora-1: rgba(133, 79, 108, 0.45); --aurora-2: rgba(223, 182, 178, 0.6); --aurora-3: rgba(251, 228, 216, 0.9);
    --especular: rgba(251, 228, 216, 0.5);
    --acento: linear-gradient(135deg, #854F6C, #522B5B); --acento-texto: #FBE4D8;
    color-scheme: light;
  }
}
:root[data-tema="claro"] {
  --bg: #FBE4D8; --ink: #190019; --moss: #522B5B; --lime: #522B5B; --lime-2: #854F6C;
  --glass-bg: rgba(251, 228, 216, 0.5); --glass-fuerte: rgba(251, 228, 216, 0.85); --cabecera-cal: #FBE4D8; --glass-line: rgba(82, 43, 91, 0.16);
  --campo-bg: rgba(251, 228, 216, 0.65); --campo-borde: rgba(82, 43, 91, 0.18); --label: #854F6C; --label-up-bg: #FBE4D8;
  --linea: rgba(82, 43, 91, 0.09); --hover: rgba(82, 43, 91, 0.05); --hoy-col: rgba(133, 79, 108, 0.05); --hora-actual: rgba(133, 79, 108, 0.1);
  --peligro: #854F6C; --sombra: 0 12px 40px rgba(25, 0, 25, 0.14);
  --aurora-1: rgba(133, 79, 108, 0.45); --aurora-2: rgba(223, 182, 178, 0.6); --aurora-3: rgba(251, 228, 216, 0.9);
  --especular: rgba(251, 228, 216, 0.5);
  --acento: linear-gradient(135deg, #854F6C, #522B5B); --acento-texto: #FBE4D8;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
/* Fondo "aurora": manchas de azul que se mueven lento detrás del vidrio */
body::before {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 34% at 22% 28%, var(--aurora-1), transparent 70%),
    radial-gradient(32% 30% at 78% 18%, var(--aurora-2), transparent 70%),
    radial-gradient(44% 40% at 62% 82%, var(--aurora-3), transparent 72%),
    radial-gradient(28% 26% at 12% 86%, var(--aurora-2), transparent 70%);
  animation: deriva 28s ease-in-out infinite alternate;
}
@keyframes deriva {
  0% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(4%, -3%, 0) rotate(6deg) scale(1.06); }
  100% { transform: translate3d(-3%, 4%, 0) rotate(-4deg) scale(1.02); }
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -0.02em; line-height: 1; }
p { margin: 0 0 8px; }
a { color: var(--lime); }
[hidden] { display: none !important; }
.ch { display: inline-block; white-space: pre; }

.tenue { color: var(--moss); font-size: 13px; }
.espaciador { flex: 1; }
.noscript { padding: 24px; text-align: center; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* ---------- LIQUID GLASS (efecto base reutilizable) ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  position: relative;
  box-shadow: var(--sombra), inset 0 1px 0 rgba(251, 228, 216, 0.12);
}
/* brillo especular superior, como el vidrio del iPhone */
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, var(--especular) 0%, transparent 32%, transparent 70%, rgba(223, 182, 178, 0.08) 100%);
}
.glass > * { position: relative; }

/* ---------- Detalles tipográficos ---------- */
.kicker {
  text-transform: uppercase; letter-spacing: 0.35em; font-size: 0.72rem;
  color: var(--lime); font-weight: 600; margin: 0;
}
.badge {
  display: inline-block;
  background: var(--lime); color: var(--acento-texto);
  font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0;
  padding: 0.05em 0.4em 0.12em; border-radius: 10px;
  transform: rotate(-4deg);
  box-shadow: 0 8px 30px rgba(223, 182, 178, 0.35);
}
.badge-chico { font-size: 1.15em; padding: 0 0.35em; border-radius: 8px; }
:root[data-tema="claro"] .badge { color: #FBE4D8; }
:root[data-tema="claro"] .vista-chat .badge { color: #190019; }

/* ---------- BOTONES ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 1.5rem;
  border: none; border-radius: 999px;
  font-family: var(--font); font-weight: 800; font-size: 0.92rem; letter-spacing: 0.02em;
  color: var(--ink); background: transparent; cursor: pointer; text-decoration: none;
  transition: transform 0.35s var(--rebote), box-shadow 0.3s, background-color 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: default; transform: none !important; }
.btn-primario {
  background: var(--acento);
  color: var(--acento-texto);
  box-shadow: 0 0 30px rgba(223, 182, 178, 0.35);
}
.btn-primario:hover { transform: scale(1.06) rotate(-1deg); box-shadow: 0 0 50px rgba(223, 182, 178, 0.55); }
.btn-fantasma { background: rgba(223, 182, 178, 0.07); border: 1px solid var(--glass-line); }
.btn-fantasma:hover { transform: scale(1.05); background: rgba(223, 182, 178, 0.12); }
.btn-peligro { background: linear-gradient(135deg, #DFB6B2, #854F6C); color: #190019; box-shadow: 0 0 26px rgba(133, 79, 108, 0.3); }
.btn-peligro:hover { transform: scale(1.06) rotate(-1deg); }
.btn-peligro-texto { color: var(--peligro); }
.btn-chico { min-height: 36px; padding: 0 1rem; font-size: 0.82rem; }
.btn-ancho { width: 100%; }
.btn-icono {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer;
  transition: transform 0.35s var(--rebote), background-color 0.2s, border-color 0.2s;
}
.btn-icono:hover { background: rgba(223, 182, 178, 0.1); border-color: var(--glass-line); transform: scale(1.08); }

/* ---------- FORMULARIOS (etiqueta flotante) ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.frm { position: relative; text-align: left; }
.frm input, .frm select, .frm textarea {
  width: 100%; min-height: 54px; padding: 1rem 1.1rem;
  background: var(--campo-bg);
  border: 1px solid var(--campo-borde);
  border-radius: 14px; color: var(--ink);
  font-family: var(--font); font-size: 16px; /* 16px evita el zoom automático en iOS */
  outline: none; transition: border-color 0.25s, box-shadow 0.25s;
  -webkit-appearance: none; appearance: none;
}
.frm textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.frm input:focus, .frm select:focus, .frm textarea:focus {
  border-color: var(--lime); box-shadow: 0 0 0 3px rgba(223, 182, 178, 0.15);
}
.frm label {
  position: absolute; left: 1.05rem; top: 1.05rem; font-size: 0.9rem; color: var(--label);
  pointer-events: none; transition: 0.2s; white-space: nowrap;
}
/* la etiqueta flota al enfocar o escribir */
.frm input:focus + label, .frm input:not(:placeholder-shown) + label,
.frm textarea:focus + label, .frm textarea:not(:placeholder-shown) + label,
.frm label.up {
  top: -0.55rem; left: 0.9rem; font-size: 0.68rem; color: var(--lime);
  background: var(--label-up-bg); padding: 0 0.4rem; border-radius: 6px;
}
.frm select {
  padding-right: 2.6rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--label) 50%), linear-gradient(135deg, var(--label) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.frm select option { background: var(--label-up-bg); color: var(--ink); }
.frm input[type="date"], .frm input[type="time"] { min-width: 0; }
.frm input[type="number"] { -moz-appearance: textfield; }
.frm input[type="number"]::-webkit-inner-spin-button, .frm input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.frm input::-webkit-date-and-time-value { text-align: left; }
.frm input::-webkit-calendar-picker-indicator { opacity: 0.7; cursor: pointer; }
:root:not([data-tema="claro"]) .frm input::-webkit-calendar-picker-indicator { filter: invert(0.85); }

.frm-fila { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(150px, 1fr); gap: 1rem; }
/* La hora en formato 12 h ("08:00 p. m.") necesita espacio: menos relleno lateral */
.frm-hora input { padding-inline: 0.8rem; }
.frm-estatico { display: flex; flex-direction: column; gap: 8px; }
.frm-titulo { font-size: 0.68rem; color: var(--lime); text-transform: uppercase; letter-spacing: 0.18em; font-weight: 600; }
.con-muestra { display: flex; align-items: center; gap: 12px; }
.crece { flex: 1; min-width: 0; }
.muestra-color { width: 18px; height: 18px; border-radius: 50%; background: var(--c, #854F6C); flex: none; box-shadow: 0 0 14px var(--c, transparent); }
.form-error { color: var(--peligro); font-size: 0.88rem; margin: 0; font-weight: 600; }
.form-error:empty { display: none; }
.ayuda { font-size: 0.8rem; color: var(--moss); margin: -0.4rem 0 0; }
.form-linea { flex-direction: row; align-items: center; }

/* Interruptor (checkbox con estilo) */
.check { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.92rem; color: var(--ink); position: relative; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.interruptor {
  width: 46px; height: 28px; flex: none; border-radius: 999px; position: relative;
  background: var(--campo-bg); border: 1px solid var(--campo-borde); transition: background-color 0.25s, border-color 0.25s;
}
.interruptor::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--label); transition: transform 0.35s var(--rebote), background-color 0.25s;
}
.check input:checked + .interruptor { background: var(--acento); border-color: transparent; box-shadow: 0 0 18px rgba(223, 182, 178, 0.35); }
.check input:checked + .interruptor::after { transform: translateX(18px); background: var(--deep); }
.check input:focus-visible + .interruptor { outline: 2px solid var(--lime); outline-offset: 2px; }

/* Selector segmentado */
.segmentos { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--campo-bg); border: 1px solid var(--campo-borde); align-self: flex-start; }
.segmento { border: 0; background: transparent; padding: 0.55rem 1.1rem; border-radius: 999px; cursor: pointer; font-weight: 800; font-size: 0.85rem; color: var(--moss); transition: transform 0.35s var(--rebote), background-color 0.2s, color 0.2s; }
.segmento:hover { color: var(--ink); }
.segmento.activo { background: var(--acento); color: var(--acento-texto); box-shadow: 0 0 22px rgba(223, 182, 178, 0.3); }

/* Estrellas de prioridad */
.estrellas-sel { display: flex; gap: 6px; }
.estrella { border: 0; background: transparent; padding: 4px; cursor: pointer; color: var(--label); transition: transform 0.35s var(--rebote), color 0.2s; }
.estrella:hover { transform: scale(1.15) rotate(-6deg); }
.estrella .ico { width: 28px; height: 28px; }
.estrella.activa { color: #DFB6B2; }
.estrella.activa .ico { fill: currentColor; filter: drop-shadow(0 0 8px rgba(223, 182, 178, 0.5)); }

.acciones { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 0.4rem; }

/* ---------- ACCESO ---------- */
.acceso {
  height: 100dvh; overflow-y: auto;
  display: grid; place-items: center; padding: 24px 16px;
}
.acceso > p { color: var(--moss); }
.acceso-caja {
  width: 100%; max-width: 440px; padding: 2.4rem 2rem 2rem;
  display: flex; flex-direction: column; gap: 1rem; text-align: center;
}
.acceso-logo { display: flex; justify-content: center; }
.acceso-logo img { border-radius: 16px; box-shadow: 0 0 40px rgba(133, 79, 108, 0.45); }
.acceso-titulo { font-size: clamp(2.8rem, 12vw, 3.6rem); line-height: 0.95; margin-bottom: 0.6rem; text-shadow: 0 10px 60px rgba(25, 0, 25, 0.5); }
.acceso-titulo .badge { font-size: 0.82em; vertical-align: 0.04em; }
.acceso-texto { color: var(--moss); }
.acceso .form { margin-top: 0.4rem; }
.acceso .btn-primario { margin-top: 0.4rem; min-height: 52px; font-size: 1rem; }

/* ---------- ESTRUCTURA Y NAVEGACIÓN ---------- */
.estructura {
  height: 100dvh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "banda banda" "nav principal";
}
.banda-suplantacion {
  grid-area: banda;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: calc(8px + var(--seguro-arriba));
  background: linear-gradient(135deg, #FBE4D8, #DFB6B2); color: #190019; font-size: 0.9rem; font-weight: 600;
}
.banda-suplantacion .btn { background: #190019; color: #FBE4D8; }

.nav {
  grid-area: nav;
  margin: 14px; display: flex; flex-direction: column; padding: 12px;
}
/* Fondo del menú: degradado de la paleta */
.nav.glass {
  /* Degradado de la paleta: de ciruela claro arriba a casi negro abajo */
  background: linear-gradient(170deg, #854F6C 0%, #522B5B 28%, #2B124C 62%, #190019 100%);
  color: #FBE4D8; overflow: hidden;
}
.nav .nav-item { color: #FBE4D8; text-shadow: 0 1px 10px rgba(25, 0, 25, 0.55); }
.nav .nav-item:hover { color: #FBE4D8; }
.nav .nav-item.activo { color: var(--acento-texto); text-shadow: none; }
.nav-marca { color: #FBE4D8; text-shadow: 0 2px 14px rgba(25, 0, 25, 0.6); }
/* Recuadro de vidrio oscuro detrás de los textos del menú */
.nav-caja {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 10px;
  background: rgba(25, 0, 25, 0.8);
  -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(223, 182, 178, 0.2); border-radius: 18px;
  box-shadow: 0 12px 34px rgba(25, 0, 25, 0.45), inset 0 1px 0 rgba(251, 228, 216, 0.1);
}
.nav-caja .nav-marca { padding: 4px 10px 16px; margin-bottom: 4px; border-bottom: 1px solid rgba(223, 182, 178, 0.14); }
.nav-marca b { color: #FBE4D8 !important; }
.nav-marca { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 900; font-size: 1.1rem; letter-spacing: 0.04em; }
.nav-marca b { color: var(--lime); font-weight: 900; }
.nav-marca img { border-radius: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 999px;
  color: var(--ink); opacity: 0.8; text-decoration: none; font-weight: 600; font-size: 0.95rem;
  transition: opacity 0.2s, color 0.2s, background-color 0.2s, transform 0.35s var(--rebote);
}
.nav-item:hover { opacity: 1; color: var(--lime); transform: translateX(3px); }
/* El botón Salir usa el mismo estilo que los enlaces del menú */
button.nav-item { width: 100%; border: 0; background: transparent; font-family: var(--font); text-align: left; cursor: pointer; }
.nav-salir { margin-top: 6px; border-top: 1px solid rgba(223, 182, 178, 0.14) !important; border-radius: 0 0 14px 14px; padding-top: 14px; }
.nav .nav-salir:hover { color: #DFB6B2; }
.copia-oculta { position: fixed; left: -9999px; top: 0; opacity: 0; }
/* Áreas táctiles amplias y sin retraso de doble toque en el teléfono */
button, a, .cal-celda, .cal-todo-celda, .mes-celda, .cal-ev, .cal-chip, .mes-chip, .check { touch-action: manipulation; }
.nav-item.activo {
  opacity: 1; color: var(--acento-texto); font-weight: 800;
  background: var(--acento);
  box-shadow: 0 0 26px rgba(223, 182, 178, 0.3);
}
:root[data-tema="claro"] .nav-item.activo { color: var(--acento-texto); }

.principal { grid-area: principal; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 14px 14px 14px 0; }

.vista { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vista-pagina { overflow-y: auto; padding: 1.4rem 0.4rem 2rem; gap: 1.1rem; }
.vista-pagina > * { width: 100%; max-width: 720px; margin-inline: auto; }
.pagina-titulo { font-size: clamp(2.2rem, 6vw, 3.6rem); text-transform: uppercase; padding: 0.4rem 0 0.6rem; }

.tarjeta { padding: 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.tarjeta h3 { font-size: 1.1rem; font-weight: 800; letter-spacing: 0; color: var(--lime); }

.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lista-item { padding: 0.75rem 0; border-bottom: 1px solid var(--linea); display: flex; justify-content: space-between; gap: 8px; }
.lista-item:last-child { border-bottom: 0; }
.bitacora { max-height: 320px; overflow-y: auto; font-size: 0.88rem; }

.usuario-fila { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0.85rem 0; border-bottom: 1px solid var(--linea); flex-wrap: wrap; }
.usuario-fila:last-child { border-bottom: 0; }
.usuario-fila.inactivo .usuario-info strong { color: var(--moss); }
.usuario-acciones { display: flex; gap: 6px; flex-wrap: wrap; }
.etiqueta { display: inline-block; margin-left: 6px; padding: 1px 9px; border-radius: 99px; font-size: 0.7rem; font-weight: 800; background: var(--lime); color: var(--acento-texto); vertical-align: 2px; }
.etiqueta-gris { background: var(--label); }
.etiqueta-aviso { background: #DFB6B2; color: #190019; }
.clave-temporal {
  display: block; padding: 1rem; border-radius: 14px; background: var(--campo-bg); border: 1px solid var(--campo-borde);
  font-size: 1.5rem; font-weight: 800; text-align: center; letter-spacing: 0.1em; color: var(--lime);
  user-select: all; -webkit-user-select: all;
}

/* ---------- CALENDARIO: contenedor y barra ---------- */
.vista-cal {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-line); border-radius: var(--radius);
  box-shadow: var(--sombra); overflow: hidden;
}
.cal-barra { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--glass-line); }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-titulo { font-size: 1.35rem; font-weight: 900; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; position: relative; }

/* ---------- CALENDARIO: semana ---------- */
.cal-fila { display: grid; grid-template-columns: var(--ancho-horas) repeat(7, minmax(0, 1fr)); }
.cal-fijo {
  position: sticky; top: 0; z-index: 6;
  background: var(--cabecera-cal);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 var(--glass-line);
}
.cal-esq { border-right: 1px solid var(--linea); }
.cal-esq-todo { font-size: 0.6rem; color: var(--moss); text-align: right; padding: 6px 6px 0 0; line-height: 1.15; text-transform: uppercase; letter-spacing: 0.08em; }
.cal-dia-cab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-left: 1px solid var(--linea); }
.cal-dia-nombre { font-size: 0.68rem; color: var(--moss); text-transform: uppercase; letter-spacing: 0.18em; font-weight: 600; }
.cal-dia-num { font-size: 1.15rem; font-weight: 900; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.cal-dia-cab.hoy .cal-dia-nombre { color: var(--lime); }
.cal-dia-cab.hoy .cal-dia-num { background: var(--acento); color: var(--acento-texto); box-shadow: 0 0 22px rgba(223, 182, 178, 0.45); }

.cal-todo { border-top: 1px solid var(--linea); }
.cal-todo-celda { min-height: 30px; padding: 3px; display: flex; flex-direction: column; gap: 3px; border-left: 1px solid var(--linea); cursor: pointer; transition: background-color 0.15s; }
.cal-todo-celda:hover { background: var(--hover); }
.cal-todo-celda.destino { background: var(--hora-actual); }

.cal-cuerpo { position: relative; }
.cal-horas { border-right: 1px solid var(--linea); }
.cal-hora-et { height: var(--hh); font-size: 0.68rem; color: var(--moss); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; font-weight: 600; }
.cal-hora-et:first-child { transform: none; }
.cal-hora-et.actual { color: var(--lime); font-weight: 900; }

.cal-col { position: relative; border-left: 1px solid var(--linea); }
.cal-col.hoy { background: var(--hoy-col); }
.cal-celda { height: var(--hh); border-bottom: 1px solid var(--linea); cursor: pointer; transition: background-color 0.15s; }
.cal-celda:hover { background: var(--hover); }
.cal-celda.ahora { background: var(--hora-actual); }

.cal-linea-ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--lime); z-index: 4; pointer-events: none; box-shadow: 0 0 12px var(--lime); }
.cal-linea-ahora::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px var(--lime); }

/* Evento con hora */
.cal-ev {
  position: absolute; z-index: 2; overflow: hidden;
  padding: 4px 7px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 30%, var(--label-up-bg));
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-left: 3px solid var(--c);
  color: var(--ink); font-size: 0.75rem; line-height: 1.25;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: box-shadow 0.25s, transform 0.35s var(--rebote);
}
.cal-ev:hover { box-shadow: 0 0 22px color-mix(in srgb, var(--c) 45%, transparent); z-index: 3; }
.cal-ev-titulo { font-weight: 800; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.cal-ev-hora { color: var(--moss); font-size: 0.68rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.cal-ev.compacto { padding-block: 1px; }
.cal-ev.compacto .cal-ev-titulo { -webkit-line-clamp: 1; }
.cal-ev.compacto .cal-ev-hora { display: none; }
.cal-ev-asa { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; }
.cal-ev-asa::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 20px; height: 3px; margin-left: -10px; border-radius: 2px; background: var(--ink); opacity: 0; transition: opacity 0.15s; }
.cal-ev:hover .cal-ev-asa::after { opacity: 0.6; }
.cal-ev.arrastrando { opacity: 0.3; }
.cal-ev.fantasma { z-index: 8; opacity: 0.95; pointer-events: none; cursor: grabbing; transform: rotate(-1.5deg) scale(1.03); box-shadow: 0 18px 40px rgba(25, 0, 25, 0.45), 0 0 26px color-mix(in srgb, var(--c) 50%, transparent); }
body.arrastrando-cal, body.arrastrando-cal * { cursor: grabbing !important; }

.estrellas { color: #DFB6B2; margin-right: 3px; font-size: 0.9em; letter-spacing: -1px; }

/* Prioridad: más estrellas = más resaltado */
.prio-2 { border-color: var(--c); }
.prio-3 { background: var(--c) !important; color: #FBE4D8; border-color: var(--c); box-shadow: 0 0 20px color-mix(in srgb, var(--c) 55%, transparent); }
.prio-3 .cal-ev-hora, .prio-3 .mes-chip-hora { color: rgba(251, 228, 216, 0.85); }
.prio-3 .estrellas { color: #FBE4D8; }

/* Estados */
.est-hecho { opacity: 0.5; }
.est-hecho .cal-ev-titulo, .est-hecho.cal-chip, .est-hecho .mes-chip-titulo { text-decoration: line-through; }
.est-cancelado { opacity: 0.38; border-style: dashed; }
.est-cancelado .cal-ev-titulo, .est-cancelado.cal-chip, .est-cancelado .mes-chip-titulo { text-decoration: line-through; }

/* Chip de todo el día */
.cal-chip {
  padding: 3px 7px; border-radius: 8px; font-size: 0.7rem; font-weight: 800;
  background: color-mix(in srgb, var(--c) 34%, var(--label-up-bg));
  border-left: 3px solid var(--c);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.cal-chip.arrastrando { opacity: 0.4; }

/* ---------- CALENDARIO: mes ---------- */
.mes-cab { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--glass-line); }
.mes-cab div { padding: 8px 6px; font-size: 0.68rem; color: var(--moss); text-align: center; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; }
.mes-rejilla {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(100px, 1fr);
}
.mes-celda {
  min-width: 0; padding: 6px; display: flex; flex-direction: column; gap: 3px;
  border-right: 1px solid var(--linea); border-bottom: 1px solid var(--linea);
  cursor: pointer; overflow: hidden; transition: background-color 0.15s;
}
.mes-celda:hover { background: var(--hover); }
.mes-celda.fuera { background: rgba(25, 0, 25, 0.12); }
.mes-celda.fuera .mes-num { color: var(--moss); opacity: 0.6; }
.mes-celda.destino { background: var(--hora-actual); }
.mes-num { align-self: flex-start; border: 0; background: transparent; cursor: pointer; font-weight: 900; font-size: 0.85rem; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; transition: transform 0.35s var(--rebote), background-color 0.2s; }
.mes-num:hover { background: rgba(223, 182, 178, 0.12); transform: scale(1.12); }
.mes-celda.hoy .mes-num { background: var(--acento); color: var(--acento-texto); box-shadow: 0 0 20px rgba(223, 182, 178, 0.45); }
.mes-eventos { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mes-chip {
  display: flex; align-items: center; gap: 5px; min-width: 0;
  padding: 2px 6px; border-radius: 7px; font-size: 0.72rem; font-weight: 600;
  border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 22%, transparent);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background-color 0.15s;
}
.mes-chip.todo-dia { background: color-mix(in srgb, var(--c) 36%, var(--label-up-bg)); font-weight: 800; }
.mes-chip:hover { background: color-mix(in srgb, var(--c) 38%, transparent); }
.mes-chip.arrastrando { opacity: 0.4; }
.mes-chip-hora { color: var(--moss); font-variant-numeric: tabular-nums; flex: none; }
.mes-chip-titulo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mes-mas { align-self: flex-start; border: 0; background: transparent; color: var(--lime); font-size: 0.72rem; font-weight: 800; cursor: pointer; padding: 0 4px; }
.fantasma-flotante { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: 0.95; box-shadow: 0 18px 40px rgba(25, 0, 25, 0.45); background: var(--label-up-bg) !important; }

/* ---------- CHAT (degradado de la paleta + tarjeta de vidrio) ---------- */
.vista-chat {
  /* La tarjeta del chat siempre es oscura: usa la paleta oscura aunque el tema sea claro */
  --ink: #FBE4D8; --moss: #DFB6B2; --lime: #DFB6B2; --label: #DFB6B2;
  --campo-borde: rgba(223, 182, 178, 0.18); --glass-line: rgba(223, 182, 178, 0.2);
  --especular: rgba(251, 228, 216, 0.14);
  color: var(--ink);
  position: relative; overflow: hidden; border-radius: var(--radius);
  display: grid; place-items: center; padding: clamp(16px, 4vw, 48px);
  /* Degradado de toda la paleta que se desplaza lento (sin imágenes) */
  background: linear-gradient(135deg, #FBE4D8 0%, #DFB6B2 16%, #854F6C 38%, #522B5B 58%, #2B124C 78%, #190019 100%);
  background-size: 220% 220%;
  animation: degradado-chat 22s ease-in-out infinite alternate;
  box-shadow: var(--sombra);
}
@keyframes degradado-chat { 0% { background-position: 0% 0%; } 100% { background-position: 100% 100%; } }
@media (prefers-reduced-motion: reduce) { .vista-chat { animation: none; } }
/* velo suave para que la tarjeta resalte sobre el degradado */
.vista-chat::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 70% 70% at 50% 55%, rgba(25, 0, 25, 0.35), transparent 75%); pointer-events: none; }
.chat-tarjeta {
  width: min(560px, 100%); height: min(680px, 100%);
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(43, 18, 76, 0.42);
  border-radius: 26px;
}
.chat-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 1.4rem 1.2rem; display: flex; flex-direction: column; gap: 10px; }
.chat-vacio { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 0 1rem; }
.chat-hola { font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 0.95; text-shadow: 0 10px 60px rgba(25, 0, 25, 0.45); }
.chat-sub { color: #DFB6B2; font-size: 1.05rem; max-width: 420px; line-height: 1.6; }
.burbuja { max-width: min(80%, 520px); padding: 0.75rem 1.1rem; border-radius: 20px; word-wrap: break-word; white-space: pre-wrap; font-weight: 600; }
.burbuja.yo { align-self: flex-end; background: var(--acento); color: var(--acento-texto); border-bottom-right-radius: 6px; box-shadow: 0 0 26px rgba(223, 182, 178, 0.25); transform-origin: bottom right; }
.burbuja.app {
  align-self: flex-start; border-bottom-left-radius: 6px; transform-origin: bottom left;
  background: var(--glass-bg); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.chat-form {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 18px; margin: 0 14px 14px;
  border-radius: 999px; background: rgba(25, 0, 25, 0.5); border: 1px solid var(--campo-borde);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.chat-form:focus-within { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(223, 182, 178, 0.15); }
.chat-entrada { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; padding: 0.7rem 0; color: #FBE4D8; }
.vista-chat .chat-hola, .vista-chat .burbuja.app { color: #FBE4D8; }
.chat-entrada::placeholder { color: var(--label); }
.btn-enviar {
  width: 46px; height: 46px; border: 0; border-radius: 50%; flex: none; cursor: pointer;
  display: grid; place-items: center; color: var(--acento-texto);
  background: var(--acento); box-shadow: 0 0 26px rgba(223, 182, 178, 0.35);
  transition: transform 0.35s var(--rebote), box-shadow 0.3s;
}
.btn-enviar:hover { transform: scale(1.08) rotate(-6deg); box-shadow: 0 0 40px rgba(223, 182, 178, 0.55); }

/* ---------- MODAL Y AVISOS ---------- */
.modal-fondo {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center; padding: 16px;
  background: rgba(25, 0, 25, 0.5);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 540px; max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--glass-fuerte);
  border-radius: 26px;
}
.modal-chico { max-width: 400px; }
.modal-cab { display: flex; align-items: center; justify-content: space-between; padding: 1.3rem 1.2rem 0.4rem 1.6rem; }
.modal-cab h2 { font-size: 1.6rem; text-transform: uppercase; }
.modal-cuerpo { padding: 0.9rem 1.6rem 1.6rem; overflow-y: auto; }
.modal-cuerpo > p { color: var(--moss); }

.avisos {
  position: fixed; left: 50%; bottom: calc(28px + var(--seguro-abajo)); transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.aviso {
  padding: 0.75rem 1.4rem; border-radius: 999px; font-weight: 800; font-size: 0.9rem;
  background: var(--acento); color: var(--acento-texto);
  box-shadow: 0 0 40px rgba(223, 182, 178, 0.45), 0 10px 30px rgba(25, 0, 25, 0.35);
}
.aviso::before { content: "✓ "; }
.aviso-error { background: linear-gradient(135deg, #DFB6B2, #854F6C); color: #190019; box-shadow: 0 0 34px rgba(133, 79, 108, 0.4); }
.aviso-error::before, .aviso-info::before { content: ""; }
.aviso.saliendo { opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; }

/* ---------- MÓVIL ---------- */
@media (max-width: 760px) {
  :root { --ancho-horas: 40px; --hh: 46px; --radius: 20px; }

  .estructura {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "banda" "principal" "nav";
  }
  .principal { padding: calc(8px + var(--seguro-arriba)) 8px 0; }
  .estructura.con-banda .principal { padding-top: 8px; }

  /* Navegación: píldora de vidrio flotante abajo */
  .nav {
    flex-direction: row;
    margin: 8px 10px calc(8px + var(--seguro-abajo)); border-radius: 999px;
  }
  .nav-marca { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 7px 2px; font-size: 0.62rem; justify-content: center; border-radius: 999px; }
  .nav-item:hover { transform: none; }
  .nav-item .ico { width: 22px; height: 22px; }

  .solo-ancho { display: none; }
  .cal-barra { padding: 8px 10px; gap: 6px; }
  .cal-titulo { font-size: 1.05rem; }
  .btn-icono { width: 36px; height: 36px; }
  .cal-dia-num { font-size: 0.95rem; width: 28px; height: 28px; }
  .cal-dia-nombre { font-size: 0.56rem; letter-spacing: 0.08em; }
  .cal-ev { padding: 2px 3px; font-size: 0.64rem; border-left-width: 2px; border-radius: 6px; }
  .cal-ev-hora, .cal-ev .estrellas { display: none; }
  .cal-chip { font-size: 0.6rem; padding: 2px 3px; }
  .cal-esq-todo { font-size: 0.5rem; padding-right: 3px; letter-spacing: 0; }
  .cal-hora-et { font-size: 0.6rem; padding-right: 4px; }

  .mes-rejilla { grid-auto-rows: minmax(78px, 1fr); }
  .mes-celda { padding: 3px 2px; }
  .mes-cab div { letter-spacing: 0.06em; font-size: 0.6rem; }
  .mes-chip { font-size: 0.6rem; padding: 1px 3px; border-left-width: 2px; border-radius: 5px; }
  .mes-chip-hora, .mes-chip .estrellas { display: none; }

  .vista-pagina { padding: 0.8rem 0.4rem 1.5rem; }
  .frm-fila { grid-template-columns: minmax(0, 1fr) minmax(138px, 0.9fr); gap: 0.6rem; }
  .frm-fila .frm input[type="date"] { padding-inline: 0.8rem; }
  .modal-fondo { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 26px 26px 0 0; max-height: 92dvh; padding-bottom: var(--seguro-abajo); }
  .modal-cab { padding: 1.1rem 1rem 0.3rem 1.3rem; }
  .modal-cuerpo { padding: 0.8rem 1.3rem 1.4rem; }
  .avisos { bottom: calc(96px + var(--seguro-abajo)); }
  .vista-chat { padding: 28px 18px; border-radius: 20px; }
  .chat-tarjeta { height: min(100%, 600px); border-radius: 22px; }
  .chat-form { margin: 0 10px 10px; }

  /* Menú inferior: el recuadro ocupa la píldora completa */
  .nav { padding: 5px; }
  .nav-caja { flex-direction: row; justify-content: space-around; gap: 2px; padding: 4px; border-radius: 999px; width: 100%; }
  .nav-caja .nav-marca { display: none; }
  .nav-salir { margin-top: 0; border-top: 0 !important; border-radius: 999px; padding-top: 7px; }
  .nav-item span { white-space: nowrap; }
}

/* accesibilidad: respeta usuarios sin animaciones */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Formulario: repetición y recordatorios ---------- */
.seccion-form { padding-top: 1rem; border-top: 1px solid var(--linea); gap: 10px; }
.frm-titulo.separado { margin-top: 0.6rem; }
.rep-panel { display: flex; flex-direction: column; gap: 8px; }
.chips-semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.chips-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.chips-antes { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-dia {
  min-height: 40px; min-width: 0; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--campo-borde); background: var(--campo-bg); color: var(--ink);
  font-family: var(--font); font-weight: 800; font-size: 0.85rem;
  transition: transform 0.35s var(--rebote), background-color 0.2s, color 0.2s;
}
.chip-dia:hover { transform: scale(1.06); }
.chip-dia.activo { background: var(--acento); color: var(--acento-texto); border-color: transparent; box-shadow: 0 0 16px rgba(223, 182, 178, 0.3); }
.chip-ancho { padding: 0 0.9rem; border-radius: 999px; min-height: 36px; font-size: 0.8rem; }
.resumen-rep { margin: 0; color: var(--lime); font-weight: 600; }
.resumen-rep:empty { display: none; }

.contador { display: flex; align-items: center; gap: 10px; }
.btn-contador { border: 1px solid var(--campo-borde); background: var(--campo-bg); font-size: 1.3rem; font-weight: 800; }
.btn-contador:disabled { opacity: 0.35; cursor: default; transform: none; }
.contador-valor { min-width: 2ch; text-align: center; font-size: 1.4rem; font-weight: 900; }
.contador-ayuda { margin: 0 0 0 4px; }
.lista-horas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lista-horas:empty { display: none; }
.hora-rec { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: 14px; background: var(--campo-bg); border: 1px solid var(--campo-borde); }
.hora-rec-num { font-size: 0.7rem; font-weight: 800; color: var(--lime); min-width: 1.4ch; }
.hora-rec input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-family: var(--font); font-size: 16px; padding: 0.4rem 0; outline: none; }
.hora-rec .btn-icono { width: 32px; height: 32px; font-size: 1.2rem; }
.repite { margin-right: 3px; opacity: 0.85; font-weight: 900; }
.seccion-form { display: flex; flex-direction: column; }
.seccion-form .segmentos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; border-radius: 18px; }
.seccion-form .segmento { padding: 0.55rem 0.2rem; font-size: 0.8rem; text-align: center; }
.hora-rec input::-webkit-calendar-picker-indicator { display: none; }
.lista-horas { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.hora-rec .btn-icono { width: 28px; height: 28px; flex: none; }

/* ---------- Conexión e instalación ---------- */
.banda-conexion {
  position: fixed; z-index: 55; left: 50%; transform: translateX(-50%);
  top: calc(10px + var(--seguro-arriba)); width: min(560px, calc(100% - 24px));
  padding: 0.6rem 1rem; border-radius: 16px; text-align: center;
  font-size: 0.82rem; font-weight: 700; line-height: 1.35;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(25, 0, 25, 0.35);
  pointer-events: none;
}
.banda-conexion.sin-red { background: rgba(223, 182, 178, 0.92); color: #190019; }
.banda-conexion.enviando { background: rgba(133, 79, 108, 0.92); color: var(--acento-texto); }
.pasos-instalar { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.instalada { color: var(--lime); font-weight: 700; margin: 0; }
@media (max-width: 760px) {
  /* En el teléfono la banda va abajo, sobre el menú, para no tapar la barra del calendario */
  .banda-conexion { top: auto; bottom: calc(92px + var(--seguro-abajo)); font-size: 0.74rem; padding: 0.45rem 0.8rem; border-radius: 14px; }
  body.con-banda-red .avisos { bottom: calc(160px + var(--seguro-abajo)); }
}

/* ---------- Notificaciones y calendario ---------- */
.notif-cuerpo { display: flex; flex-direction: column; gap: 0.8rem; }
.estado-notif { margin: 0; font-weight: 800; }
.estado-notif::before { content: "● "; }
.estado-notif.si { color: #DFB6B2; }
.estado-notif.no { color: var(--moss); }
.acciones-izq { justify-content: flex-start; margin-top: 0; }
.historial-notif summary { cursor: pointer; color: var(--lime); font-weight: 700; font-size: 0.9rem; }
.historial-notif .lista { margin-top: 0.4rem; font-size: 0.82rem; }
.enlace-ics { display: block; padding: 0.7rem; border-radius: 12px; background: var(--campo-bg); border: 1px solid var(--campo-borde); font-size: 0.75rem; word-break: break-all; user-select: all; -webkit-user-select: all; }

/* Asistente escribiendo */
.burbuja.escribiendo { display: inline-flex; gap: 5px; align-items: center; padding: 0.95rem 1.1rem; }
.burbuja.escribiendo span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.35; animation: punto-chat 1.1s infinite ease-in-out; }
.burbuja.escribiendo span:nth-child(2) { animation-delay: 0.15s; }
.burbuja.escribiendo span:nth-child(3) { animation-delay: 0.3s; }
@keyframes punto-chat { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 0.9; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .burbuja.escribiendo span { animation: none; opacity: 0.6; } }

/* Noctua: barra del chat e interruptores */
.chat-barra { display: flex; align-items: center; justify-content: flex-end; padding: 12px 16px 0; }
.chat-barra .check, .chat-barra > .noctua-nombre { color: #DFB6B2; font-size: 0.88rem; }
.noctua-nombre { font-family: "Instrument Serif", serif; font-style: italic; font-size: 1.15rem; letter-spacing: 0.01em; display: inline-flex; align-items: baseline; gap: 6px; }
.noctua-estado { font-family: "Archivo", sans-serif; font-style: normal; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; }
.chat-barra.activo .noctua-estado { color: var(--lime); opacity: 1; }
.chat-barra + .chat-lista { padding-top: 0.6rem; }
.usuario-info .noctua-check { margin-top: 8px; font-size: 0.86rem; }

/* =========================================================
   FINANZAS — versión crema de la paleta (se distingue del resto de la app, que es ciruela oscuro)
   ========================================================= */
:root[data-seccion="finanzas"], .modal-fin {
  --bg: #FBE4D8; --ink: #190019; --moss: #522B5B; --lime: #854F6C; --lime-2: #522B5B;
  --deep: #190019; --royal: #2B124C;
  --glass-bg: rgba(251, 228, 216, 0.55); --glass-fuerte: rgba(251, 228, 216, 0.94); --glass-line: rgba(133, 79, 108, 0.22);
  --campo-bg: rgba(223, 182, 178, 0.28); --campo-borde: rgba(133, 79, 108, 0.24); --label: #854F6C; --label-up-bg: #FBE4D8;
  --linea: rgba(133, 79, 108, 0.12); --hover: rgba(133, 79, 108, 0.07);
  --aurora-1: rgba(223, 182, 178, 0.85); --aurora-2: rgba(133, 79, 108, 0.32); --aurora-3: rgba(251, 228, 216, 0.95);
  --especular: rgba(251, 228, 216, 0.6); --peligro: #854F6C; --sombra: 0 12px 40px rgba(82, 43, 91, 0.16);
  --acento: linear-gradient(135deg, #854F6C, #522B5B); --acento-texto: #FBE4D8;
  color-scheme: light;
}
:root[data-seccion="finanzas"] .btn-fantasma, .modal-fin .btn-fantasma { background: rgba(133, 79, 108, 0.08); }
:root[data-seccion="finanzas"] .btn-fantasma:hover, .modal-fin .btn-fantasma:hover { background: rgba(133, 79, 108, 0.15); }
:root[data-seccion="finanzas"] .btn-icono:hover, .modal-fin .btn-icono:hover { background: rgba(133, 79, 108, 0.1); }
.modal-fin { background: var(--glass-fuerte); color: var(--ink); }

/* Tarjeta principal: Tengo / Gastado */
.fin-hero { align-items: center; text-align: center; padding: 1.8rem 1.4rem 1.5rem; overflow: hidden; }
.fin-hero::after {
  content: ""; position: absolute; inset: auto -20% -60% -20%; height: 120%; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, rgba(133, 79, 108, 0.28), transparent 70%);
}
.fin-tengo {
  font-size: clamp(2.6rem, 11vw, 4.4rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums; text-shadow: 0 10px 50px rgba(133, 79, 108, 0.45);
}
.fin-gastado { display: flex; flex-direction: column; gap: 2px; margin-top: 0.3rem; color: var(--moss); font-size: 0.85rem; }
.fin-gastado strong { color: var(--ink); font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.fin-ingresos { font-size: 0.8rem; }
.fin-rapidos { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 0.6rem; width: 100%; }
.fin-rapidos .btn { white-space: nowrap; }

/* Cuentas */
.fin-cuentas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fin-cuenta {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 0.85rem 0.95rem; border-radius: 18px; text-align: left; cursor: pointer;
  background: var(--campo-bg); border: 1px solid var(--campo-borde); color: var(--ink);
  transition: transform 0.35s var(--rebote), border-color 0.2s, background-color 0.2s;
}
.fin-cuenta:hover { transform: translateY(-3px) scale(1.02); border-color: var(--lime); }
.fin-cuenta-emoji { grid-row: span 2; font-size: 1.6rem; line-height: 1; }
.fin-cuenta-nombre { font-size: 0.8rem; color: var(--moss); font-weight: 600; }
.fin-cuenta strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.fin-cuenta strong.negativo { color: var(--peligro); }
.fin-cuenta-nueva { border-style: dashed; }
.fin-cuenta-nueva .fin-cuenta-emoji { color: var(--lime); }

/* Selector de mes */
.fin-barra-mes { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-transform: capitalize; }
.fin-barra-mes .btn-icono { font-size: 1.4rem; line-height: 1; }
.fin-barra-mes .btn-icono:disabled { opacity: 0.3; cursor: default; transform: none; }

/* Gasto por categoría */
.fin-cats { display: flex; flex-direction: column; gap: 12px; }
.fin-cat-fila { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.fin-cat-icono {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 1.25rem;
  background: color-mix(in srgb, var(--c) 22%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.fin-cat-info { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fin-cat-linea { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.fin-cat-linea span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-cat-linea strong { font-variant-numeric: tabular-nums; }
.fin-barra { height: 8px; border-radius: 99px; background: var(--linea); overflow: hidden; }
.fin-barra-relleno { display: block; height: 100%; border-radius: inherit; background: var(--c); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 60%, transparent); }
.fin-cat-pct { font-size: 0.75rem; color: var(--moss); min-width: 2.6em; text-align: right; }

/* Movimientos */
.fin-dia { display: flex; flex-direction: column; gap: 6px; }
.fin-dia + .fin-dia { margin-top: 0.6rem; }
.fin-dia-titulo { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--lime); font-weight: 700; }
.fin-mov {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; width: 100%;
  padding: 0.55rem 0.6rem; border-radius: 16px; border: 1px solid transparent; background: transparent;
  color: var(--ink); text-align: left; cursor: pointer;
  transition: transform 0.35s var(--rebote), background-color 0.2s, border-color 0.2s;
}
.fin-mov:hover { background: var(--hover); border-color: var(--glass-line); transform: translateX(4px); }
.fin-mov-emoji {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 1.3rem;
  background: color-mix(in srgb, var(--c) 20%, transparent);
}
.fin-mov-texto { min-width: 0; display: flex; flex-direction: column; }
.fin-mov-titulo { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-mov-sub { font-size: 0.75rem; color: var(--moss); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-mov-monto { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-mov-ingreso .fin-mov-monto { color: var(--lime); }
.fin-mov-interno .fin-mov-monto { color: var(--moss); }
.fin-fijo.inactivo { opacity: 0.55; }

/* Formulario de movimiento */
.fin-monto { display: flex; align-items: baseline; justify-content: center; gap: 6px; font-weight: 900; }
.fin-monto span { font-size: 2rem; color: var(--moss); }
.fin-monto-input {
  width: min(260px, 70%); border: 0; border-bottom: 2px solid var(--campo-borde); background: transparent; outline: none;
  font-size: 2.6rem; font-weight: 900; text-align: center; padding: 0.2rem 0; font-variant-numeric: tabular-nums; color: var(--ink);
  transition: border-color 0.2s;
}
.fin-monto-input:focus { border-color: var(--lime); }
.fin-cat-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fin-cat-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0.6rem 0.3rem; border-radius: 16px; cursor: pointer;
  background: var(--campo-bg); border: 1px solid var(--campo-borde); color: var(--ink); font-size: 0.7rem; font-weight: 700; line-height: 1.15; text-align: center;
  transition: transform 0.35s var(--rebote), border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.fin-cat-chip:hover { transform: translateY(-3px) scale(1.04); border-color: var(--c); }
.fin-cat-chip.activo {
  background: color-mix(in srgb, var(--c) 28%, transparent); border-color: var(--c);
  box-shadow: 0 0 20px color-mix(in srgb, var(--c) 45%, transparent); transform: scale(1.05);
}
.fin-cat-emoji { font-size: 1.5rem; line-height: 1; }
.fin-emoji-input { text-align: center; font-size: 1.4rem !important; }
.fin-fila-emoji { grid-template-columns: 90px minmax(0, 1fr) !important; }

@media (max-width: 760px) {
  .fin-cuentas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-cat-rejilla { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .fin-cat-chip { font-size: 0.6rem; padding: 0.5rem 0.15rem; }
  .fin-cat-emoji { font-size: 1.35rem; }
  .fin-rapidos .btn { flex: 1; padding-inline: 0.5rem; white-space: nowrap; font-size: 0.82rem; }
  .nav-item { font-size: 0.58rem; }
  .form-fin .frm-fila { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Saludo del chat: la mano saluda al entrar */
.chat-mano { font-size: 2.4rem; line-height: 1; display: inline-block; transform-origin: 70% 80%; animation: saludo-mano 1.6s ease-in-out 0.6s 2; }
@keyframes saludo-mano { 0%, 100% { transform: rotate(0); } 15%, 45% { transform: rotate(18deg); } 30%, 60% { transform: rotate(-10deg); } }
@media (prefers-reduced-motion: reduce) { .chat-mano { animation: none; } }

/* Siri: datos para copiar al atajo */
.siri-nuevo { display: flex; flex-direction: column; gap: 0.7rem; padding: 0.9rem; border-radius: 16px; background: var(--campo-bg); border: 1px solid var(--campo-borde); }
.siri-dato { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; }
.siri-dato .frm-titulo { grid-column: 1 / -1; }
.siri-secreto { letter-spacing: 0.02em; }
