:root {
  --bg: #0b1220;
  --panel: #151d2e;
  --ink: #e8eef8;
  --muted: #8b9bb4;
  --brand: #34d399;
  --dial: #1c2638;
  --dial-press: #243044;
  --danger: #fb7185;
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 45% at 50% -8%, rgba(52, 211, 153, 0.16), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hidden { display: none !important; }
.mono { font-family: var(--mono); }

.shell.dial-shell {
  max-width: 420px;
  margin: 0 auto;
  padding: 1.25rem 1.1rem calc(0.75rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#setup-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#setup-panel .phase,
#setup-panel .status {
  width: 100%;
  text-align: center;
}
.head {
  width: 100%;
  text-align: center;
  margin-bottom: 1.1rem;
}
.head h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.head strong { color: var(--brand); }

.staff-label,
.pin-label {
  display: block;
  width: 100%;
  margin: 0 0 0.25rem;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.15rem;
}

.auth-field {
  min-width: 0;
}

.staff-input {
  width: 100%;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.35rem;
  border-radius: 0.85rem;
  background: var(--panel);
  border: 1px solid rgba(139, 155, 180, 0.2);
  color: var(--ink);
}

.staff-input:focus,
.staff-input.is-active {
  outline: none;
  border-color: rgba(52, 211, 153, 0.75);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.15);
}

.pin-display.is-active {
  outline: none;
  border-color: rgba(52, 211, 153, 0.75);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.15);
}

.pin-display {
  width: 100%;
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  padding: 0.4rem 0.3rem;
  margin: 0;
  border-radius: 0.65rem;
  background: var(--panel);
  border: 1px solid rgba(139, 155, 180, 0.2);
  min-height: 2.35rem;
  color: var(--ink);
  font-family: var(--mono);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: default;
}
.phase {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.status {
  min-height: 1.1rem;
  margin: 0.35rem 0 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}
.status.err { color: var(--danger); }
.status.ok { color: var(--brand); }

.dial-pad {
  --dial-key: 6rem;
  --dial-gap: 0.7rem;
  display: grid;
  grid-template-columns: repeat(3, var(--dial-key));
  gap: var(--dial-gap);
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  align-self: center;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}
.dial-pad button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  width: var(--dial-key);
  height: var(--dial-key);
  padding: 0;
  background: var(--dial);
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
  transition: background 0.08s, transform 0.08s;
  user-select: none;
  touch-action: manipulation;
}
.dial-pad button sub {
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
  line-height: 1;
}
.dial-pad button:active,
.dial-pad button.pressed {
  background: var(--dial-press);
  transform: scale(0.96);
}
.dial-pad button.key-muted {
  font-size: 1.25rem;
  color: var(--muted);
}

.btn-call {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1rem;
  background: var(--brand);
  color: #052e1f;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-call:active { filter: brightness(1.05); }
.btn-call:disabled { opacity: 0.45; cursor: not-allowed; }

.setup-link, .link {
  margin-top: 0.65rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  text-align: center;
  align-self: center;
}
.setup-link:hover, .link:hover { color: var(--brand); }

.key-form {
  width: 100%;
  display: grid;
  gap: 0.55rem;
}
.key-form label {
  font-size: 0.8rem;
  color: var(--muted);
}
.key-form input {
  border: 1px solid rgba(139, 155, 180, 0.28);
  background: var(--panel);
  color: var(--ink);
  border-radius: 0.75rem;
  padding: 0.85rem 0.9rem;
  font: inherit;
  font-size: 16px;
}
.key-form input:focus {
  outline: none;
  border-color: rgba(52, 211, 153, 0.65);
}

@media (max-width: 380px) {
  .dial-pad {
    --dial-key: 5.35rem;
    --dial-gap: 0.55rem;
  }
  .dial-pad button { font-size: 1.5rem; }
}

@media (max-width: 320px) {
  .dial-pad {
    --dial-key: calc((100vw - 2.2rem - 2 * var(--dial-gap)) / 3);
  }
}
