/* P.A.L.I.A — tema rojo */
:root {
  --red: #e3132b;
  --red-2: #b40d1f;
  --red-3: #7d0814;
  --red-glow: rgba(227, 19, 43, .45);
  --bg: #0d0607;
  --bg-2: #160a0c;
  --surface: #1d0e11;
  --surface-2: #261317;
  --line: rgba(255, 255, 255, .08);
  --text: #fbf3f3;
  --muted: #b9a2a5;
  --ok: #33c27a;
  --warn: #f2b33d;
  --radius: 20px;
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
svg { fill: currentColor; }

.brand { font-weight: 800; letter-spacing: .32em; font-size: 15px; color: #fff; }
.brand.big { font-size: 30px; letter-spacing: .22em; text-align: center; }
.muted { color: var(--muted); }

/* ---------- Intro ---------- */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 80% at 50% 30%, #f2283f 0%, var(--red) 35%, var(--red-2) 70%, var(--red-3) 100%);
  overflow: hidden;
}
.splash-inner { text-align: center; position: relative; z-index: 1; }
.wordmark {
  margin: 0; font-size: clamp(44px, 14vw, 72px); font-weight: 800; letter-spacing: .04em; line-height: 1;
  display: flex; justify-content: center; color: #fff;
  text-shadow: 0 6px 30px rgba(0, 0, 0, .25);
}
.wordmark span, .wordmark i {
  display: inline-block; font-style: normal; opacity: 0; transform: translateY(18px);
  animation: rise .55s cubic-bezier(.2, .8, .2, 1) forwards;
}
.wordmark i { color: rgba(255, 255, 255, .55); margin: 0 .02em; }
.wordmark > :nth-child(1) { animation-delay: .10s; }
.wordmark > :nth-child(2) { animation-delay: .16s; }
.wordmark > :nth-child(3) { animation-delay: .22s; }
.wordmark > :nth-child(4) { animation-delay: .28s; }
.wordmark > :nth-child(5) { animation-delay: .34s; }
.wordmark > :nth-child(6) { animation-delay: .40s; }
.wordmark > :nth-child(7) { animation-delay: .46s; }
.wordmark > :nth-child(8) { animation-delay: .52s; }
.wordmark > :nth-child(9) { animation-delay: .58s; }
.tagline {
  margin: 14px 0 0; font-size: 13px; letter-spacing: .38em; text-transform: uppercase; color: rgba(255, 255, 255, .82);
  opacity: 0; animation: fade .6s ease .75s forwards;
}
.shine {
  position: absolute; inset: -20% -60%; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, .55) 50%, transparent 58%);
  transform: translateX(-70%); animation: shine 1s cubic-bezier(.6, 0, .2, 1) 1s forwards;
}
.splash.leaving { animation: sweep-out .75s cubic-bezier(.7, 0, .2, 1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes fade { to { opacity: 1; } }
@keyframes shine { to { transform: translateX(70%); } }
@keyframes sweep-out {
  0% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); }
}

/* ---------- Pantallas ---------- */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background:
    radial-gradient(90% 55% at 50% -5%, rgba(227, 19, 43, .38), transparent 70%),
    radial-gradient(70% 40% at 50% 110%, rgba(227, 19, 43, .16), transparent 70%),
    var(--bg);
}
.screen.enter { animation: screen-in .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px); } }

.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: rgba(255, 255, 255, .08); }
.icon-btn.ghost { visibility: hidden; }

