.phone-dialer {
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 70px #0006;
  overflow: auto;
}

.phone-dialer::backdrop {
  background: #08132599;
}

.phone-dialer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phone-dialer-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.phone-dialer-heading button {
  flex: 0 0 44px;
  height: 44px;
}

.phone-dialer-mode {
  font-weight: 600;
  margin: 12px 0;
}

.phone-dialer-navigation {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.phone-dialer-navigation button {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.phone-dialer-navigation button[aria-pressed="true"] {
  background: var(--accent-strong, #2563eb);
  color: white;
}

.phone-dialer-contacts {
  display: grid;
  gap: 8px;
}

.phone-dialer-contacts button {
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  overflow-wrap: anywhere;
  min-width: 0;
}

.phone-dialer-contacts button span {
  font-size: .9rem;
}

.phone-dialer section[hidden] {
  display: none;
}

.phone-dialer input {
  width: 100%;
  margin-top: 6px;
  min-height: 48px;
  font-size: 1.35rem;
  letter-spacing: .04em;
}

.phone-dialer-number-row {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  padding-bottom: 4px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: stretch;
}

.phone-dialer-number-row input {
  min-width: 0;
}

.phone-dialer-number-row button {
  display: grid;
  place-items: center;
  margin-top: 6px;
  min-height: 48px;
  padding: 0;
  border-radius: 12px;
}

.phone-dialer-letter-preview {
  display: grid;
  place-items: center;
  margin-top: 6px;
  border: 2px solid #ffffff;
  border-radius: 12px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
}

.phone-dialer-letter-preview:empty {
  visibility: hidden;
}

.phone-dialer-hint,
.phone-dialer-error {
  margin: 8px 0 12px;
  font-size: .85rem;
  line-height: 1.45;
}

.phone-dialer-hint {
  color: var(--muted);
}

.phone-dialer-error {
  border-left: 3px solid var(--danger);
  padding-left: 10px;
}

.phone-dialer-keys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.phone-dialer-keys button {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.phone-dialer-letters {
  font-size: .75rem;
  letter-spacing: .1em;
  line-height: 1.2;
}

.phone-dialer-availability {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .9rem;
  line-height: 1.5;
}

.phone-dialer-keys button.is-holding {
  background: var(--accent-strong, #2563eb);
  color: #fff;
}

#phoneDialerCall {
  display: flex;
  width: 52px;
  height: 52px;
  margin-inline: auto;
}

@media (max-width: 600px), (max-width: 1000px) and (max-height: 500px) {
  .phone-dialer {
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: max(16px, env(safe-area-inset-top, 0px))
      max(16px, env(safe-area-inset-right, 0px))
      max(16px, env(safe-area-inset-bottom, 0px))
      max(16px, env(safe-area-inset-left, 0px));
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overscroll-behavior: contain;
  }

  #phoneDialerForm {
    max-width: 480px;
    margin: 0 auto;
  }

  .phone-dialer-keys button {
    min-height: 56px;
  }
}
