/* ══ CHAT ROOM ══ */
#chatRoomView { position:fixed; inset:0; z-index:200; background:var(--surface); display:none; flex-direction:column; max-width:100vw; overflow:hidden; touch-action:pan-y; overscroll-behavior:contain; }
#chatRoomView::before { content:''; position:absolute; inset:0; background:
		radial-gradient(120% 70% at 20% 20%, rgba(var(--accent-rgb),0.08) 0%, transparent 60%),
		radial-gradient(90% 60% at 80% 10%, rgba(var(--accent2-rgb),0.08) 0%, transparent 55%),
		linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.05));
	pointer-events:none; z-index:0; }
#chatRoomView > * { position:relative; z-index:1; }
html[data-tm="light"] #chatRoomView { background:var(--surface); }
html[data-tm="light"] #chatRoomView::before { background:
		radial-gradient(110% 70% at 18% 18%, color-mix(in srgb, var(--chat-light-start) 22%, transparent) 0%, transparent 60%),
		radial-gradient(90% 60% at 82% 14%, color-mix(in srgb, var(--chat-light-end) 22%, transparent) 0%, transparent 55%),
		linear-gradient(180deg, rgba(255,255,255,0.90), rgba(255,255,255,0.54)); }
#chatRoomView.is-open { display:flex; }
.chat-topbar { height:calc(56px * var(--ui-scale)); min-height:calc(56px * var(--ui-scale)); background:transparent; border-bottom:1px solid var(--border); display:flex; align-items:center; padding:0 calc(16px * var(--ui-scale)); gap:calc(11px * var(--ui-scale)); flex-shrink:0; }
.chat-topbar__back { width:calc(36px * var(--ui-scale)); height:calc(36px * var(--ui-scale)); border-radius:calc(9px * var(--ui-scale)); border:1px solid var(--border); background:var(--surface2); color:var(--text-dim); cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard); }
.chat-topbar__back:hover { color:var(--accent); border-color:rgba(var(--accent-rgb),0.30); transform:translateY(var(--hover-lift-1)) scale(1.03); }
.chat-topbar__avatar { width:calc(34px * var(--ui-scale)); height:calc(34px * var(--ui-scale)); border-radius:calc(9px * var(--ui-scale)); background:linear-gradient(135deg,var(--accent2),var(--accent),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:calc(14px * var(--ui-scale)); font-weight:700; color:#fff; flex-shrink:0; }
.chat-topbar__info { flex:1; min-width:0; }
.chat-topbar__name { font-size:calc(14px * var(--ui-scale)); font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-topbar__sub { font-size:calc(10px * var(--ui-scale)); color:var(--text-muted); font-family:'Space Mono',monospace; }
.chat-topbar__menu { width:calc(36px * var(--ui-scale)); height:calc(36px * var(--ui-scale)); border-radius:calc(9px * var(--ui-scale)); border:1px solid var(--border); background:var(--surface2); color:var(--text-dim); cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
#chatRoomMembersBtn { display:none; }
.chat-topbar__delete { width:calc(34px * var(--ui-scale)); height:calc(34px * var(--ui-scale)); border-radius:50%; border:none; background:var(--surface2); color:var(--text-dim); display:inline-flex; align-items:center; justify-content:center; cursor:pointer; }
.chat-topbar__delete:hover { background:rgba(200,126,126,0.12); color:var(--danger); }
.chat-members-panel { position:absolute; top:calc(56px * var(--ui-scale)); right:0; width:calc(180px * var(--ui-scale)); background:var(--surface); border-left:1px solid var(--border); height:calc(100% - calc(56px * var(--ui-scale))); overflow-y:auto; z-index:5; padding:calc(12px * var(--ui-scale)); }
#chatMembersPanel { display:none; }
.chat-members-panel__title { font-size:calc(10px * var(--ui-scale)); font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:calc(1px * var(--ui-scale)); margin-bottom:calc(9px * var(--ui-scale)); font-family:'Space Mono',monospace; }
.chat-messages { flex:1; overflow-y:auto; overflow-x:hidden; padding:calc(14px * var(--ui-scale)); padding-bottom:calc(var(--ucim-chat-bar-height, calc(80px * var(--ui-scale))) + calc(14px * var(--ui-scale))); display:flex; flex-direction:column; gap:calc(11px * var(--ui-scale)); width:100%; max-width:100vw; box-sizing:border-box; }
.chat-messages::-webkit-scrollbar{width:3px;}.chat-messages::-webkit-scrollbar-thumb{background:rgba(var(--accent-rgb),0.14);border-radius:2px;}
.chat-msg { display:flex; gap:calc(9px * var(--ui-scale)); align-items:flex-start; }
.chat-msg--self { flex-direction:row-reverse; }
.chat-msg__av { width:calc(34px * var(--ui-scale)); height:calc(34px * var(--ui-scale)); border-radius:calc(9px * var(--ui-scale)); background:linear-gradient(135deg,var(--accent),var(--accent3)); display:flex; align-items:center; justify-content:center; font-size:calc(13px * var(--ui-scale)); font-weight:700; color:#0c0c10; flex-shrink:0; }
html[data-tm="light"] .chat-msg__av { background:linear-gradient(135deg,var(--chat-light-start),var(--chat-light-end)); color:var(--chat-light-text); }
.chat-msg__col { max-width:70vw; display:flex; flex-direction:column; gap:3px; }
.chat-msg__col--self { align-items:flex-end; }
.chat-msg__sender { font-size:calc(10px * var(--ui-scale)); color:var(--text-muted); font-family:'Space Mono',monospace; }
.chat-msg__bubble { background:var(--surface); border:1px solid var(--border); border-radius:calc(12px * var(--ui-scale)); padding:calc(9px * var(--ui-scale)) calc(13px * var(--ui-scale)); font-size:calc(13px * var(--ui-scale)); color:var(--text); line-height:1.55; word-break:break-word; }
.chat-msg__bubble--self { background:linear-gradient(135deg,var(--accent),var(--accent3)); border:none; color:#0c0c10; border-radius:calc(12px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(3px * var(--ui-scale)) calc(12px * var(--ui-scale)); }
html[data-tm="light"] .chat-msg__bubble--self { background:linear-gradient(135deg,var(--chat-light-start),var(--chat-light-end)); color:var(--chat-light-text); }
.chat-msg__time { font-size:calc(9px * var(--ui-scale)); color:var(--text-muted); font-family:'Space Mono',monospace; }
.typing-dots{display:flex;gap:4px;align-items:center;height:14px;}.typing-dot{width:5px;height:5px;border-radius:50%;background:var(--text-muted);animation:ucimPulse 1.1s var(--ease-standard) infinite;}.typing-dot:nth-child(2){animation-delay:.16s}.typing-dot:nth-child(3){animation-delay:.32s}
.chat-input-bar { position:fixed; left:max(calc(8px * var(--ui-scale)),env(safe-area-inset-left)); right:max(calc(8px * var(--ui-scale)),env(safe-area-inset-right)); bottom:var(--ucim-chat-keyboard-offset,0px); padding:calc(9px * var(--ui-scale)) calc(11px * var(--ui-scale)) calc(calc(9px * var(--ui-scale)) + env(safe-area-inset-bottom)); background:transparent; border-top:1px solid var(--border); border-radius:calc(18px * var(--ui-scale)) calc(18px * var(--ui-scale)) 0 0; display:flex; align-items:center; gap:calc(7px * var(--ui-scale)); box-shadow:0 -4px 20px rgba(0,0,0,0.30); }
html[data-tm="light"] .chat-input-bar { background:rgba(255,255,255,0.86); box-shadow:0 -4px 24px rgba(26,16,8,0.12); }
.chat-input-field { flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:calc(20px * var(--ui-scale)); padding:calc(9px * var(--ui-scale)) calc(15px * var(--ui-scale)); color:var(--text); font-size:calc(13px * var(--ui-scale)); font-family:inherit; outline:none; transition:border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard); }
.chat-input-field:focus { border-color:rgba(var(--accent-rgb),0.40); }
.chat-input-field::placeholder { color:var(--text-muted); }
.chat-route-btn { width:calc(38px * var(--ui-scale)); height:calc(38px * var(--ui-scale)); border-radius:50%; border:1px solid var(--border); background:var(--surface2); cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard); }
.chat-route-btn__u { font-family:'Space Mono',monospace; font-size:calc(12px * var(--ui-scale)); font-weight:700; color:var(--accent); }
html[data-tm="light"] .chat-route-btn { background:linear-gradient(135deg,var(--chat-light-start),var(--chat-light-end)); border:none; box-shadow:0 2px 8px rgba(var(--accent-rgb),0.18); }
html[data-tm="light"] .chat-route-btn__u { color:var(--chat-light-text); }
.chat-route-btn:hover { border-color:rgba(var(--accent-rgb),0.35); transform:translateY(var(--hover-lift-1)) scale(1.04); }
.chat-input-tool--ai { width:calc(38px * var(--ui-scale)); height:calc(38px * var(--ui-scale)); border-radius:50%; border:1px solid var(--border); background:var(--surface2); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text-dim); flex-shrink:0; font-family:'Space Mono',monospace; font-size:calc(11px * var(--ui-scale)); font-weight:700; letter-spacing:.4px; transition:transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard); }
.chat-input-tool--ai:hover { color:var(--accent); transform:translateY(var(--hover-lift-1)) scale(1.04); }
.chat-input-tool--ai.is-active { border-color:rgba(var(--accent-rgb),0.40); background:rgba(var(--accent-rgb),0.12); color:var(--accent); box-shadow:0 3px 12px rgba(var(--accent-rgb),0.24); }
.chat-input-tool--emoji { width:calc(38px * var(--ui-scale)); height:calc(38px * var(--ui-scale)); border-radius:50%; border:1px solid var(--border); background:var(--surface2); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text-dim); flex-shrink:0; transition:transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard); }
.chat-input-tool--emoji:hover { color:var(--accent); transform:translateY(var(--hover-lift-1)) scale(1.04); }
.chat-send-btn { width:calc(40px * var(--ui-scale)); height:calc(40px * var(--ui-scale)); border-radius:50%; border:none; flex-shrink:0; background:linear-gradient(135deg,var(--accent),var(--accent3)); cursor:pointer; display:flex; align-items:center; justify-content:center; color:#0c0c10; box-shadow:0 3px 10px rgba(var(--accent-rgb),0.22); transition:transform var(--motion-fast) var(--ease-standard), filter var(--motion-fast) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard); }
html[data-tm="light"] .chat-send-btn { background:linear-gradient(135deg,var(--chat-light-start),var(--chat-light-end)); color:var(--chat-light-text); box-shadow:0 3px 10px rgba(var(--accent-rgb),0.22); }
.chat-send-btn:hover { transform:translateY(var(--hover-lift-1)) scale(1.12); filter:brightness(1.1); }
.chat-send-btn:active { transform:scale(.92); }
.chat-inline-status { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(var(--ucim-chat-keyboard-offset,0px) + var(--ucim-chat-bar-height,80px) + 12px); z-index:625; display:none; align-items:center; justify-content:center; gap:7px; padding:7px 13px; border-radius:999px; background:rgba(20,20,26,0.92); border:1px solid var(--border); font-size:12px; font-weight:700; color:var(--text); box-shadow:var(--s3); }
#chatRoomView.is-loading-history .chat-inline-status,#chatRoomView.is-waiting-response .chat-inline-status,.chat-inline-status.is-visible{display:inline-flex;}
.chat-inline-status__spinner{width:13px;height:13px;border-radius:50%;border:2px solid rgba(var(--accent-rgb),0.22);border-top-color:var(--accent);animation:ucimSpin .75s linear infinite;}
.chat-ai-panel { position:fixed; left:max(calc(8px * var(--ui-scale)),env(safe-area-inset-left)); right:max(calc(8px * var(--ui-scale)),env(safe-area-inset-right)); bottom:calc(var(--ucim-chat-keyboard-offset,0px) + var(--ucim-chat-bar-height,80px) + 12px); z-index:631; border:1px solid color-mix(in srgb, var(--accent) 24%, var(--border)); border-radius:calc(16px * var(--ui-scale)); background:color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter:blur(calc(10px * var(--ui-scale))) saturate(130%); -webkit-backdrop-filter:blur(calc(10px * var(--ui-scale))) saturate(130%); box-shadow:0 calc(10px * var(--ui-scale)) calc(26px * var(--ui-scale)) rgba(0,0,0,0.24); padding:calc(10px * var(--ui-scale)); display:flex; flex-direction:column; gap:calc(9px * var(--ui-scale)); max-height:min(56vh, calc(360px * var(--ui-scale))); overflow:auto; }
.chat-ai-panel.hidden { display:none; }
.chat-ai-panel__head { display:flex; align-items:center; justify-content:space-between; gap:calc(10px * var(--ui-scale)); }
.chat-ai-panel__title { font-size:calc(12px * var(--ui-scale)); font-weight:700; color:var(--text); letter-spacing:.3px; }
.chat-ai-panel__close { border:1px solid var(--border); background:var(--surface2); color:var(--text-dim); border-radius:999px; padding:calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale)); font-size:calc(10px * var(--ui-scale)); cursor:pointer; }
.chat-ai-panel__close:hover { border-color:rgba(var(--accent-rgb),0.35); color:var(--accent); }
.chat-ai-panel__section { border:1px solid var(--border); border-radius:calc(12px * var(--ui-scale)); background:color-mix(in srgb, var(--surface2) 72%, transparent); padding:calc(8px * var(--ui-scale)); display:flex; flex-direction:column; gap:calc(7px * var(--ui-scale)); }
.chat-ai-panel__label { font-size:calc(10px * var(--ui-scale)); font-family:'Space Mono',monospace; color:var(--text-muted); letter-spacing:.6px; text-transform:uppercase; }
.chat-ai-chip-list { display:flex; flex-wrap:wrap; gap:calc(6px * var(--ui-scale)); }
.chat-ai-chip { border:1px solid color-mix(in srgb, var(--accent) 26%, var(--border)); background:rgba(var(--accent-rgb),0.10); color:var(--text); border-radius:999px; padding:calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale)); font-size:calc(11px * var(--ui-scale)); cursor:pointer; }
.chat-ai-chip:hover { border-color:rgba(var(--accent-rgb),0.50); color:var(--accent); }
.chat-ai-rewind-list { display:flex; flex-direction:column; gap:calc(6px * var(--ui-scale)); }
.chat-ai-rewind-item { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:calc(10px * var(--ui-scale)); padding:calc(7px * var(--ui-scale)) calc(9px * var(--ui-scale)); text-align:left; cursor:pointer; }
.chat-ai-rewind-item:hover { border-color:rgba(var(--accent-rgb),0.40); background:var(--surface2); }
.chat-ai-rewind-item.is-active { border-color:rgba(var(--accent-rgb),0.56); box-shadow:0 0 0 1px rgba(var(--accent-rgb),0.28) inset; }
.chat-ai-rewind-item__time { font-size:calc(9px * var(--ui-scale)); color:var(--text-muted); font-family:'Space Mono',monospace; margin-bottom:calc(3px * var(--ui-scale)); }
.chat-ai-rewind-item__text { font-size:calc(11px * var(--ui-scale)); color:var(--text); line-height:1.45; }
.chat-ai-mode-list { display:flex; flex-wrap:wrap; gap:calc(6px * var(--ui-scale)); }
.chat-ai-mode { border:1px solid var(--border); background:var(--surface); color:var(--text-dim); border-radius:calc(9px * var(--ui-scale)); padding:calc(4px * var(--ui-scale)) calc(9px * var(--ui-scale)); font-size:calc(11px * var(--ui-scale)); cursor:pointer; }
.chat-ai-mode:hover { border-color:rgba(var(--accent-rgb),0.35); color:var(--accent); }
.chat-ai-mode.is-active { border-color:rgba(var(--accent-rgb),0.55); background:rgba(var(--accent-rgb),0.12); color:var(--accent); }
.chat-ai-preview { border:1px dashed color-mix(in srgb, var(--accent) 28%, var(--border)); border-radius:calc(10px * var(--ui-scale)); padding:calc(8px * var(--ui-scale)); font-size:calc(11px * var(--ui-scale)); line-height:1.5; color:var(--text-muted); }
.chat-ai-apply { border:1px solid color-mix(in srgb, var(--accent) 34%, var(--border)); background:linear-gradient(135deg, rgba(var(--accent-rgb),0.20), rgba(var(--accent3-rgb),0.18)); color:var(--text); border-radius:calc(10px * var(--ui-scale)); padding:calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale)); font-size:calc(11px * var(--ui-scale)); font-weight:700; cursor:pointer; }
.chat-ai-apply:hover { border-color:rgba(var(--accent-rgb),0.58); color:var(--accent); }
.chat-ai-empty { font-size:calc(11px * var(--ui-scale)); color:var(--text-muted); padding:calc(4px * var(--ui-scale)); }
:root{--ucim-chat-keyboard-offset:0px;--ucim-chat-bar-height:80px;}
body.chat-room-open{overflow:hidden !important;overscroll-behavior:none !important;}
.chat-room-skeleton{display:flex;flex-direction:column;gap:10px;width:100%;}.chat-room-skeleton__row{display:flex;gap:7px;align-items:flex-start;}.chat-room-skeleton__row--self{justify-content:flex-end;}.chat-room-skeleton__bubble{max-width:min(70vw,260px);min-height:40px;border-radius:14px;background:linear-gradient(90deg,rgba(255,255,255,.04) 25%,rgba(255,255,255,.08) 37%,rgba(255,255,255,.04) 63%);background-size:400% 100%;animation:ucimShimmer 1.4s var(--ease-standard) infinite;border:1px solid var(--border);}
.chat-route-picker-sheet{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--ucim-chat-keyboard-offset,0px)+var(--ucim-chat-bar-height,80px)+8px);z-index:630;background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:11px;box-shadow:var(--s4);display:flex;gap:7px;flex-wrap:wrap;max-width:min(380px,94vw);}
.chat-route-picker-sheet.hidden{display:none;}
.chat-route-option{padding:7px 14px;border-radius:10px;border:1px solid var(--border);background:var(--surface2);color:var(--text-dim);cursor:pointer;font-size:12px;font-weight:600;font-family:inherit;transition:transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);}
.chat-route-option.is-active{background:rgba(var(--accent-rgb),0.10);border-color:rgba(var(--accent-rgb),0.26);color:var(--accent);}

@media (max-width:760px) {
	.chat-ai-panel { max-height:min(52vh, calc(320px * var(--ui-scale))); }
	.chat-ai-panel__section { padding:calc(7px * var(--ui-scale)); }
	.chat-ai-chip { font-size:calc(10px * var(--ui-scale)); }
}

/* ══ MISC ══ */
::-webkit-scrollbar{width:4px;height:4px;}::-webkit-scrollbar-track{background:transparent;}::-webkit-scrollbar-thumb{background:rgba(var(--accent-rgb),0.16);border-radius:4px;}::-webkit-scrollbar-thumb:hover{background:rgba(var(--accent-rgb),0.30);}
.stagger-1{animation-delay:.05s}.stagger-2{animation-delay:.10s}.stagger-3{animation-delay:.15s}.stagger-4{animation-delay:.20s}.stagger-5{animation-delay:.25s}.stagger-6{animation-delay:.30s}
