.siged-chat-shell {
  --chat-blue: #0f5c78;
  --chat-green: #1e755f;
  --chat-gold: #b98a16;
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(360px, 1fr) minmax(190px, 235px);
  height: clamp(560px, calc(100dvh - 255px), 790px);
  min-height: 560px;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid rgba(15, 45, 58, .12);
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(12, 35, 46, .12);
}

.siged-chat-sidebar,
.siged-chat-info {
  min-width: 0;
  background: #f5f7f8;
}

.siged-chat-sidebar { border-right: 1px solid #dde4e8; }
.siged-chat-info { border-left: 1px solid #dde4e8; padding: 20px 14px; overflow-y: auto; }
.siged-chat-main { min-width: 0; display: flex; flex-direction: column; background: linear-gradient(160deg, #edf3f4 0%, #fbfaf5 100%); }

.siged-chat-sidebar-head,
.siged-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  min-height: 72px;
  background: #fff;
  border-bottom: 1px solid #e1e6e9;
}

.siged-chat-sidebar-head { justify-content: space-between; }
.siged-chat-sidebar-head div { min-width: 0; }
.siged-chat-sidebar-head strong { display: block; font-size: 1.08rem; }
.siged-chat-sidebar-head small { display: block; color: #68757c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.siged-chat-sidebar-head button,
.siged-chat-composer > button,
.siged-chat-attach {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  background: #e4eef2;
  color: #17495c;
  font-size: 1.25rem;
  cursor: pointer;
}

.siged-chat-search {
  width: calc(100% - 24px);
  margin: 12px;
  padding: 11px 14px;
  border: 1px solid #d4dde1;
  border-radius: 999px;
  background: #fff;
}

.siged-chat-actions { display: flex; gap: 7px; align-items: center; padding: 0 12px 10px; }
.siged-chat-actions button,
.siged-chat-actions span { border: 0; border-radius: 10px; padding: 7px 9px; font-size: .78rem; }
.siged-chat-actions button { background: #d9eae5; color: #145844; cursor: pointer; font-weight: 700; }
.siged-chat-actions span { color: #5f6c72; background: #eceff1; }
.siged-chat-channel-list { overflow-y: auto; height: calc(100% - 144px); padding: 2px 8px 14px; }
.siged-chat-channel {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #172229;
  text-align: left;
  cursor: pointer;
}
.siged-chat-channel:hover { background: #e8eef1; }
.siged-chat-channel.active { background: #d7e9ee; box-shadow: inset 4px 0 var(--chat-blue); }
.siged-chat-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #e2efe9, #d8e8ee); font-size: 1.12rem; }
.siged-chat-avatar.large { width: 48px; height: 48px; }
.siged-chat-channel-copy { min-width: 0; }
.siged-chat-channel-copy strong,
.siged-chat-channel-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.siged-chat-channel-copy small { margin-top: 3px; color: #68757c; font-weight: 400; }
.siged-chat-channel-meta { text-align: right; }
.siged-chat-channel-meta b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; color: #fff; background: #c02d2d; border-radius: 999px; font-size: .72rem; }
.siged-chat-channel-meta small { display: block; color: #7a858a; margin-top: 5px; }

.siged-chat-header { min-height: 76px; }
.siged-chat-header div { min-width: 0; flex: 1; }
.siged-chat-header h3 { margin: 0; font-size: 1.08rem; }
.siged-chat-header p { margin: 3px 0 0; color: #69777d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.siged-chat-quiet { border: 1px solid #d5dcdf; color: #58656b; background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.siged-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }
.siged-chat-message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 13px; }
.siged-chat-message.mine { align-items: flex-end; }
.siged-chat-bubble { max-width: min(75%, 680px); padding: 10px 13px 8px; border-radius: 5px 17px 17px 17px; background: #fff; box-shadow: 0 3px 12px rgba(26, 49, 58, .09); overflow-wrap: anywhere; }
.siged-chat-message.mine .siged-chat-bubble { color: #fff; background: linear-gradient(135deg, var(--chat-blue), var(--chat-green)); border-radius: 17px 5px 17px 17px; }
.siged-chat-bubble > strong { display: block; color: var(--chat-blue); margin-bottom: 4px; font-size: .86rem; }
.siged-chat-bubble > strong small { color: #718087; font-weight: 400; }
.siged-chat-bubble p { margin: 0; line-height: 1.45; }
.siged-chat-bubble time { display: block; margin-top: 5px; text-align: right; opacity: .7; font-size: .68rem; }
.siged-chat-image-button { display: block; border: 0; padding: 0; margin-top: 8px; background: transparent; cursor: zoom-in; }
.siged-chat-image-button img { display: block; width: min(100%, 360px); max-height: 320px; object-fit: cover; border-radius: 12px; }
.siged-chat-file { display: flex; align-items: center; gap: 9px; width: 100%; border: 1px solid rgba(0,0,0,.1); border-radius: 11px; padding: 9px; margin-top: 8px; background: rgba(255,255,255,.86); color: #193847; text-align: left; cursor: pointer; }
.siged-chat-file > span:first-child { font-size: 1.4rem; }
.siged-chat-file strong,
.siged-chat-file small { display: block; }
.siged-chat-file small { color: #6b777c; }
.siged-chat-reactions { display: flex; gap: 4px; margin: 3px 6px 0; }
.siged-chat-reactions button { border: 1px solid #d7e0e3; border-radius: 999px; padding: 2px 7px; background: #fff; cursor: pointer; font-size: .75rem; }
.siged-chat-reactions button.active { background: #d8edf3; border-color: #75adbd; }
.siged-chat-reaction-picker { position: relative; }
.siged-chat-reaction-picker summary { list-style: none; width: 24px; height: 22px; display: grid; place-items: center; border: 1px solid #d7e0e3; border-radius: 999px; background: #fff; cursor: pointer; font-size: .75rem; }
.siged-chat-reaction-picker summary::-webkit-details-marker { display: none; }
.siged-chat-reaction-picker > div { position: absolute; z-index: 4; bottom: 28px; left: 0; display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: #fff; box-shadow: 0 5px 18px rgba(0,0,0,.18); }
.siged-chat-message.mine .siged-chat-reaction-picker > div { left: auto; right: 0; }
.siged-chat-reaction-picker > div button { border: 0; padding: 3px; font-size: 1rem; }

.siged-chat-composer { position: relative; z-index: 3; display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; background: #fff; border-top: 1px solid #dfe6e8; }
.siged-chat-composer textarea { position: relative; z-index: 1; flex: 1; min-height: 42px; max-height: 130px; resize: vertical; padding: 10px 13px; border: 1px solid #d4dde1; border-radius: 18px; font: inherit; pointer-events: auto; }
.siged-chat-message.sending { opacity: .72; }
.siged-chat-emoji-panel[hidden],
.siged-chat-selected-file[hidden] { display: none !important; }
.siged-chat-composer .siged-chat-send { background: linear-gradient(135deg, var(--chat-blue), var(--chat-green)); color: #fff; }
.siged-chat-selected-file { position: absolute; bottom: 66px; left: 14px; right: 14px; padding: 8px 10px; border: 1px solid #cddcdf; border-radius: 9px; background: #fff; box-shadow: 0 5px 18px rgba(0,0,0,.12); font-size: .8rem; }
.siged-chat-selected-file button { float: right; border: 0; background: none; color: #a52626; cursor: pointer; }
.siged-chat-emoji-panel { position: absolute; bottom: 66px; left: 12px; display: flex; gap: 3px; padding: 8px; border-radius: 13px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.siged-chat-emoji-panel button { border: 0; background: transparent; font-size: 1.35rem; cursor: pointer; }
.siged-chat-readonly { padding: 14px; text-align: center; color: #59676d; background: #fff; border-top: 1px solid #dfe6e8; }
.siged-chat-welcome { margin: auto; padding: 30px; text-align: center; color: #607078; }
.siged-chat-welcome > span { display: block; font-size: 3rem; }
.siged-chat-welcome h3 { margin-bottom: 5px; }
.siged-chat-welcome p { margin: 0; }
.siged-chat-empty { padding: 12px; }

.siged-chat-info h4 { margin: 2px 0 14px; }
.siged-chat-info > div { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 13px; }
.siged-chat-info p { margin: 0; min-width: 0; }
.siged-chat-info strong,
.siged-chat-info small { display: block; overflow-wrap: anywhere; }
.siged-chat-info small { color: #6d797e; margin-top: 2px; }
.siged-chat-person-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; background: #35a46d; box-shadow: 0 0 0 3px #d8eee3; }

.siged-chat-modal { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: 18px; background: rgba(8,25,33,.65); backdrop-filter: blur(5px); }
.siged-chat-modal > div,
.siged-chat-modal > form { position: relative; width: min(620px, 100%); max-height: min(780px, 92dvh); overflow-y: auto; padding: 24px; border-radius: 20px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.siged-chat-modal h3 { margin-top: 0; }
.siged-chat-modal-close { position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; font-size: 1.5rem; background: #edf1f2; cursor: pointer; }
.siged-chat-modal input[type="search"],
.siged-chat-modal input[type="text"],
.siged-chat-modal input[type="datetime-local"],
.siged-chat-modal textarea { width: 100%; }
.siged-chat-contact-list { margin-top: 12px; max-height: 420px; overflow-y: auto; }
.siged-chat-contact-list button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-bottom: 1px solid #e6ebed; background: #fff; text-align: left; cursor: pointer; }
.siged-chat-contact-list button:hover { background: #edf4f5; }
.siged-chat-contact-list strong,
.siged-chat-contact-list small { display: block; }
.siged-chat-contact-list small { color: #68777d; }
.siged-chat-project-members { max-height: 260px; overflow-y: auto; border: 1px solid #dbe2e5; border-radius: 12px; }
.siged-chat-project-members label { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border-bottom: 1px solid #e8edef; }
.siged-chat-project-members strong,
.siged-chat-project-members small { display: block; }
.siged-chat-project-members small { color: #68777d; }
.siged-chat-check { display: flex !important; align-items: center; gap: 8px; }

body.dark-mode .siged-chat-shell,
body.dark-mode .siged-chat-sidebar-head,
body.dark-mode .siged-chat-header,
body.dark-mode .siged-chat-composer,
body.dark-mode .siged-chat-modal > div,
body.dark-mode .siged-chat-modal > form { background: #182229; color: #eef5f7; }
body.dark-mode .siged-chat-sidebar,
body.dark-mode .siged-chat-info { background: #111a20; color: #eef5f7; }
body.dark-mode .siged-chat-main { background: #202c33; }
body.dark-mode .siged-chat-channel,
body.dark-mode .siged-chat-contact-list button { color: #eef5f7; background: transparent; }
body.dark-mode .siged-chat-channel.active { background: #24404c; }
body.dark-mode .siged-chat-bubble { background: #2a3941; color: #eef5f7; }

@media (max-width: 1180px) {
  .siged-chat-shell { grid-template-columns: minmax(230px, 280px) minmax(350px, 1fr); }
  .siged-chat-info { display: none; }
}

@media (max-width: 760px) {
  .siged-chat-shell { display: flex; flex-direction: column; height: calc(100dvh - 190px); min-height: 500px; border-radius: 0; border-left: 0; border-right: 0; }
  .siged-chat-sidebar { flex: 0 0 auto; border-right: 0; border-bottom: 1px solid #dce4e7; }
  .siged-chat-sidebar-head { min-height: 55px; padding: 8px 12px; }
  .siged-chat-search { margin: 7px 10px; width: calc(100% - 20px); padding: 8px 12px; }
  .siged-chat-actions { padding-bottom: 6px; overflow-x: auto; }
  .siged-chat-actions span { white-space: nowrap; }
  .siged-chat-channel-list { display: flex; gap: 6px; height: auto; max-height: 92px; overflow-x: auto; overflow-y: hidden; padding: 2px 8px 7px; }
  .siged-chat-channel { flex: 0 0 210px; padding: 7px; grid-template-columns: 36px minmax(0,1fr) auto; }
  .siged-chat-avatar { width: 36px; height: 36px; }
  .siged-chat-main { flex: 1; min-height: 0; }
  .siged-chat-header { min-height: 57px; padding: 8px 10px; }
  .siged-chat-header .siged-chat-avatar { display: none; }
  .siged-chat-header p { font-size: .75rem; }
  .siged-chat-messages { padding: 12px 9px; }
  .siged-chat-bubble { max-width: 88%; }
  .siged-chat-composer { padding: 8px; gap: 5px; }
  .siged-chat-composer > button,
  .siged-chat-attach { width: 38px; height: 38px; }
  .siged-chat-composer textarea { min-height: 40px; }
  .siged-chat-modal { padding: 8px; align-items: end; }
  .siged-chat-modal > div,
  .siged-chat-modal > form { width: 100%; max-height: 90dvh; border-radius: 20px 20px 0 0; padding: 20px 16px; }
}
