/* FEBRY.OPS V313 — MS-Chat member UI density refinement.
   Visual-only overrides. Loaded only by /ms-chat/.
   No global zoom / transform scale, no JS or business logic changes.
   Uses desktop layout with readable minimums and preserves touch targets on mobile. */

/* Member-only topbar: do not change the public login or App Review views. */
@media (min-width: 961px) {
  body.cl-ms:has(#chatView:not(.hidden)) .topbar {
    height: 58px !important;
    min-height: 58px !important;
    padding: 6px 21px !important;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .hamb {
    width: 33px;
    height: 33px;
    min-width: 33px;
    border-radius: 9px;
    font-size: 17px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand-mark {
    width: 32px;
    height: 32px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand,
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand>div:last-child {
    font-size: 13px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand small {
    font-size: 9px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser {
    gap: 6px !important;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser .btn {
    min-height: 34px;
    padding: 7px 13px;
    font-size: 11px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser .model-chip,
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser .badge {
    font-size: 10px;
    padding: 6px 10px;
  }
  body.cl-ms #chatView.app:not(.hidden):not(:has(#sdScreen:not([hidden]))) {
    /* 290px sidebar instead of old 390px; enough space for core account stats. */
    grid-template-columns: minmax(258px, 290px) minmax(0, 1fr) !important;
    height: calc(100dvh - 58px) !important;
    min-height: 0;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar {
    padding: 12px 10px 22px !important;
    border-radius: 0 !important;
  }
  body.cl-ms #chatView:not(.hidden) > .chat-head {
    padding: 10px 18px !important;
    min-height: 76px;
    gap: 12px;
    border-radius: 0 !important;
  }
  body.cl-ms #chatView:not(.hidden) > .messages {
    padding: 18px clamp(18px,3.1vw,45px) 20px !important;
    gap: 11px !important;
  }
  body.cl-ms #chatView:not(.hidden) > .composer-wrap {
    padding: 9px clamp(16px,3vw,46px) 12px !important;
  }
  body.cl-ms #chatView:not(.hidden) > .composer-wrap .composer {
    max-width: 1050px !important;
    padding: 6px !important;
    border-radius: 13px !important;
    gap: 7px;
  }
  body.cl-ms #chatView:not(.hidden) > .composer-wrap textarea {
    min-height: 38px;
    max-height: 132px;
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 10px;
  }
}

/* Shared member content styling: scope to active workspace, not product landing. */
body.cl-ms #chatView:not(.hidden) .ms-sidebar-label {
  margin-bottom: 9px;
  font-size: 9px;
}
body.cl-ms #chatView:not(.hidden) .account-usage {
  border-radius: 14px !important;
}
body.cl-ms #chatView:not(.hidden) .usage-metric {
  min-width: 0;
  border-radius: 10px;
}
body.cl-ms #chatView:not(.hidden) .usage-metric > span,
body.cl-ms #chatView:not(.hidden) .usage-line > span {
  font-size: 9px;
  letter-spacing: .07em;
}
body.cl-ms #chatView:not(.hidden) .usage-metric small,
body.cl-ms #chatView:not(.hidden) .usage-metric > small {
  font-size: 9px;
  line-height: 1.4;
}
body.cl-ms #chatView:not(.hidden) .sd-entry {
  padding: 12px !important;
  gap: 8px;
  margin: 10px 0 !important;
  border-radius: 14px !important;
}
body.cl-ms #chatView:not(.hidden) .sd-entry strong {
  font-size: 16px;
  line-height: 1.25;
}
body.cl-ms #chatView:not(.hidden) .sd-entry p {
  font-size: 11px;
  line-height: 1.5;
  margin-top: 4px;
}
body.cl-ms #chatView:not(.hidden) .sd-entry-tag {
  font-size: 9px;
}
body.cl-ms #chatView:not(.hidden) .sd-entry-button {
  font-size: 12px;
  line-height: 1.3;
  padding: 9px 12px;
  min-height: 40px;
}
body.cl-ms #chatView:not(.hidden) .ms-credential-settings {
  margin: 10px 0;
  padding: 11px;
  border-radius: 12px;
}
body.cl-ms #chatView:not(.hidden) .ms-credential-settings summary {
  font-size: 12px;
  line-height: 1.5;
}
body.cl-ms #chatView:not(.hidden) .referral-dashboard-desktop {
  margin: 9px 0;
}
body.cl-ms #chatView:not(.hidden) .referral-dashboard-desktop .ref-card {
  padding: 12px;
  border-radius: 13px;
}
body.cl-ms #chatView:not(.hidden) .referral-dashboard-desktop .ref-head h3 {
  font-size: 14px;
}
body.cl-ms #chatView:not(.hidden) .referral-dashboard-desktop .ref-head>strong {
  font-size: 19px;
}
body.cl-ms #chatView:not(.hidden) .threads-oauth-card,
body.cl-ms #chatView:not(.hidden) .writing-style-card {
  border-radius: 13px !important;
}
body.cl-ms #chatView:not(.hidden) .chat-title h1 {
  font-size: 19px !important;
  line-height: 1.2;
}
body.cl-ms #chatView:not(.hidden) .chat-title p {
  font-size: 11px;
  line-height: 1.4;
}
body.cl-ms #chatView:not(.hidden) .chat-actions {
  gap: 8px;
}
body.cl-ms #chatView:not(.hidden) .chat-actions .btn {
  padding: 9px 13px;
  min-height: 38px;
  font-size: 12px;
  border-radius: 10px;
  white-space: nowrap;
}
body.cl-ms #chatView:not(.hidden) .bubble {
  padding: 11px 14px !important;
  font-size: 12.5px !important;
  line-height: 1.55 !important;
  border-radius: 13px !important;
}
body.cl-ms #chatView:not(.hidden) .composer .send,
body.cl-ms #chatView:not(.hidden) .composer #sendBtn {
  width: 39px;
  height: 39px;
  min-width: 39px;
  flex-basis: 39px;
  border-radius: 10px;
}
body.cl-ms #chatView:not(.hidden) .composer #attachBtn {
  min-width: 39px;
  min-height: 39px;
  padding: 5px 9px;
}
body.cl-ms #chatView:not(.hidden) .quick .chip {
  font-size: 10px;
  padding: 7px 10px;
}

