:root {
  --bg: #070b16;
  --ink: #f4fbff;
  --muted: #9bb0c7;
  --cyan: #5ce1e6;
  --pad: linear-gradient(165deg, #e9fff6 0%, #fff6d8 45%, #ffe8f2 78%, #e7f1ff 100%);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
}

input,
textarea,
[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}

.stars {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(92, 225, 230, 0.16), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(255, 196, 120, 0.1), transparent 26%),
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 18%, #cfefff, transparent),
    radial-gradient(1px 1px at 40% 80%, #fff, transparent),
    radial-gradient(1px 1px at 88% 42%, #fff, transparent);
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: calc(var(--safe-top) + 8px) 14px 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.gear-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(92, 225, 230, 0.12);
  color: var(--cyan);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 12px;
  font-weight: 600 !important;
}

.check-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--cyan);
  flex: 0 0 auto;
}

.settings-help {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  font-weight: 400;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.brand {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--cyan);
}

.home {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 72px);
  padding: 8px 16px calc(var(--safe-bottom) + 8px);
}

#flash-btn {
  position: relative;
  z-index: 3;
  width: min(78vw, 300px);
  height: min(78vw, 300px);
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(92, 225, 230, 0.2), transparent 58%),
    radial-gradient(circle at 50% 50%, rgba(7, 11, 22, 0.15), rgba(7, 11, 22, 0.85) 70%);
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px rgba(92, 225, 230, 0.18),
    0 22px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.flash-core {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 16px 24px;
  background:
    radial-gradient(circle at 32% 28%, #b7fbff 0%, #5ce1e6 28%, #14b8c9 58%, #0a5f78 100%);
  box-shadow:
    0 0 0 10px rgba(92, 225, 230, 0.18),
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 10px 18px rgba(255, 255, 255, 0.28),
    inset 0 -22px 34px rgba(0, 20, 40, 0.42);
  overflow: hidden;
  transform: translateZ(0);
}

.bolt {
  display: grid;
  place-items: center;
  color: #fff7d6;
  line-height: 0;
  filter:
    drop-shadow(0 3px 0 rgba(0, 40, 60, 0.35))
    drop-shadow(0 0 14px rgba(255, 255, 255, 0.55));
  transform: translateY(-2px);
}

.bolt svg {
  width: clamp(52px, 18vw, 78px);
  height: auto;
  display: block;
}

.cadete-mark {
  width: min(78%, 190px);
  height: auto;
  display: block;
  border-radius: 12px;
  opacity: 1;
  transform: translateY(2px);
  box-shadow:
    0 8px 18px rgba(0, 18, 36, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.16);
  filter: none;
  pointer-events: none;
  image-rendering: auto;
}

@media (min-width: 768px) {
  #flash-btn {
    width: min(42vw, 380px);
    height: min(42vw, 380px);
  }

  .flash-core {
    inset: 22px;
    gap: 12px;
    padding: 28px 22px 32px;
  }

  .bolt svg {
    width: 96px;
  }

  .cadete-mark {
    width: min(72%, 230px);
  }
}

.app-watermark,
.hint {
  display: none;
}

.status-line {
  min-height: 0;
  margin: 0;
  text-align: center;
  color: var(--cyan);
  font-size: 0.95rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(90vw, 340px);
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(16, 24, 42, 0.96);
  border: 1px solid rgba(92, 225, 230, 0.35);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.toast.ok {
  border-color: rgba(92, 225, 230, 0.55);
  color: var(--cyan);
}

.toast.err {
  border-color: rgba(255, 100, 120, 0.55);
  color: #ffb3be;
}

.about-card {
  width: min(92vw, 380px);
  background: #10182a;
  border: 1px solid rgba(92, 225, 230, 0.25);
  border-radius: 28px;
  padding: 12px 22px 28px;
  text-align: center;
}

.about-title {
  margin: 4px 0 18px;
  font-size: clamp(1.7rem, 7vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: 0.04em;
  font-weight: 800;
  color: var(--ink);
}

.about-btn-img {
  width: min(48vw, 180px);
  height: auto;
  display: block;
  margin: 0 auto 18px;
  border-radius: 50%;
  box-shadow:
    0 0 0 8px rgba(92, 225, 230, 0.14),
    0 16px 36px rgba(0, 0, 0, 0.4);
}

.about-legal {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: var(--ink);
}

.about-legal span {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: none;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(92, 225, 230, 0.35);
  animation: pulse 2.2s ease-out infinite;
}

#flash-btn:active .flash-core,
#flash-btn.holding .flash-core {
  transform: scale(0.95);
}

.badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ff4d6d;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: grid;
  place-items: center;
}

