:root{color-scheme:light;--bg:#f5f6f8;--surface:#fff;--text:#17191d;--muted:#6b7280;--border:#e1e4e8;--primary:#2563eb;--radius:16px}*{box-sizing:border-box}html{min-width:0;scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--text);font:15px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;overflow-wrap:anywhere}img{max-width:100%;height:auto}a{color:var(--primary)}button{border:0;background:var(--primary);color:#fff;padding:12px 16px;border-radius:10px;cursor:pointer;font-weight:650;font:inherit;white-space:normal;min-height:44px}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #93c5fd;outline-offset:2px}input,textarea,select{width:100%;min-width:0;padding:12px;border:1px solid #d7dbe1;border-radius:10px;font:inherit;background:#fff;color:inherit}textarea{resize:vertical}label{display:block;margin:12px 0;font-weight:600}label input,label textarea,label select{margin-top:6px;font-weight:400}.wrap{width:min(100% - 32px,960px);margin:clamp(8px,3vw,30px) auto;padding:clamp(8px,2vw,16px)}.narrow{max-width:500px}.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:clamp(14px,3vw,22px);box-shadow:0 4px 20px #1111}.error{color:#b91c1c}.muted{color:var(--muted)}.chatbox{height:min(65dvh,650px);min-height:220px;overflow:auto;overscroll-behavior:contain;border:1px solid #e4e6ea;background:#fff;border-radius:16px;padding:clamp(8px,2vw,14px)}.msg{padding:10px 13px;border-radius:15px;max-width:min(80%,680px);margin:8px 0;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.msg img{max-width:min(100%,360px);border-radius:8px}.user{background:#2563eb;color:#fff;margin-left:auto}.admin,.automation{background:#eef0f3;color:#222}.row{display:flex;gap:9px;align-items:center;min-width:0}.row input{flex:1;min-width:0}.row button{flex-shrink:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:15px;flex-wrap:wrap}.top h1,.top h2{margin:.2em 0}.grid{display:grid;grid-template-columns:minmax(220px,300px) minmax(0,1fr);gap:16px}.list a{display:block;padding:12px;border-bottom:1px solid #eee;text-decoration:none;color:inherit;overflow-wrap:anywhere}.small{font-size:13px}.photo{width:48px;height:48px;border-radius:50%;object-fit:cover;background:#e5e7eb}.install hr,hr{border:0;border-top:1px solid #eee;margin:20px 0}.card>*{min-width:0}nav{display:flex;flex-wrap:wrap;gap:8px;align-items:center}form{min-width:0}#history{scrollbar-gutter:stable}#sendForm{align-items:stretch}#sendForm input{min-height:46px}#image{font-size:14px}.hidden-file{display:none!important}.message-composer{gap:8px}.attach-btn{width:44px;height:44px;min-width:44px;padding:0;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:26px;line-height:1;background:#eef0f3;color:#202124;border:1px solid #d7dbe1;flex-shrink:0}.attach-btn:hover{background:#e2e5e9}.message-composer input{flex:1;min-width:0}.message-composer button[type=submit]{flex-shrink:0}
@media(max-width:700px){.message-composer{gap:6px}.attach-btn{width:40px;height:40px;min-width:40px;font-size:24px}.message-composer button[type=submit]{padding:10px 12px}}.wrap{width:min(100% - 12px,960px);margin:6px auto;padding:4px}.grid{grid-template-columns:minmax(0,1fr)}.chatbox{height:58dvh;min-height:200px}.card{padding:clamp(12px,4vw,16px);border-radius:14px}.msg{max-width:88%;padding:9px 11px}.top{align-items:flex-start}.top nav{width:100%}.row{gap:6px}.row button{padding:10px 12px}.row input{padding:10px}.wrap.narrow{width:min(100% - 12px,500px)}}
@media(max-width:420px){body{font-size:14px}h1{font-size:1.45rem}h2{font-size:1.25rem}h3{font-size:1.08rem}.chatbox{height:56dvh;padding:8px}.msg{max-width:92%;font-size:14px}.row{gap:5px}.row button{min-width:62px;padding:9px}.card{padding:12px}label{margin:10px 0}}
@media(min-width:701px) and (max-width:1024px){.wrap{width:min(100% - 24px,960px)}.grid{grid-template-columns:minmax(230px,34%) minmax(0,1fr)}}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*{animation:none!important;transition:none!important}}

