:root {
  color-scheme: dark;
  --bg: #09090b;
  --card: #15151a;
  --muted: #9ca3af;
  --text: #f9fafb;
  --line: #2a2a33;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(34, 197, 94, 0.16), transparent 35%),
    linear-gradient(180deg, #09090b, #0f0f14);
  color: var(--text);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.card {
  width: min(460px, 100%);
  background: rgba(21, 21, 26, 0.94);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 32px var(--ok);
  flex: 0 0 auto;
}

h1 {
  font-size: 1.35rem;
  margin: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

.panel {
  display: grid;
  gap: 14px;
}

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 7px;
  color: #d1d5db;
  font-size: 0.92rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c0c11;
  color: var(--text);
  border-radius: 16px;
  padding: 15px 16px;
  font-size: 1rem;
  outline: none;
}

input:focus {
  border-color: #22c55e;
}

button {
  border: 0;
  border-radius: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s ease, filter 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary,
.secondary {
  padding: 15px 16px;
  font-size: 1rem;
}

.primary {
  background: #f9fafb;
  color: #111827;
}

.secondary {
  background: #252532;
  color: #f9fafb;
}

.hint {
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-grid > div {
  border: 1px solid var(--line);
  background: #101016;
  border-radius: 18px;
  padding: 13px;
  min-height: 70px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 7px;
}

strong {
  word-break: break-word;
}

.talk {
  height: 220px;
  border-radius: 36px;
  background:
    radial-gradient(circle at 35% 20%, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(145deg, #16a34a, #047857);
  color: white;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  box-shadow: 0 22px 60px rgba(34, 197, 94, 0.2);
  user-select: none;
  touch-action: none;
}

.talk.speaking {
  filter: brightness(1.18);
  box-shadow:
    0 0 0 8px rgba(34, 197, 94, 0.14),
    0 28px 80px rgba(34, 197, 94, 0.38);
}

.talk.blocked {
  background: linear-gradient(145deg, #b45309, #7c2d12);
}

.talk span {
  font-size: 1.2rem;
  letter-spacing: 0.04em;
}

.talk small {
  opacity: 0.85;
  font-weight: 600;
}

.details {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: #0c0c11;
}

.details summary {
  cursor: pointer;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.log {
  margin-top: 10px;
  min-height: 80px;
  max-height: 150px;
  overflow: auto;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

/* Celular: modo app pantalla completa */
@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  body {
    background: #09090b;
  }

  .app {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: block;
    padding: 0;
  }

  .card {
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .brand {
    margin-bottom: 12px;
    gap: 12px;
    flex: 0 0 auto;
  }

  h1 {
    font-size: 1.2rem;
  }

  .brand p {
    font-size: 0.86rem;
  }

  #setup.panel {
    flex: 1;
    height: 100%;
    display: grid;
    align-content: center;
    gap: 14px;
  }

  #walkie.panel {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(260px, 1fr) auto auto;
    gap: 12px;
  }

  .status-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .status-grid > div {
    min-height: 58px;
    padding: 10px;
    border-radius: 16px;
  }

  .label {
    font-size: 0.7rem;
    margin-bottom: 5px;
  }

  strong {
    font-size: 0.9rem;
  }

  .talk {
    width: 100%;
    height: 100%;
    min-height: 260px;
    border-radius: 30px;
  }

  .talk span {
    font-size: 1.12rem;
  }

  .talk small {
    font-size: 0.85rem;
  }

  .primary,
  .secondary {
    padding: 14px 15px;
    font-size: 0.95rem;
  }

  .details {
    max-height: 120px;
    overflow: auto;
    padding: 10px;
    border-radius: 16px;
  }

  .log {
    min-height: 60px;
    max-height: 78px;
    font-size: 0.72rem;
  }
}

/* Celulares bajos o en horizontal */
@media (max-width: 640px) and (max-height: 700px) {
  .brand {
    margin-bottom: 8px;
  }

  .brand p {
    display: none;
  }

  #walkie.panel {
    grid-template-rows: auto minmax(210px, 1fr) auto auto;
    gap: 8px;
  }

  .status-grid > div {
    min-height: 50px;
    padding: 8px;
  }

  .talk {
    min-height: 210px;
    border-radius: 26px;
  }

  .details {
    max-height: 90px;
  }

  .log {
    max-height: 55px;
  }
}

/* FIX fuerte para celulares táctiles, aunque el navegador reporte ancho grande */
@media (hover: none) and (pointer: coarse) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden;
    background: #09090b;
  }

  .app {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    display: block;
    padding: 0;
  }

  .card {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .brand {
    margin-bottom: 12px;
    flex: 0 0 auto;
  }

  #walkie.panel {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(280px, 1fr) auto auto;
    gap: 12px;
  }

  #setup.panel {
    flex: 1;
    min-height: 0;
    display: grid;
    align-content: center;
    gap: 14px;
  }

  .status-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .status-grid > div {
    min-height: 58px;
    padding: 10px;
    border-radius: 16px;
  }

  .talk {
    width: 100%;
    height: 100%;
    min-height: 280px;
    border-radius: 30px;
  }

  .secondary {
    width: 100%;
  }

  .details {
    max-height: 120px;
    overflow: auto;
  }

  .log {
    max-height: 75px;
    min-height: 60px;
  }
}


/* Efecto profundo de botón físico */
.talk {
  position: relative;
  border-bottom: 12px solid rgba(0, 0, 0, 0.38);
  transform: translateY(0);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    filter 0.08s ease,
    border-bottom-width 0.08s ease;
  box-shadow:
    0 18px 0 rgba(0, 0, 0, 0.22),
    0 34px 70px rgba(34, 197, 94, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.18);
}

.talk::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 35% 20%, rgba(255,255,255,0.22), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 45%);
}

.talk.speaking,
.talk:active {
  transform: translateY(12px) scale(0.985);
  border-bottom-width: 2px;
  filter: brightness(1.18);
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.32),
    0 10px 28px rgba(34, 197, 94, 0.22),
    inset 0 7px 18px rgba(0, 0, 0, 0.34),
    inset 0 -2px 0 rgba(255, 255, 255, 0.08);
}

.talk.blocked {
  border-bottom: 12px solid rgba(0, 0, 0, 0.42);
  box-shadow:
    0 18px 0 rgba(0, 0, 0, 0.22),
    0 34px 70px rgba(180, 83, 9, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.12);
}

@media (hover: none) and (pointer: coarse) {
  .talk {
    border-bottom-width: 14px;
  }

  .talk.speaking,
  .talk:active {
    transform: translateY(14px) scale(0.98);
    border-bottom-width: 2px;
  }
}

