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

body {
  background-color: #e8edf5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
}

#dialer-app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ── Container ─────────────────────────────── */
.dialer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Status badge ───────────────────────────── */
.status-badge {
  background-color: #3a3d45;
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 1;
  margin-bottom: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4cd964;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Card ───────────────────────────────────── */
.dialer-card {
  background: #fff;
  border-radius: 20px;
  width: 360px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

/* ── Input section ──────────────────────────── */
.dialer-input-section {
  padding: 16px 16px 4px;
}

.dialer-input-wrapper {
  display: flex;
  align-items: center;
  background: #f4f6fa;
  border-radius: 10px;
  padding: 8px 10px;
  gap: 8px;
  position: relative;
}

.flag-dropdown-wrapper {
  position: relative;
  flex-shrink: 0;
}

.country-cc-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.country-cc-btn:hover {
  background: #eaecf0;
}

.country-cc-label {
  font-size: 13px;
  font-weight: 700;
  color: #5b90f0;
  line-height: 1;
}

.country-acronym {
  font-size: 10px;
  font-weight: 600;
  color: #8a96a8;
  letter-spacing: 0.3px;
}

.country-caret {
  font-size: 9px;
  color: #aab0be;
  line-height: 1;
  margin-left: 1px;
}

.dialer-number-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #333;
  outline: none;
  min-width: 0;
  line-height: 1.4;
}

.dialer-number-input::placeholder {
  color: #c0c5ce;
}

.clear-btn {
  background: #bcc0c8;
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
}

.clear-btn:hover {
  background: #a8adb6;
}

/* country dropdown */
.country-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e2e6ec;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
  width: 220px;
}

.country-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.country-dropdown-item:hover {
  background: #f4f6fa;
}

.country-item-cc {
  font-size: 13px;
  font-weight: 700;
  color: #5b90f0;
  min-width: 38px;
  flex-shrink: 0;
}

.country-item-name {
  font-size: 12px;
  color: #555;
}

/* ── Log message ────────────────────────────── */
.log-message {
  font-size: 11px;
  color: #a0a8b4;
  text-align: center;
  padding: 6px 0 2px;
  min-height: 20px;
}

/* ── Keypad ─────────────────────────────────── */
.keypad {
  padding: 4px 16px 8px;
}

.key-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0;
}

.key-btn {
  background: none;
  border: none;
  width: 96px;
  height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.12s;
  padding: 0;
  gap: 1px;
}

.key-btn:hover {
  background: #f0f4fa;
}

.key-btn:active {
  background: #e4ebf5;
}

.key-number {
  font-size: 28px;
  font-weight: 300;
  color: #5b90f0;
  line-height: 1.1;
}

.key-letters {
  font-size: 9px;
  color: #b0b8c8;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  height: 12px;
  line-height: 12px;
}

/* ── Phone-end icon (rotated phone) ─────────── */
.phone-end-icon {
  display: inline-block;
  transform: rotate(135deg);
}

/* ── Dark neon key number colors ───────────── */
.dark .dialer-card.neon-idle .key-number {
  color: rgba(255, 60, 65, 0.88);
}

.dark .dialer-card.neon-on .key-number {
  color: rgba(50, 220, 110, 0.9);
}

/* ── Action buttons ─────────────────────────── */
.action-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 8px 0 18px;
}

.btn-call {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #4cd964;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  transition: filter 0.15s;
  box-shadow: 0 4px 14px rgba(76, 217, 100, 0.45);
}

.btn-call.on-phone {
  background: #ff3b30;
  box-shadow: 0 4px 14px rgba(255, 59, 48, 0.45);
}

.btn-call:hover {
  filter: brightness(1.06);
}

.btn-call:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-message {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #eff2f7;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8fa0bc;
  font-size: 19px;
  transition: background 0.15s;
}

.btn-message:hover {
  background: #e3e9f3;
}

.btn-mute {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #eff2f7;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8fa0bc;
  font-size: 18px;
  transition: background 0.15s;
}

.btn-mute.muted {
  background: #ff3b30;
  color: #fff;
  box-shadow: 0 3px 10px rgba(255, 59, 48, 0.35);
}

/* ── Call via ───────────────────────────────── */
.call-via-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 14px;
  border-top: 1px solid #f0f3f8;
}

.call-via-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #8a96a8;
  white-space: nowrap;
  flex-shrink: 0;
}

.call-via-label .fa {
  color: #c0c8d4;
}

.call-via-select {
  flex: 1;
  border: 1px solid #dde2ea;
  border-radius: 8px;
  padding: 7px 30px 7px 10px;
  font-size: 13px;
  color: #333;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}

.call-via-select:focus {
  border-color: #5b90f0;
}

.call-via-flag-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #dde2ea;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: #333;
}

.call-via-flag-row .chevron {
  margin-left: auto;
  color: #8a96a8;
  font-size: 11px;
}

