:root {
  color-scheme: dark;
  --bg: #050a13;
  --card: #0d1728;
  --card-soft: #111e33;
  --line: rgba(148, 163, 184, .18);
  --text: #f8fafc;
  --muted: #9ca9bd;
  --cyan: #24d7ec;
  --blue: #3478f6;
  --green: #2bd576;
  --red: #f24f5f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 90% -5%, rgba(52, 120, 246, .22), transparent 28rem),
    radial-gradient(circle at 0 35%, rgba(36, 215, 236, .08), transparent 25rem),
    var(--bg);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.app-shell { width: min(560px, 100%); min-height: 100vh; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 14px max(30px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 4px 10px; }
.brand { font-size: 1.08rem; font-weight: 950; letter-spacing: .15em; }
.brand-sub { margin-top: 2px; color: #68e9f7; font-size: .65rem; font-weight: 800; letter-spacing: .12em; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: rgba(17, 30, 51, .8); }
.card { padding: 24px; border: 1px solid var(--line); border-radius: 28px; background: rgba(13, 23, 40, .96); box-shadow: 0 22px 65px rgba(0, 0, 0, .3); }
h1 { margin: 4px 0 12px; font-size: clamp(1.65rem, 7vw, 2.25rem); letter-spacing: -.04em; }
h2 { margin: 8px 0 5px; font-size: 1.35rem; }
p { color: var(--muted); line-height: 1.55; }
.step-mark { width: max-content; margin-bottom: 12px; padding: 6px 10px; border-radius: 999px; color: #9ff4fc; background: rgba(36, 215, 236, .1); font-size: .78rem; font-weight: 800; }
label { display: grid; gap: 7px; margin: 15px 0; font-weight: 800; }
input { width: 100%; min-height: 52px; padding: 12px 15px; color: var(--text); border: 1px solid var(--line); border-radius: 16px; outline: none; background: #07101f; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(36, 215, 236, .1); }
.primary { border: 0; border-radius: 999px; color: white; font-weight: 900; background: linear-gradient(135deg, var(--cyan), var(--blue)); box-shadow: 0 12px 30px rgba(52, 120, 246, .22); }
.wide { width: 100%; min-height: 54px; }
button:disabled { opacity: .42; cursor: not-allowed; }
button:active { transform: translateY(1px); }
.dialer-card { padding-top: 30px; text-align: center; }
.dialer-card h1 { margin-bottom: 24px; }
.search-wrap { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 17px; border: 1px solid var(--line); border-radius: 19px; background: #07101f; }
.search-wrap span { color: var(--muted); font-size: 1.7rem; transform: rotate(-20deg); }
.search-wrap input { min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
.contact-results { display: grid; gap: 8px; margin-top: 10px; text-align: left; }
.contact-result { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 16px; background: var(--card-soft); }
.contact-result .result-avatar, .contact-avatar { display: grid; place-items: center; width: 43px; height: 43px; flex: 0 0 auto; border-radius: 50%; color: #04131b; background: linear-gradient(135deg, #6ee7f2, #60a5fa); font-weight: 950; }
.contact-result strong, .contact-result small { display: block; }
.contact-result small { margin-top: 3px; color: var(--muted); }
.selected-contact { display: flex; align-items: center; gap: 13px; margin-top: 17px; padding: 14px; border: 1px solid rgba(36, 215, 236, .28); border-radius: 19px; text-align: left; background: rgba(36, 215, 236, .07); }
.selected-contact > div:nth-child(2) { min-width: 0; flex: 1; }
.selected-contact strong, .selected-contact span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-contact span { margin-top: 4px; color: var(--muted); font-size: .86rem; }
.clear-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: rgba(148, 163, 184, .12); font-size: 1.3rem; }
.call-button { width: 100%; min-height: 66px; margin-top: 20px; font-size: 1.18rem; }
.phone-icon { display: inline-block; margin-right: 8px; color: white; transform: rotate(-28deg); }
.simple-note { margin: 14px 4px 0; font-size: .87rem; }
.call-card { position: relative; display: flex; flex-direction: column; height: calc(100dvh - 92px); min-height: 520px; padding: 0; overflow: hidden; text-align: left; }
.call-head { z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 70px; padding: 13px 17px; border-bottom: 1px solid var(--line); background: rgba(13, 23, 40, .98); }
.call-peer { min-width: 0; }
.call-peer > strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.language-status { display: flex; align-items: center; gap: 5px; margin-top: 5px; color: var(--muted); font-size: .69rem; font-weight: 750; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px rgba(36, 215, 236, .1); }
.call-time { flex: 0 0 auto; text-align: right; }
.call-time span, .call-time strong { display: block; }
.call-time span { color: var(--muted); font-size: .65rem; }
.call-time strong { margin-top: 2px; font-size: .92rem; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.conversation-feed { flex: 1 1 auto; min-height: 0; padding: 18px 14px 126px; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; }
.conversation-empty { display: grid; place-items: center; min-height: 100%; padding: 32px; color: var(--muted); text-align: center; font-size: .88rem; line-height: 1.55; }
.message-row { display: flex; align-items: flex-end; gap: 7px; width: 100%; margin: 8px 0; }
.message-row.message--mine { justify-content: flex-end; }
.message-stack { display: grid; gap: 4px; max-width: min(82%, 390px); }
.message-row.message--mine .message-stack { justify-items: end; }
.message-meta { display: flex; align-items: center; gap: 5px; padding: 0 4px; color: var(--muted); font-size: .65rem; }
.message-ai-badge { display: inline-flex; align-items: center; min-height: 17px; padding: 2px 5px; border: 1px solid rgba(36, 215, 236, .25); border-radius: 5px; color: #9ff4fc; background: rgba(36, 215, 236, .08); font-size: .59rem; font-weight: 900; letter-spacing: .06em; }
.message-bubble { padding: 10px 13px; border: 1px solid var(--line); border-radius: 6px 17px 17px 17px; color: var(--text); background: #111e33; font-size: .94rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 5px 15px rgba(0, 0, 0, .12); }
.message--mine .message-bubble { border-color: rgba(52, 120, 246, .35); border-radius: 17px 6px 17px 17px; background: linear-gradient(145deg, #2367d9, #2859ba); }
.message--pending .message-bubble { color: #c7d2e3; opacity: .78; }
.incoming-actions { position: absolute; top: 50%; right: 14px; left: 14px; z-index: 3; padding: 16px; border: 1px solid var(--line); border-radius: 18px; text-align: center; background: rgba(7, 16, 31, .97); box-shadow: 0 18px 50px rgba(0, 0, 0, .32); transform: translateY(-50%); }
.incoming-actions > p { padding: 12px; border-radius: 14px; background: rgba(36, 215, 236, .07); }
.action-grid { display: flex; justify-content: center; gap: 56px; margin: 27px 0 12px; }
.round-action { display: grid; place-items: center; width: 72px; height: 72px; border: 0; border-radius: 50%; font-size: 1.2rem; }
.round-action span { position: absolute; margin-top: 105px; color: var(--muted); font-size: .85rem; }
.round-action.decline { background: var(--red); }
.round-action.accept { background: var(--green); }
.live-panel { position: absolute; inset: auto 14px 96px; z-index: 3; pointer-events: none; }
#remoteAudio { display: none; }
.progress-line { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.takeover-button { width: 100%; min-height: 42px; border: 1px solid rgba(36, 215, 236, .32); border-radius: 13px; color: #b8f8fc; background: rgba(8, 30, 49, .96); pointer-events: auto; font-size: .82rem; font-weight: 850; box-shadow: 0 9px 28px rgba(0, 0, 0, .28); }
.takeover-button span { margin-right: 6px; }
.call-dock { position: absolute; inset: auto 0 0; z-index: 4; display: grid; grid-template-columns: 54px 54px minmax(82px, 1fr) auto; align-items: stretch; gap: 7px; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(7, 16, 31, .98); backdrop-filter: blur(16px); }
.dock-button { display: grid; place-items: center; min-width: 0; min-height: 56px; padding: 6px 3px; border: 1px solid var(--line); border-radius: 15px; background: var(--card-soft); }
.dock-button > span { font-size: 1.15rem; line-height: 1; }
.dock-button small { color: #d8e1ee; font-size: .61rem; font-weight: 800; }
.dock-button:disabled { opacity: .45; }
.call-state { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; padding: 0 9px; border: 1px solid rgba(43, 213, 118, .24); border-radius: 15px; color: #a8f2c8; background: rgba(43, 213, 118, .07); text-align: center; }
.call-state span { transform: rotate(-18deg); }
.call-state strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; }
.end-button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 56px; padding: 0 13px; border: 0; border-radius: 15px; color: white; background: var(--red); font-size: .76rem; font-weight: 900; white-space: nowrap; }
.end-button span { font-size: .75rem; }
.recovery { position: absolute; z-index: 5; right: 14px; bottom: 88px; left: 14px; padding: 12px; color: var(--muted); text-align: left; border: 1px solid var(--line); border-radius: 14px; background: #07101f; font-size: .8rem; }
.recovery input { min-height: 40px; margin-top: 10px; font-size: .75rem; }
.text-btn { margin-top: 7px; padding: 6px 9px; border: 0; color: #9beff7; background: transparent; }
.result-card { padding-top: 45px; text-align: center; }
.result-icon { display: grid; place-items: center; width: 80px; height: 80px; margin: 0 auto 20px; border-radius: 50%; color: #052818; background: #72edaa; font-size: 2rem; font-weight: 950; }
.result-card .wide { margin-top: 20px; }
.lab-status { margin: 14px 8px 0; color: #5f6d81; font-size: .72rem; }
.lab-status summary { cursor: pointer; }
.lab-status div { margin-top: 5px; }

@media (max-width: 480px) {
  .app-shell { padding-left: 9px; padding-right: 9px; }
  .card { padding: 20px 17px; border-radius: 24px; }
  body.call-screen-active { overflow: hidden; }
  body.call-screen-active .app-shell { padding: 0; }
  body.call-screen-active .topbar { display: none; }
  .call-card { height: 100dvh; min-height: 100dvh; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .conversation-feed { padding-right: 11px; padding-left: 11px; }
  .message-stack { max-width: 86%; }
  .end-button { padding-right: 10px; padding-left: 10px; }
}

@media (max-width: 350px) {
  .call-dock { grid-template-columns: 48px 48px minmax(62px, 1fr) auto; gap: 5px; padding-right: 6px; padding-left: 6px; }
  .dock-button, .end-button { min-height: 52px; border-radius: 13px; }
  .end-button { gap: 4px; padding-right: 8px; padding-left: 8px; font-size: .7rem; }
  .call-state { gap: 4px; padding: 0 5px; }
  .call-state strong { font-size: .68rem; }
}
