:root {
  color-scheme: light;
  font: 15px/1.5 system-ui, "Segoe UI", sans-serif;
  color: #202b2a;
  background: #f5f7f5;
  --line: #e1e6e2;
  --muted: #566661;
  --accent: #1f604b;
  --tint: #ebf4ef;
  --paper: #fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea, .file-button { border-radius: 8px; }
button, .file-button { background: var(--paper); border: 1px solid var(--line); color: inherit; padding: 7px 12px; cursor: pointer; }
button:hover:not(:disabled), .file-button:hover { background: var(--tint); }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible, .visually-hidden:focus-visible + textarea { outline: 2px solid #258264; outline-offset: 3px; }
.composer:has(input:focus-visible) .file-button { outline: 2px solid #258264; outline-offset: 3px; }
input:not([type="file"]), select, textarea { min-width: 0; width: 100%; padding: 9px 11px; border: 1px solid var(--line); background: var(--paper); color: inherit; }
textarea { resize: vertical; }
h1 { font-size: 25px; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 15px; }
p { margin: 0; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 650; }
.primary:hover:not(:disabled) { background: #164d3b; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 22px; min-height: 67px; padding: 10px 26px; border-bottom: 1px solid var(--line); background: var(--paper); }
.site-context { order: -1; color: var(--muted); font-size: 12px; min-width: 0; }
.bar .brand { order: -2; }
.site-context select { width: auto; max-width: min(24vw, 220px); padding: 5px 8px; }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-size: 20px; font-weight: 750; letter-spacing: -.04em; }
.mark { width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--accent); color: white; }
nav, .bar-actions { display: flex; align-items: center; gap: 7px; }
nav button { border-color: transparent; color: var(--muted); white-space: nowrap; }
nav [aria-current], .filters [aria-pressed="true"] { background: var(--tint); color: var(--accent); font-weight: 650; }
.connection { font-size: 12px; color: var(--muted); white-space: nowrap; }
.connection.online { color: var(--accent); }
.connection::before { content: ""; display: inline-block; height: 7px; width: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.inbox { display: grid; grid-template-columns: minmax(270px, 330px) minmax(0, 1fr); height: calc(100dvh - 67px); max-width: 1510px; margin: auto; }
.sidebar, .active-chat { display: flex; flex-direction: column; min-height: 0; }
.sidebar { background: var(--paper); border-inline: 1px solid var(--line); }
.list-controls { padding: 21px 17px 13px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.filters button { padding: 4px 8px; font-size: 12px; }
.session-list { overflow: auto; flex: 1; }
.session { width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px; text-align: left; }
.session[aria-current] { background: var(--tint); box-shadow: inset 3px 0 var(--accent); }
.session strong, .session .preview { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.session-main { display: grid; gap: 2px; min-width: 0; }
.session-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.avatar { display: grid; place-items: center; align-content: center; width: 34px; height: 34px; border-radius: 50%; background: #e7eee9; color: var(--accent); font-weight: 700; overflow: hidden; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.session small, .preview { font-size: 12px; color: var(--muted); }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--tint); color: var(--accent); white-space: nowrap; }
.badge.pending { background: #fcf0d7; color: #685014; }
.badge.closed { background: #eff1f1; color: #505c5a; }
.count { font-size: 11px; border-radius: 99px; padding: 1px 6px; background: var(--accent); color: white; }
.conversation { min-height: 0; min-width: 0; border-right: 1px solid var(--line); }
.active-chat { height: 100%; }
.empty { padding: 34px 16px; color: var(--muted); text-align: center; }
#empty-chat { height: 100%; display: grid; place-items: center; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.chat-person { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chat-person small { display: block; color: var(--muted); }
.chat-head select { width: auto; max-width: 100%; }
.back { display: none; padding: 6px 8px; white-space: nowrap; }
.thread { overflow: auto; flex: 1; padding: 16px 22px; }
.older { margin: 0 auto 12px; display: block; font-size: 13px; color: var(--accent); }
.message { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 13px; }
.message.agent { flex-direction: row-reverse; }
.message-avatar { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; background: #e7eee9; color: var(--accent); font-size: 12px; font-weight: 700; overflow: hidden; }
.message-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.message-content { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; max-width: min(calc(100% - 36px), 510px); }
.message.agent .message-content { align-items: flex-end; }
.bubble { max-width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px 13px 13px 3px; background: var(--paper); overflow-wrap: anywhere; white-space: pre-wrap; }
.agent .bubble { background: #dceee5; border-color: #dceee5; border-radius: 13px 13px 3px 13px; }
.bubble img { display: block; max-width: min(100%, 300px); max-height: 260px; object-fit: contain; border-radius: 6px; }
.message time { color: var(--muted); font-size: 11px; }
.message-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.edited { font-style: italic; }
.message-actions { position: relative; }
.message-actions summary { cursor: pointer; list-style: none; color: var(--accent); }
.message-actions summary::-webkit-details-marker { display: none; }
.message-action-buttons { display: flex; gap: 5px; margin-top: 4px; }
.message-action-buttons button { font-size: 11px; padding: 3px 7px; white-space: nowrap; }
.message-edit { display: grid; gap: 6px; margin-top: 6px; width: min(100%, 430px); }
.message-edit textarea { width: 100%; padding: 7px; border: 1px solid var(--line); }
.message .bubble.deleted { color: var(--muted); background: #f1f3f2; border-color: var(--line); font-style: italic; }
.reply { border-top: 1px solid var(--line); padding: 11px 16px; background: var(--paper); }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; max-height: 120px; resize: vertical; }
.file-button { white-space: nowrap; font-size: 13px; }
.selected-file { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 13px; overflow-wrap: anywhere; }
.settings { max-width: 640px; margin: 32px auto; padding: 0 18px; }
.site-management { max-width: 1100px; margin: 32px auto; padding: 0 18px; }
.management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.management-grid > section { min-width: 0; }
.management-grid h2 { font-size: 16px; margin: 0 0 10px; }
.management-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.management-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.management-item > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.management-item small { display: block; color: var(--muted); }
.management-actions { display: flex; gap: 8px; }
.management-item .management-actions { flex-shrink: 0; align-items: center; flex-wrap: wrap; }
.management-item .management-actions a { color: var(--accent); white-space: nowrap; }
.profile-form, .login-card { display: grid; gap: 14px; padding: 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; }
.profile-form label, .login-card label { display: grid; gap: 5px; font-weight: 550; }
.profile-form .primary { justify-self: start; }
.profile-avatar { display: flex; align-items: center; gap: 14px; min-width: 0; flex-wrap: wrap; }
.profile-avatar .avatar { width: 60px; height: 60px; font-size: 24px; }
.profile-avatar input { max-width: 100%; }
.profile-avatar button { display: block; margin-top: 7px; font-size: 12px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 14px; }
.login-card { width: min(100%, 380px); }
.login-card h1 { margin: 0; }
.login-card p { color: var(--muted); }
.form-message { font-size: 13px; margin-top: 6px; color: var(--accent); }
.form-message.error, .login-card .error { color: #ab272c; }
.notice { position: fixed; bottom: 20px; right: 18px; max-width: calc(100% - 36px); border-radius: 8px; padding: 10px 13px; color: white; background: #263b34; }
.startup { padding: 30px; text-align: center; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 660px) {
  .bar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; min-height: 0; }
  .brand { font-size: 0; }
  .brand .mark { font-size: 17px; }
  nav button, .bar-actions button { font-size: 12px; padding: 6px; }
  .connection { font-size: 0; }
  .connection::before { margin: 0; }
  .site-context { order: 4; width: 100%; }
  .site-context select { max-width: 80%; }
  .workspace { height: 100dvh; display: flex; flex-direction: column; }
  .inbox { flex: 1; height: auto; min-height: 0; width: 100%; display: flex; }
  .sidebar, .conversation { width: 100%; }
  .conversation, .inbox.has-chat .sidebar { display: none; }
  .inbox.has-chat .conversation { display: block; }
  .back { display: inline-block; font-size: 12px; }
  .chat-head { padding: 9px 10px; gap: 8px; }
  .chat-head select { font-size: 12px; padding: 6px; }
  .thread { padding: 12px; }
  .reply { padding: 8px; }
}
@media (max-width: 800px) { .management-grid { grid-template-columns: 1fr; } }
