/* ============================================================
   Dial Practice — styles
   Dependency-free. Sizing driven by --scale (set from JS).
   ============================================================ */

:root {
  --scale: 1;                 /* set by the size slider */
  --bg: #0b1020;
  --bg-2: #141b30;
  --panel: #1b2236;
  --key-bg: #2a3350;
  --key-bg-active: #3a456b;
  --text: #f2f5ff;
  --muted: #9aa6c7;
  --accent: #3ddc84;          /* call green */
  --danger: #ff5d5d;
  --target: #ffd24d;
  --radius: 18px;
  --key-size: calc(72px * var(--scale));
  --key-gap: calc(14px * var(--scale));
  --digit-size: calc(30px * var(--scale));
  --display-size: calc(40px * var(--scale));
}

/* High contrast theme */
body.hc {
  --bg: #000000;
  --bg-2: #000000;
  --panel: #0a0a0a;
  --key-bg: #ffffff;
  --key-bg-active: #ffe600;
  --text: #ffffff;
  --muted: #d0d0d0;
}
body.hc .key { color: #000; border: 3px solid #fff; }
body.hc .display { color: #fff; }

/* Extra large text */
body.large {
  --digit-size: calc(40px * var(--scale));
  --display-size: calc(52px * var(--scale));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2), var(--bg));
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  min-height: 52px;
}
.app-title { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: .3px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 24px;
  width: 48px; height: 48px;
  border-radius: 12px;
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: rgba(255,255,255,.08); }

/* ---------- Target banner ---------- */
.target-banner {
  text-align: center;
  background: rgba(255,210,77,.12);
  border: 1px solid rgba(255,210,77,.35);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.target-label { display: block; font-size: 13px; color: var(--muted); }
.target-name { display: block; font-size: 16px; font-weight: 600; color: var(--target); }
.target-number {
  display: block;
  font-size: calc(26px * var(--scale));
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--target);
}
.target-banner.done {
  background: rgba(61,220,132,.15);
  border-color: rgba(61,220,132,.5);
}

/* ---------- Display ---------- */
.display-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: calc(64px * var(--scale));
  padding: 4px 0;
}
.display {
  font-size: var(--display-size);
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  min-height: 1.2em;
  word-break: break-all;
  line-height: 1.1;
}
.display:empty::before {
  content: "Enter a number";
  color: var(--muted);
  font-weight: 400;
  font-size: calc(20px * var(--scale));
  letter-spacing: normal;
}
.backspace-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: calc(28px * var(--scale));
  cursor: pointer;
  padding: 8px;
  flex: 0 0 auto;
}
.backspace-btn:active { color: var(--text); }

/* ---------- Pad ---------- */
.pad-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--key-gap);
}
.pad {
  display: grid;
  grid-template-columns: repeat(3, var(--key-size));
  gap: var(--key-gap);
  justify-content: center;
}
.key {
  width: var(--key-size);
  height: var(--key-size);
  border-radius: 50%;
  border: none;
  background: var(--key-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform .06s ease, background .1s ease;
}
.key:active, .key.pressed {
  background: var(--key-bg-active);
  transform: scale(.94);
}
.key .digit { font-size: var(--digit-size); font-weight: 600; }
.key .letters {
  font-size: calc(10px * var(--scale));
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-top: 2px;
  min-height: 1em;
}
body.no-letters .key .letters { display: none; }
body.no-letters .key .digit { font-size: calc(34px * var(--scale)); }

/* ---------- Action row ---------- */
.action-row {
  display: grid;
  grid-template-columns: var(--key-size) var(--key-size) var(--key-size);
  gap: var(--key-gap);
  align-items: center;
  justify-items: center;
}
.action-spacer { width: var(--key-size); }
.call-btn {
  width: var(--key-size);
  height: var(--key-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(61,220,132,.35);
}
.call-btn:active { transform: scale(.94); }
.call-icon { font-size: calc(30px * var(--scale)); }
.clear-btn {
  width: var(--key-size);
  height: var(--key-size);
  border-radius: 50%;
  border: none;
  background: var(--key-bg);
  color: var(--muted);
  font-size: calc(26px * var(--scale));
  cursor: pointer;
}
.clear-btn:active { background: var(--key-bg-active); color: var(--text); }

/* ---------- Calling overlay ---------- */
.calling-screen {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, #0a1f15, #08111d);
  display: grid; place-items: center;
  z-index: 50;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.calling-inner { text-align: center; padding: 24px; }
.calling-avatar {
  font-size: 84px;
  width: 140px; height: 140px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  display: grid; place-items: center;
}
.calling-name { font-size: 28px; font-weight: 600; }
.calling-number { font-size: 18px; color: var(--muted); margin-top: 6px; letter-spacing: 1px; }
.calling-status { font-size: 16px; color: var(--accent); margin-top: 18px; min-height: 1.2em; }
.hangup-btn {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  margin-top: 40px;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(255,93,93,.4);
}
.hangup-btn .call-icon { transform: rotate(135deg); font-size: 34px; }

/* ---------- Panels (settings / contacts) ---------- */
.panel {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
.panel-card {
  background: var(--panel);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.panel-header h2 { margin: 0; font-size: 20px; }
.panel-body { overflow-y: auto; padding: 8px 18px 24px; -webkit-overflow-scrolling: touch; }

.group {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 14px 0 0;
}
.group legend { padding: 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.sub { margin-top: 8px; padding-left: 6px; border-left: 2px solid rgba(255,255,255,.1); }

.toggle, .row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  font-size: 16px;
  cursor: pointer;
}
.row { justify-content: space-between; }
.toggle input[type=checkbox] {
  width: 26px; height: 26px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer;
}
.toggle span { flex: 1; }
.row-val { display: block; text-align: right; padding-right: 4px; }
input[type=range] { width: 60%; accent-color: var(--accent); height: 28px; }

.text-input, .pin-input {
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
  width: 55%;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }

.btn {
  background: var(--key-bg);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
}
.btn:active { background: var(--key-bg-active); }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.btn-danger { background: rgba(255,93,93,.18); color: var(--danger); }

/* ---------- Contacts ---------- */
.contacts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
}
.contact-tile {
  background: var(--key-bg);
  border: none;
  border-radius: 16px;
  padding: 16px 10px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.contact-tile:active { background: var(--key-bg-active); }
.contact-tile .avatar { font-size: 40px; display: block; }
.contact-tile .c-name { font-size: 16px; font-weight: 600; margin-top: 6px; }
.contact-tile .c-num { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Contact editor rows in settings */
.editor-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.editor-row input { width: 100%; }
.editor-row .emoji-input { text-align: center; }
.editor-row .del { background: transparent; border: none; color: var(--danger); font-size: 22px; cursor: pointer; }

.lock-gate { padding: 8px 4px; }
.pin-row { display: flex; gap: 10px; margin-top: 8px; }
.pin-input { width: auto; flex: 1; }
