.pet-entry{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:4px 12px;border:1px solid #d9e4df;border-radius:24px;background:#fffdf8;color:#365c52;text-decoration:none;flex-shrink:0}
.pet-entry img{width:30px;height:30px;object-fit:contain}.sync-summary{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.pet-chat{box-sizing:border-box;display:flex;flex-direction:column;position:relative;width:100%;max-width:460px;height:min(640px,78dvh);min-height:300px;margin:0 auto;color:#4a5047;background:linear-gradient(155deg,#f6eee6dd,#eff3e9df);border:1px solid #fff9;border-radius:24px;overflow:hidden;box-shadow:0 16px 50px #5445360d;font:14px/1.6 system-ui,sans-serif}
.pet-chat[hidden],.pet-chat [hidden]{display:none!important}.pet-head{display:flex;align-items:center;gap:3px;padding:10px 10px 8px 16px;flex-shrink:0;z-index:2;background:#fffdf8a8}.pet-head>div{flex:1;min-width:0}.pet-head strong{display:block;font-size:14px}.pet-head small{display:block;font-size:10px;color:#7b8177;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pet-head button{border:0;background:transparent;color:#697566;font-size:19px;min-width:34px;min-height:44px;padding:4px;cursor:pointer;border-radius:12px}.pet-head .pet-history-button{font-size:11px;white-space:nowrap;padding:4px 8px}.pet-head button:hover,.pet-head button[aria-pressed=true]{background:#e7ebdf}
.pet-content{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}.pet-stage{flex:1;position:relative;min-height:0;isolation:isolate;overflow:hidden;background:radial-gradient(ellipse at 50% 65%,#fff9 0,transparent 65%)}.pet-stage-caption{position:absolute;top:14px;left:20px;color:#998d7c;font-size:9px;letter-spacing:.19em}.pet-portrait{position:absolute;inset:0 0 -10px;pointer-events:none}.pet-portrait img{width:100%;height:100%;object-fit:contain;object-position:center bottom;filter:drop-shadow(0 8px 15px #7c5b4818)}
.pet-bubble{position:absolute;left:16px;right:16px;bottom:15px;max-height:32%;overflow-y:auto;padding:13px 16px;background:#fffefaed;border:1px solid #fff;border-radius:19px 19px 19px 5px;box-shadow:0 7px 24px #80684b18;backdrop-filter:blur(7px);overflow-wrap:anywhere;white-space:pre-wrap;overscroll-behavior:contain}.pet-bubble>strong{display:block;color:#8e795f;font-size:11px;margin-bottom:4px}.pet-bubble-error{color:#8a5144}.pet-bubble-text{line-height:1.7}
.pet-chat #pet-form{margin:0;padding:7px 12px 12px;background:#fffdf8d9;flex-shrink:0}.pet-compose{display:flex;align-items:flex-end;gap:7px}.pet-compose textarea{flex:1;min-width:0;resize:none;max-height:100px}.pet-chat textarea,.pet-chat input:not([type=checkbox]){box-sizing:border-box;width:100%;padding:10px 12px;border:1px solid #d9dfd2;border-radius:14px;background:#fffdfb;color:#414d40;font:inherit}.pet-chat .btn{min-height:44px;flex-shrink:0}.pet-chat .primary{background:#566a55!important;color:#fff!important;border-radius:14px!important}.pet-options{font-size:10px;color:#808777;margin:0 0 6px 2px}.pet-options summary{cursor:pointer;width:max-content}.pet-context{display:flex;gap:5px;align-items:center;padding:5px 0}.pet-caption{font-size:11px;color:#7e857a;margin:4px 0 8px}.pet-link{border:0;background:none;color:#577354;font:inherit;font-size:12px;min-height:38px;cursor:pointer;padding:4px 7px}
.pet-archive,.pet-settings,.pet-drafts{flex:1;min-height:0;background:#fffdf8;overflow-y:auto;padding:14px}.pet-archive{display:flex;flex-direction:column}.pet-archive-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}.pet-archive-heading h2{font-size:16px;margin:0}.pet-messages{overflow-y:auto;overscroll-behavior:contain;flex:1;min-height:0;display:flex;flex-direction:column;gap:12px;padding:10px 0}.pet-message{max-width:92%;padding:10px 12px;border-radius:14px;background:#eef2e8;white-space:pre-wrap;overflow-wrap:anywhere;align-self:flex-start}.pet-message small{display:block;font-size:9px;color:#7e887b;margin-bottom:4px}.pet-user{align-self:flex-end;background:#e0eee6}.pet-error{background:#fff0ec;color:#934b39}.pet-notice{font-size:12px;background:#f2f0e8}.pet-empty{color:#8b9285;font-size:12px;text-align:center;padding:40px 10px}.pet-settings label,.pet-draft label{display:block;font-size:12px;margin:8px 0}.pet-draft{border:1px solid #d6dfce;border-radius:12px;padding:12px;margin:12px 0;background:#f7f9f2}.pet-draft>strong{display:block;margin-bottom:10px}.pet-draft .btn{margin-right:8px}.pet-draft-link{font:inherit;font-size:12px;color:#617254;background:#f0eddd;border:0;padding:9px;cursor:pointer;flex-shrink:0}
.pet-floating{position:fixed;z-index:850;right:20px;bottom:20px;width:330px;height:min(500px,calc(100dvh - 40px));margin:0;box-shadow:0 12px 36px #4a493b24}.pet-floating[data-view=archive]{height:min(620px,calc(100dvh - 40px));width:390px}.pet-floating[data-view=settings],.pet-floating[data-view=drafts]{height:min(580px,calc(100dvh - 40px));width:360px}.pet-pip{margin:0!important;padding:0!important;background:#f3f0e8}.pet-pip .pet-chat{border:0;border-radius:0;width:100%;max-width:none;height:100dvh;min-height:0}.pet-page-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.pet-page-heading h1{font-size:24px}.pet-page-help{font-size:11px;color:#87907f;max-width:460px;margin:12px auto}.pet-page-help a{float:right}.auth-locked .pet-chat{display:none!important}#page-pet-connect{overflow-wrap:anywhere}
@media(max-width:768px){.pet-chat{height:min(600px,calc(100dvh - 200px));min-height:280px}.pet-floating,.pet-floating[data-view=archive],.pet-floating[data-view=settings],.pet-floating[data-view=drafts]{width:min(360px,calc(100% - 16px));right:8px;bottom:calc(72px + env(safe-area-inset-bottom));height:min(520px,calc(100dvh - 100px - env(safe-area-inset-bottom)));border-radius:20px}.pet-compose textarea,.pet-settings input,.pet-settings textarea,.pet-draft input{font-size:16px!important}.pet-head{padding:6px 8px 6px 12px}.pet-head button{min-width:32px}.pet-head .pet-history-button{padding:4px 5px}.pet-bubble{left:12px;right:12px;bottom:10px;padding:10px 13px;font-size:13px}.pet-page-heading h1{font-size:21px}}
@media(max-height:500px){.pet-floating,.pet-floating[data-view=archive],.pet-floating[data-view=settings],.pet-floating[data-view=drafts]{bottom:4px;height:calc(100dvh - 8px);min-height:180px}.pet-options,.pet-stage-caption{display:none}.pet-head{padding-top:0;padding-bottom:0}.pet-bubble{max-height:52%;padding:7px 12px}.pet-stage{min-height:80px}}

/* The character shares the page background; only reading/editing views use a panel. */
.pet-chat[data-view=stage]{background:transparent;border:0;border-radius:0;box-shadow:none;overflow:visible}
.pet-chat[data-view=stage] .pet-head,.pet-chat[data-view=stage] #pet-form,.pet-chat[data-view=stage] .pet-stage{background:transparent}
.pet-chat[data-view=stage] .pet-stage-caption{display:none}
.pet-chat[data-view=stage] .pet-head{padding-left:12px;padding-right:12px}
.pet-chat[data-view=stage] .pet-head>div{opacity:.8}
.pet-chat[data-view=stage] .pet-head button{background:#fffdf87a;backdrop-filter:blur(6px)}
.pet-chat[data-view=stage] .pet-head button:hover,.pet-chat[data-view=stage] .pet-head button:focus-visible{background:#fffdf8}
.pet-chat[data-view=stage] .pet-portrait{inset:0 0 calc(32% + 22px)}
.pet-chat[data-view=stage] .pet-bubble{right:auto;box-sizing:border-box;width:fit-content;max-width:calc(100% - 64px);background:#fffefad9;border:0;box-shadow:0 3px 14px #5445360c}
.pet-chat[data-view=stage] .pet-compose textarea{background:#fffdf8c4;border-color:#ffffff8a;backdrop-filter:blur(6px)}
.pet-chat[data-view=stage] .pet-options{width:fit-content;padding:2px 7px;border-radius:12px;background:#fffdf880}
.pet-pip{background:transparent!important}

/* Resting desktop character. Only the alpha-clipped character and speech receive events. */
.pet-chat[data-view=stage][data-controls=false] .pet-head,.pet-chat[data-view=stage][data-controls=false] #pet-form,.pet-chat[data-view=stage][data-controls=false] #pet-review-drafts,.pet-chat[data-view=stage][data-controls=false] #pet-enter-space{display:none!important}
.pet-chat[data-view=stage][data-controls=false]{height:min(520px,68dvh);pointer-events:none}
.pet-chat[data-view=stage][data-controls=false] .pet-content,.pet-chat[data-view=stage][data-controls=false] .pet-stage{pointer-events:none}
.pet-chat[data-view=stage][data-controls=false] .pet-stage{touch-action:none;cursor:grab;outline:0;user-select:none;-webkit-user-select:none}
.pet-chat.pet-dragging[data-view=stage][data-controls=false] .pet-stage{cursor:grabbing}
.pet-chat[data-view=stage][data-controls=false] .pet-bubble{bottom:8px}
.pet-chat[data-view=stage][data-controls=true] .pet-stage{touch-action:manipulation}
.pet-floating{z-index:180}
.pet-floating[data-surface=desktop][data-controls=false][data-portrait-fallback=true]{width:170px;height:240px;min-height:0}
.pet-floating[data-surface=desktop][data-controls=false][data-portrait-fallback=true] .pet-portrait{inset:0 0 96px}
.pet-floating[data-surface=desktop][data-controls=false][data-portrait-fallback=true] .pet-bubble{left:8px;max-width:calc(100% - 24px)}
.pet-hit-defs{position:absolute;pointer-events:none}
.pet-portrait img{pointer-events:none}
.pet-character{position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;pointer-events:auto;cursor:grab;touch-action:none;clip-path:inset(10% 22% 0);-webkit-tap-highlight-color:transparent}
.pet-character:focus-visible{background:#72968028;outline:2px solid #527564;outline-offset:-3px}
.pet-chat[data-controls=true] .pet-character{cursor:pointer;touch-action:manipulation}
.pet-chat[data-controls=false] .pet-bubble{pointer-events:auto}
.pet-head-avatar{width:30px;height:30px;object-fit:contain;flex-shrink:0;border-radius:50%;background:#edf1e9}
.pet-enter-space{flex-shrink:0;min-height:44px;border:0;border-top:1px solid #dce2d6;background:#fffdf8;color:#536e60;font:inherit;font-size:12px;cursor:pointer}
.pet-chat select{width:100%;font:inherit;padding:10px;border:1px solid #d9dfd2;border-radius:12px;background:#fffdfb;color:#414d40}
.pet-novel-nav{display:none;align-items:center;justify-content:space-between;gap:12px;margin-top:8px;color:#7b8578}
.pet-novel-nav button{width:36px;height:32px;background:transparent;border:0;font-size:21px;color:#62715c;cursor:pointer}.pet-novel-nav button:disabled{opacity:.3;cursor:default}.pet-novel-nav small{font-size:10px}
.pet-chat[data-surface=companion] .pet-novel-nav{display:flex}
.pet-companion{max-width:680px;height:calc(100dvh - 170px);min-height:360px}
.pet-chat.pet-companion[data-view=stage]{background:linear-gradient(155deg,#f6eee66b,#eff3e94d);border-radius:24px;overflow:hidden}
.pet-companion .pet-head{flex-shrink:0;min-height:62px}
.pet-companion .pet-stage{min-height:0}
.pet-chat.pet-companion[data-view=stage] .pet-portrait{inset:0 0 155px}
.pet-chat.pet-companion[data-view=stage] .pet-bubble{bottom:10px;left:18px;right:18px;width:auto;max-width:none;max-height:145px;min-height:105px;background:#fffefaed;border:1px solid #e4e8dd;box-shadow:0 7px 24px #80684b0c;padding:12px 16px}
.pet-companion #pet-form{background:#fffdf8e6!important}
.pet-message{position:relative;max-width:88%;margin-left:36px;background:transparent;padding:0}
.pet-message-text{padding:10px 13px;border:1px solid #e5e9df;border-radius:3px 15px 15px 15px;background:#eef2e8}
.pet-message-avatar{position:absolute;left:-36px;top:15px;width:28px;height:28px;object-fit:contain;border-radius:50%;background:#e3eadf}
.pet-user{margin-left:0;margin-right:36px;background:transparent}.pet-user .pet-message-text{background:#dfede3;border-color:#d9e6db;border-radius:15px 3px 15px 15px}.pet-user .pet-message-avatar{left:auto;right:-36px}
.pet-error,.pet-notice{margin-left:0;margin-right:0}.pet-error .pet-message-text{background:#fff0ec;border-color:#f0dad0}.pet-notice .pet-message-text{background:#f2f0e8}
.pet-typing{font-size:12px;color:#76816f;padding:8px 36px}
.pet-orb{--pet-safe-top:env(safe-area-inset-top,0px);--pet-safe-bottom:env(safe-area-inset-bottom,0px);display:none;position:fixed;z-index:180;width:56px;height:56px;border:3px solid #fffdf8;border-radius:50%;background:#e5ecdf;box-shadow:0 4px 16px #314b3924;padding:4px;touch-action:none;user-select:none;cursor:grab;-webkit-tap-highlight-color:transparent}
.pet-orb img{width:100%;height:100%;object-fit:contain;border-radius:50%;pointer-events:none}.pet-orb:focus-visible{outline:3px solid #627c67;outline-offset:3px}.pet-orb[aria-expanded=true]{border-color:#b9cdb6}
.pet-orb[hidden],.auth-locked .pet-orb{display:none!important}
.pet-floating.pet-business-pass[data-controls=false]{opacity:.15}
.pet-floating.pet-business-pass[data-controls=false] .pet-character,.pet-floating.pet-business-pass[data-controls=false] .pet-bubble{pointer-events:none!important}
body.modal-open .pet-floating[data-surface=desktop],body.viewer-open .pet-floating[data-surface=desktop]{visibility:hidden;pointer-events:none}
.pet-pip .pet-companion{height:100dvh;min-height:0}.pet-pip #pet-back{display:none}
@keyframes pet-breathe{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
.pet-chat:not(.pet-dragging) .pet-portrait img{animation:pet-breathe 5s ease-in-out infinite}
@media(prefers-reduced-motion:reduce){.pet-chat .pet-portrait img{animation:none!important}}
@media(max-width:768px){
  .pet-orb{display:block}
  .pet-chat.pet-floating[data-surface=desktop]{display:none!important}
  .pet-chat.pet-quick{left:8px;right:8px;bottom:calc(80px + env(safe-area-inset-bottom));top:auto;width:calc(100% - 16px);max-width:none;height:min(440px,calc(100dvh - 110px - env(safe-area-inset-bottom)));min-height:180px;border-radius:20px;z-index:185}
  .pet-quick .pet-archive{padding:0 12px}.pet-quick .pet-archive-heading{display:none}.pet-quick .pet-caption{font-size:10px;margin:4px 0}.pet-quick .pet-head{min-height:55px}.pet-quick .pet-messages{gap:10px}
  .pet-quick .pet-compose{gap:5px}.pet-quick .pet-compose textarea{padding:10px 8px}.pet-chat .pet-compose .btn{padding-left:12px;padding-right:12px}
  body.pet-companion-open{overflow:hidden}
  #pet-host .pet-companion{position:fixed;z-index:180;inset:0;max-width:none;width:100%;height:100dvh;min-height:180px;margin:0;border:0;border-radius:0;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom);background:#f6f5ef}
  #pet-host .pet-companion[data-view=stage]{border-radius:0;background:linear-gradient(155deg,#f6f0e8,#edf2e8)}
  .pet-companion #pet-pop{display:none}.pet-companion .pet-head{min-height:60px}.pet-companion .pet-head strong{font-size:15px}
  .pet-chat.pet-companion[data-view=stage] .pet-portrait{inset:0 0 155px}
  .pet-chat.pet-companion[data-view=stage] .pet-bubble{left:12px;right:12px;max-width:none;max-height:145px;min-height:105px;font-size:14px}
  .pet-companion .pet-compose textarea,.pet-chat select{font-size:16px}
}
@media(max-height:500px){.pet-chat.pet-companion[data-view=stage] .pet-portrait{inset:0 0 100px}.pet-chat.pet-companion[data-view=stage] .pet-bubble{max-height:95px;min-height:65px}.pet-novel-nav{margin-top:0}.pet-companion .pet-head{min-height:46px}.pet-companion .pet-head small{display:none}.pet-companion #pet-form{padding-top:4px;padding-bottom:4px}}

/* Shared compact entry and draggable desktop chat. */
.pet-orb{display:block}
.pet-connection-note{margin:6px 12px;padding:10px 12px;border:1px solid #cbd4c6;border-radius:12px;background:#f4f6ef;font-size:12px;max-height:145px;overflow:auto;flex-shrink:0}.pet-connection-note p{margin:4px 0;overflow-wrap:anywhere}.pet-connection-note details{font-size:11px}.pet-connection-note summary{cursor:pointer}.pet-message.pet-error{font-size:12px}.pet-message.pet-error details{font-size:11px}
.assistant-plan-toolbar{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0}.pet-draft .input{width:100%;min-width:0;box-sizing:border-box}.pet-draft select,.pet-draft textarea{font-size:16px}.pet-draft small{display:block;overflow-wrap:anywhere}
@media(min-width:769px){.pet-chat.pet-quick{position:fixed;right:24px;bottom:24px;width:min(420px,calc(100vw - 24px));height:min(620px,calc(100dvh - 32px));min-height:260px;border-radius:20px;z-index:185;background:#fffdf8;box-shadow:0 12px 40px #314b3930;overflow:hidden}.pet-floating.pet-quick .pet-head{cursor:grab;touch-action:none}.pet-quick .pet-head{min-height:52px;gap:5px;padding:8px}.pet-quick .pet-head button{min-width:28px;padding:5px}.pet-quick .pet-head>div{min-width:0;flex:1}.pet-quick .pet-status{overflow-wrap:anywhere}.pet-quick .pet-stage{min-height:0}.pet-quick .pet-archive{padding:10px 12px}}
