/* v1.2：群聊页面与消息浏览工具栏。 */
.chat{--bg:#111;--panel:#191919;--muted:#888;--line:#242424;background:#111;min-height:100dvh;padding-bottom:calc(116px + env(safe-area-inset-bottom));color:#eee;font-size:16px}
.chat-header{height:58px;padding:0 10px;gap:8px;background:#191919;border-bottom:1px solid #242424;backdrop-filter:none;display:flex;justify-content:space-between}
.chat-header h1{font-size:17px;font-weight:600;letter-spacing:0;line-height:1.3;text-align:center;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat .icon-button{background:transparent;border:0;padding:8px;width:38px;height:40px;flex-shrink:0;color:#ededed;display:grid;place-items:center;cursor:pointer;margin:0;border-radius:4px}
.chat .icon-button svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.chat .more{font-size:19px;letter-spacing:2px}
.chat .timeline{padding:0 12px 18px}
.chat .history{margin:12px auto;padding:7px;font-size:12px;color:#888;background:transparent}
.chat #state{font-size:12px;color:#8c8c8c;margin:12px 0}
.chat .date{color:#777;text-align:center;font-size:12px;margin:19px 0 22px;line-height:1.4}
.chat .date time{background:none;border-radius:0;padding:0}
.chat .message{display:flex;align-items:flex-start;gap:10px;margin:0 0 18px}
.chat .avatar{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0;background:#383838;color:#ccc;font-size:18px}
.chat .avatar-fallback{display:grid;place-items:center;font-weight:500}
.chat .content{min-width:0;max-width:min(calc(100% - 68px),440px)}
.chat .meta{display:block;font-size:12px;line-height:16px;color:#8c8c8c;margin:0 0 5px;overflow-wrap:anywhere}
.chat .bubble{position:relative;display:inline-block;border:0;border-radius:5px;background:#2c2c2c;color:#ededed;line-height:1.55;padding:10px 12px;font-size:16px;overflow-wrap:anywhere;max-width:100%;vertical-align:top}
.chat .bubble::before{content:"";position:absolute;left:-5px;top:13px;width:10px;height:10px;transform:rotate(45deg);background:#2c2c2c}
.chat .body{position:relative;white-space:pre-wrap;z-index:1}
.chat .bubble a{color:#7aa5dc;text-decoration:none;border:0}
.chat .bubble.copyable{cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:text}
.chat .bubble.copyable:active,.chat .bubble.copyable:active::before{background:#393939}
.chat .bubble.copyable:focus-visible{outline:2px solid #8ab3e8;outline-offset:3px}
.chat .picture{padding:0;margin:0;background:none;border:0;border-radius:5px;display:block;max-width:100%;overflow:hidden}
.chat .picture img{display:block;width:auto;max-width:min(240px,100%);max-height:310px;height:auto;object-fit:contain;border-radius:5px}
.chat .chat-tools{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(680px,100%);padding:8px 12px calc(8px + env(safe-area-inset-bottom));background:#1b1b1b;border-top:1px solid #303030;display:block;z-index:5;color:#aaa}
.chat .tool-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.chat .tool-actions button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:9px 5px;border:1px solid #383838;border-radius:6px;background:#282828;color:#ddd;font-size:13px;line-height:20px;white-space:nowrap}
.chat .tool-actions button:first-child{color:#a9d5b4;border-color:#35463b;background:#25342a}
.chat .tool-actions button:disabled{opacity:.45;cursor:default}
.chat .tool-actions svg{width:18px;height:18px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.chat .update-status{margin:8px 0 0;text-align:center;color:#858585;font-size:11px;line-height:16px}
.chat .update-status::before{content:"";display:inline-block;width:5px;height:5px;border-radius:50%;margin:0 6px 1px 0;background:#7b9e83}
.chat .update-status[data-status="error"]{color:#d7a890}
.chat .update-status[data-status="error"]::before{background:#d7a890}
.chat #new{bottom:calc(115px + env(safe-area-inset-bottom));border-radius:5px;background:#292929;color:#9db8d8;box-shadow:0 2px 10px #0005;font-size:12px}
.chat-menu{position:absolute;top:53px;right:9px;z-index:10;background:#303030;color:#aaa;border:1px solid #444;border-radius:6px;padding:12px;box-shadow:0 5px 20px #0007;width:250px;font-size:12px}
.chat-menu button{display:block;background:#3c3c3c;color:#eee;width:100%;margin:0 0 10px;padding:10px;font-size:14px}
.chat .chat-menu p{font-size:12px;color:#aaa;line-height:1.7;margin:5px 0}
.toast{position:fixed;z-index:30;left:50%;top:45%;transform:translate(-50%,-50%);max-width:min(82vw,360px);padding:16px 20px;background:#080808ed;border-radius:8px;color:#fff;font-size:14px;line-height:1.6;text-align:center;pointer-events:none}
.image-viewer{padding:0;background:transparent;max-width:100vw;max-height:100dvh}
.image-viewer img{max-width:94vw;max-height:88dvh}
.copy-dialog{width:min(90vw,400px);border:1px solid #444;border-radius:10px;background:#272727;color:#eee;padding:22px}
.copy-dialog h2{font-size:18px;margin:0 0 10px}
.copy-dialog p{font-size:13px;color:#aaa;line-height:1.7}
.copy-dialog textarea{width:100%;min-height:90px;resize:vertical;background:#191919;color:#eee;border:1px solid #555;padding:10px;font:inherit;font-size:16px;border-radius:5px}
.copy-dialog button{margin-top:12px;color:#95ec69;background:#333;width:100%}
.copy-helper{position:fixed;top:0;left:-9999px;font-size:16px}
[hidden]{display:none!important}
@media(max-width:550px){.chat-header{padding:0 7px}.chat .timeline{padding:0 12px 18px}.chat .bubble{padding:10px 12px}}

/* v3.1: reserve thumbnail geometry to prevent late image loads moving history. */
#messages{overflow-anchor:none}
.chat .picture{width:240px;height:240px;max-width:100%;background:#202327}
.chat .picture img{width:100%;height:100%;max-width:100%;max-height:none;object-fit:contain}
