/* The companion uses existing theme colors and stays outside page scroll areas. */
.babycat-companion{position:fixed;right:20px;bottom:max(18px,env(safe-area-inset-bottom));z-index:8000;color:var(--theme-surface-ink,var(--ink));font-size:13px}
.companion-launcher{display:flex;align-items:center;gap:8px;padding:10px 16px;border:1px solid var(--green);border-radius:24px;background:var(--theme-surface);color:var(--theme-surface-ink);box-shadow:0 6px 24px #0003;font-weight:700;animation:companion-hello 1.2s ease-out 1}
.companion-launcher:hover svg{transform:rotate(-8deg)}
.companion-panel{position:absolute;right:0;bottom:68px;width:min(440px,calc(100vw - 32px));height:min(720px,calc(100dvh - 110px));display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--green);border-radius:20px;background:var(--theme-surface);box-shadow:0 12px 50px #0005}
.companion-panel[hidden]{display:none!important}
.companion-panel header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:16px 18px;border-bottom:1px solid var(--border)}
.companion-panel h2{font-size:20px;margin:4px 0 0}.companion-panel small{display:block;color:var(--theme-surface-muted,var(--muted));font-size:11px}
.companion-disclosure{margin:0;padding:10px 18px;font-size:11px;line-height:1.5;color:var(--theme-surface-muted,var(--muted));max-height:88px;overflow:auto;border-bottom:1px solid var(--border)}
.companion-context{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 18px;font-size:11px;background:var(--theme-panel);color:var(--theme-panel-ink)}
.companion-context button{font-size:11px;padding:4px 6px}
.companion-chat{overflow:auto;flex:1;min-height:80px;padding:12px;overscroll-behavior:contain;display:flex;flex-direction:column;gap:12px}
.companion-message{padding:12px;border:1px solid var(--border);border-radius:14px;background:var(--theme-panel);color:var(--theme-panel-ink);overflow-wrap:anywhere;flex:none}
.companion-message.from-user{margin-left:24px}.companion-message p{margin:8px 0;white-space:pre-wrap;line-height:1.6}
.companion-message button{margin:4px 6px 4px 0;max-width:100%;text-align:left;white-space:normal}
.companion-rule{margin:12px 0;padding:10px;border:1px solid var(--border);border-radius:10px;background:var(--theme-surface);color:var(--theme-surface-ink)}
.companion-rule pre{font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:180px}.companion-rule p{font-size:11px}
.companion-starters{display:flex;gap:4px;padding:6px 12px;flex-wrap:wrap}.companion-starters button{font-size:11px;padding:6px 8px}
.companion-panel form{padding:8px 16px;margin:0}.companion-panel label{display:block;font-size:12px}.companion-panel textarea{display:block;box-sizing:border-box;width:100%;min-height:52px;max-height:120px;resize:vertical;margin:5px 0}
.companion-actions{display:flex;gap:8px;align-items:center}.companion-drafting{display:flex;align-items:end;gap:8px;padding:4px 16px}.companion-drafting label{flex:1}.companion-drafting select{width:100%;margin-top:4px}
.companion-panel [data-companion-status]{padding:8px 16px;margin:0;max-height:74px;overflow:auto;font-size:11px;line-height:1.5;flex:none}
.assistant-rule-target{outline:3px solid var(--green);outline-offset:3px}
@keyframes companion-hello{0%,100%{transform:translateY(0)}40%{transform:translateY(-7px)}70%{transform:translateY(-3px)}}
@media(prefers-reduced-motion:reduce){.companion-launcher{animation:none}.companion-launcher:hover svg{transform:none}}
@media(max-width:700px){.babycat-companion{right:12px;bottom:max(12px,env(safe-area-inset-bottom))}.companion-launcher{padding:8px 12px}.companion-panel{bottom:62px;width:calc(100vw - 24px);height:calc(100dvh - 92px)}.companion-disclosure{max-height:62px}.companion-starters{padding:4px 12px}.companion-panel header{padding:10px 16px}}
/* Context help wraps labels without changing the companion's bounded layout. */
.companion-panel .help-field{min-width:0}.companion-drafting>.help-field{flex:1}.companion-panel>.help-info{align-self:flex-start;margin:0 16px;height:18px;min-height:18px}.supplier-correction-table .help-field{padding-right:24px}.supplier-correction-table .help-info{position:absolute;right:0;top:0}

.companion-source,.companion-workflow{border:1px solid var(--border);border-radius:10px;padding:10px;margin-top:12px}.companion-source pre{white-space:pre-wrap;overflow-wrap:anywhere;font-size:12px;max-height:220px;overflow:auto}.companion-workflow ol{padding-left:22px}.companion-workflow li{padding:8px 0}.companion-workflow label{display:flex;align-items:flex-start;gap:8px}.companion-workflow input[type=checkbox]{width:18px;height:18px;flex:0 0 auto;margin-top:3px}.companion-workflow label:has(input:checked) span{text-decoration:line-through;opacity:.7}.companion-workflow li p{font-size:12px}.companion-workflow h3{margin:0 0 6px}

.companion-history{padding:8px 14px;border-bottom:1px solid var(--border)}.companion-history [data-companion-history]{display:grid;gap:6px;max-height:180px;overflow:auto}.companion-history button{text-align:left;overflow-wrap:anywhere}.companion-history-actions{padding:6px 14px;display:flex;gap:8px;flex-wrap:wrap;align-items:center;font-size:12px}.companion-history-actions span{flex:1;min-width:0;overflow-wrap:anywhere}

