:root {
  --bg: #eef3f2; --card: #ffffff; --text: #0f1f1d; --muted: #5b6b68; --line: #dbe4e2;
  --accent: #0f766e; --accent-ink: #ffffff; --key: #f3f7f6; --key-hover: #e6eeec;
  --green: #16a34a; --red: #dc2626; --amber: #d97706; --shadow: 0 10px 30px rgba(15, 31, 29, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1211; --card: #121c1b; --text: #e6efed; --muted: #93a5a1; --line: #22302e;
    --accent: #2dd4bf; --accent-ink: #062320; --key: #1a2625; --key-hover: #223231;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.app { max-width: 420px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h3 { font-size: 16px; margin: 18px 0 6px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand p { margin: 2px 0 0; }

/* forms */
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
label input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--key); color: var(--text); font-size: 17px;
}
label input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.error { color: var(--red); font-size: 14px; margin: -4px 0 12px; }
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.call { background: var(--green); color: #fff; font-size: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.wide { width: 100%; }
.link { background: none; border: 0; color: var(--accent); padding: 14px 0 0; font-size: 15px; width: 100%; text-align: center; }
.chip { border: 1px solid var(--line); background: var(--key); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip:hover { background: var(--key-hover); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--key); font-size: 17px; line-height: 1; }
.icon-btn:hover { background: var(--key-hover); }

/* phone */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.top-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.me { font-weight: 700; font-size: 18px; }
.status { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.number-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.number {
  flex: 1; min-width: 0; border: 0; border-bottom: 2px solid var(--line); background: transparent;
  font-size: 30px; font-weight: 600; text-align: center; padding: 6px 4px; letter-spacing: .04em;
}
.number:focus { outline: none; border-bottom-color: var(--accent); }
.number::placeholder { font-size: 18px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.keypad button {
  border: 0; background: var(--key); border-radius: 16px; height: 62px; font-size: 26px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.keypad button small { font-size: 10px; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.keypad button:hover { background: var(--key-hover); }
.keypad button:active { transform: scale(.97); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.recent { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent .who { flex: 1; min-width: 0; }
.recent .who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .who span { font-size: 13px; color: var(--muted); }
.recent .missed b { color: var(--red); }
.recent .dir { width: 22px; text-align: center; color: var(--muted); }

/* call screen */
.call-screen {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center;
  padding: calc(48px + env(safe-area-inset-top)) 20px calc(36px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #0f766e 0%, #0b3b37 100%); color: #fff; text-align: center;
}
.avatar {
  width: 96px; height: 96px; border-radius: 50%; background: rgba(255, 255, 255, .16);
  display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 700; margin-bottom: 16px;
}
.call-screen.ringing .avatar { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .35); } 50% { box-shadow: 0 0 0 18px rgba(255, 255, 255, 0); } }
.c-name { font-size: 26px; font-weight: 700; max-width: 100%; overflow-wrap: anywhere; }
.c-state { opacity: .85; margin-top: 4px; font-variant-numeric: tabular-nums; }
.c-keys { margin-top: 18px; width: 100%; max-width: 300px; }
.dtmf-shown { min-height: 28px; font-size: 22px; letter-spacing: .1em; }
.small-pad button { height: 52px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 22px; }
.small-pad button:hover { background: rgba(255, 255, 255, .22); }
.c-actions { display: flex; gap: 18px; margin-top: auto; margin-bottom: 26px; }
.c-main { display: flex; gap: 48px; }
.round {
  width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; gap: 2px;
}
.round span { font-size: 22px; line-height: 1; filter: grayscale(1) brightness(10); }
.round[aria-pressed=true] span { filter: grayscale(1) brightness(.25); }
.round b { font-weight: 500; }
.round[aria-pressed=true] { background: #fff; color: #0b3b37; }
.round.big { width: 78px; height: 78px; }
.round.answer { background: var(--green); }
.round.hangup { background: var(--red); }
.round.hangup span { transform: rotate(135deg); display: inline-block; }

/* help dialog */
dialog { border: 0; border-radius: 20px; padding: 0; max-width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.help { padding: 22px; max-height: 85vh; overflow: auto; }
.help h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 20px; }
.help table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help th { text-align: left; font-weight: 600; padding: 7px 10px 7px 0; vertical-align: top; color: var(--muted); width: 40%; }
.help td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.help th { border-bottom: 1px solid var(--line); }
.help ul { padding-left: 18px; font-size: 14px; }
.help li { margin-bottom: 6px; }
.help p { font-size: 14px; }
code { background: var(--key); border-radius: 6px; padding: 1px 6px; font-size: .92em; }
.right { text-align: right; margin-top: 12px; }
