:root {
  font: 14px/1.5 system-ui, sans-serif;
  color: #182b24;
  background: #f6f8f7;
  --green: #08694e;
  --muted: #586b63;
  --line: #e2ebe6;
  --panel: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
p, small { color: var(--muted); }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button {
  border: 0;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 600;
  background: var(--green);
  color: #fff;
}
button:hover:not(:disabled) { filter: brightness(.94); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid #008e65; outline-offset: 2px; }
input, select, textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: inherit;
  padding: 10px 12px;
}
input, textarea { width: 100%; }
label { display: block; font-weight: 600; }
label input { display: block; margin-top: 6px; }
.secondary, #back, #resolve, .icon-button {
  color: var(--green);
  background: #edf5f0;
}
.brandmark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #fff;
  background: var(--green);
  font-size: 20px;
  font-weight: 800;
}
#login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 380px); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.login-card > * + * { margin-top: 14px; }
.login-card small { display: block; letter-spacing: .1em; }
.login-card h1 { font-size: 25px; line-height: 1.2; }
.login-card button { width: 100%; }
.login-art { display: none; }
#loginError, #accountError, .delivery-error { color: #9b3a28; }
#workspace { display: flex; height: 100dvh; overflow: hidden; background: #fff; }
nav { width: 60px; flex: 0 0 60px; padding: 13px 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; background: #f3f7f4; border-right: 1px solid var(--line); }
nav button { display: grid; place-items: center; width: 40px; height: 40px; padding: 8px; color: #52665c; background: transparent; }
nav button.nav-active { background: #dceee3; color: var(--green); }
nav svg { width: 23px; height: 23px; stroke: currentColor; stroke-width: 1.7; fill: #f3f7f4; stroke-linecap: round; stroke-linejoin: round; }
.nav-space { flex: 1; }
main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
header { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
header h1 { font-size: 23px; letter-spacing: -.04em; }
.account { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account div { min-width: 0; }
header:has(#pageTitle[hidden]) .account { flex: 1; justify-content: space-between; }
.account label { display: none; }
.account select { max-width: min(340px, 100%); color: var(--green); font-size: 13px; font-weight: 650; padding: 5px 8px; }
.account button { flex: 0 0 auto; white-space: nowrap; padding: 4px 9px; border-radius: 8px; font-size: 12px; }
#notice { padding: 9px 16px; background: #fff4df; color: #674919; font-size: 13px; }
#inboxView { flex: 1; display: grid; grid-template-columns: clamp(260px, 29vw, 380px) minmax(0,1fr); min-height: 0; }
.conversation-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); padding: 6px 12px 0; }
.list-title { margin-bottom: 6px; text-align: center; font-size: 17px; }
.chat-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: #f4f7f5; }
.chat-search:focus-within { border-color: var(--green); }
.chat-search svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
#search { margin: 0; padding: 4px 0; border: 0; outline: none; background: transparent; font-weight: 400; }
.tabs { display: flex; flex-wrap: nowrap; gap: 6px; padding: 10px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { flex: 0 0 auto; white-space: nowrap; color: var(--muted); background: transparent; border: 1px solid var(--line); padding: 5px 9px; border-radius: 999px; font-size: 12px; }
.tabs .selected { background: #e4f3e9; border-color: #d0e8d9; color: var(--green); }
#contacts { flex: 1; overflow: auto; min-height: 0; }
.contact { display: flex; align-items: center; width: 100%; gap: 10px; padding: 11px 8px; border-radius: 8px; color: inherit; text-align: left; background: #fff; font-weight: 400; }
.contact:hover:not(:disabled), .contact.active { background: #eef6f1; filter: none; }
.avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; background: #dceee3; color: #35634d; display: grid; place-items: center; font-weight: 650; }
.contact-main { flex: 1; min-width: 0; }
.contact strong, .contact p { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact p, .contact-side { font-size: 12px; }
.contact-side { color: var(--muted); text-align: right; }
.badge { display: inline-block; min-width: 19px; text-align: center; color: #fff; background: var(--green); border-radius: 20px; padding: 1px 4px; }
.empty-list { padding: 18px 8px; }
#chat { display: flex; min-height: 0; min-width: 0; background: #f1f1e9; }
#empty { margin: auto; padding: 20px; text-align: center; }
.empty-icon { font-size: 25px; color: var(--green); }
#empty h2 { font-size: 19px; margin: 8px 0 3px; }
#setup { margin-top: 14px; background: transparent; color: var(--green); }
#activeChat { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 10px 17px; background: #f9fbfa; border-bottom: 1px solid var(--line); }
.chat-header small { display: block; font-size: 11px; }
#resolve { margin-left: auto; font-size: 12px; }
#back { display: none; }
#messages { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow: auto; min-height: 0; --message-gutter: clamp(12px, 4vw, 52px); padding: 8px var(--message-gutter) 18px; }
.date-divider { align-self: center; font-size: 11px; padding: 3px 10px; border-radius: 7px; color: var(--muted); background: #fff; margin: 8px 0; }
.bubble { align-self: flex-start; max-width: min(84%, 640px); background: #fff; border-radius: 4px 10px 10px; padding: 7px 10px; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 1px 1px #223c2920; }
.bubble.out { align-self: flex-end; background: #dcf6d4; border-radius: 10px 4px 10px 10px; }
.bubble.status-failed { background: #ffede2; }
.bubble footer { text-align: right; font-size: 10px; color: #526453; margin-top: 3px; }
.delivery-ticks { display: inline-flex; vertical-align: middle; margin-left: 3px; color: #64756c; }
.delivery-ticks svg { width: 18px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.delivery-ticks.delivery-read { color: #087eac; }
.delivery-error, .message-kind { font-size: 11px; }
#composer { padding: 8px 14px 12px; }
.compose-row { display: flex; align-items: end; gap: 8px; }
#message { resize: none; field-sizing: content; min-height: 42px; max-height: 130px; }
#send { min-width: 42px; height: 42px; border-radius: 50%; font-size: 17px; }
#settingsView { flex: 1; overflow: auto; padding: 22px; background: #f6f8f7; }
.settings-list { display: grid; gap: 8px; max-width: 560px; margin: 0 auto; }
.settings-panel { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.settings-panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 13px; font-weight: 650; list-style: none; }
.settings-panel > summary::-webkit-details-marker { display: none; }
.settings-panel > summary::after { content: ''; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin-right: 3px; }
.settings-panel[open] > summary::after { transform: rotate(225deg); }
.settings-body { display: grid; gap: 9px; padding: 11px 13px 13px; border-top: 1px solid var(--line); }
.settings-body label { min-width: 0; font-size: 12px; }
.settings-body input, .settings-body textarea { padding: 8px 9px; }
.settings-body > button { justify-self: start; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.settings-note, .settings-body small { font-size: 11px; overflow-wrap: anywhere; }
.settings-note:empty { display: none; }
dialog { border: 1px solid var(--line); background: #fff; padding: 18px; border-radius: 14px; color: inherit; }
dialog form > * + * { margin-top: 12px; }
dialog small { display: block; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-label { display: flex; align-items: center; gap: 7px; }
.toggle-label input { width: auto; margin: 0; accent-color: var(--green); }
dialog { width: min(440px, calc(100% - 24px)); max-height: 90dvh; }
dialog::backdrop { background: #172d2470; }
.dialog-heading { display: flex; justify-content: space-between; gap: 8px; }
@media (max-width: 680px) {
  nav { flex-basis: 45px; width: 45px; padding-inline: 4px; }
  nav button { width: 35px; height: 35px; }
  header { padding: 5px 10px; }
  header h1 { font-size: 17px; }
  .account select { max-width: 100%; }
  #inboxView { grid-template-columns: minmax(0, 1fr); }
  #chat, .has-chat .conversation-list { display: none; }
  .has-chat #chat { display: flex; }
  #workspace:has(.has-chat:not([hidden])) > nav,
  main:has(.has-chat:not([hidden])) > header { display: none; }
  #back { display: inline-block; }
  .chat-header { padding: 8px; }
  #settingsView { padding: 12px; }
}
#knowledgeBase, #aiInstructions { display: block; margin-top: 6px; resize: vertical; font-weight: 400; }
.handling-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; padding: 6px 12px; background: #f9fbfa; border-bottom: 1px solid var(--line); font-size: 12px; }
.handling-bar #handlingStatus { color: var(--muted); }
.handling-bar button { padding: 4px 8px; font-size: 12px; }
#handoffReason { flex: 1 1 130px; overflow-wrap: anywhere; }
.handling-tag { display: inline-block; color: var(--green); font-size: 11px; }
.bubble { position: relative; padding-right: 31px; }
.message-actions { position: absolute; top: 3px; right: 5px; z-index: 1; }
.message-actions[open] { position: static; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.message-actions summary { list-style: none; border-radius: 5px; min-width: 22px; min-height: 24px; text-align: center; color: var(--muted); }
.message-actions summary::-webkit-details-marker { display: none; }
.message-actions button { padding: 5px 8px; white-space: nowrap; background: #fff; color: #9b3a28; border: 1px solid var(--line); box-shadow: 0 3px 10px #0002; font-size: 12px; }
#selectionCount { margin-right: auto; font-weight: 650; }
.selectable-message { display: flex; margin: -3px calc(-1 * var(--message-gutter)); padding: 3px var(--message-gutter); min-width: 0; cursor: pointer; user-select: none; }
.selectable-message .bubble { align-self: center; }
.selectable-message .bubble.out { margin-left: auto; }
.message-chosen { background: #bfe7cc; }
.selectable-message:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.message-actions[open] { flex-wrap: wrap; }
.message-actions button:first-of-type { color: var(--green); }
@media (max-width: 680px) {
  #activeChat .chat-header { flex-wrap: wrap; }
}

.bubble { -webkit-touch-callout: none; }
@media (pointer: coarse) {
  .bubble { user-select: none; -webkit-user-select: none; }
}
.conversation-actions { position: relative; z-index: 3; }
.conversation-actions summary { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 8px; background: #edf5f0; color: var(--green); list-style: none; }
.conversation-actions summary::-webkit-details-marker { display: none; }
.conversation-actions button { position: absolute; top: calc(100% + 4px); right: 0; white-space: nowrap; background: #fff; color: #9b3a28; border: 1px solid var(--line); box-shadow: 0 3px 10px #0002; font-size: 12px; }
#chatSelectBar { display: flex; align-items: center; gap: 9px; flex: 1; }
#chatSelectCount { font-weight: 650; }
#deleteSelectedChats { margin-left: auto; }
.trash-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.contact { -webkit-touch-callout: none; user-select: none; }
.contact.chat-chosen { background: #d9f3df; }
.contact .avatar { position: relative; }
.chat-choice-check { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 17px; height: 17px; border: 1.5px solid #fff; border-radius: 50%; color: #fff; background: var(--green); font-size: 10px; }
#deleteChatsTitle, #deleteMessagesTitle { font-size: 20px; }
.delete-chat-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#attachPhoto { flex: 0 0 38px; height: 42px; display: grid; place-items: center; padding: 0; }
#attachPhoto svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#photoAttachment { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
#photoName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#removePhoto { padding: 3px 8px; }
.chat-photo { display: block; width: auto; height: auto; max-width: min(100%, 260px, 52vw); max-height: min(360px, 55vh); border-radius: 6px; }
.bubble:has(> .chat-photo) { padding: 3px; }
.bubble:has(> .chat-photo) > .message-actions:not([open]) summary { background: #fffffff0; }
.bubble:has(> .chat-photo) > div,
.bubble:has(> .chat-photo) > footer { padding-inline: 3px; }

.photo-preview-icon { width: 15px; height: 15px; margin-right: 4px; vertical-align: -2px; fill: currentColor; }
.contact-main .delivery-ticks { margin: 0 4px 0 0; }