@media (min-width: 961px) {
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .account-usage {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 7px;
    padding: 8px;
    margin-bottom: 9px !important;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .usage-metric {
    padding: 9px 10px;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .usage-metric strong {
    font-size: 17px !important;
    line-height: 1.16;
    overflow-wrap: anywhere;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .usage-wide strong {
    font-size: 13px !important;
    line-height: 1.35;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .threads-oauth-card {
    padding: 10px;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .ref-card {
    font-size: 12px;
  }
  body.cl-ms #chatView:not(.hidden) > .ms-workspace-sidebar .writing-style-head {
    gap: 8px;
  }
}

/* Simpel Dashboard is still a standalone mode. Refine density without changing the 4-step flow. */
@media (min-width: 901px) {
  body.cl-ms.sd-mode-simple #sdScreen .sd-shell {
    width: min(1150px,calc(100% - 44px)) !important;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-brand h1 {
    font-size: clamp(26px,2.8vw,36px) !important;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-top {
    padding-bottom: 16px;
    margin-bottom: 16px;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-compose {
    padding: 20px !important;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-side-card {
    padding: 17px;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-side h3 {
    font-size: 18px;
  }
  body.cl-ms.sd-mode-simple #sdScreen .sd-summary-row {
    padding: 10px 0;
  }
}

/* Tablet/mobile: remain legible and finger-friendly; no tiny touch targets. */
@media (max-width: 960px) {
  body.cl-ms:has(#chatView:not(.hidden)) .topbar {
    min-height: 58px !important;
    height: auto !important; /* Font-size toolbar may wrap on narrow phones. */
    padding: 7px 12px !important;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand {
    font-size: 12px;
    gap: 7px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand-mark {
    width: 30px;
    height: 30px;
  }
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser {gap: 5px !important;}
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser .btn {
    min-height: 39px;
    font-size: 11px;
    padding: 7px 9px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .chat-title h1 {
    font-size: 18px !important;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .mobile-pane-title h3 {
    font-size: 18px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .messages {
    gap: 12px;
    padding-inline: 12px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .bubble {
    font-size: 13px !important;
    padding: 10px 12px !important;
    line-height: 1.55 !important;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane :where(.mobile-card,.mobile-schedule-card) {
    border-radius: 13px !important;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .composer {
    padding: 7px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .composer textarea {
    font-size: 16px; /* preserve iOS no-autozoom behavior */
    min-height: 42px;
    padding: 10px 8px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .composer .send,
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .composer #sendBtn,
  body.cl-ms #chatView:not(.hidden) .ms-mobile-pane .composer #attachBtn {
    min-width: 44px;
    min-height: 44px;
    height: 44px;
  }
  body.cl-ms #chatView:not(.hidden) .ms-mobile-nav button {
    min-height: 57px;
  }
}
@media (max-width: 390px) {
  body.cl-ms:has(#chatView:not(.hidden)) .topbar .brand {font-size: 11px;}
  body.cl-ms:has(#chatView:not(.hidden)) .topbar #topUser .model-chip {display:none;}
  body.cl-ms #chatView:not(.hidden) .chat-actions .btn {font-size: 11px;padding: 8px 10px;}
}
