/* 雪野 B. Only the chat shell changes; original controls, data and Pelle remain.
   Text contrast is verified against rendered glass (not the alpha color alone).
   White .92 and secondary .6 must each reach 4.5:1; darkening the scene behind
   the blur preserves this on bright stars/mountains. See candidate acceptance notes. */
:root[data-theme="snow"] {
  color-scheme: dark;
  --ref-width:720px; --header-h:96px; --side-pad:18px; --avatar-size:32px;
  --bg:#0B1220; --header-bg:#0B1220; --text:#E8EEF7; --text-soft:#B4C2D5; --text-faint:#9FB0C7;
  --accent:#BFD7F2; --accent-fg:#0B1220; --send-bg:#1B2942; --tick:#BFD7F2;
  --bubble-ai-bg:rgba(14,22,40,.42); --bubble-ai-fg:rgba(255,255,255,.92);
  --bubble-human-bg:rgba(143,184,232,.16); --bubble-human-fg:rgba(255,255,255,.92);
  --hairline:rgba(191,215,242,.18); --card-bg:rgba(20,31,51,.94); --card-line:rgba(255,255,255,.14);
  --seg-track:rgba(191,215,242,.1); --seg-thumb:#2C405D; --row-press:rgba(191,215,242,.12);
  --slider-track:#405570; --slider-thumb:#BFD7F2; --info-ring:#6B7C95;
  --think-label:#BFD7F2; --think-body:#B4C2D5; --think-flourish:#9FB0C7;
  --composer-bg:#141F33; --field-bg:rgba(14,22,36,.55); --field-line:rgba(255,255,255,.23);
  --scrim:linear-gradient(135deg,rgba(11,18,32,.08),rgba(26,42,74,.06));
  --wall-default:var(--snow-wall-url); --menu-wall-default:var(--wall-default); --theme-avatar:var(--snow-avatar-url);
  --theme-avatar-size:830.5556% auto; --theme-avatar-position:17.1103% 20.2128%;
  --call-glass-top:rgba(20,31,51,.68); --call-glass-bot:rgba(20,31,51,.55);
  --call-glass-edge:rgba(255,255,255,.14); --call-glass-hi:rgba(255,255,255,.22);
  --call-glass-shadow:0 20px 50px rgba(0,0,0,.28); --call-scrim:rgba(5,10,20,.35);
  --snow-font:13.5px; --snow-width:min(71vw,calc(19 * var(--snow-font) + 26px));
  --snow-corner:clamp(24px,calc(var(--snow-width) * .125786),40px);
  --snow-blur:12px; --snow-brightness:.72;
}
.snow-only,.snow-label{display:none}
:root[data-theme="snow"] .snow-label{display:inline}
:root[data-theme="snow"] .snow-only:not([hidden]):not([popover]){display:flex}
:root[data-theme="snow"], :root[data-theme="snow"] body{background:#0B1220!important}
:root[data-theme="snow"] .wall{inset:0 auto 0 50%;width:min(100vw,720px);height:100%;transform:translateX(-50%);background-position:center top}
:root[data-theme="snow"] .app{z-index:2}
:root[data-theme="snow"] .topbar{justify-content:flex-start;gap:12px;border:0;padding:calc(env(safe-area-inset-top) + 12px) 20px 10px 60px;background:linear-gradient(#07101a66,transparent)}
:root[data-theme="snow"] .backbtn{left:10px;top:calc(env(safe-area-inset-top) + 30px);width:44px;height:44px}
:root[data-theme="snow"] .backbtn svg{display:none}
:root[data-theme="snow"] .backbtn::after{content:"";width:23px;height:18px;background:linear-gradient(var(--text),var(--text)) 0 0/23px 1.5px no-repeat,linear-gradient(var(--text),var(--text)) 0 8px/16px 1.5px no-repeat,linear-gradient(var(--text),var(--text)) 0 16px/23px 1.5px no-repeat}
:root[data-theme="snow"] .snow-header-avatar{width:46px;height:46px;flex:none;border-radius:50%;border:1px solid #BFD7F299;background:var(--avatar-default) center/cover;box-shadow:0 0 0 2px #ffffff0a;cursor:pointer}
:root[data-theme="snow"] .peerpill{align-items:flex-start;padding:0;gap:2px}
:root[data-theme="snow"] .peerpill .name{font-size:24px;text-shadow:none}
:root[data-theme="snow"] .peerpill .status{font-size:12px;max-width:calc(100vw - 190px)}
:root[data-theme="snow"] .header-actions{right:16px;top:calc(env(safe-area-inset-top) + 30px);height:44px}
:root[data-theme="snow"] #moreBtn{width:44px;height:44px}
:root[data-theme="snow"] #moreBtn svg{transform:rotate(90deg)}
:root[data-theme="snow"] #memoryEntryBtn{display:none}
:root[data-theme="snow"] .scroll{padding-left:18px;padding-right:18px;mask-image:none;-webkit-mask-image:none}
:root[data-theme="snow"] .row{margin-top:26px}
:root[data-theme="snow"] .row.grouped{margin-top:22px}
:root[data-theme="snow"] .row.ai{padding-left:42px;padding-right:14px}
:root[data-theme="snow"] .row.human{padding-left:24px;padding-right:0}
:root[data-theme="snow"] .row.human::before,:root[data-theme="snow"] .row.human::after{display:none}
:root[data-theme="snow"] .message-avatar{width:32px;height:32px;top:5px;border:1px solid #BFD7F266;box-shadow:0 2px 8px #0003}
:root[data-theme="snow"] .snow-header-avatar,:root[data-theme="snow"] .message-avatar,:root[data-theme="snow"] .character-avatar,:root[data-theme="snow"] .call-avatar-img,:root[data-theme="snow"] .incoming-call-avatar,:root[data-theme="snow"] .login .orb{background-size:var(--avatar-image-size);background-position:var(--avatar-image-position)}
:root[data-theme="snow"] .bubble{
  max-width:var(--snow-width);padding:12px 12px 10px;border:1px solid rgba(255,255,255,.16);border-radius:20px;
  font-size:var(--snow-font);line-height:1.6;overflow:visible;isolation:isolate;
  background-image:linear-gradient(135deg,rgba(255,255,255,.10),transparent 45%);
  -webkit-backdrop-filter:blur(var(--snow-blur)) saturate(140%) brightness(var(--snow-brightness));
  backdrop-filter:blur(var(--snow-blur)) saturate(140%) brightness(var(--snow-brightness));
  box-shadow:0 1px 0 rgba(255,255,255,.22) inset,0 8px 24px rgba(0,0,0,.28);
}
:root[data-theme="snow"] .bubble.snow-offscreen{-webkit-backdrop-filter:none;backdrop-filter:none}
:root[data-theme="snow"] .bubble .txt{display:block}
:root[data-theme="snow"] .bubble::after{display:none}
:root[data-theme="snow"] .bubble::before{
  content:"";position:absolute;top:calc(var(--snow-corner) * -.4);right:calc(var(--snow-corner) * -.3);left:auto;
  width:var(--snow-corner);height:var(--snow-corner);transform:rotate(8deg);transform-origin:center;
  background:linear-gradient(135deg,#F5F7FF,#BFD7F2);opacity:.9;pointer-events:none;
  -webkit-mask-image:url('../assets/snow-night/snowflakes-01-02.png');mask-image:url('../assets/snow-night/snowflakes-01-02.png');mask-mode:luminance;
  -webkit-mask-position:0% 50%;mask-position:0% 50%;-webkit-mask-size:200% 100%;mask-size:200% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;
}
:root[data-theme="snow"] .row.human .bubble::before,:root[data-theme="snow"] .clone-human::before{left:calc(var(--snow-corner) * -.3);right:auto;-webkit-mask-position:100% 50%;mask-position:100% 50%}
:root[data-theme="snow"] .row.ai .txt::before,:root[data-theme="snow"] .clone-ai .txt::before{content:"";float:right;width:calc(var(--snow-corner) * .55);height:1.6em}
:root[data-theme="snow"] .row.human .txt,:root[data-theme="snow"] .clone-human .txt{text-indent:calc(var(--snow-corner) * .55)}
:root[data-theme="snow"] .bubble .meta{display:flex;align-items:center;justify-content:flex-end;font-size:12px;color:rgba(255,255,255,.6);margin:8px 0 0;min-height:20px;padding-left:46px}
/* Voice 02: the approved six-petal artwork, displayed through a luminance mask.
   Original text/aria-label, loading/playing classes and TTS handlers stay intact.
   The 36px touch target fits inside the approved bubble without covering text. */
:root[data-theme="snow"] .message-tts{position:relative;flex:0 0 36px;width:36px;height:36px;margin:-8px 2px -8px 0;padding:0;border:0;border-radius:50%;background:transparent;color:#E8EEF7;font-size:0;opacity:.9;-webkit-tap-highlight-color:transparent}
:root[data-theme="snow"] .message-tts::before{content:"";position:absolute;inset:5px;pointer-events:none;background:linear-gradient(135deg,#FFFFFF 10%,#BFD7F2 52%,#E8EEF7 82%);-webkit-mask-image:url('../assets/snow-night/voice-02-board.png');mask-image:url('../assets/snow-night/voice-02-board.png');mask-mode:luminance;-webkit-mask-size:336.071429% 597.142857%;mask-size:336.071429% 597.142857%;-webkit-mask-position:84.720121% 13.146552%;mask-position:84.720121% 13.146552%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}
:root[data-theme="snow"] .message-tts:hover,:root[data-theme="snow"] .message-tts:focus-visible{opacity:1;background:rgba(191,215,242,.07)}
:root[data-theme="snow"] .message-tts:focus-visible{outline:1px solid #BFD7F2;outline-offset:1px}
:root[data-theme="snow"] .message-tts.is-loading{opacity:.65}
:root[data-theme="snow"] .message-tts.is-loading::after{content:"…";position:absolute;right:0;bottom:3px;font:14px/12px sans-serif;color:#E8EEF7}
:root[data-theme="snow"] .message-tts.is-playing{opacity:1;background:rgba(191,215,242,.08)}
:root[data-theme="snow"] .message-tts.is-playing::after{content:"";position:absolute;right:3px;bottom:5px;width:6px;height:6px;border:2px solid #141F33;border-radius:2px;background:#E8EEF7;box-shadow:0 0 0 1px rgba(191,215,242,.4)}
.message-cost{display:none}
:root[data-theme="snow"] .message-cost{display:block;position:absolute;left:12px;bottom:12px;font-size:10px;line-height:16px;color:rgba(255,255,255,.6);font-variant-numeric:tabular-nums}
:root[data-theme="snow"] .bubble > .api-receipt,:root[data-theme="snow"] .bubble > .trust-card{display:none}
:root[data-theme="snow"] .clone-ai{background-color:var(--bubble-ai-bg);color:var(--bubble-ai-fg)}
:root[data-theme="snow"] .clone-human{background-color:var(--bubble-human-bg);color:var(--bubble-human-fg)}
:root[data-theme="snow"] .enter-human .bubble,:root[data-theme="snow"] .enter-ai .bubble{animation:snow-jelly 160ms cubic-bezier(.34,1.56,.64,1) both}
@keyframes snow-jelly{0%{transform:scale(.96)}65%{transform:scale(1.02)}100%{transform:scale(1)}}
:root[data-theme="snow"] .composer{padding:10px 14px calc(8px + env(safe-area-inset-bottom));background:linear-gradient(180deg,#0b122099,#0b1220f2);border-top:1px solid #ffffff12;gap:8px}
:root[data-theme="snow"] .composer-main{gap:10px}
:root[data-theme="snow"] .composer .field{min-width:0;min-height:46px;border:1px solid var(--field-line);border-radius:28px;padding-left:10px;-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px)}
:root[data-theme="snow"] #input{min-width:0;font-size:15px;color:var(--text)}
:root[data-theme="snow"] #sendBtn{position:relative;width:46px;height:46px;flex:none;border:0;border-radius:0;overflow:visible;background:transparent;box-shadow:none}
:root[data-theme="snow"] #sendBtn svg{display:none}
:root[data-theme="snow"] #sendBtn:disabled{opacity:.58}
:root[data-theme="snow"] #sendBtn:active:not(:disabled){transform:scale(.94)}
:root[data-theme="snow"] .snow-nav{width:100%;justify-content:space-around;border-top:1px solid #ffffff0c;padding-top:8px;gap:4px}
:root[data-theme="snow"] .snow-nav > button{position:relative!important;inset:auto!important;width:25%;height:48px;display:flex;flex-direction:column;gap:3px;border:0;background:transparent;color:var(--text-soft);font:12px var(--font-cn);align-items:center;justify-content:center;border-radius:12px;cursor:pointer}
:root[data-theme="snow"] .snow-nav svg{width:23px;height:23px}
:root[data-theme="snow"] #keepaliveBtn[data-state="on"]{color:#C3E2D9}
:root[data-theme="snow"] .snow-nav > button:active{background:var(--row-press)}
:root[data-theme="snow"] #sessionPop{top:auto;bottom:calc(var(--composer-zone) + 8px);max-height:55dvh;overflow:auto;z-index:30;background:#141F33f5;color:var(--text)}
.snow-tools{position:fixed;inset:auto max(16px,calc((100vw - 688px)/2)) calc(var(--composer-zone) + 8px) auto;margin:0;padding:10px;width:min(320px,calc(100vw - 32px));border:1px solid #ffffff24;border-radius:20px;background:#141F33f5;color:#E8EEF7;box-shadow:0 15px 45px #0006}
:root[data-theme="snow"] .snow-tools:popover-open{display:flex;flex-direction:column;gap:2px}
:root[data-theme="snow"] .snow-tools > button,:root[data-theme="snow"] .snow-tools > label{position:static!important;inset:auto!important;width:100%;min-height:48px;height:auto;border:0;border-radius:12px;padding:12px;display:flex;align-items:center;justify-content:flex-start;gap:12px;background:transparent;box-shadow:none;color:inherit;font:14px var(--font-cn);cursor:pointer}
:root[data-theme="snow"] .snow-tools svg{width:22px;height:22px;flex:none}
.snow-tools input{margin-left:auto;accent-color:#BFD7F2;width:18px;height:18px}
:root[data-theme="snow"] #pelleDisableBtn .pelle-disable-toggle__track{margin-left:auto;flex:none}
.snow-tools small{padding:6px 12px;color:#B4C2D5;font:12px/1.5 var(--font-cn)}
.snow-technical{width:min(620px,calc(100vw - 24px));max-height:80dvh;margin:auto;padding:18px;border:1px solid var(--hairline);border-radius:20px;background:var(--bg);color:var(--text);overflow:auto;font:14px/1.6 var(--font-cn)}
.snow-technical::backdrop{background:#030812b3;backdrop-filter:blur(6px)}
.snow-technical header{display:flex;align-items:center;justify-content:space-between;gap:12px}
.snow-technical h2{font-size:16px;margin:0}
.snow-technical header button{min-width:44px;min-height:44px;border:0;background:transparent;color:inherit;font:22px sans-serif;cursor:pointer}
.snow-technical .api-receipt{font-size:13px}.snow-technical .api-receipt-body{overflow-wrap:anywhere}
.snow-technical .trust-use{background:var(--seg-thumb)}
:root[data-theme="snow"] .snow-technical .api-receipt-body,:root[data-theme="snow"] .snow-technical .trust-card{background:#141F33}
:root[data-theme="snow"] .snow-technical .api-call-row{background:#1B2942}
:root[data-theme="snow"] .snow-technical .api-receipt-badge{color:#ACD3BE}
:root[data-theme="snow"] .snow-technical .api-receipt.warn .api-receipt-badge,:root[data-theme="snow"] .snow-technical .api-context-alert{color:#E5C98F}
:root[data-theme="snow"] .snow-technical .api-receipt.danger .api-receipt-badge,:root[data-theme="snow"] .snow-technical .trust-incident{color:#F0AEA6}
:root[data-theme="snow"] .msg-menu-actions{background:#141F33f2;color:var(--text);width:min(320px,calc(100vw - 24px));max-height:70dvh;overflow:auto}
:root[data-theme="snow"] .msg-act{color:inherit}
:root[data-theme="snow"] .msg-act[data-act="technical"]{width:100%;font-size:13px}
#snow-atmosphere{display:none;position:fixed;inset:0 auto auto 50%;transform:translateX(-50%);width:min(100vw,720px);height:var(--screen-height);pointer-events:none;z-index:3}
:root[data-theme="snow"] #snow-atmosphere{display:block}
/* Pelle owns the current emotional reply's full-width stage and avatar choice.
   Do not impose ice corners/blur on that stage or recolor emotion-specific spans. */
:root[data-theme="snow"] body[data-mood] .row.ai.pelle-current-reply{padding-left:0;padding-right:0}
:root[data-theme="snow"] body[data-mood] .row.ai.pelle-current-reply .bubble{width:100%;max-width:100%;padding-left:0;padding-right:0;border:0;border-radius:0;background:transparent;box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none;color:var(--bubble-ai-fg)}
:root[data-theme="snow"] body[data-mood] .pelle-current-reply .bubble::before,:root[data-theme="snow"] body[data-mood] .pelle-current-reply .txt::before{display:none}
:root[data-theme="snow"] body[data-mood] .pelle-current-reply .meta,:root[data-theme="snow"] body[data-mood] .pelle-current-reply .message-cost{color:var(--text-soft)}
@media(min-width:760px){:root[data-theme="snow"]{--snow-font:16px;--snow-blur:18px;--snow-brightness:.66}}
@media(prefers-reduced-motion:reduce){:root[data-theme="snow"] .enter-human .bubble,:root[data-theme="snow"] .enter-ai .bubble{animation:none}}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){:root[data-theme="snow"] .bubble{background-color:#142036}:root[data-theme="snow"] .row.human .bubble{background-color:#243955}}

:root[data-theme="snow"]{--panel-bg:#141F33}
:root[data-theme="snow"] .row.ai.tail .bubble,:root[data-theme="snow"] .row.human.tail .bubble{border-radius:20px}
:root[data-theme="snow"] .app.kb .snow-nav{display:none}

/* Installed iOS apps can anchor fixed bottom:0 above the physical bottom after
   black-translucent enables the status-bar area. Use the full standalone vh
   for the host and anchor the composer to that host, not the shortened viewport.
   Keep the existing keyboard transform and one bottom safe-area padding. */
@media (display-mode:standalone){
  :root[data-theme="snow"]{--screen-height:100vh;height:100vh}
  :root[data-theme="snow"] body{position:relative;height:100vh}
  :root[data-theme="snow"] .app{position:absolute;bottom:auto;height:100vh}
  :root[data-theme="snow"] .wall{height:100vh}
  :root[data-theme="snow"] .composer{position:absolute}
  :root[data-theme="snow"] .app.kb .composer{padding-bottom:8px}
}

/* The approved moon butterfly: fixed hit area, mirrored artwork, separate wings. */
.snow-butterfly,.snow-butterfly-defs,.composer-stop-icon{display:none}
#sendBtn .snow-butterfly-defs{position:absolute;display:block;width:0;height:0;overflow:hidden}
#sendBtn[data-action="stop"]>svg:not(.snow-butterfly-defs){display:none}
#sendBtn[data-action="stop"]>.composer-stop-icon{display:block}
:root[data-theme="snow"] #sendBtn>svg{display:none}
:root[data-theme="snow"] #sendBtn .snow-butterfly-defs{display:block;width:0;height:0}
:root[data-theme="snow"] #sendBtn .snow-butterfly{display:block;width:46px;height:46px;transform:scaleX(-1);mix-blend-mode:screen;pointer-events:none}
:root[data-theme="snow"] #sendBtn .snow-butterfly svg{width:46px;height:46px;overflow:hidden;display:none}
:root[data-theme="snow"] #sendBtn[data-action="send"] .snow-butterfly-open{display:block}
:root[data-theme="snow"] #sendBtn:not([data-action="send"]) .snow-butterfly-closed{display:block}
:root[data-theme="snow"] #sendBtn:active:not(:disabled){transform:none}
:root[data-theme="snow"] #sendBtn .snow-flight-rig{position:absolute;inset:0;display:block;transform:scaleX(-1);perspective:180px;pointer-events:none;mix-blend-mode:screen}
:root[data-theme="snow"] #sendBtn .snow-flight-layer{position:absolute;inset:0;display:block;width:46px;height:46px;overflow:hidden;mix-blend-mode:screen;transform-origin:48.6813% 51.3187%;backface-visibility:visible}
:root[data-theme="snow"] #sendBtn .snow-flight-body{transform:none}
:root[data-theme="snow"] #sendBtn.is-fluttering .snow-butterfly{opacity:0}
@media(prefers-reduced-motion:reduce){:root[data-theme="snow"] #sendBtn .snow-flight-rig{display:none}}
