:root {
  --pink: #ff1493;
  --pink-2: #ff4fb0;
  --pink-soft: rgba(255, 20, 147, .12);
  --pink-line: rgba(255, 20, 147, .45);
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  --bg: #0c0c0e;
  --bg-2: #141417;
  --card: #18181c;
  --card-called: #2a1020;
  --line: #2a2a30;
  --text: #f4f4f6;
  --muted: #9a9aa3;
  --input: #1f1f24;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --glow: 0 0 0 1px var(--pink-line), 0 8px 28px rgba(255, 20, 147, .22);
}
:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-called: #ffe6f3;
  --line: #e7e7ec;
  --text: #121214;
  --muted: #6d6d76;
  --input: #f2f2f5;
  --shadow: 0 8px 24px rgba(20, 20, 30, .08);
  --glow: 0 0 0 1px var(--pink-line), 0 8px 24px rgba(255, 20, 147, .16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Logos por tema */
:root[data-theme="dark"] .logo-for-light, :root[data-theme="light"] .logo-for-dark { display: none; }

/* ---------- Splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 20, 147, .18), transparent 55%), var(--bg);
  transition: opacity .6s var(--ease), visibility .6s;
}
#splash.hide { opacity: 0; visibility: hidden; }
.spin-stage { perspective: 700px; width: 120px; height: 180px; }
.spin-k {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  animation: spin3d 2.2s var(--ease) infinite;
}
.spin-k img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transform: translateZ(var(--z));
  filter: brightness(.55);
}
.spin-k img.front { filter: drop-shadow(0 0 18px rgba(255, 20, 147, .55)); }
@keyframes spin3d {
  0% { transform: rotateY(0deg) rotateX(8deg); }
  100% { transform: rotateY(360deg) rotateX(8deg); }
}
.splash-word { width: min(220px, 60vw); opacity: .9; }
.splash-bar { width: 140px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--pink); border-radius: 3px; animation: bar 1.1s ease-in-out infinite; }
@keyframes bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { height: 26px; width: auto; display: block; }
.brand-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--pink); border: 1px solid var(--pink-line); padding: 3px 8px; border-radius: 999px;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--input); border: 1px solid var(--line); color: var(--pink);
  transition: transform .3s var(--ease);
}
.icon-btn:active { transform: scale(.9) rotate(-20deg); }
.icon-btn svg { grid-area: 1 / 1; transition: transform .5s var(--ease), opacity .4s; }
:root[data-theme="dark"] .ico-sun, :root[data-theme="light"] .ico-moon { opacity: 0; transform: rotate(-90deg) scale(.4); }

/* View Transition: círculo que se expande a partir do botão */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: reveal .6s var(--ease); }
@keyframes reveal {
  from { clip-path: circle(0 at var(--vt-x, 90%) var(--vt-y, 30px)); }
  to { clip-path: circle(150vmax at var(--vt-x, 90%) var(--vt-y, 30px)); }
}
/* Fallback sem View Transition */
html.theme-anim, html.theme-anim * { transition: background-color .5s var(--ease), color .5s var(--ease), border-color .5s var(--ease) !important; }

/* ---------- Painel ---------- */
main { padding: 16px; max-width: 760px; margin: 0 auto; }
.panel {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
  position: relative; overflow: hidden;
}
.panel::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--pink), transparent);
}
.row { display: flex; gap: 10px; }
.row.two > * { flex: 1; min-width: 0; }
.row.between { justify-content: space-between; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field select {
  appearance: none; -webkit-appearance: none;
  background: var(--input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ff1493' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 32px 12px 12px;
  font-size: 15px; font-weight: 500; color: var(--text); width: 100%;
}
.field select:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-soft); }
.field select:disabled { opacity: .5; }

.seg { display: flex; width: 100%; background: var(--input); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--muted); transition: all .25s var(--ease);
}
.seg-btn.active { background: var(--pink); color: #fff; box-shadow: 0 4px 14px rgba(255, 20, 147, .35); }

.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 46px; height: 28px; border-radius: 999px; background: var(--input); border: 1px solid var(--line); position: relative; transition: background .25s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .3s var(--ease), background .25s; }
.switch input:checked + .track { background: var(--pink); border-color: var(--pink); }
.switch input:checked + .track .thumb { transform: translateX(18px); background: #fff; }

.primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--pink), var(--pink-2));
  color: #fff; border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 18px rgba(255, 20, 147, .35); transition: transform .2s, opacity .2s;
}
.primary:active { transform: scale(.96); }
.primary:disabled { opacity: .45; box-shadow: none; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--pink-soft); color: var(--pink); }
.pill.muted { background: var(--input); color: var(--muted); }
.pill.warn { background: #ff1493; color: #fff; }

/* ---------- Status ---------- */
.status { text-align: center; color: var(--muted); font-size: 14px; padding: 18px 8px 6px; }
.status .mini-k { width: 34px; height: 50px; margin: 0 auto 10px; perspective: 300px; }
.status .mini-k img { width: 100%; height: 100%; object-fit: contain; animation: spin3d 1.4s linear infinite; }
.status strong { color: var(--text); }

/* ---------- Cards ---------- */
.results { display: grid; gap: 12px; margin-top: 8px; }
@media (min-width: 640px) { .results { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
  animation: cardIn .45s var(--ease) both;
  transition: background .35s var(--ease), border-color .35s, box-shadow .35s;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.card.called { background: var(--card-called); border-color: var(--pink-line); box-shadow: var(--glow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; }
.badge { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--pink); color: #fff; }
.addr { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.act {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 13px; font-weight: 600; padding: 9px 12px; border-radius: 10px;
  background: var(--input); border: 1px solid var(--line); color: var(--text);
  transition: transform .15s;
}
.act:active { transform: scale(.95); }
.act.wa { background: #1fae54; border-color: #1fae54; color: #fff; }
.act.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); border: 0; color: #fff; }
.act.maps svg { color: var(--pink); }
.mark {
  margin-top: 2px; width: 100%; padding: 10px; border-radius: 10px;
  border: 1px dashed var(--pink-line); background: transparent; color: var(--pink);
  font-weight: 700; font-size: 13px; transition: all .25s var(--ease);
}
.card.called .mark { border-style: solid; background: var(--pink); color: #fff; }

.more-wrap { display: flex; justify-content: center; padding: 18px 0 28px; }
.ghost {
  border: 1px solid var(--pink-line); background: var(--pink-soft); color: var(--pink);
  font-weight: 700; padding: 12px 22px; border-radius: 12px; font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600; transition: all .35s var(--ease); z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.limit-banner {
  font-size: 13px; font-weight: 600; text-align: center; line-height: 1.4;
  padding: 10px 12px; border-radius: 12px;
  background: var(--pink-soft); border: 1px solid var(--pink-line); color: var(--pink);
}
.limit-banner[hidden], .modal[hidden] { display: none; }

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 24px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s var(--ease);
}
.modal.show { opacity: 1; }
.modal-box {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--pink-line); border-radius: 22px;
  padding: 26px 22px 22px; box-shadow: var(--glow);
  transform: scale(.92); transition: transform .35s var(--ease);
}
.modal.show .modal-box { transform: scale(1); }
.modal-k { width: 38px; height: 56px; object-fit: contain; animation: spin3d 2.2s linear infinite; }
.modal-box h2 { margin: 12px 0 8px; font-size: 19px; font-weight: 800; }
.modal-box p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; color: var(--text); }
.modal-box .modal-note { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.modal-box .primary { width: 100%; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .spin-k, .status .mini-k img { animation-duration: 6s; }
  .card { animation: none; }
}
