:root {
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe3ef;
  --surface: #ffffff;
  --panel: #f7f9fc;
  --brand: #2152d8;
  --brand-dark: #183b8f;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-page {
  display: grid;
  place-items: center;
  background: linear-gradient(130deg, #061b34 0%, #0d2d66 55%, #163d8b 100%);
}

.login-shell {
  width: min(92vw, 560px);
}

.login-panel {
  padding: 44px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: white;
  box-shadow: 0 24px 80px rgba(0,0,0,0.26);
}

.eyebrow {
  color: #8bb7ff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 14px 0 10px;
  font-size: 2.4rem;
  line-height: 1;
}

.login-panel p {
  margin: 0 0 26px;
  color: rgba(255,255,255,0.82);
  line-height: 1.5;
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  border-radius: 8px;
  background: #2879ea;
  color: white;
  text-decoration: none;
  font-weight: 800;
}

.google-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  color: #4285f4;
  font-weight: 900;
}

.access-note {
  margin-top: 18px !important;
  margin-bottom: 0 !important;
  font-size: 0.92rem;
}

.error-box {
  margin-top: 18px !important;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fee4e2;
  color: var(--danger) !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 88px;
  padding: 18px 28px;
  background: #071b39;
  color: white;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 1.7rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  font-size: 0.92rem;
}

.config-badge {
  border: 1px solid rgba(255,255,255,0.26);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(139, 183, 255, 0.18);
  color: white;
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
}

.config-badge:hover {
  background: rgba(139, 183, 255, 0.28);
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.secondary {
  background: white;
  color: var(--brand-dark);
}

.button.primary {
  background: var(--brand-dark);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  height: calc(100vh - 88px);
  padding: 18px;
}

.sidebar,
.thread-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-toggle {
  display: none;
}

.sync-row {
  padding: 10px 18px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.sync-row .error {
  color: var(--danger);
}

.sidebar h2 {
  margin: 0;
  font-size: 1.1rem;
}

.search,
.filter-row select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

.search {
  margin: 14px 18px 10px;
  width: calc(100% - 36px);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 14px;
}

.conversation-list {
  overflow: auto;
  border-top: 1px solid var(--line);
}

.conversation-item {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  text-align: left;
  cursor: pointer;
}

.conversation-item.active {
  background: #dbe8ff;
}

.conversation-title,
.conversation-meta,
.conversation-preview {
  display: block;
}

.conversation-title {
  font-weight: 900;
}

.conversation-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.conversation-badges {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
}

.account-pill {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: white;
  background: #475569;
  font-size: 0.72rem;
  font-weight: 900;
}

.account-redisoft {
  background: #0f172a;
}

.account-iexe {
  background: #1d4ed8;
}

.account-ad {
  background: #7c3aed;
}

.account-meta {
  background: #475569;
}

.channel-pill {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: white;
  background: #16a34a;
  font-size: 0.72rem;
  font-weight: 900;
}

.channel-messenger {
  background: #7c3aed;
}

.channel-instagram {
  background: #dc2626;
}

.channel-lead_ads {
  background: #0f766e;
}

.channel-meta {
  background: #475569;
}

.conversation-meta,
.conversation-preview {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-panel {
  display: flex;
  min-width: 0;
}

.empty-state {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--ink);
}

.thread-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.thread-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.back-button {
  display: none;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: #eef2f7;
  color: var(--brand-dark);
  font-weight: 800;
  cursor: pointer;
}

.thread-mobile-actions {
  display: contents;
}

.thread-mobile-action-right {
  display: contents;
}

.assignment-toggle-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--brand-dark);
  cursor: pointer;
}

.assignment-toggle-button[aria-expanded="true"] {
  background: var(--brand);
  color: white;
}

.assignment-toggle-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 14px;
}

.assignment-toggle-icon::before,
.assignment-toggle-icon::after {
  content: "";
  position: absolute;
  display: block;
}

.assignment-toggle-icon::before {
  left: 0;
  right: 0;
  top: 1px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}

.assignment-toggle-icon::after {
  left: 3px;
  top: -1px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 8px 5px 0 currentColor, 4px 10px 0 currentColor;
}

.assignment-bar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto auto;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.advisor-search-wrap {
  min-width: 0;
}

.assignment-bar select,
.assignment-bar input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.origin-button {
  border: 0;
  cursor: pointer;
  color: white;
  background: #f97316;
}

.origin-button:hover {
  background: #ea580c;
}

.mobile-origin-button {
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 11px;
  background: #f97316;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.mobile-origin-button:hover {
  background: #ea580c;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 10px;
  background: white;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.modal-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-panel h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.modal-panel p {
  margin: 0;
  color: var(--muted);
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: #dc2626;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-floating-close {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  z-index: 80;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #dc2626;
  color: white;
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.24);
  cursor: pointer;
}