/* ── Bottom nav ─────────────────────────────── */
.bottom-nav {
  background: #1b2c6e;
  display: flex;
  justify-content: space-around;
  padding: 10px 4px 8px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  min-width: 52px;
  transition: color 0.15s;
}

.nav-item.active {
  color: #fff;
}

.nav-item .fa {
  font-size: 19px;
}

/* ── Misc resets ────────────────────────────── */
button:focus { outline: none; }

/* ══════════════════════════════════════════════
   DARK MODE TOGGLE BUTTON
══════════════════════════════════════════════ */
.dark-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  color: #555;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.dark-toggle:hover {
  background: rgba(0, 0, 0, 0.15);
}

.dark .dark-toggle {
  background: rgba(255, 255, 255, 0.07);
  color: #ffd060;
}

.dark .dark-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ══════════════════════════════════════════════
   DARK MODE — PAGE & CARD BASE
══════════════════════════════════════════════ */
.dark ~ * , body:has(.dark) {
  /* fallback handled below via .dark class selectors */
}

.dialer-container.dark + * {}

/* Apply dark background to body when dark mode is active */
.dark ~ body { background: #0d0f16; }

/* We can't target <body> from a child, so we use a data attribute on body
   toggled via JS — handled with the .dark class on container cascading
   via CSS :has() where supported, otherwise we colour what we can inline. */
body:has(.dialer-container.dark) {
  background-color: #0d0f16;
}

.dark .dialer-card {
  background: #12151f;
}

.dark .status-badge {
  background-color: #1e2235;
  border: 1px solid #2e3350;
}

/* ── Neon glow — idle (not on call) → red ── */
@keyframes neon-pulse-red {
  0%, 100% {
    box-shadow:
      0 0 8px  rgba(255, 45,  50, 0.45),
      0 0 22px rgba(255, 45,  50, 0.22),
      0 0 50px rgba(255, 45,  50, 0.10);
  }
  50% {
    box-shadow:
      0 0 14px rgba(255, 45,  50, 0.75),
      0 0 36px rgba(255, 45,  50, 0.40),
      0 0 70px rgba(255, 45,  50, 0.18);
  }
}

.dark .dialer-card.neon-idle {
  border: 1.5px solid rgba(255, 45, 50, 0.55);
  animation: neon-pulse-red 3s ease-in-out infinite;
}

/* ── Neon glow — on call → green ── */
@keyframes neon-pulse-green {
  0%, 100% {
    box-shadow:
      0 0 8px  rgba(50, 230, 120, 0.45),
      0 0 22px rgba(50, 230, 120, 0.22),
      0 0 50px rgba(50, 230, 120, 0.10);
  }
  50% {
    box-shadow:
      0 0 14px rgba(50, 230, 120, 0.75),
      0 0 36px rgba(50, 230, 120, 0.40),
      0 0 70px rgba(50, 230, 120, 0.18);
  }
}

.dark .dialer-card.neon-on {
  border: 1.5px solid rgba(50, 230, 120, 0.55);
  animation: neon-pulse-green 3s ease-in-out infinite;
}

/* ── Dark mode element overrides ── */
.dark .dialer-input-wrapper {
  background: #1c2030;
}

.dark .dialer-number-input {
  color: #e8ecf4;
}

.dark .dialer-number-input::placeholder {
  color: #3d4460;
}

.dark .country-cc-btn:hover {
  background: #252b3d;
}

.dark .country-cc-label {
  color: #5b90f0;
}

.dark .country-acronym {
  color: #4a5880;
}

.dark .country-caret {
  color: #3a4460;
}

.dark .country-item-cc {
  color: #5b90f0;
}

.dark .country-item-name {
  color: #8892b0;
}

.dark .clear-btn {
  background: #3d4460;
}

.dark .clear-btn:hover {
  background: #505878;
}

.dark .log-message {
  color: #4a5270;
}

.dark .country-dropdown-menu {
  background: #1a1e2e;
  border-color: #2a3050;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.dark .country-dropdown-item {
  color: #c8d0e0;
}

.dark .country-dropdown-item:hover {
  background: #222840;
}

.dark .key-btn:hover {
  background: #1c2030;
}

.dark .key-btn:active {
  background: #222840;
}

.dark .key-number {
  color: #5b90f0;
}

.dark .key-letters {
  color: #3a4260;
}

.dark .btn-message {
  background: #1c2030;
  color: #4a5880;
}

.dark .btn-message:hover {
  background: #222840;
}

.dark .btn-mute {
  background: #1c2030;
  color: #4a5880;
}

.dark .call-via-section {
  border-top-color: #1c2030;
}

.dark .call-via-label {
  color: #4a5270;
}

.dark .call-via-label .fa {
  color: #2e3555;
}

.dark .call-via-flag-row {
  border-color: #2a3050;
  color: #c8d0e0;
}

.dark .call-via-flag-row .chevron {
  color: #4a5270;
}

.dark .bottom-nav {
  background: #0b0e17;
}