:root{color-scheme:light;--canvas:#ededed;--shell:#f6f6f6;--ink:#191b1c;--dim:#535c57;--line:#dedfdd;--accent:#087b42;--mine:#a8e982;font:16px/1.45 system-ui,-apple-system,"Noto Sans SC","Microsoft YaHei",sans-serif}
*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;color:var(--ink);background:#dfe3e0;overflow:hidden}
button,input,textarea,select{font:inherit;color:inherit}
button,.attach{cursor:pointer}
button:disabled,fieldset:disabled .attach{opacity:.48;cursor:default}
button,a,textarea,input,select,.attach{touch-action:manipulation}
:focus-visible{outline:2px solid #16824f;outline-offset:2px}
a{color:var(--accent)}
button{border:0;background:none;min-height:32px}
.shell{max-width:760px;margin:auto;height:100vh;height:100dvh;background:var(--canvas);display:flex;flex-direction:column;box-shadow:0 0 42px #24323315}
.top{flex:none;min-height:62px;padding:max(6px,env(safe-area-inset-top)) 12px 6px;background:var(--shell);border-bottom:1px solid var(--line);display:grid;grid-template-columns:minmax(86px,1fr) minmax(0,2.4fr) minmax(86px,1fr);align-items:center;gap:8px}
.title{text-align:center;min-width:0}.title h1{font-size:16px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}.title span{font-size:10px;color:var(--dim)}
.icon{display:inline-grid;place-items:center;width:44px;height:44px;padding:0;text-align:center}.top .icon{justify-self:end}.icon svg,.guest-mark svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round}
.identity{display:flex;align-items:center;gap:5px;min-width:0;justify-self:start;max-width:100%;min-height:44px;padding:0 4px;color:var(--accent);font-size:13px;font-weight:650}.identity span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.avatar{display:grid;place-items:center;flex:none;width:38px;height:38px;min-height:0;border-radius:50%;font-size:17px;font-weight:680;color:#234734;background:#d6e9dc;padding:0}.identity .avatar{width:25px;height:25px;font-size:12px}.tone1{background:#e4def2;color:#4d3c6e}.tone2{background:#f2e1d2;color:#754323}.tone3{background:#d5e6f0;color:#284963}.tone4{background:#e8e8c8;color:#555627}
.chat{display:flex;flex-direction:column;flex:1;min-height:0;position:relative}
.history{overflow:auto;overscroll-behavior:contain;flex:1;min-height:0;padding:8px 12px 12px}
.history-top{text-align:center}.history-top button,#jump{border-radius:18px;background:white;color:var(--accent);font-size:12px;padding:0 12px}
#items{list-style:none;padding:0;margin:0}
.guest{margin:clamp(38px,14dvh,145px) auto 20px;text-align:center;color:var(--dim);max-width:265px;padding:0 10px}.guest strong{color:#333b36;font-size:16px}.guest p{font-size:13px;margin:5px 0 15px}.guest a{font-size:13px;text-decoration:none}.guest-mark{width:59px;height:59px;border-radius:20px;display:grid;place-items:center;background:#e1e8e3;color:#587266;margin:0 auto 16px}.guest-mark svg{width:29px;height:29px}
.row{display:flex;align-items:flex-start;gap:9px;margin:12px 0}.row.mine{flex-direction:row-reverse}.row article{min-width:0;max-width:min(78%,520px);display:flex;align-items:flex-start;flex-direction:column;gap:3px}.mine article{align-items:flex-end}
.meta{color:#525c55;font-size:11px;max-width:100%;display:flex;align-items:center;gap:6px}.meta button{padding:0;min-height:20px;max-width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.tag{font-size:10px;font-weight:650;color:#256244;background:#dbe9df;border-radius:4px;padding:1px 5px;flex:none}
.bubble{position:relative;background:#fff;border-radius:7px;max-width:100%;padding:7px 10px;min-width:0;overflow-wrap:anywhere;white-space:pre-wrap;line-height:1.46;font-size:15px}.mine .bubble{background:var(--mine)}.bubble::before{content:"";position:absolute;left:-4px;top:10px;width:9px;height:9px;background:inherit;transform:rotate(45deg);border-radius:1px}.mine .bubble::before{left:auto;right:-4px}
.bubble:has(.preview):not(:has(.message-text,.ref,.file)){background:transparent;padding:0}.bubble:has(.preview):not(:has(.message-text,.ref,.file))::before{display:none}
.system,.stamp{text-align:center;color:#515a54;font-size:11px;margin:14px 0;white-space:pre-wrap;overflow-wrap:anywhere}
.row-actions{display:flex;flex-wrap:wrap;gap:1px;color:#525c55}.row-actions button{font-size:11px;padding:0 7px;min-height:30px}.row-actions button[aria-pressed=true]{color:#075a32;background:#d9ebdc;border-radius:12px}
.ref{display:block;max-width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;border-radius:5px;font-size:12px;background:#111a1310;padding:3px 7px;margin-bottom:5px}
.file{display:block;text-align:left;border:1px solid #657b6544;border-radius:7px;background:#ffffff60;max-width:100%;padding:5px 8px;margin-top:5px;font-size:13px;overflow-wrap:anywhere}
.preview{display:block;border-radius:8px;overflow:hidden;max-width:100%;padding:0;background:#e1e8e2;text-align:center}.preview img{display:block;width:min(220px,100%);height:auto;max-height:252px;object-fit:contain}.preview:not(:has(img)){padding:7px 10px;color:#225a3e;font-size:13px}
#jump{position:absolute;bottom:106px;right:14px;box-shadow:0 3px 15px #435b4935}
#status{flex:none;padding:3px 12px;background:#edf5ef;border-top:1px solid #d9e5dc;color:#456051;font-size:12px;overflow-wrap:anywhere}#status[data-tone=error]{background:#fff2e9;color:#80441e}
.compose{background:var(--shell);border-top:1px solid var(--line);padding:5px 10px max(7px,env(safe-area-inset-bottom));flex:none}
fieldset{border:0;margin:0;padding:0;min-inline-size:0}.composer-line{display:flex;align-items:flex-end;gap:7px}.attach{border:1px solid #9aa59d;border-radius:50%;font-size:21px;width:33px;height:33px;margin:4px 1px;flex:none}fieldset:disabled .attach{pointer-events:none}
textarea{background:#fff;border:1px solid #e1e4e2;border-radius:6px;padding:8px 9px;min-height:41px;resize:none;flex:1;min-width:0}
.primary{background:#087b42;border-radius:6px;color:#fff;font-weight:650;padding:0 12px;min-height:41px;white-space:nowrap}
.composer-options{display:flex;align-items:center;gap:6px;padding-top:2px;min-height:24px;font-size:11px;color:var(--dim)}.composer-options select{border:0;background:transparent;font-size:12px;padding:0 2px;min-height:24px}.composer-options span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.quote{display:flex;align-items:center;justify-content:space-between;padding:0 8px;margin:0 0 5px;background:#e8ede9;font-size:12px;border-radius:6px;gap:6px}.quote span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.quote button{font-size:19px}
dialog{width:min(calc(100% - 22px),480px);max-height:86dvh;overflow:auto;border:1px solid #dce3df;border-radius:13px;padding:0;color:var(--ink);background:#fcfdfc;box-shadow:0 18px 65px #101d1850}
dialog::backdrop{background:#1220186e}dialog .sheet-head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:4px 10px 4px 16px;border-bottom:1px solid var(--line)}.sheet-head h2{font-size:16px;margin:0}.close{font-size:25px}
#signin form,#account>p,#account>#lock,.sheet-body{padding:12px 16px}#signin form label{display:block;font-size:13px;font-weight:650}#signin input{display:block;width:100%;padding:9px;border:1px solid #aab4ad;border-radius:7px;margin-top:5px}#login-error{color:#8a3722;font-size:13px;min-height:1em}#signin form a{margin-left:8px;font-size:13px}
.sheet-body p{overflow-wrap:anywhere}.directory-row{width:100%;min-height:54px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:9px;text-align:left;padding:6px 1px}.directory-row strong,.directory-row small{display:block;overflow-wrap:anywhere}.directory-row small,.card-date{font-size:11px;color:var(--dim)}
.daily-card{margin:8px 0;border-radius:6px;background:#ecf4ee;padding:9px;overflow-wrap:anywhere}.daily-card p{white-space:pre-wrap;margin:4px 0}
.lightbox{width:min(calc(100% - 12px),900px);background:#101411;color:#f4f8f5}.lightbox .sheet-head{border-color:#414844}.lightbox .sheet-head span{font-size:13px;overflow-wrap:anywhere}.lightbox img{display:block;max-width:100%;max-height:70dvh;object-fit:contain;margin:auto}.lightbox #image-stage{text-align:center;padding:4px;min-height:28px}.image-actions{text-align:right;padding:5px 12px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
@media(min-width:600px){.history{padding-left:22px;padding-right:22px}.top{padding-left:18px;padding-right:18px}}
.avatar{position:relative;overflow:hidden}.avatar img{position:absolute;width:100%;height:100%;object-fit:cover;inset:0;background:inherit}
.self-profile{padding:12px 16px;display:grid;gap:7px}.self-profile label,.self-profile p{font-size:13px;margin:0}.self-profile input{max-width:100%;width:100%;border:1px solid #aab4ad;border-radius:6px;padding:7px}.self-profile>#avatar-clear{color:var(--accent)}
.daily-meta{display:flex;align-items:center;gap:8px}.daily-meta .avatar{width:24px;height:24px;font-size:12px}

/* Media is its own shape: no bubble padding/triangle, forced aspect ratio, or fill behind photos. */
.bubble.with-media,.mine .bubble.with-media{padding:0;background:transparent}
.bubble.with-media::before{display:none}
.bubble.with-media>.message-text,.bubble.with-media>.ref{padding:6px 9px;border-radius:7px;background:#fff;margin-bottom:5px;width:fit-content;max-width:100%}
.mine .bubble.with-media>.message-text,.mine .bubble.with-media>.ref{background:var(--mine);margin-left:auto}
.preview.media-picture:has(img){background:transparent;width:var(--media-width, 160px);min-height:0;border:0;padding:0}
.preview.media-picture img{display:block;width:var(--media-width, 160px);height:auto;max-width:100%;object-fit:initial;border-radius:8px}
.video-frame{width:min(240px,100%);overflow:hidden;border-radius:8px}
.video-frame video{display:block;width:100%;height:auto;max-height:260px;background:#171c19}
.video-download{display:block;margin:2px 0 0 auto;font-size:11px;padding:0 5px;color:var(--accent)}
button.recall{color:#894c43}
.invite-panel{padding:10px 16px 16px;border-top:1px solid var(--line)}.invite-panel h3{font-size:14px;margin:0 0 4px}.invite-panel p,.invite-panel a{font-size:12px;margin:4px 0}
.relation-block{margin:8px 0;border-top:1px solid var(--line);padding:7px 0}.relation-block>strong{font-size:13px}.relation-block button{font-size:13px;text-align:left;display:block}
.quote-preview{display:block;margin:0 0 5px;width:fit-content;max-width:100%}.quote-preview>img{display:block;max-width:70px;max-height:62px;width:auto;height:auto;border-radius:4px;margin-top:3px}
.pairing-panel{margin:.6rem 1rem 1rem;padding:.8rem;border:1px solid var(--line,#d9dedb);border-radius:.7rem}
.pairing-panel h3,.pairing-panel p{margin:0 0 .65rem}
.pairing-panel p{font-size:.87rem;line-height:1.5}
.pairing-result:not([hidden]){display:flex;gap:.4rem;align-items:center;margin:.55rem 0;flex-wrap:wrap}
.pairing-result input{flex:1 1 10rem;min-width:0;max-width:100%;font-size:.85rem}
#pair-status{margin:.55rem 0 0;min-height:1.2em}

/* v3.4: visible, phone-sized controls over the existing chat layout. */
html,body{width:100%;height:100%;overscroll-behavior:none;overflow:hidden}
.shell{position:fixed;inset-inline:0;top:var(--visible-top,0px);width:100%;height:100vh;height:var(--visible-height,100dvh);margin-inline:auto}
.top{background:#f9fbf9;box-shadow:0 1px 0 #233c2f0a}
.history{overscroll-behavior-y:contain}
.history button,.top button,dialog button,.composer-line button,.composer-line .attach{touch-action:manipulation}
button:not(.preview){min-height:40px}
button:not(.preview),.attach,.action-link,.guest a,#signin form a{border:1px solid #b6c9bc;border-radius:10px;background:#f3faf5;color:#225541;padding:0 .65rem;font-weight:640}
button:not(.preview):hover,.attach:hover,.action-link:hover{background:#e4f2e9;border-color:#81ad93}
button:not(.preview):active,.attach:active,.action-link:active{background:#cfebd7;border-color:#3b855f;transform:translateY(1px)}
button.primary:not(.preview){border-color:#0a6c3e;background:#087b42;color:#fff}
button.primary:not(.preview):hover{background:#096d3d}
button.primary:not(.preview):active{background:#0c5937}
button.icon:not(.preview){padding:0;min-width:44px}
.identity:not(.preview){padding:0 6px;max-width:100%}
.row-actions{gap:5px;margin-top:3px}
.row-actions button{padding:0 7px;min-width:40px;font-size:12px}
.row-actions button[aria-pressed=true]{color:#134d2b;background:#d9f0df;border-color:#79a88a}
.meta button:not(.preview){min-height:40px;padding:0 6px;font-size:12px}
.composer-line .attach{display:inline-grid;place-items:center;width:42px;height:42px;padding:0;border-radius:10px}
.composer-options select{min-height:40px;background:#f5faf6;border:1px solid #bfd0c5;border-radius:8px;padding:0 6px}
.profile-edit-title,.self-profile h3{font-size:15px;margin:0 0 4px}
dialog .sheet-head{background:#fcfdfc;position:sticky;top:0;z-index:2}
.lightbox .sheet-head{background:#101411}
#jump{bottom:122px}
.guest a,#signin form a,.action-link{display:inline-flex;align-items:center;min-height:40px;text-decoration:none}
.invite-panel{padding:14px 16px;border-top:1px solid var(--line);background:#f5faf7}.invite-panel h3{margin-top:0}
#member-invite-link{display:block;width:100%;min-height:54px;overflow-wrap:anywhere;line-height:1.35}
.invite-buttons,.ai-relation-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:5px 0}
.ai-badge{display:inline-block;background:#e1e8fc;color:#2e4d84;border:1px solid #bfcef2;border-radius:9px;padding:0 6px;font-size:.75rem;font-weight:680;margin:2px 5px 2px 0}
@media(max-width:420px){.history{padding-inline:8px}.composer-line{gap:5px}.row-actions button{padding:0 6px}.top{gap:5px;padding-inline:8px}}
@media(prefers-reduced-motion:reduce){button:not(.preview):active,.attach:active,.action-link:active{transform:none}}
#account-ai h3{margin-top:0}
.binding-picker:not([hidden]){display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:6px}
.binding-picker select,#invite-kind{min-height:40px;border:1px solid #b6c9bc;border-radius:8px;background:#f3faf5;max-width:100%;padding:0 6px}
#invite-type-row{margin-bottom:.5rem}
#profile-binding{margin:.4rem 0}
#owner-tools{margin:1rem;padding:.7rem;background:#f6faf7;border:1px solid var(--line);border-radius:10px}
#owner-tools summary{cursor:pointer;min-height:40px;padding:.45rem .6rem;border:1px solid #b6c9bc;border-radius:8px;background:#eaf5ed;font-weight:650}
#owner-tools section{padding:.65rem;margin:.6rem 0;background:white;border:1px solid var(--line);border-radius:8px}
#owner-tools h2,#room-edit-profile h2{font-size:1rem;margin:.3rem 0}
#owner-tools .row{display:block;border-top:1px solid var(--line);padding:.4rem 0}
#owner-tools p,#owner-tools pre{overflow-wrap:anywhere;white-space:pre-wrap}
#owner-tools button{margin:.2rem}#owner-tools textarea{width:100%}
#room-edit-profile{padding:1rem}#room-edit-profile label{display:block;margin-top:.5rem}#room-edit-profile input{max-width:100%}

/* Nicknames remain native controls, but are labels visually. Leave action buttons and focus outlines alone. */
button.nickname-control:not(.preview){
 border:0;border-radius:0;background:transparent;box-shadow:none;color:var(--ink);
 padding:1px calc(.65rem + 1px);
}
button.nickname-control:not(.preview):is(:hover,:active){background:transparent;transform:none}
button.identity.nickname-control:not(.preview){padding:1px 7px}
.meta .member-name{color:#555;min-width:0;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.meta button.member-name.nickname-control:not(.preview){padding:1px 7px;color:#555;font-size:12px;font-weight:400}
#profile-edit-title{overflow-wrap:anywhere}

.member-card-owner{display:flex;flex-wrap:wrap;align-items:center;gap:0 .2rem;margin-top:.2rem;font-size:.9rem}
.member-card-owner .ai-badge{margin-right:.35rem}
#profile .relation-name{padding-inline:.35rem;text-align:left;overflow-wrap:anywhere;max-width:100%;font-weight:700}
#profile .member-card-owner .relation-name{color:#225541}

.connection-grants{padding:.3rem 0;border-bottom:1px solid var(--line)}
.connection-grants summary{min-height:40px;cursor:pointer;color:var(--accent);padding:.45rem .15rem;font-size:.87rem}
.connection-grant{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.3rem 0}
.connection-grant button{flex:none}
