/* v50.css —— 放在最后加载
 * 1. 气泡小角：线下模式把圆角强制成 18px!important，小角就浮在圆角外面（看起来像一小片碎的）；这里让「有小角的那个角」变成直角，小角和气泡严丝合缝
 * 2. 线上 / 线下模式条不再占聊天页（已收进「…」聊天详情）
 * 3. 通讯录：微信的格式（搜索、入口、拼音分组、右侧字母索引、新的朋友）
 */

/* ---------- 1. 气泡小角 ---------- */
#chatRoomApp.chat-ios.chat-imsg .user-message.grp-last .bubble:not(.sticker-img):not(.card-voice):not(:has(img)) { border-bottom-right-radius: 0 !important; }
#chatRoomApp.chat-ios.chat-imsg .ai-message.grp-last .bubble:not(.sticker-img):not(.card-voice):not(:has(img)) { border-bottom-left-radius: 0 !important; }
#chatRoomApp.chat-ios.chat-imsg .message.grp-last .bubble:not(.sticker-img):not(.card-voice):not(:has(img))::after {
    width: 13px; height: 17px; bottom: 0; background: inherit;
    -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 17'%3E%3Cpath d='M0 0V17H13C6 16.600 1 11.500 0 2Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
    mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 17'%3E%3Cpath d='M0 0V17H13C6 16.600 1 11.500 0 2Z'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
#chatRoomApp.chat-ios.chat-imsg .user-message.grp-last .bubble:not(.sticker-img):not(.card-voice):not(:has(img))::after { right: -12px; left: auto; transform: none; }
#chatRoomApp.chat-ios.chat-imsg .ai-message.grp-last .bubble:not(.sticker-img):not(.card-voice):not(:has(img))::after { left: -12px; right: auto; transform: scaleX(-1); }

/* ---------- 2. 模式条收起 ---------- */
#chatRoomApp #modeBar { display: none !important; }

