/* WeChat-like reading order. Scoped so articles and tools keep their own layout. */
.wechat-layout{--wx-bg:#ededed;--wx-panel:#f7f7f7;--wx-paper:#fff;--wx-text:#181818;--wx-subtle:#929292;--wx-divider:#e5e5e5;--wx-selected:#dedede;--wx-own:#95ec69;--wx-peer:#fff;background:var(--wx-bg);color:var(--wx-text)}
.wechat-layout .sidebar{width:84px;padding:20px 9px;background:var(--wx-panel);border-color:var(--wx-divider);z-index:20}
.wechat-layout .brand{justify-content:center}.wechat-layout .brand>span{display:none}.wechat-layout .brand-mark{width:44px;height:44px}
.wechat-layout .sidebar nav{margin-top:26px;gap:4px}.wechat-layout .sidebar nav button{flex-direction:column;gap:0;align-items:center;justify-content:center;padding:7px 2px;font-size:21px;color:var(--wx-subtle);border-radius:7px}
.wechat-layout .sidebar nav button span{font-size:10px;line-height:1.6;max-width:66px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.wechat-layout .sidebar nav button.active{color:#07a35c;background:#07a35c12}.wechat-layout .sidebar-bottom{justify-content:center}.wechat-layout .sidebar-bottom .private-dot{display:none}.wechat-layout .sidebar-bottom{font-size:0}.wechat-layout .sidebar-bottom button{font-size:11px;margin-left:0}
.wechat-layout main{margin-left:84px;padding:0;max-width:none;height:100dvh;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.wechat-layout .topbar{padding:10px 22px;min-height:48px;background:var(--wx-panel);border-color:var(--wx-divider);flex-shrink:0}
.wechat-layout footer,.wechat-layout:is([data-view=chat],[data-view=groups],[data-view=himeko]) .page-head{display:none}.wechat-layout #content{flex:1;min-height:0;overflow:hidden}.wechat-layout #notice{margin:8px 16px;flex-shrink:0}
.wechat-layout .filter-panel{border:0;border-bottom:1px solid var(--wx-divider);border-radius:0;background:var(--wx-panel);padding:12px 20px;margin:0;flex-shrink:0}
.wechat-layout .filter-panel .search-row input{background:#e9e9e9;border-color:transparent}.wechat-layout .filter-row{margin-top:8px}.wechat-layout .filter-row input,.wechat-layout .filter-row select{background:var(--wx-paper);color:var(--wx-text);border-color:var(--wx-divider)}
.wechat-layout .filter-panel .primary{background:#07a35c;border-color:#07a35c}.wechat-layout .chips{margin-top:8px}
.wechat-layout .filter-panel .chip{background:var(--wx-selected);color:var(--wx-text)}.wechat-layout .filter-panel .chip.selected{background:#07a35c;color:white}
body[data-view=chat].wechat-layout .topbar{display:none}
.wechat-layout:not([data-view=chat]):not([data-view=groups]):not([data-view=himeko]) #content{overflow:auto;padding:20px;background:var(--bg);color:var(--ink)}.wechat-layout .page-head{padding:20px 22px;flex-shrink:0;background:var(--bg);color:var(--ink)}
.archive-search-results{height:100%;overflow:auto;padding:16px 22px}
.chat-shell{height:100%;min-height:0;display:flex;flex-direction:column;background:var(--wx-bg)}
.thread-header{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:66px;padding:12px 24px;border-bottom:1px solid var(--wx-divider);background:var(--wx-panel);flex-shrink:0}
.thread-title{display:flex;align-items:center;gap:11px;min-width:0}.thread-title h2{font-size:18px;font-weight:600;line-height:1.4}.thread-title .wechat-avatar{width:36px;height:36px;font-size:18px}.thread-title small{font-size:11px;color:var(--wx-subtle);display:block}
.thread-tools{display:flex;gap:6px;align-items:center}.thread-tools button{font-size:12px;padding:6px 10px;border-color:transparent;background:transparent;color:var(--wx-subtle);white-space:nowrap}
.thread-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:14px 26px 22px;overscroll-behavior-y:contain;scrollbar-width:thin;scrollbar-color:#c6c6c6 transparent}
.wechat-layout .chat-log{display:block;margin:0;max-width:none}.chat-time{text-align:center;color:var(--wx-subtle,#929292);font-size:12px;line-height:1.5;padding:15px 0 18px;clear:both}.chat-time time{display:inline-block}
.chat-message,.wechat-layout .message{margin:0 0 18px;padding:0;border:0;border-radius:0;background:transparent;min-width:0}
.chat-row{display:flex;align-items:flex-start;gap:11px;min-width:0}.chat-row.mine{flex-direction:row-reverse}
.wechat-avatar{width:40px;height:40px;flex:0 0 auto;border-radius:5px;display:grid;place-items:center;background:#d6e6dd;color:#3d6655;font-size:19px;font-weight:600;overflow:hidden;user-select:none}
.wechat-avatar.own-avatar{background:#b7dbe7;color:#385b69}.wechat-avatar.himeko-avatar{background:#ffe7ce;color:#8b333c}
.wechat-avatar>.himeko-portrait{width:100%;height:100%;max-width:none;object-fit:cover;display:block;border-radius:inherit}
.wechat-avatar.avatar-tone-0{background:#e4d7c4;color:#7d6546}.wechat-avatar.avatar-tone-1{background:#d8dcef;color:#5c638b}.wechat-avatar.avatar-tone-2{background:#dbdfc6;color:#67734f}.wechat-avatar.avatar-tone-3{background:#ecd5d8;color:#8e6269}.wechat-avatar.avatar-tone-4{background:#cce3e1;color:#4f7a77}
.wechat-avatar.group-avatar{grid-template-columns:1fr 1fr;padding:3px;gap:2px;background:#dadada}.group-avatar span{display:grid;place-items:center;background:#b8d5c3;color:#4d695a;align-self:stretch;font-size:11px;border-radius:2px}.group-avatar span:nth-child(2){background:#dfc7ab;color:#7a6347}.group-avatar span:nth-child(3){background:#d0c9e0;color:#76618b}.group-avatar span:nth-child(4){background:#b7cfdf;color:#4d7086}
.chat-stack{display:flex;flex-direction:column;align-items:flex-start;max-width:min(72%,780px);min-width:0;position:relative}
.chat-row.mine .chat-stack{align-items:flex-end}.chat-sender{display:block;max-width:100%;font-size:12px;color:var(--wx-subtle);margin:-3px 0 5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.wechat-layout .chat-bubble{position:relative;background:var(--wx-peer);border:0;border-radius:5px;max-width:100%;padding:10px 13px;white-space:normal;color:var(--wx-text);align-self:auto;min-width:22px;box-shadow:0 1px 1px #00000004}
.wechat-layout .chat-bubble:before{content:'';position:absolute;left:-5px;top:14px;border-right:6px solid var(--wx-peer);border-top:5px solid transparent;border-bottom:5px solid transparent}
.wechat-layout .chat-bubble.mine{background:var(--wx-own);align-self:auto}.wechat-layout .chat-bubble.mine:before{left:auto;right:-5px;border-right:0;border-left:6px solid var(--wx-own)}
.wechat-layout .message-text{font-size:15px;line-height:1.65;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}.wechat-layout .chat-bubble p{margin:0}
.message-details{align-self:flex-start;position:relative;margin-top:1px;min-height:8px}.chat-row.mine .message-details{align-self:flex-end}.message-details>summary{list-style:none;cursor:pointer;color:var(--wx-subtle);font-size:14px;line-height:16px;padding:0 4px;opacity:.35}.message-details>summary::-webkit-details-marker{display:none}.message-details:hover>summary,.message-details:focus-within>summary,.message-details[open]>summary{opacity:1}
.message-detail-panel{position:absolute;top:20px;left:0;z-index:10;background:var(--wx-paper,#fff);border:1px solid var(--wx-divider,#ddd);padding:10px 12px;border-radius:7px;box-shadow:0 4px 18px #0002;width:230px;max-width:65vw;color:var(--wx-subtle,#888);font-size:11px}.chat-row.mine .message-detail-panel{left:auto;right:0}.message-detail-panel button{font-size:11px;padding:4px 7px;background:transparent;color:inherit}.message-detail-panel .message-actions{flex-wrap:wrap;margin-top:7px;justify-content:start}
.wechat-layout .message.anchor .chat-bubble{outline:2px solid #d1ad5a;outline-offset:3px}.wechat-layout .chat-images{margin:0}.wechat-layout .chat-images+.message-text{margin-top:9px}.wechat-layout .chat-images img{border-radius:4px;max-width:100%;width:230px;max-height:280px}
.wechat-layout .chat-compose{border-top:1px solid var(--wx-divider);max-width:none;margin:0;background:var(--wx-panel);padding:12px 24px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:9px;align-items:end;flex-shrink:0}
.wechat-layout .chat-compose textarea{min-height:42px;max-height:144px;resize:none;border:1px solid var(--wx-divider);background:var(--wx-paper);color:var(--wx-text);padding:9px 12px;line-height:1.5;font-size:15px;border-radius:5px}
.wechat-layout .compose-actions{align-items:center;gap:6px}.wechat-layout .compose-actions .plain{font-size:24px;width:38px;height:40px;min-height:40px;padding:0;color:var(--wx-text)}.wechat-layout .compose-actions .primary{background:#07b75b;border-color:#07b75b;min-width:62px;font-size:13px;min-height:40px;border-radius:5px;padding:8px 12px}
.wechat-layout .chat-compose>p{grid-column:1/-1;font-size:11px;color:var(--wx-subtle);margin:0}.wechat-layout .chat-compose:has(.attachment-tray[hidden])>p{display:none}.wechat-layout .attachment-tray{grid-column:1/-1;background:var(--wx-bg);border:0;padding:8px;gap:10px}.wechat-layout .attachment-card{width:76px}.wechat-layout .attachment-card img{width:76px;height:68px;border-radius:5px}.wechat-layout .attachment-card small{max-width:76px;color:var(--wx-subtle)}
.chat-requests:empty{display:none}.wechat-layout .chat-requests .card{font-size:12px;margin:10px 0;padding:12px;background:var(--wx-panel);border-color:var(--wx-divider);color:var(--wx-subtle);border-radius:7px}
.conversation-workspace{height:100%;display:grid;grid-template-columns:310px minmax(0,1fr);min-height:0;background:var(--wx-bg)}
.conversation-directory{min-height:0;overflow:auto;border-right:1px solid var(--wx-divider);background:var(--wx-panel)}.directory-heading{display:flex;justify-content:space-between;gap:12px;padding:14px 16px 10px;font-size:13px;color:var(--wx-text)}.directory-heading span{font-size:11px;color:var(--wx-subtle)}.directory-heading{gap:6px;flex-wrap:wrap}.directory-heading>strong{flex:1;font-size:12px}.directory-heading button{padding:3px 5px;font-size:11px}
.conversation-list{display:flex;flex-direction:column}.conversation-row{display:flex;position:relative;min-height:82px;padding-right:22px;border-bottom:1px solid var(--wx-divider)}.conversation-row.selected{background:var(--wx-selected)}.conversation-row:hover{background:var(--wx-selected)}
.conversation-open{display:flex;align-items:center;gap:13px;min-width:0;flex:1;padding:14px 8px 14px 16px;text-align:left;background:transparent!important;border:0;border-radius:0;color:var(--wx-text)}.conversation-open .wechat-avatar{width:46px;height:46px}
.conversation-copy{flex:1;min-width:0}.conversation-heading{display:flex;align-items:baseline;gap:9px}.conversation-name{font-size:15px;font-weight:500;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.conversation-time{font-size:10px;color:var(--wx-subtle);white-space:nowrap}.conversation-preview{font-size:12px;line-height:1.6;color:var(--wx-subtle);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}.conversation-tags{display:flex;gap:5px;margin-top:3px;overflow:hidden}.conversation-tags span,.conversation-paused{font-size:10px;color:var(--wx-subtle)}.conversation-tags span{background:var(--wx-bg);padding:0 4px;border-radius:2px}.conversation-settings{position:absolute;right:2px;top:28px;padding:0 3px;border:0;background:transparent;color:var(--wx-subtle);font-size:13px}
.conversation-thread{display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden}.conversation-thread>.empty{border:0;margin:auto;max-width:400px}.conversation-thread>.toolbar{margin:0;min-height:58px;padding:10px 18px;background:var(--wx-panel);border-bottom:1px solid var(--wx-divider);flex-shrink:0;color:var(--wx-text)}.conversation-thread>.toolbar button{font-size:12px;padding:5px 9px;background:transparent;border-color:transparent;color:var(--wx-subtle)}.archive-scroll{flex:1;min-height:0;overflow:auto;padding:10px 23px 24px}.wechat-layout .messages{display:block}.wechat-layout .archive-count{color:var(--wx-subtle);font-size:11px;text-align:center;margin-bottom:12px}
.more-functions{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}.more-functions button{font-size:12px}
/* The back action also restores archive search filters on desktop. */
@media(max-width:950px) and (min-width:651px){.conversation-workspace{grid-template-columns:270px minmax(0,1fr)}.thread-scroll{padding:12px 18px}.chat-stack{max-width:80%}}
@media(max-width:650px){
 .wechat-layout .sidebar{position:fixed;inset:auto 0 0;width:100%;height:calc(60px + env(safe-area-inset-bottom,0px));padding:0 5px env(safe-area-inset-bottom,0px);border:0;border-top:1px solid var(--wx-divider)}
 .wechat-layout .sidebar .brand,.wechat-layout .sidebar-bottom{display:none}.wechat-layout .sidebar nav{margin:0;padding:0;height:60px;overflow:visible;display:grid;grid-template-columns:repeat(4,1fr);gap:0}
 .wechat-layout .sidebar nav button{display:none;border-radius:0;font-size:23px;padding:3px}.wechat-layout .sidebar nav button:is([data-view=chat],[data-view=groups],[data-view=articles],[data-view=settings]){display:flex}.wechat-layout .sidebar nav button span{font-size:10px;line-height:1.5;max-width:none}
 .wechat-layout main{height:calc(100dvh - 60px - env(safe-area-inset-bottom,0px));margin:0;padding:0}
 .wechat-layout .topbar{min-height:42px;padding:7px 13px}.wechat-layout .quiet-badge{display:none}.wechat-layout .filter-panel{padding:9px 12px}.wechat-layout .filter-row{gap:6px;max-height:160px;overflow:auto}.wechat-layout .filter-row input{max-width:126px}
 .thread-header{padding:9px 14px;min-height:58px;gap:6px}.thread-title{gap:8px}.thread-title h2{font-size:17px}.thread-title .wechat-avatar{display:none}.thread-tools{gap:0}.thread-tools button{padding:7px;font-size:11px}
 .thread-scroll{padding:8px 12px 18px}.chat-row{gap:9px}.wechat-avatar{width:36px;height:36px;font-size:18px}.chat-stack{max-width:calc(100% - 90px)}.wechat-layout .chat-bubble{padding:9px 11px}.wechat-layout .message-text{font-size:16px;line-height:1.6}.chat-message,.wechat-layout .message{margin-bottom:13px}.chat-time{font-size:11px;padding:11px 0 15px}
 .wechat-layout .chat-compose{padding:9px 10px;gap:7px}.wechat-layout .chat-compose textarea{font-size:16px;padding:8px 10px;min-height:41px}.wechat-layout .compose-actions{gap:3px}.wechat-layout .compose-actions .primary{min-width:52px;padding:8px}.wechat-layout .compose-actions .plain{width:32px}
 .conversation-workspace{display:block}.conversation-directory{height:100%;border:0}.conversation-thread{display:none;height:100%}.conversation-workspace.has-thread .conversation-directory{display:none}.conversation-workspace.has-thread .conversation-thread{display:flex}.directory-heading{padding:11px 15px}.conversation-open{padding:13px 9px 13px 15px}.conversation-row{min-height:80px}.conversation-preview{font-size:13px}.conversation-name{font-size:16px}.conversation-time{font-size:11px}.conversation-open .wechat-avatar{width:46px;height:46px}.archive-scroll{padding:9px 12px 18px}.conversation-thread>.toolbar{min-height:54px;padding:8px 10px;gap:5px}.conversation-thread>.toolbar>strong{font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:42%}
}
@media(prefers-color-scheme:dark){.wechat-layout{--wx-bg:#1f1f1f;--wx-panel:#292929;--wx-paper:#353535;--wx-text:#dedede;--wx-subtle:#858585;--wx-divider:#333;--wx-selected:#393939;--wx-own:#95ec69;--wx-peer:#363636}.wechat-layout .chat-bubble.mine{color:#15200e}.wechat-layout .filter-panel .search-row input{background:#373737;color:var(--wx-text)}.wechat-layout .sidebar{background:#242424}.wechat-layout .sidebar nav button.active{background:transparent;color:#07c160}.wechat-layout .attachment-remove{background:#353535;color:#ddd;border-color:#666}.wechat-layout .thread-scroll{scrollbar-color:#4c4c4c transparent}}