.hint {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.status-line.legacy {
  min-height: 1.4em;
  margin: 14px 24px 0;
  text-align: center;
  color: var(--cyan);
  font-size: 0.95rem;
}

.overlay,
.pad {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 8, 16, 0.62);
  display: grid;
  place-items: start center;
  align-content: start;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: transparent;
  pointer-events: none;
}

.install-banner .install-card {
  pointer-events: auto;
  position: relative;
  margin: 0 auto;
  max-height: 46vh;
  overflow: auto;
}

.install-x {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.12) !important;
  color: var(--ink) !important;
}

.hidden {
  display: none !important;
}

.install-card,
.settings-card,
.pad-screen {
  width: min(92vw, 380px);
}

.install-card,
.settings-card {
  background: #10182a;
  border: 1px solid rgba(92, 225, 230, 0.25);
  border-radius: 28px;
  padding: 28px 22px 24px;
  text-align: center;
}

.install-card h1,
.settings-card h2 {
  margin: 12px 0 8px;
  font-size: 1.35rem;
}

.install-card p,
.muted {
  color: var(--muted);
  line-height: 1.45;
}

.btn-primary,
.chat-form button,
.settings-card button[type="submit"] {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #7af0f5, #2db8c4);
  color: #062026;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
}

.btn-ghost {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.ios-steps {
  text-align: left;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.6;
  padding-left: 22px;
}

.ios-share {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
}

.pad-screen {
  height: min(62vh, 430px);
  background: var(--pad);
  border-radius: 30px;
  box-shadow:
    0 0 40px rgba(255, 255, 220, 0.45),
    0 20px 50px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  color: #243044;
  overflow: hidden;
}

.pad-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px;
}

.pad-head p,
.pad-head h2 {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  color: #243044;
  font-size: 1.2rem;
  cursor: pointer;
}

.chat-list {
  flex: 1;
  overflow: auto;
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.35;
  user-select: text;
}

.bubble.cliente {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.78);
}

.bubble.operador,
.bubble.sistema {
  align-self: flex-start;
  background: rgba(36, 80, 90, 0.12);
}

.bubble small {
  display: block;
  margin-top: 4px;
  opacity: 0.65;
  font-size: 0.72rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

.chat-form input,
.settings-card input,
.settings-card textarea {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 1.05rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.8);
  color: #1b2433;
}

.settings-card {
  text-align: left;
  max-height: none;
  margin-top: 8px;
}

.settings-card .pad-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #10182a;
  padding-top: 4px;
  margin-bottom: 4px;
}

.save-chip {
  min-width: 72px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  background: linear-gradient(180deg, #7af0f5, #2db8c4);
  color: #062026;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.settings-card label {
  display: block;
  margin: 14px 0;
  color: var(--ink);
  font-weight: 700;
}

.settings-card textarea {
  resize: none;
}

.route-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-card select {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 1.05rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.8);
  color: #1b2433;
}

.empty-chat {
  margin: auto;
  text-align: center;
  opacity: 0.7;
  padding: 20px;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

@media (display-mode: standalone),
  (display-mode: fullscreen),
  (display-mode: minimal-ui) {
  #install-overlay {
    display: none !important;
  }
}
