.app { height: 100dvh; min-height: 0; grid-template-columns: 180px minmax(0, 1fr); overflow: hidden; }
.app .main, .app .workspace { min-height: 0; }
.app .workspace { overflow: auto; }
#view-chat { height: 100%; min-height: 0; }
#view-chat .chat-workspace { height: 100%; min-height: 0; grid-template-columns: 210px minmax(0, 1fr) 270px; gap: 12px; }
#view-chat .band { border-radius: 0; box-shadow: none; min-width: 0; }
#view-chat .chat-sidebar .band-body { display: flex; flex-direction: column; gap: 8px; }
#sessionSearch { flex: 0 0 38px; height: 38px; }
#view-chat .session-list { height: auto; flex: 1; min-height: 0; }
#view-chat .chat-stream { height: auto; }
.icon-button { width: 34px; height: 34px; flex: 0 0 34px; padding: 6px !important; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; }
.icon-button svg, .source-open svg { width: 17px; height: 17px; }
.icon-button:hover { background: #e9f2ef; }
.icon-button:disabled { opacity: .5; cursor: default; }
.message-actions { display: flex; gap: 5px; }
.message-actions .icon-button { border-color: transparent; background: transparent; color: #626b75; width: 30px; height: 30px; flex-basis: 30px; }
.message-actions .icon-button:hover { background: #e5ece8; color: #155e48; }
.scope-row { display: flex; gap: 10px; align-items: center; min-width: 0; margin-bottom: 8px; font-size: 12px; }
.scope-row label { flex-shrink: 0; color: #606b73; }
.scope-row select { flex: 1; min-width: 0; max-width: 100%; padding: 6px; }
#sessionSearch { width: 100%; margin-bottom: 12px; }
#editingNotice { font-size: 12px; color: #8a5610; display: flex; align-items: center; gap: 12px; }
.chat-panel .chat-stream { padding: 20px 24px; background: #f8faf9; }
.chat-panel .message-row { min-width: 0; max-width: 100%; width: 100%; }
.chat-panel .message-row.user { width: auto; max-width: 90%; }
.chat-panel .markdown-body { white-space: normal; width: 100%; min-width: 0; overflow: hidden; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-size: 17px; line-height: 1.5; margin: 14px 0 8px; }
.markdown-body ul, .markdown-body ol { padding-left: 23px; margin: 8px 0; }
.markdown-body li { margin-bottom: 5px; }
.markdown-body pre { white-space: pre; overflow: auto; background: #f0f2f4; padding: 12px; border: 1px solid #dce0e3; border-radius: 5px; }
.markdown-body code { font-family: ui-monospace, monospace; font-size: 13px; background: #eef1f2; }
.table-scroll { width: 100%; overflow-x: auto; }
.markdown-body table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; }
.markdown-body th { position: static; }
.markdown-body td, .markdown-body th { border: 1px solid #d4ded8; padding: 7px 9px; min-width: 90px; white-space: normal; }
.markdown-body th { background: #ecf1ee; }
.citation-marker { color: #076c54; border: 0; background: #e0f0e8; padding: 1px 3px; cursor: pointer; font: inherit; border-radius: 3px; }
.source-open { display: inline-flex; gap: 6px; align-items: center; color: #0b6b63; border: 0; background: transparent; padding: 5px 0; cursor: pointer; }
.citation-card .result-meta { display: none; }
.chat-panel .band-header h3 { max-width: 100%; overflow-wrap: anywhere; font-size: 17px; }
.chat-panel .band-header > div:first-child { min-width: 0; }
.chat-panel .band-header > .actions { flex-shrink: 0; }
.chat-panel .band-header { flex-wrap: wrap; gap: 10px; }
.chat-panel #chatSessionStatus { display: none; }
#sourceDialog { width: min(1050px, 94vw); max-height: 90dvh; padding: 0; border: 1px solid #bac9c0; border-radius: 8px; overflow: auto; color: #19251e; }
#sourceDialog::backdrop { background: rgb(10 20 16 / 45%); }
#sourceDialog header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; position: sticky; top: 0; background: #fff; border-bottom: 1px solid #d4ded8; z-index: 1; }
#sourceDialog h2 { font-size: 17px; overflow-wrap: anywhere; margin: 0; }
.source-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 18px; font-size: 13px; background: #f0f5f2; }
#sourceBody { padding: 16px; }
.source-excerpt { max-height: 180px; overflow: auto; white-space: pre-wrap; font-size: 13px; padding: 12px; line-height: 1.6; margin-bottom: 12px; border: 1px solid #dce3de; }
.source-excerpt mark { background: #fff4bf; }
.source-page { display: block; width: 100%; height: auto; border: 1px solid #dce3de; }
@media (max-width: 1200px) and (min-width: 981px) {
  #view-chat .chat-workspace { grid-template-columns: 180px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 190px; }
  #view-chat .citation-panel { grid-column: 1 / -1; max-height: 240px; }
}
@media (max-width: 980px) {
  .app { display: block; height: auto; min-height: 100dvh; overflow: visible; }
  .app .main { display: block; }
  .app .sidebar .brand { padding: 10px 16px; }
  .app .sidebar .brand p { display: none; }
  .app .sidebar .nav { display: flex; overflow-x: auto; flex-wrap: nowrap; padding: 6px; gap: 4px; }
  .app .sidebar .nav button { width: auto; flex: 0 0 auto; padding: 8px; font-size: 12px; white-space: nowrap; }
  .app .topbar { padding: 8px 12px; position: static; gap: 8px; }
  .app .topbar .status-line { flex-wrap: wrap; gap: 5px; font-size: 11px; }
  .app .topbar #queueCount { display: none; }
  .app .workspace { padding: 8px; overflow: visible; }
  #view-chat .chat-workspace { display: flex; flex-direction: column; min-height: 0; }
  #view-chat .chat-sidebar .band-body { padding: 8px; }
  #view-chat .chat-sidebar .session-list { display: flex; flex-direction: row; overflow-x: auto; flex: 0 0 60px; max-height: 60px; gap: 6px; }
  #view-chat .chat-sidebar .session-item { min-width: 180px; max-width: 240px; flex-shrink: 0; padding: 6px 8px; }
  #view-chat .chat-sidebar .band-header { padding: 8px 12px; }
  #sessionSearch { margin-bottom: 6px; padding: 6px; }
  #view-chat .chat-stream { height: 48dvh; min-height: 260px; padding: 12px; }
  #view-chat .chat-panel { display: flex; flex-direction: column; }
  #view-chat .chat-panel .band-header { padding: 10px; }
  #view-chat .chat-composer { padding: 10px; }
  #view-chat .composer-row { flex-wrap: wrap; gap: 8px; }
  #view-chat .composer-row > .actions { flex: 1; gap: 6px; }
  #view-chat .compact-control { font-size: 12px; }
  #view-chat .citation-panel { max-height: 280px; }
  .chat-panel .band-header > .actions { gap: 4px; }
  #sourceDialog { width: 96vw; }
}