.modal-floating-close:hover,
.modal-close:hover {
  background: #b91c1c;
}

.lead-card {
  padding: 18px 20px 20px;
  background: white;
}

.lead-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.lead-profile-image {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.lead-profile strong,
.lead-profile span,
.lead-profile a {
  display: block;
}

.lead-profile span {
  color: var(--muted);
  font-size: 0.86rem;
}

.lead-profile a,
.lead-card a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.lead-profile a:hover,
.lead-card a:hover {
  text-decoration: underline;
}

.lead-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.lead-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.lead-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0;
}

.lead-card dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.lead-card dd {
  margin: 2px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.config-panel {
  width: min(620px, 100%);
}

.config-card {
  display: grid;
  gap: 16px;
  padding: 18px 20px 20px;
}

.config-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.config-card input[type="search"],
.config-card select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

.config-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink) !important;
  font-size: 0.9rem !important;
  font-weight: 700 !important;
}

.config-check input {
  width: 18px;
  height: 18px;
}

.config-current {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
}

.config-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.thread-header h2 {
  margin: 0 0 6px;
}

.thread-header p {
  margin: 0;
  color: var(--muted);
}

#threadMeta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.thread-meta-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #d1fadf;
  color: #067647;
  font-size: 0.84rem;
  font-weight: 800;
}

.badge.muted {
  background: #eef2f7;
  color: #475467;
}

.account-badge.account-redisoft {
  background: #0f172a;
  color: white;
}

.account-badge.account-iexe {
  background: #1d4ed8;
  color: white;
}

.account-badge.account-ad {
  background: #7c3aed;
  color: white;
}

.account-badge.account-meta {
  background: #475569;
  color: white;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #f8fafc;
}

.message {
  width: fit-content;
  max-width: min(720px, 84%);
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 2px rgba(15,23,42,0.08);
  line-height: 1.45;
}

.message.outbound {
  margin-left: auto;
  background: #dbeafe;
}

.message footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 52px auto;
  align-items: stretch;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: white;
}

.button.audio-library-button,
.button.attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-width: 52px;
  padding: 0;
  background: #eef2f7;
  color: #344054;
}

.button.audio-library-button {
  position: relative;
  grid-column: 2;
  background: #e0f2fe;
  color: #075985;
}

.button.attach {
  grid-column: 3;
}

.composer .button.primary {
  grid-column: 4;
}

.button.attach.is-loading {
  opacity: 0.72;
}

.button.attach.is-loading .attach-icon {
  animation: attachPulse 0.8s ease-in-out infinite alternate;
}

.attach-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 22px;
  transform: rotate(38deg);
}

.attach-icon::before,
.attach-icon::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.attach-icon::before {
  inset: 1px 3px 1px 3px;
  border-left-color: transparent;
}

.attach-icon::after {
  inset: 5px 7px 5px 7px;
  border-left-color: transparent;
}

@keyframes attachPulse {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

.audio-library-icon {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
}

.audio-library-icon::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 8px;
  height: 13px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 15px 0 -3px currentColor;
}

.audio-library-icon::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 11px;
  width: 14px;
  height: 9px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 999px 999px;
}

.audio-library-button::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #dc2626;
  box-shadow: 0 0 0 2px #e0f2fe;
}

.audio-library-panel {
  max-width: min(780px, 94vw);
}

.audio-library-body {
  display: grid;
  gap: 14px;
}

.audio-library-field,
.audio-library-manage label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 800;
}

.audio-library-field select,
.audio-library-manage input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
}

.audio-library-list {
  display: grid;
  gap: 10px;
}

.audio-library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.audio-library-item strong,
.audio-library-item span {
  display: block;
}

.audio-library-item span,
.audio-library-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.audio-library-empty.error {
  color: var(--danger);
}

.audio-library-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-library-item audio {
  width: 220px;
  max-width: 34vw;
  height: 36px;
}

.audio-library-manage {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  min-height: 52px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.attachment-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px dashed #b8c5d6;
  border-radius: 8px;
  color: #344054;
  background: #f8fafc;
}

.attachment-preview button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
}

.empty-list {
  padding: 18px;
  color: var(--muted);
}