/* Mobile chat card: keep equal top/bottom viewport spacing */
@media(max-width:700px){.wrap.narrow{margin:6px auto;min-height:calc(100dvh - 12px);display:flex;flex-direction:column}.wrap.narrow #chat.card{min-height:calc(100dvh - 24px);display:flex;flex-direction:column}.wrap.narrow #chat .chatbox{flex:1 1 auto;height:auto;min-height:200px}.wrap.narrow #chat .message-composer{flex:0 0 auto}}

/* Admin image composer attachment button styles */
.admin-composer{width:100%;}
.admin-composer-row{display:flex;align-items:center;gap:8px;min-width:0;}
.admin-attach-btn{width:44px;height:44px;min-width:44px;padding:0;border-radius:50%;font-size:26px;line-height:1;background:#eef0f3;color:#17191d;border:1px solid #d7dbe1;display:flex;align-items:center;justify-content:center;}
.admin-reply-input{flex:1;min-width:0;}
.admin-file-hidden{display:none!important;}
.admin-selected-file{margin:6px 0 0 52px;font-size:13px;color:#6b7280;overflow-wrap:anywhere;}
@media(max-width:520px){.admin-composer-row{gap:5px}.admin-attach-btn{width:40px;height:40px;min-width:40px}.admin-composer-row button[type=submit]{padding:10px 11px;min-width:78px}.admin-selected-file{margin-left:45px}}

/* Fixed chat viewport: history scrolls inside the card, composer stays pinned */
.wrap.narrow:has(#chat[style*="display:block"]){
  width:min(100% - 12px,500px);
  height:calc(100dvh - 16px);
  max-height:calc(100dvh - 16px);
  min-height:0;
  margin:8px auto;
  padding:4px;
  display:flex;
  flex-direction:column;
}
.wrap.narrow #chat.card[style*="display:block"]{
  display:flex!important;
  flex:1 1 auto;
  width:100%;
  height:100%;
  min-height:0;
  max-height:100%;
  flex-direction:column;
  overflow:hidden;
}
.wrap.narrow #chat .top{flex:0 0 auto;}
.wrap.narrow #chat #history.chatbox{
  flex:1 1 0;
  width:100%;
  height:0;
  min-height:0;
  max-height:none;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
}
.wrap.narrow #chat #sendForm.message-composer{
  flex:0 0 auto;
  width:100%;
  margin-top:12px!important;
}
.wrap.narrow #chat #image{flex:0 0 auto;}
@media(max-height:520px){
  .wrap.narrow:has(#chat[style*="display:block"]){height:calc(100dvh - 8px);max-height:calc(100dvh - 8px);margin:4px auto;}
  .wrap.narrow #chat .top{margin-bottom:8px;}
  .wrap.narrow #chat #sendForm.message-composer{margin-top:8px!important;}
}

/* Requested visual adjustment: transparent image message containers and darker neutral user bubbles */
.msg:has(img){background:transparent!important;padding:0!important;color:inherit!important;}
.msg:has(img) img{display:block;border-radius:8px;}
.user:not(:has(img)){background:#d1d5db!important;color:#17191d!important;}

/* Voice controls: high-contrast play triangle and recording waveform visualizer */
.voice-player{display:flex;align-items:center;gap:10px;min-width:min(260px,100%);max-width:100%;padding:10px 12px;border-radius:14px;background:#eef0f3;color:#202124;}
.msg.user .voice-player{background:#d1d5db;color:#17191d;}
.msg.admin .voice-player,.msg.automation .voice-player{background:#eef0f3;color:#202124;}
.voice-play-btn{width:38px;height:38px;min-width:38px;padding:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#fff;color:#111;border:1px solid #aab0b8;box-shadow:0 1px 2px #0002;}
.voice-play-btn svg{width:20px;height:20px;display:block;fill:currentColor;}
.voice-play-btn:hover{background:#e5e7eb;}
.voice-progress{flex:1;min-width:40px;width:100%;padding:0!important;margin:0;accent-color:#374151;}
.voice-duration{font-size:12px;white-space:nowrap;color:inherit;}
.voice-player audio{display:none;}
.voice-mic-btn,.admin-composer-row .voice-mic-btn{width:44px;height:44px;min-width:44px;padding:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;background:#eef0f3;color:#17191d;border:1px solid #d7dbe1;flex-shrink:0;}
.voice-mic-btn svg{width:22px;height:22px;fill:currentColor;}
.voice-mic-btn.recording{background:#fee2e2;color:#b91c1c;border-color:#fca5a5;}
.voice-waveform{display:inline-flex;align-items:center;justify-content:center;gap:2px;height:34px;min-width:34px;padding:0 3px;color:#6b7280;vertical-align:middle;}
.voice-waveform i{display:block;width:3px;height:5px;border-radius:2px;background:currentColor;transform-origin:center;}
.voice-waveform.active{color:#dc2626;}
.voice-waveform.active i{animation:voice-wave 620ms ease-in-out infinite alternate;animation-delay:calc(var(--bar-index)*-70ms);}
@keyframes voice-wave{0%{height:4px;opacity:.6}50%{height:22px;opacity:1}100%{height:8px;opacity:.75}}
@media(max-width:520px){.voice-mic-btn,.admin-composer-row .voice-mic-btn{width:40px;height:40px;min-width:40px}.voice-waveform{min-width:28px;gap:2px;height:30px}.voice-waveform i{width:2.5px}.voice-player{gap:7px;padding:8px 9px;min-width:min(220px,100%)}.voice-play-btn{width:34px;height:34px;min-width:34px}.voice-duration{font-size:11px}}
@media(prefers-reduced-motion:reduce){.voice-waveform.active i{animation:none;height:12px!important}}

/* Latest requested audio UI refinements: remove colored message shell around audio player */
.msg:has(.voice-player){background:transparent!important;padding:0!important;color:inherit!important;}
.msg:has(.voice-player) .voice-player{background:#e5e7eb!important;color:#17191d!important;border:1px solid #d1d5db;}
.msg.user:has(.voice-player) .voice-player{background:#d1d5db!important;color:#17191d!important;}
.msg.admin:has(.voice-player) .voice-player,.msg.automation:has(.voice-player) .voice-player{background:#e5e7eb!important;color:#17191d!important;}
.voice-play-btn{background:transparent!important;color:#17191d!important;border:0!important;box-shadow:none!important;}
.voice-play-btn:hover{background:#d1d5db!important;}
/* Dark-gray actions for recording preview only; normal Send button remains unchanged */
.voice-preview-action{background:#4b5563!important;color:#fff!important;border:1px solid #374151!important;border-radius:9px!important;}
.voice-preview-action:hover{background:#374151!important;}

/* Recording preview panel: dark-gray background, neutral play control; leave normal Send unchanged */
.voice-preview:not([hidden]),#adminVoicePreview:not([hidden]){
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
  background:#4b5563!important;
  color:#fff!important;
  border:1px solid #374151!important;
  border-radius:12px;
  padding:10px 12px;
}
.voice-preview-play{
  width:38px;height:38px;min-width:38px;padding:0;
  display:inline-flex;align-items:center;justify-content:center;
  border-radius:50%;background:#f3f4f6!important;color:#111827!important;
  border:1px solid #9ca3af!important;box-shadow:none!important;
}
.voice-preview-play svg{width:20px;height:20px;display:block;fill:currentColor;}
.voice-preview-play:hover{background:#d1d5db!important;}
.voice-preview-action{background:#374151!important;color:#fff!important;border:1px solid #1f2937!important;}
.voice-preview-action:hover{background:#1f2937!important;}
#adminVoicePreview audio{max-width:100%;width:min(100%,360px);}
#adminVoicePreview audio::-webkit-media-controls-panel{background:#4b5563;}
/* Attachment plus button: remove colored bubble while keeping click target */
.attach-btn,
.attach-btn:hover,
.attach-btn:active {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.attach-btn {
  color: var(--text);
}

/* Universal attachment display and video/document support */
.file-attachment{display:inline-flex;align-items:center;gap:7px;max-width:min(100%,520px);padding:10px 12px;margin-top:6px;border:1px solid #d7dbe1;border-radius:10px;background:#f8fafc;color:inherit;text-decoration:none;overflow-wrap:anywhere}
.file-attachment:hover{background:#eef2f7}
.msg video{border-radius:10px;max-height:360px;background:#111}
.admin-selected-file{overflow-wrap:anywhere}
