:root {
  --bg: #eef2f9; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --blue: #3b82f6; --green: #16a34a; --red: #dc2626; --amber: #d97706; --key: #f1f5f9; --key-hover: #e2e8f0;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #111a2e; --text: #e6ecf7; --muted: #8a98b3; --line: #22304d; --key: #182238; --key-hover: #1f2d4b; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* No zooming on a phone: a quick second tap on a key must not zoom the page (touch-action), and text fields are 16px or more (iOS zooms into smaller ones). */
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: manipulation; overscroll-behavior: none; }
button, input, label, a { touch-action: manipulation; }
button { font: inherit; }
.pad button, .tab, .btn, .pillbtn, .icon, .recent li { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* the phone is one fixed screen: header, the current screen, and the menu at the bottom */
.app { height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; flex: none; }
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand #brandText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--blue); color: #fff; font-size: 15px; flex: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex: none; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status[data-state="online"] .dot { background: var(--green); } .status[data-state="online"] { color: var(--green); }
.status[data-state="connecting"] .dot { background: var(--amber); } .status[data-state="connecting"] { color: var(--amber); }
.status[data-state="error"] .dot { background: var(--red); } .status[data-state="error"] { color: var(--red); }
.callbar { display: flex; align-items: center; justify-content: space-between; margin: 0 16px 8px; padding: 8px 12px; background: var(--green); color: #fff; border-radius: 12px; flex: none; font-weight: 600; }
main { flex: 1; min-height: 0; position: relative; }
.screen { height: 100%; display: flex; flex-direction: column; padding: 0 16px 12px; min-height: 0; }
.screenhead { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 10px; flex: none; }
h1 { font-size: 20px; margin: 0 0 12px; } h2 { font-size: 20px; margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=tel], input:not([type]) { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 14px 0; }
label.check input { width: 18px; height: 18px; }
.login { justify-content: center; padding-bottom: 12vh; }

.btn { border: 0; border-radius: 999px; padding: 13px 22px; font-size: 16px; font-weight: 600; cursor: pointer; color: #fff; }
.btn.primary { background: var(--blue); } .btn.call { background: var(--green); } .btn.call.hang { background: var(--red); }
.btn.decline { background: var(--red); } .btn.ghost { background: var(--key); color: var(--text); } .btn.ghost.on { background: var(--amber); color: #fff; }
.btn.wide { width: 100%; } .btn:disabled { opacity: .55; }
.pillbtn { border: 0; border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600; background: var(--key); color: var(--text); cursor: pointer; flex: none; }
.pillbtn.hang { background: #fff; color: var(--red); }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; font-size: 14px; padding: 0; }
.error { color: var(--red); font-size: 14px; margin: 8px 0 0; text-align: center; }

/* keypad screen */
.display { display: flex; align-items: center; gap: 6px; flex: none; }
.display input { font-size: 26px; text-align: center; letter-spacing: .5px; border: 0; background: transparent; padding: 8px 4px; }
.display input:focus { outline: none; }
.icon { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; padding: 6px 10px; }
.callstate { text-align: center; color: var(--muted); font-size: 14px; min-height: 22px; flex: none; }
.callstate.live { color: var(--green); font-weight: 600; }
.pad { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 10px; margin: 8px 0 12px; max-height: 420px; }
.pad button { background: var(--key); color: var(--text); border: 0; border-radius: 18px; font-size: 26px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; min-height: 0; }
.pad button:active { background: var(--key-hover); transform: scale(.97); }
.pad small { font-size: 9px; letter-spacing: 1.5px; color: var(--muted); margin-top: 2px; min-height: 11px; }
.actions { display: flex; align-items: center; justify-content: center; gap: 12px; flex: none; }
.actions .btn.call { min-width: 150px; }
@media (max-height: 640px) { .pad button { font-size: 22px; } .btn { padding: 10px 20px; } }

/* recent calls */
.recentscreen .recent { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.recent li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.recent li:first-child { border-top: 0; }
.recent .num { font-weight: 600; } .recent .meta { color: var(--muted); font-size: 12px; }
.recent .in { color: var(--green); } .recent .out { color: var(--blue); } .recent .miss { color: var(--red); }
.recent .dial { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--green); color: #fff; font-size: 18px; cursor: pointer; }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* settings */
.who { display: flex; align-items: baseline; gap: 6px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.setrow + .setrow { border-top: 1px solid var(--line); }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; z-index: 1; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--key-hover); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green); } .switch input:checked + span::after { transform: translateX(20px); }

/* the menu at the bottom */
.tabs { flex: none; display: flex; border-top: 1px solid var(--line); background: var(--card); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; cursor: pointer; position: relative; }
.tab .ico { font-size: 20px; line-height: 1; }
.tab.on { color: var(--blue); }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--red); color: #fff; font-style: normal; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px; text-align: center; }

/* an incoming call */
.incoming { position: fixed; inset: 0; background: rgba(2, 6, 23, .78); display: grid; place-items: center; z-index: 10; padding: 16px; }
.ring-card { background: var(--card); border-radius: 22px; padding: 26px 22px; width: 100%; max-width: 340px; text-align: center; }
.ring-title { color: var(--muted); font-size: 14px; }
.ring-from { font-size: 26px; font-weight: 700; margin: 8px 0 22px; word-break: break-all; }
[hidden] { display: none !important; }