.empty-list.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #071b39;
  color: white;
  box-shadow: 0 14px 40px rgba(0,0,0,0.22);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 860px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    min-height: auto;
    padding: 10px 14px;
  }

  .topbar h1 {
    font-size: 1.22rem;
  }

  .eyebrow {
    font-size: 0.7rem;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: space-between;
  }

  .topbar-actions form {
    flex: 0 0 auto;
  }

  .user-pill {
    padding: 7px 10px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
  }

  .topbar .button {
    padding: 8px 12px;
  }

  body.mobile-thread-open .topbar {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
    gap: 0;
    height: calc(100dvh - 112px);
    min-height: 0;
    padding: 10px;
  }

  body.mobile-thread-open .app-shell {
    height: 100dvh;
    padding: 0;
  }

  body.mobile-thread-open {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar,
  .thread-panel {
    min-height: 0;
    border-radius: 8px;
  }

  .sidebar {
    height: 100%;
    max-height: none;
  }

  body:not(.mobile-thread-open) .thread-panel {
    display: none;
  }

  body.mobile-thread-open .sidebar {
    display: none;
  }

  body.mobile-thread-open .thread-panel {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 20;
    height: 100%;
    border-radius: 0;
  }

  .thread-view {
    height: 100%;
    min-height: 0;
  }

  .sidebar-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }

  .sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .sidebar-actions .button {
    padding-inline: 12px;
  }

  .filter-toggle {
    display: inline-flex;
    justify-content: center;
    background: white;
  }

  .filter-panel {
    display: none;
  }

  body.mobile-filters-open .filter-panel {
    display: block;
  }

  .search {
    margin: 12px 14px 10px;
    width: calc(100% - 28px);
  }

  .filter-row {
    grid-template-columns: 1fr;
    padding: 0 14px 12px;
  }

  .conversation-list {
    flex: 1;
    min-height: 180px;
  }

  .conversation-item {
    padding: 14px;
  }

  .conversation-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .conversation-badges {
    flex-wrap: wrap;
  }

  .thread-panel {
    min-height: 0;
  }

  .thread-header {
    flex-direction: column;
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 4px;
    padding: 6px 10px;
  }

  .thread-mobile-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .thread-mobile-action-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .back-button {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 7px 10px;
  }

  .assignment-toggle-button {
    display: inline-flex;
  }

  .mobile-origin-button {
    display: inline-flex;
    min-height: 36px;
    font-size: 0.82rem;
  }

  .thread-header h2 {
    margin-bottom: 3px;
    font-size: 1rem;
    line-height: 1.15;
  }

  #threadMeta {
    align-items: flex-start;
    font-size: 0.84rem;
    line-height: 1.35;
  }

  #threadMeta > span:not(.thread-meta-badges),
  .thread-header > .badges {
    display: none;
  }

  .badge {
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.76rem;
  }

  .account-pill,
  .channel-pill {
    padding: 2px 7px;
    font-size: 0.7rem;
  }

  .assignment-bar {
    display: none;
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 12px;
  }

  body.mobile-assignment-open .assignment-bar {
    display: grid;
  }

  .assignment-bar .button {
    width: 100%;
  }

  .messages {
    flex: 1;
    min-height: 0;
    padding: 14px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    max-width: 92%;
  }

  .composer {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 3;
    grid-template-columns: 48px 48px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    background: white;
  }

  .composer textarea {
    grid-column: 1 / -1;
    min-height: 64px;
    max-height: 96px;
  }

  .composer .button.primary {
    grid-column: 3;
    width: 100%;
  }

  .button.audio-library-button,
  .button.attach {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
  }

  .button.audio-library-button {
    grid-column: 1;
  }

  .button.attach {
    grid-column: 2;
  }

  .audio-library-item {
    grid-template-columns: 1fr;
  }

  .audio-library-item-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .audio-library-item audio {
    width: 100%;
    max-width: none;
  }

  .attachment-preview {
    grid-column: 1 / -1;
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-backdrop {
    align-items: stretch;
    justify-items: stretch;
    padding: 0;
  }

  .modal-panel {
    position: relative;
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-panel header {
    position: sticky;
    top: 0;
    z-index: 2;
    align-items: center;
    padding: 10px 54px 10px 14px;
    background: white;
  }

  .modal-panel h2 {
    font-size: 1rem;
  }

  .modal-close {
    display: none;
  }

  .modal-floating-close {
    display: inline-flex;
  }

  .lead-card dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }

  .topbar-actions .button {
    width: auto;
  }

  .config-badge {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .app-shell {
    height: calc(100dvh - 104px);
    padding: 0;
  }

  body.mobile-thread-open .app-shell {
    height: 100dvh;
  }

  .sidebar,
  .thread-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .sidebar {
    height: 100%;
    max-height: none;
  }

  .thread-panel {
    min-height: 0;
  }

  .thread-header {
    padding: 8px 10px;
  }

  .messages {
    min-height: 0;
  }

  .message {
    max-width: 96%;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }
}