/* Chat first: utilities stay in the toolbar and history opens as an overlay. */
.companion-panel>[hidden]{display:none!important}
.companion-panel>header{gap:8px;padding:12px;flex:none}.companion-panel>header>div{flex:1;min-width:0}.companion-panel>header h2{font-size:17px;margin:0}.companion-panel>header small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px}.companion-panel>header button{padding:6px;background:transparent;border:0;font-size:21px;min-width:32px;height:34px}
.companion-panel .companion-history{position:absolute;inset:64px 0 0;z-index:5;background:var(--theme-surface);padding:18px;overflow:auto}.companion-history [data-companion-history]{max-height:none}.companion-history button{display:block;width:100%;padding:12px;margin:6px 0;border-radius:10px}.companion-history h3{margin-top:0}.companion-action-history{margin-top:20px}
.companion-context{background:transparent;padding:6px 16px}.companion-welcome{margin:auto 8px;text-align:center;padding:24px 12px;color:var(--muted)}.companion-welcome h3{color:var(--theme-surface-ink);font-size:20px}.companion-welcome p{line-height:1.6}
.companion-panel form{flex:none;padding:10px 12px 0}.companion-composer{position:relative;border:1px solid var(--border);border-radius:18px;background:var(--theme-input)}.companion-composer:focus-within{outline:2px solid var(--green)}.companion-panel .companion-composer textarea{border:0;background:transparent;box-shadow:none;outline:none;padding:14px 52px 14px 14px;margin:0;resize:none;min-height:78px}.companion-composer [data-companion-send]{position:absolute;right:9px;bottom:9px;width:34px;height:34px;padding:0;border-radius:50%;font-size:23px;text-align:center}.companion-panel [data-companion-status]{padding:6px 16px;min-height:14px}.companion-panel [data-thread-older]{align-self:center;font-size:12px}

.companion-answer{font-size:14px;line-height:1.65}.companion-answer h3{font-size:18px;line-height:1.35;margin:10px 0}.companion-answer h4{font-size:14px;line-height:1.4;margin:0 0 8px}.companion-answer p{white-space:normal;margin:8px 0}.companion-answer-summary{color:var(--theme-panel-ink)}.companion-answer-section{padding-top:12px;margin-top:12px;border-top:1px solid var(--border)}.companion-answer ol,.companion-answer ul{padding-left:24px;margin:8px 0}.companion-answer li{padding:5px 0 5px 3px}.companion-answer li::marker{color:var(--theme-accent);font-weight:700}.companion-answer code{font:12px ui-monospace,monospace;background:var(--theme-input);padding:2px 5px;border-radius:4px}.companion-answer pre{white-space:pre-wrap;overflow-wrap:anywhere;padding:12px;border:1px solid var(--border);border-radius:8px;background:var(--theme-input);font:12px/1.6 ui-monospace,monospace}.companion-answer .answer-callout{padding:12px;border:1px solid var(--border);border-left:3px solid var(--theme-accent);border-radius:8px;background:var(--theme-input)}.companion-answer .answer-callout.warning{border-left-color:#d6a34c}
/* Rich replies keep the chat compact; controls answer questions, not hidden APIs. */
.assistant-rich-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}.assistant-rich-grid>h4{grid-column:1/-1}.assistant-rich-card{display:flex;flex-direction:column;gap:5px;padding:12px;border:1px solid var(--border);border-radius:10px;background:var(--theme-surface);min-width:0}.assistant-rich-card>strong{font-size:15px}.assistant-rich-card>small{color:var(--muted)}.assistant-rich-card p{font-size:12px;margin:0}.assistant-rich-card.tone-success{border-color:var(--green)}.assistant-rich-card.tone-warning{border-color:#b88029}.assistant-rich-table{overflow:auto}.assistant-rich-table table{width:100%;border-collapse:collapse;font-size:12px}.assistant-rich-table th,.assistant-rich-table td{padding:8px;text-align:left;vertical-align:top;border:1px solid var(--border)}.assistant-rich-table th{font-weight:700;background:var(--theme-surface)}.assistant-rich-choice{display:flex;flex-direction:column;gap:4px;width:100%;padding:10px!important;border:1px solid var(--border);border-radius:8px;background:var(--theme-surface)}.assistant-rich-choice small{color:var(--muted)}.companion-panel .assistant-rich-form{padding:0;display:grid;gap:9px}.assistant-rich-form label{display:flex;flex-direction:column;gap:4px}.assistant-rich-form input:not([type=checkbox]),.assistant-rich-form select{width:100%;box-sizing:border-box}.assistant-rich-form input[type=checkbox]{align-self:flex-start}.assistant-rich-form>small{color:var(--muted);font-size:11px}.companion-panel .assistant-rich-form>button{justify-self:start}

.companion-review-step{border:1px solid var(--border);border-radius:10px;padding:10px;margin:8px 0}.companion-review-step h4{margin:0 0 6px}.companion-review-step p{margin:5px 0;overflow-wrap:anywhere}.companion-review-fields{padding-left:8px;border-left:2px solid var(--border)}.companion-review-controls{display:flex;gap:8px}.companion-review-step pre{max-height:220px;overflow:auto;white-space:pre-wrap}

.assistant-rich-grid>.assistant-rich-card:only-of-type{grid-column:1/-1}
