/* Rose borders, pink chat surfaces and powder-blue accents share both themes. */
:root{color-scheme:light;--theme-bg:#fff7fb;--theme-surface:#fff;--theme-field:#fff0f6;--theme-ink:#442638;--theme-muted:#775568;--theme-accent:#be2d6f;--theme-border:#d94b8a;--theme-bubble:#ffe8f1;--theme-own:#ffd0e3;--theme-soft:#ffe7f1;--theme-wave:#c17b9d;--theme-primary:#be2d6f;--theme-on-primary:#fff;--theme-powder-blue:#dbeafb;--theme-blue-ink:#436b91;--theme-error:#a1373b;--theme-error-bg:#fff0eb;--theme-warning:#fff2d6;--theme-warning-ink:#714d13;--theme-shadow:#64223e20;--theme-overlay:#42162d66;}
:root[data-theme="dark"]{color-scheme:dark;--theme-bg:#100c14;--theme-surface:#241520;--theme-field:#301b29;--theme-ink:#ffeaf4;--theme-muted:#d2b7c4;--theme-accent:#ff9bc6;--theme-border:#b34e7c;--theme-bubble:#321c2b;--theme-own:#52243d;--theme-soft:#412135;--theme-wave:#b46c91;--theme-primary:#b82f6e;--theme-on-primary:#fff;--theme-powder-blue:#253b52;--theme-blue-ink:#bcdaf4;--theme-error:#ffb6b1;--theme-error-bg:#3c2522;--theme-warning:#3b311b;--theme-warning-ink:#f0d79e;--theme-shadow:#0006;--theme-overlay:#0009;}
html,body,.im-chat-host{background:var(--theme-bg);color:var(--theme-ink);}
.im-shell,.im-recorder,.im-details{--im-bg:var(--theme-bg);--im-ink:var(--theme-ink);--im-muted:var(--theme-muted);--im-green:var(--theme-accent);--im-line:var(--theme-border);--im-bubble:var(--theme-bubble);--im-own:var(--theme-own);color-scheme:inherit;}
.im-header,.im-menu,.im-composer,.im-composer-hint,.im-recorder,.im-details{background:var(--theme-surface);}
.im-header,.im-menu,.im-tools,.im-composer,.im-timeline,.im-avatar-circle{border-color:var(--theme-border);}
.im-menu{box-shadow:0 12px 38px var(--theme-shadow);}
.im-avatar{background:var(--theme-soft);}
.im-avatar-circle{background:var(--theme-soft);box-shadow:0 8px 30px var(--theme-shadow);}
.im-composer textarea{background:var(--theme-field);color:var(--theme-ink);}
.im-composer textarea::placeholder{color:var(--theme-muted);}
.im-shell .im-send,.im-recorder .im-record-send,.im-recorder .im-record-stop{background:var(--theme-primary);color:var(--theme-on-primary);}
.im-shell .im-call-record,.im-shell .im-voice-play,.im-call-banner,.im-active-call,.pwa-update-notice{background:var(--theme-soft);color:var(--theme-ink);}
.im-waveform>span:not(.im-audio-progress),.im-audio-progress{background:var(--theme-wave);}
.im-waveform>span[data-played="true"],.im-audio-progress>span{background:var(--theme-accent);}
.im-sheet-handle,.im-level{background:var(--theme-border);}
.im-error,.im-message-error,.im-error button,.auth-error,.form-error{color:var(--theme-error);}
.im-preview-audio,.voice-preview audio,.voice-model{color-scheme:inherit;}
.im-modal-overlay,.settings-overlay{background:var(--theme-overlay);}
.im-history-warning,.im-auth-warning{background:var(--theme-warning);color:var(--theme-warning-ink);}
.im-global-error{background:var(--theme-error-bg);color:var(--theme-error);}
.im-global-error button{color:inherit;}
.im-active-call button,.pwa-update-notice button{background:var(--theme-primary);color:var(--theme-on-primary);}
.im-active-call button:last-child{background:#a9343c;color:white;}
.theme-toggle,.im-shell .theme-toggle{display:inline-flex;flex:0 0 44px;align-items:center;justify-content:center;width:44px;min-width:44px;height:44px;min-height:44px;padding:10px;border:1px solid var(--theme-border);border-radius:50%;background:var(--theme-field);color:var(--theme-accent);touch-action:manipulation;}
.theme-toggle:hover{background:var(--theme-soft);}
.theme-toggle:focus-visible,.password-toggle:focus-visible{outline:2px solid var(--theme-accent);outline-offset:3px;}
.auth-theme-toggle{position:fixed;z-index:5;right:max(16px,env(safe-area-inset-right));top:max(16px,env(safe-area-inset-top));}
/* 多語言切換（2026-11-17）：放在主題按鈕左邊，同高同框線 */
.auth-lang-toggle{position:fixed;z-index:5;right:calc(max(16px,env(safe-area-inset-right)) + 56px);top:max(16px,env(safe-area-inset-top));height:44px;min-height:44px;padding:0 14px;border:1px solid var(--theme-border);border-radius:22px;background:var(--theme-field);color:var(--theme-accent);font:inherit;font-size:14px;font-weight:600;touch-action:manipulation;cursor:pointer;}
.auth-lang-toggle:hover{background:var(--theme-soft);}
.auth-lang-toggle:focus-visible{outline:2px solid var(--theme-accent);outline-offset:3px;}
.primary-button,.primary-button:hover{background:var(--theme-primary);color:var(--theme-on-primary);border-color:var(--theme-primary);}
.secondary-button,.secondary-button:hover{background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-ink);}
.settings-panel,.hangup-dialog,.install-dialog{background:var(--theme-surface);color:var(--theme-ink);border-color:var(--theme-border);box-shadow:0 20px 70px var(--theme-shadow);}
.settings-header,.memory-list li{border-color:var(--theme-border);}
.settings-header-actions{display:flex;align-items:center;gap:8px;}
.settings-header .icon-button,.memory-list button{color:var(--theme-accent);}
.settings-header .icon-button:hover{background:var(--theme-field);}
/* #42 設定頁要看得出怎麼回聊天：左上角文字按鈕，不只一個 X。 */
.settings-done{display:inline-flex;align-items:center;gap:2px;flex:0 0 auto;min-height:44px;padding:8px 14px 8px 8px;border:0;border-radius:22px;background:var(--theme-field);color:var(--theme-accent);font:inherit;font-size:15px;font-weight:600;cursor:pointer;touch-action:manipulation;}
.settings-done:disabled{opacity:.5;cursor:not-allowed;}
.settings-done:focus-visible{outline:2px solid var(--theme-accent);outline-offset:2px;}
.settings-section h2,.voice-range output,.voice-actions [role=status]{color:var(--theme-accent);}
.settings-section label{color:var(--theme-ink);}
.settings-section input:not([type=checkbox]),.settings-section textarea,.voice-model{background:var(--theme-field);border-color:var(--theme-border);color:var(--theme-ink);}
.settings-section input::placeholder,.empty-copy,.settings-section p,.install-dialog p,.training-row{color:var(--theme-muted);}
.settings-section input:focus-visible,.settings-section textarea:focus-visible,.voice-model:focus-visible{outline-color:var(--theme-accent);}
.settings-section .voice-range input[type=range],.settings-section input[type=range],.checkbox-label input,.auth-check input{accent-color:var(--theme-accent);}
.settings-section input[type=range]{background:transparent;}
.settings-section .form-error{color:var(--theme-error);}

/* Calm surfaces: hierarchy comes from fill and space, not outlines. */
.im-bubble{border:0;}
.im-header,.im-composer{border-color:color-mix(in srgb,var(--theme-border) 30%,transparent);}
@media(min-width:800px){.im-header,.im-timeline,.im-composer{border-inline-color:transparent;}}
.im-empty h2{font-size:22px;font-weight:700;margin:0 0 18px;}
.im-starters{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;max-width:360px;}
/* Empty-state starters: soft pills on the opening screen. */
.im-shell .im-starters button{min-height:40px;padding:8px 16px;border-radius:999px;background:var(--theme-soft);color:var(--theme-ink);font-size:15px;line-height:20px;white-space:nowrap;transition:background-color 120ms ease,transform 120ms ease;}
.im-shell .im-starters button:hover{background:var(--theme-field);}
.im-shell .im-starters button:active{transform:scale(.97);}
/* Reply chips: solid pink bubbles with white text — their own shape, not the
   chat bubble's. Generous vertical padding so the horizontal scroll never
   clips a pill's top or bottom edge. */
/* flex:none — inside the column shell the row was shrunk to ~55px and cut the bubbles' top edge and shadow */
.im-chips{flex:none;display:flex;align-items:center;gap:8px;width:min(100%,760px);margin-inline:auto;box-sizing:border-box;padding:10px max(16px,env(safe-area-inset-right)) 12px max(16px,env(safe-area-inset-left));overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch;animation:im-chips-in 180ms ease-out;}
.im-chips::-webkit-scrollbar{display:none;}
.im-shell .im-chips button{flex:0 0 auto;min-height:44px;padding:11px 18px;border-radius:999px;background:var(--theme-primary);color:var(--theme-on-primary);font-size:15px;line-height:20px;font-weight:600;white-space:nowrap;border:0;box-shadow:0 1px 5px var(--theme-shadow);transition:filter 120ms ease,transform 120ms ease;}
.im-shell .im-chips button:hover{filter:brightness(1.08);}
.im-shell .im-chips button:active{transform:scale(.97);}
@keyframes im-chips-in{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:none;}}
@media(prefers-reduced-motion:reduce){.im-chips{animation:none;}.im-shell .im-starters button,.im-shell .im-chips button{transition:none;}}

/* 底部導覽列：聊天｜IG */
.has-tabbar{--tabbar-h:calc(56px + env(safe-area-inset-bottom,0px));}
.has-tabbar .im-shell{height:calc(100vh - var(--tabbar-h));height:calc(100dvh - var(--tabbar-h));}
/* #38 切 App 回來輸入框不見：殼高度跟著真正看得到的視窗（--app-vh 由 app-viewport 依 visualViewport 寫入，沒有就退回 100dvh）。 */
@supports(height:1dvh){
  .im-shell{height:var(--app-vh,100dvh);}
  .has-tabbar .im-shell{height:calc(var(--app-vh,100dvh) - var(--tabbar-h));}
  .im-chat-host{min-height:var(--app-vh,100dvh);}
}
/* 底部導覽列已經墊了 safe-area，輸入框不要再墊一次。 */
.has-tabbar .im-composer{padding-bottom:10px;}
.has-tabbar .im-composer-hint{padding-bottom:8px;}
/* 鍵盤打開時收起底部導覽，輸入框直接貼在鍵盤上方。 */
[data-keyboard="open"] .has-tabbar{--tabbar-h:0px;}
[data-keyboard="open"] .app-tabbar{display:none;}
.app-tabbar{position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;justify-content:center;gap:0;height:var(--tabbar-h);padding-bottom:env(safe-area-inset-bottom,0px);box-sizing:border-box;background:var(--theme-bg);border-top:1px solid color-mix(in srgb,var(--theme-ink) 12%,transparent);}
.app-tabbar button{flex:1;max-width:380px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;border:0;background:none;color:var(--theme-muted);font-size:11px;font-weight:600;min-height:44px;}
.app-tabbar button[aria-current="page"]{color:var(--theme-primary);}
/* 未讀角標（老闆 2026-11-20）：疊在聊天圖示右上角。 */
.app-tabbar button{position:relative;}
.app-tab-badge{position:absolute;top:3px;left:calc(50% + 5px);min-width:18px;height:18px;padding:0 5px;box-sizing:border-box;border-radius:9px;background:var(--theme-badge,#e5484d);color:#fff;font-size:11px;font-weight:700;line-height:18px;text-align:center;font-variant-numeric:tabular-nums;box-shadow:0 0 0 2px var(--theme-bg);}

/* IG 分頁：生活照動態（版型參考常見相片社群，不使用任何品牌標誌） */
.ig-page{width:min(100%,600px);margin:0 auto;min-height:calc(100dvh - var(--tabbar-h,0px));box-sizing:border-box;padding-bottom:16px;background:var(--theme-bg);color:var(--theme-ink);overflow-y:auto;}
.ig-top{position:sticky;top:0;z-index:2;display:grid;grid-template-columns:44px 1fr 44px;align-items:center;height:52px;padding:0 8px;background:var(--theme-bg);border-bottom:1px solid color-mix(in srgb,var(--theme-ink) 10%,transparent);text-align:center;font-size:16px;}
.ig-back{display:grid;place-items:center;width:44px;height:44px;border:0;background:none;color:inherit;}
.ig-profile{display:flex;align-items:center;gap:28px;padding:16px 16px 8px;}
.ig-avatar{width:86px;height:86px;border-radius:50%;object-fit:cover;object-position:50% 15%;flex:none;background:color-mix(in srgb,var(--theme-primary) 20%,transparent);box-shadow:0 0 0 2px var(--theme-bg),0 0 0 4px var(--theme-primary);}
.ig-stats{display:flex;gap:24px;}
.ig-stats div{display:flex;flex-direction:column;align-items:center;}
.ig-stats strong{font-size:18px;}
.ig-stats small{font-size:13px;color:var(--theme-muted);}
.ig-bio{padding:0 16px 12px;font-size:14px;line-height:1.5;}
.ig-bio p{margin:0;}
.ig-tabs{display:flex;justify-content:center;padding:10px 0;border-top:1px solid color-mix(in srgb,var(--theme-ink) 10%,transparent);color:var(--theme-ink);}
.ig-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:2px;margin:0;padding:0;list-style:none;}
.ig-grid button{display:block;width:100%;aspect-ratio:4/5;padding:0;border:0;background:color-mix(in srgb,var(--theme-ink) 6%,transparent);}
.ig-grid img{width:100%;height:100%;object-fit:cover;display:block;}
.ig-empty{padding:32px 16px;text-align:center;color:var(--theme-muted);font-size:14px;}
.ig-post-head{display:flex;align-items:center;gap:10px;padding:10px 12px;font-size:14px;}
.ig-avatar-sm{width:32px;height:32px;border-radius:50%;object-fit:cover;object-position:50% 15%;background:color-mix(in srgb,var(--theme-primary) 20%,transparent);}
.ig-photo{width:100%;aspect-ratio:4/5;object-fit:cover;display:block;background:color-mix(in srgb,var(--theme-ink) 6%,transparent);}
.ig-actions{display:flex;gap:8px;padding:6px 6px 0;}
.ig-actions button{display:grid;place-items:center;width:44px;height:44px;border:0;background:none;color:var(--theme-ink);}
.ig-actions .ig-liked{color:#ed4956;}
.ig-likes{margin:0 12px;font-size:14px;font-weight:600;}
.ig-caption{margin:4px 12px;font-size:14px;line-height:1.5;}
.ig-reply{display:block;margin:4px 12px;padding:0;border:0;background:none;color:var(--theme-muted);font-size:14px;text-align:left;min-height:32px;}
.ig-when{display:block;margin:2px 12px;color:var(--theme-muted);font-size:12px;}
.pwa-install-banner{background:var(--theme-soft);color:var(--theme-ink);border-color:var(--theme-border);}
.pwa-install-banner .pwa-install-banner-icon{color:var(--theme-accent);}
.pwa-install-banner button.pwa-install-banner-primary{background:var(--theme-primary);color:var(--theme-on-primary);}
.pwa-install-banner button.pwa-install-banner-later{color:var(--theme-muted);}
