:root {
  --green: #086fe5;
  --line: #d9e4ee;
  --muted: #536b7d;
  --panel: #fff;
  color: #20394e;
  background: #f2f7fb;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body { min-height: 100dvh; background: radial-gradient(ellipse at 0 0, #dceeff 0, transparent 48%), #f2f7fb; }
button { min-height: 40px; border-radius: 9px; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover { background: #edf5fc; border-color: #a9c9e4; }
button:disabled { opacity: 1; color: #65798a; border-color: #d9e4ee; background: #f0f4f7; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #147ce1; outline-offset: 3px; }
input, select, textarea { border-color: #bccfde; }
input:focus, select:focus, textarea:focus { border-color: #1679da; }
.primary { background: #086fe5; border-color: #086fe5; color: #fff; box-shadow: 0 3px 8px #087bff16; }
.primary:hover { background: #075fc5; border-color: #075fc5; }
.danger { background: #b72f3c; border-color: #b72f3c; color: #fff; }
.danger:hover { background: #9f2531; border-color: #9f2531; }
.text-button { color: #0967c3; }
.muted { line-height: 1.6; }
.logo { background: linear-gradient(135deg, #078bdc, #0865d3); border-radius: 10px; box-shadow: 0 3px 9px #087bff1c; }
.top { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px; }
.top .actions { gap: 12px; }
.user-chip { max-width: 190px; overflow: hidden; text-overflow: ellipsis; padding: 5px 10px; border-radius: 7px; background: #f2f6fa; font-weight: 600; }
.connection-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #466278; white-space: nowrap; }
.connection-state::before { content: ''; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #8899a8; }
.connection-state.is-connected::before { background: #168269; }
.connection-state.is-connecting { color: #895707; }
.connection-state.is-connecting::before { background: #b87608; }
.layout { grid-template-columns: 176px minmax(0, 1fr); }
.nav { background: #f8fbfe; border-right: 1px solid var(--line); padding: 24px 12px; }
.nav-label { color: #62798a; letter-spacing: .04em; padding-bottom: 16px; }
.nav button { color: #405d74; padding: 12px 14px; border: 1px solid transparent; font-size: 14px; }
.nav button:hover { background: #eaf3fb; }
.nav button.active { color: #0860bb; background: #e2effe; border-color: #c7dff7; box-shadow: inset 3px 0 0 #0874e8; font-weight: 600; }
.main { max-width: 1560px; padding: 24px; }
.heading { margin-bottom: 20px; }
.heading h1 { font-weight: 650; letter-spacing: .02em; }
.heading p { line-height: 1.6; }
.panel, .desk { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 5px 18px #254f7110; }
.panel { padding: 22px; }
.pill { background: #e7f1ff; color: #1760a8; border-radius: 6px; padding: 3px 8px; font-weight: 500; }
.pill.success { background: #e7f5ef; color: #12654e; }
.pill.neutral { background: #edf1f5; color: #536677; }
.gold { background: #fff2d9; color: #865408; }
.badge { background: #0871d9; font-weight: 600; }
.avatar { border-radius: 10px; background: #e7f2fc; border: 1px solid #d7e7f4; }

/* Account cards put identity, permissions and actions in distinct rows. */
.accounts-panel { padding: 8px 22px; }
.account-row { padding: 22px 0; }
.account-heading { display: flex; gap: 12px; align-items: center; }
.account-avatar { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: 12px; background: #e8f2ff; color: #1264b8; font-size: 21px; font-weight: 650; }
.account-title { flex: 1; min-width: 0; }
.account-title h3 { font-weight: 650; overflow-wrap: anywhere; }
.account-title .muted { margin-top: 3px; }
.account-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.setting-group { border: 1px solid #dfe8f0; border-radius: 10px; background: #f8fbfe; padding: 11px 14px; }
.setting-group > small, .setting-label { display: block; font-size: 12px; color: #536b7d; margin-bottom: 5px; }
.setting-group .check { min-height: 30px; color: #2b455b; }
.check input { flex-shrink: 0; }
.account-footer { display: flex; grid-column: 1 / -1; justify-content: space-between; align-items: center; gap: 12px; margin-top: 2px; }
.account-row .account-footer .actions { margin-top: 0; }
.account-footer .actions { gap: 8px; }
.account-footer button { font-size: 13px; }
.entry-url { background: #f2f7fc; border: 1px solid #dce8f2; color: #405f78; }

/* Empty states give the next step a clear place without overwhelming the desk. */
.empty-state { padding: 48px 22px; text-align: center; color: var(--muted); align-self: center; }
.empty-action { padding: 48px 22px; text-align: center; color: var(--muted); align-self: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 16px; background: #eaf3fd; color: #337fbd; border: 1px solid #d7e9f8; border-radius: 16px; font-size: 26px; }
.empty-action .empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 16px; background: #eaf3fd; color: #337fbd; border: 1px solid #d7e9f8; border-radius: 16px; font-size: 26px; }
.empty-state h3 { font-size: 17px; font-weight: 600; color: #294b65; margin-bottom: 7px; }
.empty-action h3 { font-size: 17px; font-weight: 600; color: #294b65; margin-bottom: 7px; }
.empty-state p { max-width: 380px; margin: 0 auto; font-size: 13px; line-height: 1.8; }
.empty-action p { max-width: 380px; margin: 0 auto; font-size: 13px; line-height: 1.8; }
.empty-state button { margin-top: 20px; }
.empty-action button { margin-top: 20px; }
.empty-state.compact { padding-top: 26px; padding-bottom: 26px; }
.empty-action.compact { padding-top: 26px; padding-bottom: 26px; }
.sessions .empty-state { padding: 32px 16px; }
.sessions .empty-action { padding: 32px 16px; }
.sessions .empty-state .empty-icon { width: 42px; height: 42px; font-size: 20px; border-radius: 12px; }
.sessions .empty-action .empty-icon { width: 42px; height: 42px; font-size: 20px; border-radius: 12px; }
.sessions .empty-state h3 { font-size: 14px; }
.sessions .empty-action h3 { font-size: 14px; }
.sessions .empty-state p { font-size: 12px; }
.sessions .empty-action p { font-size: 12px; }
.desk > .empty-state { padding: 60px 22px; }
.desk > .empty-action { padding: 60px 22px; }

/* Compact business information stays separate from the conversation. */
.desk-heading { margin-bottom: 16px; }
.desk-summary { display: flex; align-items: center; gap: 18px; padding: 8px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.desk-summary > span { display: inline-flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 12px; }
.desk-summary b { color: #245275; font-size: 20px; font-weight: 650; }
.identity-tabs { gap: 9px; margin-bottom: 16px; }
.identity-tabs button { background: #fff; border-color: #d6e3ee; padding: 9px 13px; font-size: 14px; }
.identity-tabs button.active { background: #eaf4ff; border-color: #8ebef0; color: #095daa; box-shadow: inset 0 -2px 0 #1680e3; font-weight: 600; }
.identity-tabs .avatar { width: 32px; height: 32px; font-size: 19px; border-radius: 8px; }
.desk { grid-template-columns: 232px minmax(0, 1fr); min-height: 570px; }
.sessions { background: #f8fafc; border-right: 1px solid var(--line); }
.sessions-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #3a5972; padding: 16px; min-height: 56px; font-weight: 600; border-bottom: 1px solid var(--line); }
.sessions-title > span:last-child { padding: 1px 7px; min-width: 24px; text-align: center; border-radius: 5px; background: #e7eef5; color: #466278; font-size: 12px; }
.sessions-list { padding: 6px 0; }
.session { width: calc(100% - 14px); margin: 3px 7px; border: 1px solid transparent; border-radius: 9px; padding: 12px 10px; gap: 9px; }
.session:hover { background: #edf4fb; border-color: #d9e7f2; }
.session.active { background: #e2f0ff; border-color: #a9d0f7; box-shadow: inset 3px 0 0 #086fe5; }
.session .copy { overflow: hidden; }
.session .copy > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .preview { max-width: 100%; color: #526d83; margin-top: 3px; }
.session .avatar { width: 36px; height: 36px; font-size: 21px; }
.chat { background: #f4f8fc; }
.chat-head { padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-heading { display: flex; gap: 10px; align-items: center; min-width: 0; }
.chat-heading > div { min-width: 0; }
.chat-head h3 { font-weight: 650; overflow-wrap: anywhere; }
.chat-heading .muted { margin-top: 2px; }
.call-control { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.call-button { background: #eef6ff; color: #0b66bd; border-color: #c2dcf4; font-size: 13px; min-height: 36px; padding: 7px 12px; }
.call-button:disabled { background: #f2f5f8; border-color: #dce4ec; color: #607386; }
.call-hint { color: #5d7183; font-size: 11px; line-height: 1.4; }
.casebar { background: #fcfdff; border-bottom: 1px solid var(--line); padding: 10px 20px; }
.casebar-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.case-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.source-label { color: #536b7d; overflow-wrap: anywhere; }
.casebar .actions { gap: 6px; }
.casebar button { min-height: 32px; background: #fff; border-color: #d6e2ec; }
.casebar button:hover { background: #eaf3fc; }
.case-note { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 12px; line-height: 1.6; color: #4f687c; white-space: normal; }
.case-note > label, .case-note > span:first-child { flex-shrink: 0; font-size: 11px; color: #5b7284; }
.case-note > span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.messages { height: min(44dvh, 460px); min-height: 240px; background: #f1f7fc; padding: 20px; }
.chat-intro { width: fit-content; max-width: 100%; margin: 0 auto 20px; padding: 5px 11px; color: #526d82; background: #e6eff7; border-radius: 7px; font-size: 12px; line-height: 1.6; text-align: center; }
.message { margin-bottom: 18px; gap: 10px; }
.message .avatar { border-radius: 9px; }
.bubble { background: #fff; border: 1px solid #dce7f0; border-radius: 3px 12px 12px 12px; box-shadow: 0 2px 5px #37577306; padding: 10px 13px; line-height: 1.65; color: #20394e; }
.mine .bubble { background: #d9f1ec; border-color: #bce3da; border-radius: 12px 3px 12px 12px; color: #1d5048; }
.msg-time { color: #536d82; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 10px 18px 14px; }
.tools { gap: 8px; }
.tools button { min-height: 36px; border-radius: 7px; padding: 5px 8px; color: #466278; }
.tools button:hover { background: #eaf3fd; color: #075ead; }
.composer textarea { display: block; background: #f8fbfe; border: 1px solid #dbe6ee; border-radius: 8px; min-height: 66px; padding: 10px 12px; margin: 6px 0 9px; outline: none; }
.composer textarea:focus { border-color: #3389dc; outline: 2px solid #c5e0fa; outline-offset: 1px; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.composer .primary { min-width: 82px; min-height: 38px; font-size: 14px; }
.send-hint { color: #5c7182; font-size: 12px; }
.send-hint-mobile { display: none; }
.readonly { background: #fff; border-top: 1px solid var(--line); }

body[data-view='guest'] { background: #eaf2f9; }
.guest-shell { max-width: 700px; min-height: 100dvh; background: #fff; border-left: 1px solid #d6e3ef; border-right: 1px solid #d6e3ef; box-shadow: 0 8px 36px #28587b12; }
.guest-shell .chat { height: 100dvh; min-height: 0; }
.guest-shell .chat-head { padding: 14px 17px; flex: 0 0 auto; }
.guest-shell .chat-head .avatar { width: 43px; height: 43px; border-radius: 12px; }
.guest-shell .messages { height: auto; flex: 1 1 auto; min-height: 0; background: linear-gradient(160deg, #edf6fd, #eef8f6); }
.guest-shell .composer { position: static; flex: 0 0 auto; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.guest-shell .composer textarea { min-height: 60px; max-height: 120px; }
.guest-footer { color: #597185; font-size: 11px; padding-top: 7px; }

body[data-view='login'] { background: radial-gradient(ellipse at 8% 12%, #bfe1ff 0, transparent 50%), radial-gradient(ellipse at 93% 86%, #bcece3 0, transparent 50%), #f2f9ff; }
body[data-view='login'] #app { display: grid; place-items: center; min-height: 100dvh; padding: 28px 16px; }
.login { width: 100%; max-width: 430px; margin: 0 auto; padding: 32px; border: 1px solid #fff; border-radius: 20px; background: #fffffff5; box-shadow: 0 20px 60px #245d8920; gap: 19px; }
.login .brand { margin-bottom: 5px; }
.login h2 { margin-bottom: 5px; font-weight: 650; font-size: 24px; color: #244660; }
.login-heading { padding-bottom: 2px; }
.login-intro { font-size: 13px; color: #536b7d; line-height: 1.7; }
.login label { font-weight: 500; }
.login input { min-height: 46px; }
.login .primary { min-height: 46px; font-size: 15px; font-weight: 600; }
.login-help { padding: 12px 14px; border: 1px solid #e0eaf3; border-radius: 9px; background: #f5f9fd; color: #506a80; font-size: 12px; line-height: 1.8; }
.login-help p + p { margin-top: 3px; }
.login .error:empty { display: none; }
.error { color: #a32935; }
dialog { background: #fff; box-shadow: 0 24px 65px #1e405833; border: 1px solid #d3e2ee; border-radius: 16px; }
dialog::backdrop { background: #163b596b; }
#call-modal { background: linear-gradient(140deg, #eef7ff, #e8f8f3); }
#toast { background: #254a66; }
[data-action='message-sound'] { background: #f2f8fe; border-color: #ccdfef; color: #226498; font-size: 12px; min-height: 36px; padding: 7px 10px; }
[data-action='message-sound'][aria-pressed='false'] { color: #5a6d7d; background: #f2f5f8; }

@media (max-width: 1100px) {
  .top .actions { gap: 8px; }
  .main { padding: 20px; }
  .desk { grid-template-columns: 215px minmax(0, 1fr); }
  .chat-head { padding: 13px 16px; }
  .casebar { padding: 10px 16px; }
}
@media (max-width: 950px) {
  .layout { grid-template-columns: 1fr; }
  .nav { background: #fff; padding: 8px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav button { padding: 9px 12px; }
  .nav button.active { box-shadow: none; border-radius: 8px; }
  .main { padding: 18px; }
  .top { padding: 12px 18px; flex-wrap: wrap; }
  .desk-summary { gap: 12px; }
}
@media (max-width: 600px) {
  button { min-height: 44px; }
  .top { padding: 12px; gap: 10px; }
  .top .actions { width: 100%; gap: 7px; font-size: 12px; }
  .top .connection-state { margin-right: auto; }
  .top .actions > button { padding: 7px 9px; font-size: 12px; }
  .user-chip { max-width: 110px; }
  .nav { gap: 5px; padding: 8px 12px; }
  .nav button { flex: 1 0 auto; justify-content: center; font-size: 13px; padding: 8px 10px; }
  .main { padding: 14px 12px; }
  .heading { gap: 12px; margin-bottom: 16px; }
  .heading h1 { font-size: 22px; }
  .heading p { font-size: 13px; }
  .panel { padding: 16px; border-radius: 12px; }
  .accounts-panel { padding: 0 16px; }
  .account-row { padding: 18px 0; }
  .account-heading { gap: 10px; }
  .account-settings { grid-template-columns: 1fr; gap: 9px; margin-top: 14px; }
  .setting-group { padding: 8px 12px; }
  .setting-group .check { min-height: 35px; }
  .account-footer { flex-wrap: wrap; gap: 8px; }
  .account-footer .actions { width: 100%; }
  .account-footer button { flex: 1; }
  .desk-heading .desk-summary { width: 100%; justify-content: flex-start; }
  .desk-summary { padding: 7px 12px; }
  .identity-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .identity-tabs button { padding: 8px; gap: 7px; font-size: 13px; }
  .identity-tabs .avatar { width: 30px; height: 30px; font-size: 18px; }
  .desk { grid-template-columns: 1fr; min-height: 0; border-radius: 12px; }
  .sessions { border-right: 0; border-bottom: 1px solid var(--line); }
  .sessions-title { padding: 10px 13px; min-height: 42px; font-size: 13px; }
  .sessions-list { padding: 6px; gap: 5px; }
  .session { flex: 0 0 auto; width: auto; max-width: 210px; min-width: 128px; margin: 0; padding: 9px 10px; }
  .session .copy > div:first-child { max-width: 150px; font-size: 13px; }
  .sessions .empty-state, .sessions .empty-action { width: 100%; padding: 18px 12px; }
  .sessions .empty-state .empty-icon, .sessions .empty-action .empty-icon { display: none; }
  .sessions .empty-state h3, .sessions .empty-action h3 { margin-bottom: 3px; }
  .desk > .empty-state, .desk > .empty-action { padding: 38px 18px; }
  .chat-head { padding: 12px; gap: 9px; flex-wrap: nowrap; }
  .chat-head h3 { font-size: 16px; }
  .chat-heading { gap: 8px; }
  .chat-heading .muted { font-size: 12px; }
  .call-button { min-height: 44px; padding: 7px 10px; font-size: 12px; }
  .call-hint { font-size: 10px; }
  .casebar { padding: 10px 12px; }
  .casebar .row.between { gap: 8px; }
  .casebar .actions { gap: 6px; }
  .casebar button { min-height: 44px; padding: 7px 10px; }
  .case-note { gap: 6px; margin-top: 7px; flex-wrap: wrap; }
  .messages { padding: 18px 12px; min-height: 250px; }
  .chat-intro { margin-bottom: 18px; }
  .message { gap: 8px; }
  .bubble { padding: 10px 12px; }
  .composer { padding: 7px 10px 12px; }
  .tools { gap: 2px; justify-content: flex-start; flex-wrap: wrap; }
  .tools button { min-height: 44px; padding: 6px 8px; font-size: 13px; }
  .composer textarea { min-height: 60px; padding: 9px 10px; margin: 2px 0 8px; }
  .composer .primary { min-height: 44px; min-width: 82px; }
  .send-hint-desktop { display: none; }
  .send-hint-mobile { display: inline; }
  .guest-shell { border: 0; box-shadow: none; }
  .guest-shell .chat-head { padding: 12px; }
  .guest-shell .chat-head .avatar { width: 38px; height: 38px; border-radius: 10px; }
  .guest-shell .call-button { max-width: 112px; }
  .guest-shell .messages { min-height: 0; height: auto; }
  .guest-shell .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .guest-footer { font-size: 10px; padding-top: 6px; }
  .login { max-width: 430px; width: 100%; padding: 25px 23px; margin: 0; }
  .login-help { padding: 10px 12px; }
  [data-action='message-sound'] { min-height: 44px; }
  dialog { padding: 22px; }
}
@media (max-width: 360px) {
  .top .connection-state { width: 100%; }
  .tools { gap: 0; }
  .tools button { padding-left: 6px; padding-right: 6px; font-size: 12px; }
  .guest-shell .chat-head { padding: 10px; }
  .guest-shell .chat-head .avatar { width: 34px; height: 34px; }
  .guest-shell h3 { font-size: 15px; }
  .call-button { padding: 6px 8px; }
  .call-hint { max-width: 106px; text-align: right; }
  .identity-tabs button { gap: 5px; font-size: 12px; }
  .identity-tabs .avatar { width: 26px; height: 26px; font-size: 16px; }
  .account-heading { flex-wrap: wrap; }
  .account-title { min-width: 125px; }
  .desk-summary { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* local preview while an image uploads */
.upload-preview{align-self:flex-end;display:flex;flex-direction:column;align-items:flex-end;gap:4px;margin:6px 0}
.upload-preview img{max-width:200px;max-height:200px;border-radius:10px;opacity:.65}
.message.sending{opacity:.6}