/* Acceso */
.login { justify-content: center; align-items: center; padding: 16px; }
.login-card { width: min(340px, 100%); display: grid; gap: 14px; text-align: center; }
.login-card input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); text-align: center; font-size: 17px;
}
.error { color: #ff8a8a; min-height: 1.2em; margin: 0; }

button.primary {
  padding: 14px 18px; border-radius: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #f02a40, var(--red-2));
  box-shadow: 0 8px 24px var(--red-glow);
}
button.secondary { padding: 13px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; }
button.secondary.danger { color: #ff9a9a; }

/* ---------- Inicio ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 0 22px; }
.hero { text-align: center; padding: 6vh 24px 0; }
.greeting { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.next-up { margin: 8px auto 0; color: var(--muted); font-size: 15px; max-width: 30ch; min-height: 2.9em; }

.dial { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding-bottom: 4vh; }
.dial-row { display: flex; gap: clamp(40px, 16vw, 72px); }
.dial-item { display: flex; flex-direction: column; align-items: center; gap: 10px; opacity: 0; transform: scale(.6); }
.home.ready .dial-item { animation: pop .55s cubic-bezier(.2, 1.4, .3, 1) forwards; }
.home.ready .dial-item.main { animation-delay: .05s; }
.home.ready .dial-row .dial-item:first-child { animation-delay: .18s; }
.home.ready .dial-row .dial-item:last-child { animation-delay: .28s; }
@keyframes pop { to { opacity: 1; transform: none; } }
.label { font-size: 14px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }

.orb-btn {
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, #3a1a1f, var(--surface) 70%);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .15s ease;
}
.orb-btn svg { width: 36px; height: 36px; }
.orb-btn:active { transform: scale(.94); }
.orb-btn.call {
  width: 132px; height: 132px;
  background: radial-gradient(circle at 35% 28%, #ff4a5d, var(--red) 45%, var(--red-2) 80%);
  border: 0; box-shadow: 0 18px 50px var(--red-glow), inset 0 2px 0 rgba(255, 255, 255, .25);
}
.orb-btn.call svg { width: 48px; height: 48px; }
.halo { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--red); opacity: 0; pointer-events: none; }
.orb-btn.call.ringing .halo { animation: halo 1.6s ease-out infinite; }
.orb-btn.call.ringing .halo.two { animation-delay: .8s; }
.orb-btn.call.ringing { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes halo { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.7); } }
@keyframes wiggle { 0%, 60%, 100% { rotate: 0deg; } 65% { rotate: -10deg; } 72% { rotate: 10deg; } 79% { rotate: -6deg; } 86% { rotate: 4deg; } }
.badge {
  position: absolute; top: 4px; right: 4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 3px var(--bg);
}

.home-foot { padding: 0 24px 22px; display: grid; justify-items: center; gap: 8px; min-height: 60px; }
.pill {
  padding: 11px 18px; border-radius: 999px; background: rgba(227, 19, 43, .14); color: #ffd7dc;
  border: 1px solid rgba(227, 19, 43, .45); font-weight: 600; font-size: 15px;
}
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; max-width: 34ch; }

/* ---------- Subpantallas ---------- */
.sub { background: var(--bg); }
.subbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.subbar h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .02em; }

/* Mensajes */
.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.chat-hint { color: var(--muted); text-align: center; margin: auto 8px; line-height: 1.6; }
.msg { max-width: 84%; padding: 10px 14px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; animation: screen-in .25s ease; }
.msg.user { align-self: flex-end; background: linear-gradient(180deg, #e8203a, var(--red-2)); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.pending { color: var(--muted); }
.msg.error { color: #ff9a9a; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--bg-2); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 140px; padding: 12px 16px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
.round { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.round svg { width: 22px; height: 22px; }
.round.mic { background: var(--surface-2); border: 1px solid var(--line); }
.round.mic.recording { background: var(--red); border-color: transparent; animation: pulse 1.1s ease-in-out infinite; }
.round.send { background: var(--red); color: #fff; }
.round.send:disabled { opacity: .4; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(227, 19, 43, .2); } }
.rec-bar { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 6px; font-size: 14px; color: #ffd7dc; background: var(--bg-2); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Calendario */
.cal-scroll { flex: 1; overflow-y: auto; padding: 8px 14px 24px; -webkit-overflow-scrolling: touch; }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h3 { margin: 0; font-size: 20px; font-weight: 700; text-transform: capitalize; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-week { margin: 8px 0 4px; }
.cal-week span { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.day {
  aspect-ratio: 1; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--surface); border: 1px solid transparent; font-weight: 600; font-size: 15px; position: relative;
}
.day.other { opacity: .3; }
.day.today { border-color: var(--red); }
.day.selected { background: linear-gradient(180deg, #e8203a, var(--red-2)); color: #fff; }
.dots { display: flex; gap: 3px; height: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.day.selected .dots i { background: #fff; }
.dots i.done { background: #6b5a5d; }
.dots i.missed { background: var(--warn); }
.dots i.fixed { background: transparent; box-shadow: inset 0 0 0 1.5px #9d8a8d; }
.day.selected .dots i.fixed { box-shadow: inset 0 0 0 1.5px #fff; background: transparent; }
.day-title { margin: 22px 4px 10px; font-size: 16px; color: var(--muted); font-weight: 600; }
.day-title::first-letter { text-transform: uppercase; }
.day-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.day-list li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
}
.day-list .time { font-variant-numeric: tabular-nums; font-weight: 700; color: #ff6b7c; min-width: 46px; }
.day-list .body { flex: 1; min-width: 0; }
.day-list .meta { font-size: 13px; color: var(--muted); }
.day-list li.done { opacity: .55; }
.day-list li.done .time { color: var(--muted); }
.day-list li.missed .time { color: var(--warn); }
.day-list li.fixed { background: var(--bg-2); border-style: dashed; }
.day-list li.fixed .time { color: #d9c2c5; }
.day-list .remove { padding: 7px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: #ffb3bc; }
.day-list .empty { justify-content: center; color: var(--muted); background: none; border: 0; }

/* ---------- Llamada ---------- */
.callscreen {
  align-items: center; justify-content: space-between; padding: calc(28px + env(safe-area-inset-top)) 20px calc(36px + env(safe-area-inset-bottom));
  background: radial-gradient(80% 60% at 50% 42%, rgba(227, 19, 43, .35), transparent 70%), #0a0405;
}
.call-top { text-align: center; }
.call-status { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.voice-orb { position: relative; width: 220px; height: 220px; display: grid; place-items: center; }
.orb {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff6474, var(--red) 45%, var(--red-3) 85%);
  box-shadow: 0 0 60px var(--red-glow), inset 0 3px 0 rgba(255, 255, 255, .3);
  transform: scale(var(--level, 1)); transition: transform .08s linear;
}
.orb-ring { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(227, 19, 43, .5); animation: breathe 3s ease-in-out infinite; }
.orb-ring.r2 { inset: -26px; border-color: rgba(227, 19, 43, .22); animation-delay: 1.5s; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .5; } }
.callscreen.ringing .orb { animation: ringpulse 1.2s ease-in-out infinite; }
@keyframes ringpulse { 50% { transform: scale(1.08); } }
.call-transcript { width: min(520px, 100%); height: 22vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; mask-image: linear-gradient(to bottom, transparent, #000 30%); }
.call-transcript p { margin: 0; font-size: 15px; color: var(--muted); }
.call-transcript p.assistant { color: var(--text); }
.call-buttons { display: flex; gap: 64px; }
.round.huge { width: 76px; height: 76px; }
.round.huge svg { width: 34px; height: 34px; }
.round.answer { background: var(--ok); color: #fff; box-shadow: 0 10px 30px rgba(51, 194, 122, .35); }
.round.hangup { background: var(--red); color: #fff; box-shadow: 0 10px 30px var(--red-glow); }

/* ---------- Ajustes ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; animation: fade .2s ease; }
.sheet {
  width: 100%; max-height: 88vh; overflow-y: auto; padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  background: var(--bg-2); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line);
  animation: sheet-in .3s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .2); margin: 4px auto 10px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; }
.settings { display: grid; gap: 14px; margin-bottom: 18px; }
.settings label { display: grid; gap: 6px; font-weight: 600; }
.settings input[type=time] { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 8px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: block; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-weight: 700; cursor: pointer; }
.days input:checked + span { background: var(--red); border-color: transparent; color: #fff; }
.days input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }
.status { margin: 0; color: var(--muted); min-height: 1.2em; text-align: center; }
.sheet-section { margin: 8px 0 -4px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: #ff6b7c; }
.settings select, .settings input[type=time] { font-size: 16px; }
.settings select {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.switch-row { display: flex !important; align-items: center; justify-content: space-between; }
.switch { -webkit-appearance: none; appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--surface-2);
  border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--red); border-color: transparent; }
.switch:checked::after { transform: translateX(20px); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 9px 4px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--red); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid #fff; outline-offset: 1px; }

/* Aviso flotante */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 60; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); padding: 14px 18px; border-radius: 16px;
  background: rgba(38, 19, 23, .96); border: 1px solid rgba(227, 19, 43, .5); color: #fff; font-weight: 600; text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: toast-in .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition: none !important; }
}
