:root {
  color-scheme: light;
  --ink: #111b21;
  --muted: #667781;
  --line: #e6e9e9;
  --panel: #f7f8f8;
  --chat: #ebe8df;
  --sent: #dcf8c6;
  --green: #25d366;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: #e8ebec; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: wait; }
:focus-visible { outline: 2px solid #128c7e; outline-offset: 2px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.layout { min-height: 100dvh; display: flex; }
.sidebar { width: 304px; flex: none; padding: 23px 18px; background: var(--panel); border-right: 1px solid #dce1e2; transition: width .2s ease, padding .2s ease; }
.sidebar-toggle { margin-bottom: 34px; }
.icon-button { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #56656c; }
.icon-button:hover, .icon-button:focus-visible { background: #e8ecec; }
.sidebar-actions { display: flex; flex-direction: column; gap: 12px; }
.candidate-picker { position: relative; }
.picker-row { display: flex; align-items: center; gap: 8px; }
.search-field { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 46px; padding: 0 5px 0 12px; border: 1px solid #d7dede; border-radius: 10px; background: white; }
.search-field:focus-within { border-color: #8fcbb3; }
.search-field > .icon { width: 17px; height: 17px; color: #839198; }
.search-field input { width: 0; min-width: 0; flex: 1; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-field input::placeholder { color: #8b969b; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.chevron-button { width: 28px; height: 32px; border-radius: 7px; }
.chevron-button .icon { width: 16px; height: 16px; transition: transform .18s ease; }
.candidate-picker.open .chevron-button .icon { transform: rotate(180deg); }
.add-button { width: 46px; height: 46px; flex: none; border-radius: 10px; background: #e4f5e9; color: #116b4b; }
.add-button:hover, .switch-button:hover { background: #d5efdf; }
.candidate-options { position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; width: 100%; max-height: min(430px, calc(100dvh - 155px)); overflow-y: auto; padding: 5px; border: 1px solid #dce3e2; border-radius: 11px; background: white; box-shadow: 0 12px 30px #203a3222; scrollbar-width: thin; }
.candidate-option { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; min-height: 54px; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; }
.candidate-option:hover, .candidate-option.highlighted { background: #f0f5f2; }
.candidate-option[aria-selected="true"] { background: #e3f5e9; }
.candidate-option-name { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.candidate-option-phone { color: var(--muted); font-size: 12px; }
.candidate-option:not(:has(.candidate-option-name)) .candidate-option-phone { color: var(--ink); font-size: 13px; }
.candidate-empty { padding: 14px 10px; color: var(--muted); font-size: 12px; }
.new-number-form { display: flex; gap: 7px; margin-top: 10px; }
.new-number-form input { width: 0; min-width: 0; flex: 1; height: 42px; padding: 0 12px; border: 1px solid #d7dede; border-radius: 9px; background: white; color: var(--ink); font-size: 13px; }
.switch-button { width: 42px; height: 42px; flex: none; border-radius: 9px; background: #e6f6ec; color: #116b4b; }
.directory-error { margin: 9px 0 0; color: #a2463d; font-size: 12px; line-height: 1.4; }
.chat-actions { display: flex; flex-direction: column; gap: 7px; }
.chat-actions button { min-height: 38px; padding: 7px 10px; border: 1px solid #d7dede; border-radius: 8px; background: white; color: #116b4b; text-align: left; font-size: 12px; }
.chat-actions button:hover:not(:disabled) { background: #e6f6ec; }
.chat-actions button:disabled { color: var(--muted); cursor: default; }
.action-status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.action-status:empty { display: none; }
.receipts:empty { display: none; }
.receipts { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 11px; font-size: 12px; line-height: 1.4; color: #a2463d; overflow-wrap: anywhere; }
.receipts p { margin: 0 0 8px; }
.sidebar.collapsed { width: 72px; padding-inline: 14px; }
.sidebar.collapsed .sidebar-toggle { margin-inline: 0; }
.sidebar.collapsed .sidebar-actions { display: none; }

.stage { flex: 1; min-width: 0; min-height: 100dvh; display: grid; place-items: center; padding: 25px; }
.phone-shell { width: min(432px, 100%); height: min(842px, calc(100dvh - 50px)); min-height: 480px; padding: 7px; background: #293136; border: 1px solid #1f282d; border-radius: 38px; box-shadow: 0 22px 52px #2a3a3c21, 0 3px 8px #26363914; }
.phone-screen { position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden; background: var(--chat); border-radius: 31px; }
.phone-sensor { flex: none; height: 24px; background: #f7f8f8; position: relative; }
.phone-sensor::after { content: ""; position: absolute; width: 68px; height: 5px; top: 9px; left: calc(50% - 34px); background: #cbd1d2; border-radius: 10px; }
.chat-header { height: 66px; flex: none; display: flex; align-items: center; gap: 11px; padding: 0 17px; background: #f7f8f8; border-bottom: 1px solid #e9eded; }
.mobile-sidebar-toggle { display: none; }
.chat-header strong { font-size: 16px; font-weight: 600; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #d8e9df; color: #24694a; font-size: 18px; font-weight: 600; }
.connection { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: #abb6ba; }
.connection.connected { background: var(--green); }
.connection.disconnected { background: #d55c51; }
#messages { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; padding: 20px 16px 24px; background-color: var(--chat); background-image: radial-gradient(#7e89831a .7px, transparent .7px); background-size: 19px 19px; scrollbar-width: thin; }
.message { position: relative; align-self: flex-start; max-width: 82%; padding: 8px 10px 6px; border-radius: 2px 9px 9px 9px; background: #fff; box-shadow: 0 1px 1px #42504c17; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.42; }
.message::before { content: ""; position: absolute; left: -6px; top: 0; width: 9px; height: 11px; background: inherit; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.message.in { align-self: flex-end; background: var(--sent); border-radius: 9px 2px 9px 9px; }
.message.in::before { left: auto; right: -6px; transform: scaleX(-1); }
.message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1; white-space: nowrap; }
.message-meta .checks { font-size: 13px; letter-spacing: -3px; padding-right: 3px; }
.message-meta .checks.read { color: #34b7f1; }
.message audio, .message img { display: block; max-width: 100%; }
.message img { max-height: 300px; border-radius: 5px; }
.message button { display: block; width: 100%; min-height: 38px; margin-top: 8px; border: 1px solid #cbd9d2; background: transparent; color: #166e60; border-radius: 6px; font-size: 13px; }
#error { flex: none; margin: 0 8px 7px; padding: 8px 11px; border-radius: 8px; background: #fff1ed; color: #a93f33; font-size: 12px; }
#error:empty { display: none; }
.composer { flex: none; display: flex; align-items: flex-end; gap: 3px; padding: 9px 10px 13px; background: #f7f8f8; }
.composer textarea { flex: 1; min-width: 0; height: 42px; max-height: 120px; resize: none; padding: 11px 8px; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 14px; line-height: 20px; }
.composer textarea::placeholder { color: #88949a; }
.composer .icon-button { width: 39px; height: 42px; flex: none; }
.composer .icon-button:hover { background: #e8ecec; }
.record-button.recording { color: #d55c51; background: #f9e7e5; }
.send-button { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: var(--green); color: #075e54; }
.send-button:hover { background: #1fc15a; }
.send-button .icon { width: 19px; height: 19px; margin-left: 2px; }

.login-stage { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-shell { width: min(400px, 100%); min-height: min(650px, calc(100dvh - 48px)); padding: 7px; border: 1px solid #1f282d; border-radius: 38px; background: #293136; box-shadow: 0 22px 52px #2a3a3c21, 0 3px 8px #26363914; }
.login-screen { display: flex; flex-direction: column; min-height: calc(min(650px, 100dvh - 48px) - 14px); overflow: hidden; border-radius: 31px; background: #f7f8f8; }
.login-content { display: flex; flex: 1; flex-direction: column; justify-content: center; padding: 36px 32px 68px; }
.login-avatar { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 50%; background: #d8e9df; color: #24694a; font-size: 25px; font-weight: 600; }
.login-content h1 { margin: 0 0 36px; text-align: center; font-size: 24px; font-weight: 600; letter-spacing: -.03em; }
.login-form { display: flex; flex-direction: column; }
.login-form label { margin: 0 0 8px; color: #56656c; font-size: 12px; }
.login-form input { width: 100%; height: 48px; margin-bottom: 19px; padding: 0 14px; border: 1px solid #d7dede; border-radius: 9px; background: white; color: var(--ink); font-size: 15px; }
.login-form input:focus { border-color: #8fcbb3; outline: 2px solid #8fcbb3; outline-offset: 1px; }
.login-form button { height: 48px; margin-top: 12px; border: 0; border-radius: 9px; background: var(--green); color: #075e54; font-weight: 600; }
.login-form button:hover { background: #1fc15a; }
.login-error { margin: -3px 0 5px; color: #a93f33; font-size: 12px; }

@media (max-width: 720px) {
  .layout { display: block; }
  .stage { padding: 0; }
  .phone-shell { width: 100%; height: 100dvh; min-height: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .phone-screen { border-radius: 0; }
  .phone-sensor { display: none; }
  .chat-header { padding-left: 10px; }
  .mobile-sidebar-toggle { display: inline-grid; margin-right: 2px; }
  .sidebar, .sidebar.collapsed { position: fixed; z-index: 30; inset: 0; width: 100%; height: 100dvh; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 0; box-shadow: none; visibility: hidden; pointer-events: none; transform: translateX(-100%); transition: transform .24s cubic-bezier(.2, .75, .25, 1), visibility .24s; }
  .sidebar:not(.collapsed) { visibility: visible; pointer-events: auto; transform: translateX(0); }
  .sidebar-toggle { margin: 0 0 25px -3px; }
  .sidebar.collapsed .sidebar-toggle { margin: 0 0 25px -3px; }
  .sidebar-actions { display: flex; padding: 0; }
  .candidate-options { position: static; width: 100%; max-height: calc(100dvh - 155px); margin-top: 10px; box-shadow: none; }
  .login-stage { padding: 0; }
  .login-shell { width: 100%; min-height: 100dvh; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .login-screen { min-height: 100dvh; border-radius: 0; }
  .login-content { padding-inline: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .sidebar .chevron-button .icon { transition: none; }
}

.scenarios-title { font-size: 1.2rem; margin: 0 0 1rem; }
.sidebar-actions details { margin-top: 1rem; font-size: .85rem; line-height: 1.5; }
.sidebar-actions > button { margin-bottom: .6rem; }