/* ---------- 3. 通讯录 ---------- */
.ct-pane .scroll-area { position: relative; padding: 0 !important; background: var(--bg-color); }
.ct-pane #contactsList { background: var(--card-bg); border-radius: 0; padding-bottom: 6px; }
.ct-pane #addContactBtn, .ct-pane #newCharacterBtn { display: none; }
.ct-search { padding: 8px 14px 10px; background: var(--bg-color); }
.ct-search input { width: 100%; box-sizing: border-box; border: none; outline: none; border-radius: 10px; padding: 9px 12px 9px 12px; font-size: 15px; text-align: center; background: var(--card-bg); color: var(--theme-dark); }
.ct-search input:focus { text-align: left; }
.ct-row { position: relative; display: flex; align-items: center; gap: 13px; padding: 9px 38px 9px 16px; min-height: 46px; background: var(--card-bg); cursor: pointer; -webkit-user-select: none; user-select: none; }
.ct-row:active { background: color-mix(in srgb, var(--theme-color) 12%, var(--card-bg)); }
.ct-row::after { content: ''; position: absolute; left: 73px; right: 0; bottom: 0; border-bottom: .5px solid var(--border-color); }
.ct-entries .ct-row::after { left: 73px; }
.ct-entries .ct-row:last-child::after, .ct-row:last-child::after { display: none; }
.ct-ic, .ct-av { width: 42px; height: 42px; border-radius: 9px; flex: 0 0 42px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ct-av { background: color-mix(in srgb, var(--theme-color) 18%, var(--card-bg)); font-size: 18px; }
.ct-av > *, .ct-av img { width: 100%; height: 100%; object-fit: cover; }
.ct-av .avatar-small { width: 100%; height: 100%; border-radius: 0; }
.ct-av-l { background: hsl(var(--h), 14%, 70%) !important; color: #fff; font-weight: 600; font-size: 20px; }
.ct-name { flex: 1; min-width: 0; font-size: 16.5px; color: var(--theme-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-row small { color: var(--text-sub); font-size: 13px; }
.ct-badge, .ct-dot { font-style: normal; background: #fa5151; color: #fff; font-size: 11px; line-height: 18px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; text-align: center; box-sizing: border-box; }
.ct-dot { position: absolute; top: 2px; right: calc(50% - 26px); }
#wechatTabs .tab { position: relative; }
.ct-sec { padding: 4px 16px; font-size: 13px; font-weight: 600; color: var(--text-sub); background: var(--bg-color); position: sticky; top: 0; z-index: 2; }
.ct-empty { text-align: center; color: var(--text-sub); padding: 34px 20px; font-size: 14px; }
.ct-foot { text-align: center; color: var(--text-sub); font-size: 12.5px; padding: 12px 0 8px; margin: 0; }
.ct-index-OFF { position: sticky; top: 0; height: 0; z-index: 5; overflow: visible; }
.ct-index-in { position: absolute; right: 1px; top: 70px; display: flex; flex-direction: column; align-items: center; font-size: 10.5px; font-weight: 700; color: var(--theme-dark); }
.ct-index span { padding: 1.5px 6px; line-height: 1.15; }
.ct-sub { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg-color); position: sticky; top: 0; z-index: 3; }
.ct-sub b { font-size: 16px; } .ct-sub .ct-back { border: none; background: none; color: var(--theme-dark); font-weight: 500; font-size: 15px; padding: 4px 2px; cursor: pointer; } .ct-sub span { width: 60px; }
.ct-req { cursor: default; padding-right: 12px; }
.ct-req::after { left: 73px; }
.ct-mid { flex: 1; min-width: 0; } .ct-mid b { display: block; font-size: 16px; font-weight: 500; color: var(--theme-dark); }
.ct-mid p { margin: 2px 0 0; font-size: 13px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-tag { font-style: normal; font-size: 10.5px; background: var(--theme-color); color: #fff; border-radius: 8px; padding: 1px 6px; margin-left: 6px; }
.ct-btn { border: none; border-radius: 6px; padding: 6px 14px; font-size: 14px; background: #07c160; color: #fff; white-space: nowrap; flex: none; cursor: pointer; }
.ct-btn.ghost { background: rgba(120, 120, 128, .16); color: var(--theme-dark); margin-left: -6px; }
.ct-st { color: var(--text-sub); font-size: 14px; flex: none; }

/* 只留线条：入口图标没有底色，用主题深色描线；「接受」也不用绿色 */
.ct-ic { background: none !important; color: var(--theme-dark); border: .5px solid var(--border-color); }
.ct-btn { background: var(--theme-dark); color: var(--card-bg); }

/* 设置页卡片：iOS 点开下拉选项时会把 overflow:hidden 的卡片横向推走，内容被切掉。改成 clip（不能被滚动） */
.sx-card, .cell-group, .tk-card, .pk-perm { overflow: clip; }
.ct-index { display: none !important; }

/* ---------- 主屏编辑：落点提示条 / 底部留白 ---------- */
#desktop > .hm-ins { position: absolute !important; z-index: 45 !important; width: 3px; border-radius: 2px; background: rgba(255, 140, 175, .95); box-shadow: 0 0 0 1px rgba(255, 255, 255, .7); pointer-events: none; display: none; }
/* 编辑时底下多留一截：最后一行的名字不再被页点压住，也有地方可以放到最后 */
#desktop.editing .desktop-grid { padding-bottom: 90px !important; }

/* ---------- 格子定位：每一行至少一个图标那么高，中间留空的行不会缩成一条线 ---------- */
#desktop .desktop-grid { grid-auto-rows: minmax(var(--hm-row, 80px), min-content); }
/* 落点：格子虚线框 */
#desktop > .hm-ins.box { width: auto; box-sizing: border-box; border: 2px dashed rgba(255, 140, 175, .95); background: rgba(255, 255, 255, .22); border-radius: 20px; box-shadow: none; }

/* ===== 桌面自由摆放（v54）：图标 / 组件不再吸附网格，位置由 home.js 用 left/top 写在行内 ===== */
#desktop .desktop-grid.free { display: block; position: relative; }
#desktop .desktop-grid.free > [data-app], #desktop .desktop-grid.free > [data-w], #desktop .desktop-grid.free > [data-fo] { position: absolute; margin: 0; }
#desktop .desktop-grid .hm-fsp { display: block; width: 1px; pointer-events: none; visibility: hidden; }

/* 桌面上长按不再选中文字 / 弹出系统「拷贝 搜一搜 翻译」菜单 */
#desktop, #desktop * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#desktop input, #desktop textarea { -webkit-user-select: text; user-select: text; }

/* ---------- 聊天输入框：多行自动长高（消息再长也能看到后面的内容），最高 5 行左右再滚动 ---------- */
.input-area textarea#userInput { resize: none; display: block; font-family: inherit; line-height: 1.3; max-height: 120px; overflow-y: auto; -webkit-appearance: none; appearance: none; scrollbar-width: none; }
.input-area textarea#userInput::-webkit-scrollbar { display: none; }
#chatRoomApp.chat-imsg .input-area textarea#userInput { height: auto; min-height: 40px; line-height: 22px; padding-top: 9px; padding-bottom: 9px; max-height: 128px; }
.input-area.ta-multi { align-items: flex-end !important; }

/* ---------- 主屏编辑：图标不让浏览器抢手势（否则拖到一半被当成滚动而取消，就是「挪不动」）；上下滚动由 home.js 自己处理 ---------- */
#desktop.editing .desktop-grid > [data-app], #desktop.editing .desktop-grid > [data-w], #desktop.editing .desktop-grid > [data-fo], #desktop.editing .dock-icon { touch-action: none; }

/* ---------- 聊天多选删除 ---------- */
#chatRoomApp.msel .input-area, #chatRoomApp.msel #attachPanel { display: none !important; }
.ms-bar { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px max(10px, env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--card-bg) 92%, transparent); border-top: .5px solid var(--border-color); }
.ms-bar.hidden { display: none; }
.ms-bar .ms-n { flex: 1; text-align: center; font-size: 14px; color: var(--text-sub); }
.ms-bar button { border: 1px solid var(--border-color); background: var(--card-bg); color: var(--theme-dark); border-radius: 18px; padding: 8px 16px; font-size: 14px; font-family: inherit; }
.ms-bar button.ms-del { background: #e5484d; border-color: #e5484d; color: #fff; font-weight: 600; }
.ms-bar button.ms-del:disabled { opacity: .4; }
#chatRoomApp.msel .message[data-idx] { position: relative; padding-left: 34px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#chatRoomApp.msel .message[data-idx]::before { content: ''; position: absolute; left: 6px; top: 50%; width: 18px; height: 18px; margin-top: -10px; border-radius: 50%; border: 1.5px solid var(--text-sub); background: var(--card-bg); box-sizing: content-box; }
#chatRoomApp.msel .message[data-idx].ms-on::before { background: var(--theme-color); border-color: var(--theme-color); }
#chatRoomApp.msel .message[data-idx].ms-on::after { content: ''; position: absolute; left: 13px; top: 50%; width: 5px; height: 9px; margin-top: -7px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
#chatRoomApp.msel .message[data-idx].ms-on .bubble { outline: 2px solid color-mix(in srgb, var(--theme-color) 55%, transparent); outline-offset: 1px; }

/* ---------- 桌面网格四周留「出血」：发光 / 阴影 / 旋转的自定义组件超出格子的部分不再被网格边缘一刀切掉（设计器预览里是完整的）。
   用负边距把内容位置抵回去，所以图标和组件的位置一点没变 ---------- */
#desktop .desktop-grid { margin-left: -40px; margin-right: -40px; padding-left: 40px; padding-right: 40px; }
#desktop.sweet .desktop-grid { margin-left: -38px; margin-right: -38px; padding-left: 40px; padding-right: 40px; }
#desktop:not(.editing) .desktop-grid { margin-top: -24px; padding-top: 24px; }
#desktop.sweet:not(.editing) .desktop-grid { margin-top: -22px; }
.ct-row, .ct-person { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ---------- 用户亲手选的气泡颜色 / 聊天背景色，要盖过主题（奶油等）里写死的颜色 ----------
   applyUI() 在选过颜色时给 <html> 打 data-ui-my / data-ui-ai / data-ui-bg 标记 */
html[data-ui-my][data-theme] #chatRoomApp.chat-ios .user-message .bubble,
html[data-ui-my][data-theme] #chatRoomApp .user-message .bubble:not(.sticker-img):not(.sticker-face):not(.gen-card) { background: var(--my-bubble); color: var(--my-bubble-text); }
html[data-ui-ai][data-theme] #chatRoomApp.chat-ios .ai-message .bubble,
html[data-ui-ai][data-theme] #chatRoomApp .ai-message .bubble:not(.sticker-img):not(.sticker-face):not(.gen-card) { background: var(--ai-bubble); color: var(--ai-bubble-text); }
html[data-ui-my][data-theme] #chatRoomApp .input-area #sendBtn { background: var(--my-bubble); color: var(--my-bubble-text); }
/* 没设聊天壁纸时，聊天区底色就是选的「聊天背景色」 */
html[data-ui-bg] #chatRoomApp:not(.has-bg) .chat-box { background: var(--chat-bg); }
html[data-ui-bg] .preview-chat:not(.has-bg) { background: var(--chat-bg); }

/* v77：编辑主屏的工具栏固定贴在手机顶部（挂在 .phone 里，位置不依赖桌面的排版，也不依赖 --top-h 变量），不会再掉到屏幕底部被挤出去 */
#hmBar.hm-bar { position: absolute !important; top: calc(env(safe-area-inset-top, 0px) + 30px) !important; bottom: auto !important; left: 14px !important; right: 14px !important; margin: 0 !important; transform: none !important; z-index: 60; }
#hmBar.hm-bar.hidden { display: none !important; }
