.pet-layer,.pet-page,#petHome{--pet-ink:var(--ink,#101b30);--pet-muted:var(--muted,#54647a);--pet-line:var(--line,#d9e6f2);--pet-accent:var(--accent,var(--student-primary,#006dcc));color:var(--pet-ink);font-family:inherit}
.pet-layer [hidden],#petHome[hidden],#petPage [hidden]{display:none!important}
.pet-page{max-width:1200px}.pet-page>header p{max-width:60ch;color:var(--pet-muted)}
.pet-care{display:grid;grid-template-columns:minmax(220px,.9fr) minmax(0,1.25fr);align-items:center;gap:32px;background:#fff;border-radius:16px;padding:32px}
#petHome{margin:28px 0 36px}#petHome .pet-care{padding:24px;grid-template-columns:minmax(160px,.65fr) minmax(0,1.5fr)}
.pet-homework-first{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;min-height:48px;font-weight:650;color:var(--pet-accent)}
.pet-stage{position:relative;width:100%;max-width:384px;aspect-ratio:1;margin:auto;contain:layout paint}
.pet-stage img,.pet-stage canvas{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
.pet-image-unavailable::after{content:'攫參猿';position:absolute;inset:0;display:grid;place-items:center;color:var(--pet-muted)}
.pet-name-row{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.pet-name-row h2{font-size:1.75rem;margin:0;overflow-wrap:anywhere;line-height:1.3}.pet-level{color:#155d97;background:#eaf5ff;padding:5px 12px;border-radius:16px;font-weight:650}
.pet-state{color:#24664f;font-weight:600;margin:12px 0 4px}.pet-state[data-pet-state=hungry]{color:#795416}.pet-state[data-pet-state=sleeping]{color:#536275}
.pet-motto{color:var(--pet-muted);font-size:.9375rem;margin:0 0 24px}
.pet-stats{display:flex;flex-wrap:wrap;gap:24px;margin:0 0 18px;font-variant-numeric:tabular-nums}.pet-stats dt{color:var(--pet-muted);font-size:.875rem}.pet-stats dd{margin:4px 0 0;font-weight:650;font-size:1.5rem}.pet-stats small{font-weight:400;font-size:.875rem;color:var(--pet-muted)}
.pet-satiety{display:block;appearance:none;width:100%;height:8px;border:0;border-radius:8px;overflow:hidden;background:#e0f0ff}.pet-satiety::-webkit-progress-bar{background:#e0f0ff}.pet-satiety::-webkit-progress-value{background:#24664f;border-radius:8px}.pet-satiety::-moz-progress-bar{background:#24664f}
.pet-help,.pet-wallet{color:var(--pet-muted);font-size:.875rem;line-height:1.65;margin:12px 0 16px}.pet-wallet{margin-bottom:0}.pet-wallet span{display:block;margin-top:4px}
.pet-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px}.pet-actions button,.pet-actions a,.pet-page button,.pet-dialog button,.pet-error button{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:10px 16px;border:1px solid var(--pet-line,#d9e6f2);border-radius:24px;background:#fff;color:var(--pet-accent,var(--student-primary,#006dcc));font:inherit;font-size:.9375rem;text-decoration:none;cursor:pointer}
.pet-actions .primary,.pet-page .primary,.pet-dialog .primary{background:var(--student-primary,#006dcc);color:#fff;border-color:var(--student-primary,#006dcc)}.pet-actions button:hover:not(:disabled),.pet-page button:hover:not(:disabled),.pet-dialog button:hover:not(:disabled){background:#e0f0ff;color:var(--student-primary-hover,#005eb2)}.pet-actions .primary:hover:not(:disabled),.pet-page .primary:hover:not(:disabled),.pet-dialog .primary:hover:not(:disabled){background:var(--student-primary-hover,#005eb2);color:#fff}
.pet-actions .pet-text{border-color:transparent;padding-inline:4px}.pet-page button:disabled,.pet-actions button:disabled,.pet-dialog button:disabled{color:#54647a;background:#eff5fa;border-color:#d9e6f2;cursor:not-allowed}
.pet-daily{padding:28px 0;border-bottom:1px solid var(--pet-line)}.pet-section-heading{display:flex;justify-content:space-between;gap:16px;align-items:baseline}.pet-section-heading h2,.pet-settings h2,.pet-history h2{font-size:1.375rem;margin:0 0 16px}.pet-section-heading span{font-variant-numeric:tabular-nums;white-space:nowrap}
.pet-daily ul{list-style:none;padding:0;margin:18px 0 0;display:flex;flex-wrap:wrap;gap:12px 32px}.pet-daily li{display:flex;gap:16px;justify-content:space-between;min-width:210px}.pet-daily li span:last-child{color:var(--pet-muted)}
.pet-detail-grid{display:grid;grid-template-columns:1fr 1fr;gap:48px;margin-top:36px}.pet-settings form{display:flex;flex-direction:column;align-items:flex-start;gap:12px}.pet-settings input:not([type=checkbox]),.pet-dialog input,.pet-dialog textarea{font:inherit;padding:12px;border:1px solid #b8cee2;border-radius:10px;width:100%;box-sizing:border-box;background:#fff;color:#101b30;caret-color:var(--student-primary,#006dcc)}.pet-settings input:not([type=checkbox]){max-width:340px}.pet-check{display:flex;align-items:flex-start;gap:10px;line-height:1.6}.pet-check input{width:20px;height:20px;margin:3px 0;flex:none;accent-color:var(--student-primary,#006dcc)}.pet-settings .pet-help{margin:0 0 8px}
.pet-history ol{list-style:none;padding:0;max-height:460px;overflow:auto;scrollbar-color:#b8cee2 transparent}.pet-history li{display:flex;justify-content:space-between;gap:16px;border-bottom:1px solid var(--pet-line);padding:16px 0}.pet-history time{display:block;font-size:.8125rem;color:var(--pet-muted);margin-top:6px}.pet-history li>span{white-space:nowrap;font-variant-numeric:tabular-nums}
.pet-error:not(:empty){padding:16px 0;color:#a53242;line-height:1.6}.pet-error button{margin:8px 0 8px 12px}.pet-adopt-intro{display:flex;align-items:center;gap:32px;background:#fff;padding:24px;border-radius:16px}.pet-adopt-intro img{width:200px;height:auto;flex:none}.pet-adopt-intro h2{font-size:1.5rem}.pet-adopt-intro p{max-width:60ch;line-height:1.7}
.pet-summon{position:fixed;right:max(16px,env(safe-area-inset-right));bottom:calc(20px + env(safe-area-inset-bottom));width:64px;height:64px;border:1px solid #b8cee2;border-radius:50%;background:#fff;padding:4px;z-index:35;cursor:pointer;box-sizing:border-box}.pet-summon img{width:100%;height:100%;object-fit:contain;pointer-events:none}
.pet-layer .pet-summon{padding:4px;border-radius:50%;min-height:44px;display:grid;place-items:center}.pet-layer .pet-summon img{display:block}
/* Leave a real gutter beside question content: the companion must never cover
   source material, an answer field or a submission control. */

body[data-workspace=write] .pet-summon,.question-page .pet-summon{width:44px;height:44px;right:8px;bottom:calc(84px + env(safe-area-inset-bottom))}
.pet-notice{position:fixed;bottom:calc(96px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100vw - 32px);box-sizing:border-box;padding:14px 20px;border-radius:12px;background:#101b30;color:#fff;z-index:65;line-height:1.6;pointer-events:none;box-shadow:0 8px 24px #101b3026}
.pet-dialog{width:min(500px,calc(100% - 32px));max-height:85dvh;padding:28px;border:0;border-radius:16px;color:#101b30;background:#fff;box-shadow:0 20px 64px #101b3040;box-sizing:border-box}.pet-dialog::backdrop{background:#101b3066}.pet-dialog-heading{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:20px}.pet-dialog h2{margin:0;font-size:1.5rem}.pet-dialog p{line-height:1.7}.pet-dialog form{display:grid;gap:12px}.pet-dialog textarea{min-height:100px;margin:8px 0 12px;resize:none;background:#eff5fa}.pet-dialog-status{color:#a53242}.pet-exchange{font-size:1.25rem;font-weight:650}.pet-exchange span{margin:0 12px}.pet-dialog a,.pet-page a{color:var(--student-primary,#006dcc);text-underline-offset:3px}
.pet-layer :focus-visible,.pet-page :focus-visible,#petHome :focus-visible{outline:3px solid var(--student-primary,#006dcc);outline-offset:3px}.pet-layer ::selection,.pet-page ::selection,#petHome ::selection{background:#d9edff;color:#101b30}
@media(max-width:700px){.pet-page{padding:24px 16px 110px}.pet-care,#petHome .pet-care{grid-template-columns:1fr;gap:12px;padding:20px}.pet-stage{max-width:256px}.pet-stats{gap:16px}.pet-stats dd{font-size:1.25rem}.pet-name-row h2{font-size:1.5rem}.pet-detail-grid{grid-template-columns:1fr;gap:32px}.pet-daily ul{display:block}.pet-daily li{padding:8px 0;gap:10px;min-width:0}.pet-adopt-intro{flex-direction:column;gap:4px;padding:20px}.pet-adopt-intro img{width:180px}.pet-summon{width:48px;height:48px;right:12px;bottom:calc(80px + env(safe-area-inset-bottom))}.pet-dialog{padding:22px;max-height:calc(100dvh - 100px);margin:auto auto calc(76px + env(safe-area-inset-bottom));width:calc(100% - 24px)}.pet-dialog-heading{gap:10px}.pet-dialog-heading h2{font-size:1.25rem}.pet-dialog-heading button{flex:none}.pet-actions{gap:8px}.pet-actions button,.pet-actions a{padding:10px 12px}.pet-homework-first{font-size:.9375rem}.pet-dialog input{min-width:0}.pet-history li{font-size:.9375rem}}
@media(prefers-reduced-motion:reduce){.pet-layer *,.pet-page *,#petHome *{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
@media print{.pet-layer,#petHome{display:none!important}}
.pet-egg-intro>img{display:block;width:min(180px,100%);height:auto;margin:0 auto 12px}.pet-egg-intro h2{margin:0 0 12px}.pet-egg-intro p{line-height:1.7}.pet-egg-intro button{min-height:44px}.pet-layer .pet-summon.pet-egg-summon{background:transparent;border:0;border-radius:0;box-shadow:none;padding:0}.pet-egg-present .learning-nav-launch{display:none!important}
.pet-layer .pet-summon.pet-egg-image-failed{background:#f6f0e2;color:#193e56;border:1px solid #c8beab;border-radius:12px;font-size:12px}
.pet-care-dialogue{grid-column:1/-1;margin:.5rem 0 1rem;padding:.8rem 1rem;max-width:65ch;line-height:1.75;border:1px solid var(--ink-line,#c5d4d9);border-radius:12px;background:var(--ink-paper,#fff);color:var(--ink-blue,#153a50);overflow-wrap:anywhere}
