html, body.oa-chat-page { height: 100%; }
body.oa-chat-page {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}
body.oa-chat-page main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.oa-chat-nav {
  padding: 0.55rem 1rem;
  gap: 0.6rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.oa-chat-nav .oa-brand small { font-size: 0.78rem; }
.oa-chat-nav .oa-logo { width: 32px; height: 32px; }
.oa-menu-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: #fff3e8;
  border-radius: 12px;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 11px 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.oa-menu-btn span {
  display: block;
  height: 2px;
  background: var(--navy);
  border-radius: 2px;
}
.oa-chat-page .oa-chat-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.2rem;
  padding: 1rem 1.2rem;
  overflow: hidden;
}
.oa-chat-backdrop { display: none; }
.oa-chat-side, .oa-chat-main {
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}
.oa-chat-side {
  padding: 1.4rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.oa-chat-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  flex-shrink: 0;
}
.oa-chat-menu-head h2 {
  margin: 0;
  font-family: Outfit, sans-serif;
  font-size: 1.15rem;
}
.oa-menu-close { display: none; }
.oa-chat-side label { display: block; margin: 0.9rem 0; font-weight: 600; }
.oa-chat-menu-links {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.oa-chat-menu-links a { font-weight: 600; }
.oa-chat-main { display: flex; flex-direction: column; }
.oa-chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.oa-msg { max-width: 78%; padding: 0.8rem 1rem; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.oa-msg.user { margin-left: auto; background: #ff7a00; color: #fff; }
.oa-msg.assistant { background: #eef2ff; }
.oa-msg.agent { background: #fce7f3; }
.oa-msg.system { background: #ecfdf5; color: #166534; }
.oa-msg small { display: block; opacity: 0.75; font-size: 0.75rem; margin-top: 0.35rem; }
.oa-msg a { color: inherit; font-weight: 600; }
/* WhatsApp-style cards: map pin, document, sent photo */
.oa-msg.card { display: flex; flex-direction: column; gap: 0.2rem; white-space: normal; }
.oa-msg.card .oa-card-title { font-weight: 700; }
.oa-msg.card .oa-card-sub { opacity: 0.8; font-size: 0.9rem; }
.oa-msg.card .oa-card-action { margin-top: 0.4rem; }
.oa-msg img.oa-thumb { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 0.35rem; }
.oa-live-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--line);
  background: #fff7ed;
  flex-shrink: 0;
}
.oa-live-bar[hidden] { display: none; }
.oa-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15);
}
.oa-chat-composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem;
  border-top: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}
.oa-chat-composer input { flex: 1; min-width: 0; }
.oa-icon-btn {
  border: 0;
  background: #fff3e8;
  border-radius: 12px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  cursor: pointer;
}
.oa-icon-btn.recording,
.oa-icon-btn.live { background: #fee2e2; box-shadow: 0 0 0 3px #fecaca; }

@media (max-width: 720px) {
  .oa-chat-page .oa-flash { display: none; }
  .oa-menu-btn { display: flex; }
  .oa-menu-close { display: inline-flex; }
  .oa-chat-page .oa-chat-shell {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    gap: 0;
    padding: 0;
  }
  .oa-chat-page .oa-chat-main {
    flex: 1;
    border-radius: 0;
    box-shadow: none;
  }
  .oa-chat-page .oa-chat-log { padding: 0.85rem; }
  .oa-chat-page .oa-chat-composer {
    padding: 0.65rem 0.65rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  /* Phones: text box + Send on the first row, the four tool buttons below. */
  .oa-chat-page .oa-chat-composer input { order: -2; flex: 1 1 calc(100% - 7.5rem); }
  .oa-chat-page .oa-chat-composer #send-btn { order: -1; }
  .oa-chat-page .oa-chat-composer .oa-icon-btn { flex: 1 1 0; }
  .oa-chat-page .oa-chat-composer .oa-btn { padding: 0.7rem 0.9rem; }
  .oa-chat-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 28, 46, 0.45);
    z-index: 30;
  }
  .oa-chat-backdrop[hidden] { display: none; }
  .oa-chat-page .oa-chat-side {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 360px);
    max-width: 360px;
    margin: 0;
    border-radius: 18px 0 0 18px;
    z-index: 40;
    overflow: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  body.is-menu-open .oa-chat-side {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
}
