:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #242833;
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --green: #30c85e;
  --red: #ff3b30;
  --blue: #2f7cf6;
  --bubble-in: #262a33;
  --bubble-out: #2f7cf6;
  --accent: #f4a261;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

#app { position: relative; height: 100dvh; max-width: 480px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px); }
.screen.active { display: flex; }

/* Avatar */
.avatar { position: relative; display: grid; place-items: center; border-radius: 50%; font-weight: 600;
  background: linear-gradient(135deg, #f4a261, #e76f51); color: #fff; flex: none; }
.avatar-sm { width: 36px; height: 36px; font-size: 16px; }
.avatar-lg { width: 112px; height: 112px; font-size: 48px; }
.avatar-xl { width: 140px; height: 140px; font-size: 60px; }

/* Home */
.home-header { text-align: center; margin-top: 48px; }
.home-header .avatar { margin: 0 auto 16px; }
.home-header h1 { margin: 0; font-size: 30px; font-weight: 600; }
.home-header p { margin: 4px 0 0; }
.home-actions { display: flex; justify-content: center; gap: 40px; margin: 40px 0 32px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; }
.action-icon { position: relative; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; }
.action-icon.green { background: var(--green); }
.action-icon.blue { background: var(--blue); }
.action-icon svg { width: 28px; height: 28px; }
.badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.card { background: var(--surface); border-radius: 16px; padding: 14px 16px; }
.card p { margin: 0; }
.push-card { margin-bottom: 12px; }
.push-card p + p { margin-top: 6px; }
.push-card .primary { width: 100%; margin-top: 12px; padding: 11px; font-size: 15px; }
.link-btn { margin-top: auto; color: var(--muted); font-size: 14px; text-decoration: underline; padding: 12px; }

/* Call */
.call { background: radial-gradient(120% 80% at 50% 0%, #2a2f3d 0%, #0f1115 70%); }
.call-top { text-align: center; margin-top: 72px; }
.call-top .avatar { margin: 0 auto 20px; }
.call-top h2 { margin: 0; font-size: 32px; font-weight: 500; }
.call-top p { margin: 6px 0 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.caption { min-height: 3em; margin: 24px 8px 0 !important; color: var(--text); font-size: 16px !important; opacity: .85; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0;
  transform: scale(var(--lvl, 1)); transition: transform .08s linear; }
.speaking .ring { opacity: .55; }
.speaking .ring.r2 { opacity: .25; transform: scale(calc(var(--lvl, 1) * 1.12)); }
.ringing .ring { animation: pulse 1.6s ease-out infinite; }
.ringing .ring.r2 { animation-delay: .8s; }
@keyframes pulse { from { opacity: .6; transform: scale(1); } to { opacity: 0; transform: scale(1.5); } }

.call-controls, .call-incoming { margin-top: auto; }
.call-controls .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 12px; margin-bottom: 36px; }
.call-incoming { display: flex; justify-content: space-around; margin-bottom: 24px; }
.round { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; }
.round svg { width: 64px; height: 64px; padding: 18px; border-radius: 50%; box-sizing: border-box; }
.round.ghost svg { background: rgba(255,255,255,.14); }
.round.ghost[aria-pressed="true"] svg { background: #fff; color: #111; }
.round.green svg { background: var(--green); }
.round.red svg { background: var(--red); }
.round.big { margin: 0 auto 8px; }
.round.big svg { width: 72px; height: 72px; padding: 20px; }

/* SMS */
.sms { padding: 0; }
.sms-header { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-top) + 10px) 12px 10px;
  background: var(--surface); border-bottom: 1px solid #2a2e38; }
.sms-title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); }
.thread { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 10px 0 6px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 6px; }
.bubble.call-log { align-self: center; background: none; color: var(--muted); font-size: 13px; }
.meta { font-size: 11px; color: var(--muted); margin: 0 6px 6px; }
.meta.out { align-self: flex-end; }
.typing { align-self: flex-start; background: var(--bubble-in); border-radius: 18px; padding: 12px 14px; display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px calc(var(--safe-bottom) + 8px);
  background: var(--surface); border-top: 1px solid #2a2e38; }
.composer textarea { flex: 1; resize: none; max-height: 120px; padding: 9px 14px; border-radius: 20px; border: 1px solid #343946;
  background: var(--bg); color: var(--text); font: inherit; outline: none; }
.send { width: 38px; height: 38px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .35; }
.send svg { width: 20px; height: 20px; }

/* Dostęp i zgody */
.gate { margin-top: 40px; }
.gate p + p { margin-top: 8px; }
.invite { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.invite input { padding: 14px; border-radius: 14px; border: 1px solid #343946; background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; outline: none; }
.balance { display: inline-block; margin-top: 12px !important; padding: 4px 12px; border-radius: 999px;
  background: var(--surface); font-size: 14px; font-variant-numeric: tabular-nums; }
.balance.low { color: var(--accent); }
.consent-header { display: flex; align-items: center; gap: 12px; margin: 24px 0 8px; }
.consent-header h2 { margin: 0; font-size: 24px; font-weight: 600; }
.consent { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.consent label { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); padding: 14px; border-radius: 14px; }
.consent input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--green); }
.primary { margin-top: 8px; padding: 14px; border-radius: 14px; background: var(--green); font-weight: 600; font-size: 17px; }

.toast { position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 24px); background: var(--surface-2);
  padding: 12px 16px; border-radius: 12px; font-size: 14px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
