/* Stable viewport: only the conversation scrolls on wide screens. */
html, body { height: 100%; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; }
button, input, textarea { font-family: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible, [role=button]:focus-visible { outline: 2px solid #e75d46; outline-offset: 3px; }
.app { height: calc(100dvh - 32px); min-height: 0; }
.sidebar, .workspace { min-height: 0; }
#chat { min-height: 0; overscroll-behavior: contain; scroll-padding: 20px; }
.side-title { display: flex; align-items: center; justify-content: space-between; }
#clearChats { padding: 4px 8px; color: #d6e8df; background: transparent; border: 0; cursor: pointer; }
#conversationList { flex: 1; }
.conversation-row { display: flex; align-items: center; gap: 2px; }
.conversation { min-width: 0; flex: 1; }
.delete-chat { flex: 0 0 30px; height: 34px; border: 0; background: transparent; color: #c6ddd1; font-size: 22px; cursor: pointer; }
.delete-chat:hover { color: #ffb39a; }
.side-footer { display: flex; justify-content: space-between; }
.topbar > div { min-width: 0; }
.topbar h1 { overflow-wrap: anywhere; }
#currentTitle { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message { overflow-wrap: anywhere; }
.message-body { overflow-wrap: anywhere; }
.message-actions { display: flex; gap: 10px; margin-top: 5px; }
.message-actions button { padding: 3px 5px; border: 0; background: transparent; color: #456a5c; cursor: pointer; font-size: 12px; }
.message-actions button:hover { color: #b84936; }
.failed .message-body { background: #fff0eb; color: #8c4637; border-color: #f2cec0; }
.waiting .message-body { color: #526e62; }
#previews { display: flex; gap: 8px; overflow: auto; }
.preview { position: relative; flex: 0 0 66px; width: 66px; height: 66px; margin-bottom: 10px; }
.preview img { width: 66px; height: 66px; object-fit: cover; border-radius: 5px; border: 1px solid #d8e4dd; }
.preview button { position: absolute; top: 0; right: 0; width: 24px; height: 24px; border: 0; border-radius: 3px; background: #143d37; color: white; font-size: 18px; cursor: pointer; }
.message-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.message-images img { width: 140px; height: 100px; max-width: 100%; object-fit: contain; background: #fff; border-radius: 5px; }
#send { min-height: 60px; }
textarea { resize: none; min-height: 60px; }
.composer-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 11px; color: #657d71; min-height: 16px; }
.composer-foot details { position: relative; flex-shrink: 0; }
.composer-foot summary { cursor: pointer; }
.composer-foot details p { position: absolute; bottom: 20px; right: 0; width: min(270px, 80vw); padding: 12px; margin: 0; border: 1px solid #d4e0d8; background: #fff; border-radius: 6px; line-height: 1.7; box-shadow: 0 6px 20px #143d3714; z-index: 2; }
button:disabled { opacity: .5; cursor: wait; }
@media (max-width: 780px) {
  .app { height: 100dvh; min-height: 440px; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 10px 14px; }
  .brand { padding: 0; gap: 8px; }
  .brand b { font-size: 15px; }
  .brand span { display: none; }
  .brand-mark { width: 30px; height: 30px; font-size: 16px; flex-shrink: 0; }
  .new-chat { min-height: 34px; font-size: 13px; }
  .side-title { margin: 0; font-size: 11px; }
  .side-footer { display: block; padding: 0; margin: 0; text-align: right; grid-column: 2; grid-row: 2; }
  #conversationList { grid-column: 1 / -1; min-height: 0; }
  .conversation-row { flex: 0 0 164px; min-width: 0; }
  .conversation { padding: 6px; }
  .conversation-title { font-size: 12px; }
  .conversation-time { margin-top: 2px; font-size: 10px; }
  .delete-chat { flex-basis: 24px; }
  .workspace { min-height: 0; }
  .topbar { min-height: 52px; padding: 8px 14px; gap: 8px; }
  .topbar h1 { font-size: 16px; }
  .access { width: 100px; min-width: 80px; font-size: 16px; }
  #chat { min-height: 0; padding: 14px; }
  .composer { padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
  textarea { font-size: 16px; }
  .attachment-row { gap: 6px; margin-bottom: 7px; }
  .message { max-width: 96%; }
}
@media (max-height: 560px) and (max-width: 780px) {
  #conversationList, .side-title { display: none; }
  .sidebar { grid-template-columns: 1fr auto; }
  .side-footer { grid-column: 1; grid-row: auto; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
