.ai-panel {
  position: fixed; inset: 12px 12px 12px auto; z-index: 3200;
  width: min(510px, calc(100vw - 24px)); display: flex; flex-direction: column; min-height: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: -12px 12px 50px rgba(52, 30, 34, .16); color: var(--ink);
}
.ai-panel.ai-full { inset: 12px; width: auto; }
.ai-panel button { border: 1px solid var(--line); border-radius: 5px; padding: 7px 10px; background: #fff; color: var(--ink); }
.ai-panel button:hover { background: var(--brand-pale); border-color: var(--brand); }
.ai-panel button:disabled { opacity: .5; cursor: default; }
.ai-panel button:focus-visible, .ai-panel textarea:focus-visible, .ai-panel select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ai-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 14px; }
.ai-header strong { font-size: 18px; }
.ai-header > div > span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.ai-header nav { display: flex; gap: 5px; }
.ai-header nav button { border-color: transparent; padding: 5px 7px; font-size: 12px; }
.ai-context { display: flex; gap: 6px; align-items: center; padding: 9px 18px; background: #faf8f8; border-block: 1px solid #f1ecee; font-size: 12px; }
.ai-context > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-context button { padding: 4px 6px; font-size: 11px; }
.ai-history { display: flex; gap: 8px; padding: 0 18px 12px; }
.ai-history select { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 5px; }
.ai-history button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); }
.ai-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px; scroll-behavior: auto; }
.ai-full .ai-messages, .ai-full .ai-composer { width: 100%; max-width: 1040px; margin-inline: auto; }
.ai-welcome { padding: 34px 8px; }
.ai-wordmark { color: var(--brand); font-size: 13px; letter-spacing: 2px; margin-bottom: 18px; }
.ai-welcome h2 { margin: 0 0 12px; font-size: 23px; font-weight: 600; }
.ai-welcome p { margin: 0 0 26px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.ai-suggestions { display: grid; gap: 0; }
.ai-suggestions button { display: flex; justify-content: space-between; border: 0; border-bottom: 1px solid #f0ecee; border-radius: 0; text-align: left; padding: 14px 0; font-size: 13px; }
.ai-suggestions button span { color: var(--muted); }
.ai-turn { margin-bottom: 30px; }
.ai-question { margin-left: 28px; padding: 12px 15px; background: #f5f2f3; border-radius: 9px 9px 2px 9px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.8; }
.ai-answer-label { margin: 20px 0 10px; color: var(--brand); font-size: 12px; font-weight: 600; }
.ai-answer { line-height: 1.85; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-answer-error { color: #ad2535; }
.ai-file-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.ai-file-tags span { font-size: 11px; border-top: 1px solid var(--line); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ai-facts { padding: 13px 0; margin-top: 14px; border-block: 1px solid var(--line); font-size: 12px; }
.ai-facts dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 0; }
.ai-facts dt { color: var(--muted); margin-bottom: 5px; }
.ai-facts dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ai-action-preview { margin-top: 16px; border: 1px solid var(--line); padding: 14px; border-radius: 7px; }
.ai-action-title { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.ai-action-title span { color: var(--brand); font-size: 12px; }
.ai-action-preview dl { margin: 12px 0; }
.ai-action-preview dl > div { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 9px; padding: 5px 0; font-size: 12px; line-height: 1.6; }
.ai-action-preview dt { color: var(--muted); }
.ai-action-preview dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-action-preview p { font-size: 12px; color: var(--brand); }
.ai-edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; padding-top: 10px; border-top: 1px dashed var(--line); }
.ai-edit-fields label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; }
.ai-edit-fields label:first-child:last-child { grid-column: 1 / -1; }
.ai-edit-fields input, .ai-edit-fields select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 5px; padding: 7px; background: #fff; color: var(--ink); font: inherit; }
.ai-edit-fields input:disabled, .ai-edit-fields select:disabled { opacity: .6; }
.ai-progress-stage { margin-top: 5px; color: var(--brand); font-size: 11px; }
.ai-action-buttons { display: flex; gap: 7px; flex-wrap: wrap; }
.ai-action-buttons button { font-size: 12px; }
.ai-panel .ai-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.ai-panel .ai-primary:hover { background: var(--ui-primary-hover); }
.ai-sources { margin-top: 15px; font-size: 12px; color: var(--muted); }
.ai-sources summary { cursor: pointer; }
.ai-sources button { display: block; margin-top: 7px; max-width: 100%; text-align: left; overflow-wrap: anywhere; font-size: 12px; }
.ai-asof { margin-top: 10px; font-size: 10px; color: var(--muted); }
.ai-progress { color: var(--muted); font-size: 12px; line-height: 1.8; }
.ai-progress > span { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--brand); animation: ai-pulse 1s ease-in-out infinite alternate; }
.ai-composer { flex-shrink: 0; padding: 12px 18px 14px; border-top: 1px solid var(--line); }
.ai-input-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ai-composer textarea { display: block; width: 100%; min-height: 66px; max-height: 140px; resize: vertical; border: 1px solid var(--line); border-radius: 7px; padding: 11px; font-size: 13px; line-height: 1.7; background: #fff; color: var(--ink); }
.ai-compose-actions { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.ai-voice { min-width: 74px; color: var(--muted); }
.ai-voice-icon { width: 40px; min-width: 40px !important; padding-inline: 0 !important; font-size: 17px; line-height: 1; }
.ai-voice.is-listening { color: #a32235; border-color: #d8929e; background: #fff4f5; }
.ai-voice-hold { flex: 1; min-height: 42px; border-color: var(--brand) !important; color: var(--brand) !important; font-size: 14px; touch-action: none; user-select: none; }
.ai-voice-hold.is-listening { background: #fff4f5 !important; color: #a32235 !important; border-color: #d8929e !important; }
.ai-compose-actions small { flex: 1; font-size: 10px; color: var(--muted); text-align: right; }
.ai-compose-actions > button { min-width: 64px; }
.ai-upload { color: var(--muted); cursor: pointer; font-size: 12px; }
.ai-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ai-upload:focus-within { outline: 2px solid var(--brand); }
.ai-upload.is-disabled { opacity: .5; cursor: default; }
.ai-footnote { margin: 9px 0 0; font-size: 10px; color: var(--muted); }
.ai-error, .ai-service-status { font-size: 12px; padding: 8px 0; line-height: 1.6; color: #9b2432; }
.ai-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-attachments > span { display: flex; align-items: center; gap: 5px; max-width: 100%; overflow-wrap: anywhere; background: #f6f3f4; border-radius: 4px; padding: 3px 6px; margin-bottom: 8px; font-size: 11px; }
.ai-attachments button { padding: 0 4px; border: 0; background: transparent; }
@keyframes ai-pulse { to { opacity: .3; } }
@media (max-width: 600px) {
  html.oa-ai-open, html.oa-ai-open body { overflow: hidden; }
  .ai-panel, .ai-panel.ai-full { inset: 0; width: 100%; height: 100dvh; border-radius: 0; }
  .ai-header { padding: 13px; } .ai-header nav { gap: 2px; }
  .ai-messages { padding: 16px; }
  .ai-composer { padding: 10px 13px max(12px, env(safe-area-inset-bottom)); }
  .ai-compose-actions small { display: none; } .ai-compose-actions > button:last-child { margin-left: auto; }
  .ai-edit-fields { grid-template-columns: 1fr; }
  .ai-edit-fields label:first-child:last-child { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { .ai-progress > span { animation: none; } }
