/* Local companion: isolated from the messaging, Feed and Poker surfaces. */
.companion-panel {
  --co-bg: var(--pt-bg, #0c0f0d);
  --co-surface: var(--pt-surface-alt, #1b2418);
  --co-text: var(--pt-text, #e3edb7);
  --co-muted: var(--pt-muted, #9ba980);
  --co-line: var(--pt-line, #293323);
  --co-accent: var(--pt-accent, #d7e5a3);
  --co-button: #d7e5a3;
  --co-button-text: #25321d;
  --co-error-surface: var(--pager-error-bg-v4, #1c2118);
  position: fixed; z-index: 1800; inset: var(--companion-top, 0px) 0 auto;
  height: var(--companion-height, 100dvh); width: 100%; overflow: hidden;
  background: var(--co-bg); color: var(--co-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%; text-align: left;
  animation: companion-arrive 220ms cubic-bezier(.2,.85,.25,1) both;
}
html[data-pager-theme="light"] .companion-panel { --co-button: #dce8bf; }
.companion-panel *, .companion-panel *::before, .companion-panel *::after { box-sizing: border-box; }
.companion-panel [hidden] { display: none !important; }
.companion-panel button, .companion-panel textarea { font: inherit; color: inherit; }
.companion-panel button {
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform 170ms cubic-bezier(.2,1.35,.4,1), background-color 140ms ease;
}
.companion-panel button:active:not(:disabled) { transform: scale(.96); }
.companion-panel button:disabled { cursor: default; opacity: .46; }
.companion-panel :focus-visible { outline: 2px solid var(--co-accent); outline-offset: 3px; }
.companion-panel svg:not(.companion-avatar), .companion-entry-arrow svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.companion-frame {
  width: 100%; max-width: 600px; height: 100%; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
}
.companion-header { flex: none; display: flex; align-items: center; min-height: 76px; gap: 5px; border-bottom: 1px solid var(--co-line); }
.companion-icon-button { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 14px; background: transparent; color: var(--co-accent) !important; }
.companion-identity { min-width: 0; display: flex; gap: 10px; align-items: center; justify-content: center; flex: 1; min-height: 54px; padding: 4px 0; border: 0; background: transparent; }
.companion-identity-copy { display: flex; flex-direction: column; min-width: 0; gap: 2px; text-align: left; }
.companion-identity strong { font-size: 17px; line-height: 22px; font-weight: 650; }
.companion-subtitle { font-size: 11px; line-height: 16px; color: var(--co-muted); }
.companion-avatar { display: block; flex: none; width: 36px; height: 36px; overflow: visible; background: transparent; }
.companion-pixel-shell { fill: #95ab68; }
.companion-pixel-screen { fill: #1b291b; }
.companion-pixel-eye { fill: #d7e5a3; }
.companion-pixel-spark { fill: #c6b17c; }
html[data-pager-theme="light"] .companion-pixel-shell { fill: #8da265; }
html[data-pager-theme="light"] .companion-pixel-screen { fill: #edf1db; }
html[data-pager-theme="light"] .companion-pixel-eye { fill: #42572f; }
html[data-pager-theme="light"] .companion-pixel-spark { fill: #927237; }
.companion-entry-arrow { justify-self: end; color: var(--pt-muted, #9ba980); display: grid; place-items: center; }
.companion-entry-arrow svg { width: 16px; height: 16px; }
.companion-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 0 2px 16px; -webkit-overflow-scrolling: touch; }
.companion-scroll::-webkit-scrollbar { display: none; }
.companion-welcome { text-align: center; padding: clamp(28px, 5vh, 44px) 4px 24px; }
.companion-welcome h1 { margin: 0; white-space: pre-line; font-size: clamp(23px, 6.15vw, 26px); line-height: 1.3; font-weight: 650; letter-spacing: -.035em; }
.companion-welcome p { margin: 10px 0 0; color: var(--co-muted); font-size: 14px; line-height: 1.5; }
.companion-model-card { display: flex; flex-direction: column; align-items: center; max-width: 350px; margin: 0 auto 18px; padding: 24px 22px 20px; border: 1px solid var(--co-line); border-radius: 26px; background: var(--co-bg); text-align: center; }
.companion-model-card .is-large { width: 64px; height: 64px; margin: 0 0 18px; }
.companion-model-card h2 { margin: 0; font-size: 21px; line-height: 1.25; font-weight: 650; letter-spacing: -.025em; }
.companion-model-description { margin: 10px 0 22px; max-width: 270px; font-size: 14px; line-height: 1.55; color: var(--co-muted); }
.companion-primary { min-height: 48px; width: 100%; border: 0; border-radius: 16px; background: var(--co-button); color: var(--co-button-text) !important; padding: 12px 14px; font-size: 14px !important; line-height: 20px !important; font-weight: 650 !important; }
.companion-model-hint { color: var(--co-muted); font-size: 11px; line-height: 1.5; margin: 12px 0 0; max-width: 260px; }
.companion-progress-wrap { width: 100%; display: grid; gap: 9px; margin-top: 4px; }
.companion-progress { display: block; width: 100%; height: 6px; border: 0; border-radius: 3px; overflow: hidden; appearance: none; background: var(--co-line); color: var(--co-accent); }
.companion-progress::-webkit-progress-bar { background: var(--co-line); border-radius: 3px; }
.companion-progress::-webkit-progress-value { background: var(--co-accent); border-radius: 3px; }
.companion-progress::-moz-progress-bar { background: var(--co-accent); border-radius: 3px; }
.companion-progress-numbers { color: var(--co-muted); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }
.companion-text-button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--co-accent) !important; padding: 10px 7px; font-size: 13px !important; line-height: 20px !important; }
.companion-model-card.is-compact { margin-top: 18px; padding: 18px; max-width: none; }
.companion-model-card.is-compact .companion-avatar, .companion-model-card.is-compact h2 { display: none; }
.companion-model-card.is-compact .companion-model-description { margin: 0 0 14px; }
.companion-messages { display: flex; flex-direction: column; gap: 9px; padding-top: 18px; }
.companion-messages:empty { display: none; }
.companion-message { display: flex; width: 100%; }
.companion-message.is-user { justify-content: flex-end; }
.companion-bubble { max-width: min(89%, 460px); border-radius: 19px 19px 19px 5px; padding: 12px 14px; background: var(--co-surface); overflow-wrap: anywhere; }
.companion-message.is-user .companion-bubble { border-radius: 19px 19px 5px 19px; background: var(--co-button); color: var(--co-button-text); }
.companion-message-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
.companion-message-state { display: block; margin-top: 7px; font-size: 10px; line-height: 15px; color: var(--co-muted); }
.companion-message-text:empty + .companion-message-state { margin-top: 0; }
.companion-message.is-generating .companion-message-state { animation: companion-thinking 1.6s ease-in-out infinite; }
.companion-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.companion-suggestion { padding: 10px 13px; min-height: 44px; border: 1px solid var(--co-line); border-radius: 14px; background: transparent; font-size: 12px !important; }
.companion-footer { flex: none; padding: 9px 0 max(10px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--co-line); background: var(--co-bg); }
.companion-composer { display: flex; align-items: flex-end; gap: 8px; margin: 0; }
.companion-input { display: block; width: 0; flex: 1; min-height: 48px; max-height: 116px; resize: none; padding: 13px 15px; border: 0; border-radius: 19px; background: var(--co-surface); outline-offset: -2px !important; font-size: 16px !important; line-height: 22px !important; overflow-y: auto; scrollbar-width: none; }
.companion-input::-webkit-scrollbar { display: none; }
.companion-input::placeholder { color: var(--co-muted); opacity: 1; }
.companion-input:disabled { opacity: .65; }
.companion-send { width: 48px; height: 48px; border-radius: 18px; background: var(--co-button); color: var(--co-button-text) !important; }
.companion-send.is-stopping svg { fill: currentColor; stroke-width: 0; }
.companion-input-count { display: block; text-align: right; color: var(--co-muted); font-size: 10px; line-height: 14px; padding-right: 58px; }
.companion-input-count:empty { display: none; }
.companion-notice { padding: 0 4px 8px; font-size: 12px; line-height: 1.5; color: var(--co-muted); }
.companion-notice.is-error, .companion-info-error {
  padding: 10px 12px; border: 0; border-radius: 12px; box-shadow: none;
  color: var(--co-text); background: var(--co-error-surface);
  font-size: 14px; line-height: 1.45; overflow-wrap: anywhere;
}
.companion-notice.is-error { margin-bottom: 8px; }
.companion-notice .companion-text-button { display: block; padding-left: 0; text-align: left; }
.companion-info-overlay { position: absolute; z-index: 1; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); background: var(--pt-overlay, rgba(4,6,4,.72)); }
.companion-info { width: 100%; max-width: 370px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 16px 20px 20px; border: 1px solid var(--co-line); border-radius: 26px; background: var(--co-bg); box-shadow: 0 16px 50px #0002; }
.companion-info::-webkit-scrollbar { display: none; }
.companion-info-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.companion-info-head h2 { margin: 0; font-size: 21px; line-height: 28px; font-weight: 650; letter-spacing: -.025em; }
.companion-info-head .companion-icon-button { margin-right: -8px; }
.companion-info-lead { margin: 14px 0 24px; font-size: 14px; line-height: 1.55; color: var(--co-muted); }
.companion-details { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; font-size: 15px; line-height: 22px; }
.companion-details strong { font-weight: 650; }
.companion-info-size { color: var(--co-muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.companion-info-status { margin: 6px 0 20px; font-size: 13px; line-height: 1.5; color: var(--co-muted); }
.companion-info-actions { border-top: 1px solid var(--co-line); }
.companion-action { display: block; width: 100%; min-height: 52px; padding: 15px 0; border: 0; border-bottom: 1px solid var(--co-line); text-align: left; background: transparent; font-size: 15px !important; line-height: 22px; }
.companion-action:last-child { border-bottom: 0; padding-bottom: 0; }
.companion-info-note { display: block; margin-top: 5px; color: var(--co-muted); font-size: 13px; line-height: 1.5; white-space: pre-line; }
.companion-remove-confirm p { margin: 18px 0; color: var(--co-muted); font-size: 13px; line-height: 1.55; }
.companion-remove-confirm .companion-text-button { display: block; margin: 4px auto 0; }
.companion-info-error { margin: 14px 0 0; }
.companion-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes companion-arrive { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes companion-thinking { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@media (max-width: 359px) {
  .companion-frame { padding-left: 12px; padding-right: 12px; }
  .companion-header { min-height: 66px; }
  .companion-identity { gap: 8px; }
  .companion-identity strong { font-size: 16px; }
  .companion-model-card { padding: 20px 17px 16px; }
  .companion-model-description { font-size: 13px; }
  .companion-welcome { padding-top: 23px; }
  .companion-bubble { padding: 11px 12px; }
}
@media (max-height: 620px) {
  .companion-welcome { padding-top: 20px; padding-bottom: 16px; }
  .companion-welcome h1 { font-size: 23px; }
  .companion-model-card { padding-top: 18px; }
  .companion-model-card .is-large { width: 48px; height: 48px; margin-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .companion-panel, .companion-panel *, .companion-panel *::before, .companion-panel *::after { animation: none !important; transition: none !important; }
}
