/* Telegram-inspired visual layout. Independent experimental Matrix client. */
:root{
  color-scheme: dark;
  --panel:#17212b;--panel-lift:#202b36;--panel-2:#1f2c3a;
  --surface:#0e1621;--surface-2:#172532;
  --selected:#2b5278;--blue:#3390ec;--blue-hover:#4b9ef0;
  --text:#f1f4f7;--text-sub:#8e9dab;--border:#263341;
  --mine:#2b5278;--other:#182633;--danger:#ef7979;
  --font:Tahoma,"Segoe UI",Arial,sans-serif;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%;height:100dvh;width:100%;margin:0;overflow:hidden}
body{font-family:var(--font);font-size:14px;background:var(--surface);color:var(--text)}
button,input{font:inherit}button{cursor:pointer}input,button{outline-offset:3px}
button:focus-visible,input:focus-visible{outline:2px solid #5ca9ff}
button:disabled{cursor:not-allowed;opacity:.5}
.icon-sprite{position:absolute;width:0;height:0;overflow:hidden}
.icon{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.85;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
.icon.xl{width:38px;height:38px}.icon.xxl{width:62px;height:62px}

/* Auth – minimalist Telegram Web-inspired centered welcome surface */
.auth-screen{height:100%;height:100dvh;display:grid;place-items:center;overflow:auto;position:relative;padding:28px 14px}
.auth-backdrop{position:fixed;inset:0;pointer-events:none;background:
 radial-gradient(circle at 60% -20%,rgba(51,144,236,.15),transparent 50%),
 radial-gradient(circle at 10% 100%,rgba(15,95,165,.1),transparent 50%),#101b27}
.auth-card{position:relative;width:min(100%,440px);padding:29px 38px 23px;text-align:center;border-radius:18px;background:#172331;box-shadow:0 20px 70px #0005;border:1px solid #283846}
.auth-logo{width:80px;height:80px;margin:0 auto 20px;border-radius:50%;background:linear-gradient(145deg,#55b6f4,#1686d7);display:grid;place-items:center;box-shadow:0 14px 32px #1686d73d}
.auth-title{font-size:25px;letter-spacing:-.5px;font-weight:700}
.auth-sub{color:var(--text-sub);font-size:13px;margin:10px 0 25px}
.auth-tabs{display:flex;gap:6px;border-radius:11px;padding:5px;background:#101b26;margin-bottom:17px}
.auth-tab{flex:1;background:transparent;color:#a1b0c1;border:0;border-radius:9px;padding:11px}
.auth-tab.active{background:#2a3c52;color:white;box-shadow:0 2px 6px #0003}
.auth-form{text-align:right;display:grid;gap:13px}
.field{display:grid;gap:7px;font-size:13px;color:#b7c7d6}
.field input{height:51px;min-width:0;padding:0 14px;background:#111e2c;border:1px solid #34465b;border-radius:10px;color:white;transition:border-color .2s}
.field input:focus{border-color:var(--blue);outline:none;box-shadow:0 0 0 2px #3390ec22}
.field input::placeholder{color:#708396}
.primary-btn{height:48px;border:0;background:var(--blue);color:white;border-radius:10px;font-weight:700}
.primary-btn:hover{background:var(--blue-hover)}.full{width:100%;margin-top:4px}
.consent{text-align:right;display:flex;align-items:flex-start;gap:9px;margin-top:18px;line-height:1.8;color:#b6c4d3;font-size:12px}
.consent input{margin-top:5px;accent-color:var(--blue);width:16px;height:16px;flex-shrink:0}
.auth-error{min-height:18px;margin:11px 0 0;color:#ff9292;font-size:12px;line-height:1.6}
.auth-foot,.hint{font-size:11px;line-height:1.9;color:#8296a9;margin:12px 0 0}
.hint{text-align:right;margin:0}

/* App shell. Left sidebar and full-width messaging area on desktop. */
.workspace{height:100%;height:100dvh;width:100%;display:flex;direction:ltr;overflow:hidden;background:var(--surface)}
.sidebar{position:relative;display:flex;flex-direction:column;background:var(--panel);width:392px;flex:0 0 392px;border-right:1px solid #101b26;z-index:4;min-width:0}
.sidebar-head{position:relative;padding:18px 15px 9px;flex-shrink:0}
.sidebar-tools{display:flex;align-items:center;gap:12px;direction:ltr}
.round-icon{width:42px;height:42px;border:0;display:grid;place-items:center;color:#9eaebe;background:transparent;border-radius:50%;flex-shrink:0;transition:background .2s,color .2s}
.round-icon:hover{background:#2b3b4b;color:white}
.search-shell{direction:ltr;display:flex;align-items:center;background:#242f3d;border-radius:22px;min-width:0;flex:1;height:43px;position:relative}
.search-icon{position:absolute;left:14px;color:#8494a6;width:20px;height:20px;pointer-events:none}
.search-shell:focus-within{outline:1px solid #3390ec}
.search-shell:focus-within .search-icon{color:#61acff}
#searchRooms{direction:rtl;text-align:right;width:100%;padding:0 14px 0 43px;background:transparent;border:0;height:100%;color:#eaf0f6;outline:none;font-size:14px}
#searchRooms::placeholder{color:#8a99aa}
#searchRooms::-webkit-search-cancel-button{cursor:pointer}
.sidebar-caption{height:44px;padding:3px 20px 0;display:flex;align-items:center;justify-content:space-between;color:#f1f4f7}
.sidebar-caption strong{font-size:14px}.sidebar-caption span{font-size:12px;color:#91a3b5}
.room-list{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:4px 8px 90px}
.room-list::-webkit-scrollbar,.messages::-webkit-scrollbar{width:5px}
.room-list::-webkit-scrollbar-thumb,.messages::-webkit-scrollbar-thumb{background:#53647580;border-radius:12px}
.room-item{display:flex;align-items:center;gap:13px;width:100%;border:0;text-align:right;direction:rtl;background:transparent;color:var(--text);min-height:74px;padding:11px 10px;border-radius:12px;position:relative}
.room-item:hover{background:#223344}
.room-item.active{background:var(--selected)}
.avatar{width:53px;height:53px;border-radius:50%;display:grid;place-items:center;flex-shrink:0;color:white;font-size:19px;font-weight:700;line-height:1;user-select:none;background:linear-gradient(135deg,#648df4,#536fcb)}
.avatar.small{width:45px;height:45px;font-size:17px}
.avatar.chat-avatar{width:44px;height:44px;font-size:17px}
.avatar.av-0{background:linear-gradient(145deg,#ffb15b,#d67551)}
.avatar.av-1{background:linear-gradient(145deg,#a57be8,#7064c2)}
.avatar.av-2{background:linear-gradient(145deg,#5ac5bb,#269a9c)}
.avatar.av-3{background:linear-gradient(145deg,#ed88b1,#be5985)}
.avatar.av-4{background:linear-gradient(145deg,#58ade7,#337cc8)}
.avatar.av-5{background:linear-gradient(145deg,#8ac56c,#4b985c)}
.room-main{min-width:0;flex:1;display:flex;flex-direction:column;gap:6px}
.room-main .room-title-row{display:flex;gap:8px;align-items:center;min-width:0}
.room-main b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px;font-weight:700;min-width:0;flex:1}
.room-main .room-preview{color:#8f9fac;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:18px}
.room-item.active .room-preview,.room-item.active .room-time{color:#c9e2fa}
.room-time{font-size:11px;direction:ltr;color:#90a0b1;white-space:nowrap}
.room-invite{font-size:11px;color:#68bbff!important}
.room-empty{padding:54px 16px;text-align:center;line-height:1.9;color:#899cb0;font-size:13px}
.sidebar-footer{height:43px;display:flex;align-items:center;gap:7px;color:#8ba0b2;font-size:11px;padding:0 19px;border-top:1px solid var(--border);flex-shrink:0;white-space:nowrap;overflow:hidden}
.sidebar-footer #status{overflow:hidden;text-overflow:ellipsis}
.status-dot{height:7px;width:7px;border-radius:50%;background:#43bc8b}
.new-chat-fab{position:absolute;bottom:62px;left:24px;width:56px;height:56px;border:0;border-radius:50%;display:grid;place-items:center;color:white;background:var(--blue);box-shadow:0 8px 25px #0006;z-index:6}
.new-chat-fab:hover{background:var(--blue-hover);transform:translateY(-2px)}
.new-chat-fab .icon{width:27px;height:27px}
.user-menu{position:absolute;top:70px;left:12px;width:min(310px,calc(100vw - 24px));z-index:20;background:#243443;border:1px solid #415065;border-radius:13px;box-shadow:0 12px 32px #0007;overflow:hidden}
.menu-user-row{display:flex;align-items:center;gap:12px;padding:18px 16px;border-bottom:1px solid #42505e}
.menu-user{min-width:0;display:flex;flex-direction:column;gap:6px}
.menu-user b{font-size:12px;direction:ltr;overflow:hidden;text-overflow:ellipsis}
.menu-user small{color:#9cb0c0}
.menu-action{display:flex;align-items:center;gap:10px;padding:14px 17px;width:100%;border:0;color:#ebeff4;background:transparent;text-align:right}
.menu-action:hover{background:#304457}

/* Chat canvas */
.conversation{flex:1;position:relative;display:flex;min-width:0;background:
 radial-gradient(ellipse at 18% 9%,#21354770,transparent 31%),
 radial-gradient(circle at 90% 86%,#1a334370,transparent 34%),
 repeating-linear-gradient(30deg,transparent 0 70px,#24425418 72px 74px,transparent 76px 150px),
 linear-gradient(135deg,#101e2a,#101b26);direction:rtl}
.chat-intro{width:100%;height:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;gap:6px;padding:24px}
.intro-mark{width:112px;height:112px;display:grid;place-items:center;background:#294256bb;color:#74b7ef;border-radius:32px;margin-bottom:18px;transform:rotate(-4deg)}
.intro-mark .icon{transform:rotate(4deg)}
.chat-intro h2{margin:0;font-size:24px;font-weight:700}
.chat-intro p{color:#a0b1bf;font-size:14px;margin:9px 0 8px}
.intro-notice{border-radius:20px;background:#0a121a80;color:#a9bacc;font-size:11px;line-height:1.8;padding:9px 16px;max-width:460px}
.chat-thread{display:flex;flex-direction:column;height:100%;height:100dvh;width:100%;min-width:0}
.chat-topbar{display:flex;align-items:center;gap:12px;padding:0 23px;height:68px;flex-shrink:0;background:#17212bf4;border-bottom:1px solid #273544;box-shadow:0 2px 5px #0002;z-index:2}
.chat-heading{min-width:0;display:flex;flex-direction:column;gap:5px}
.chat-heading strong{font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-heading small{font-size:12px;color:#8dabc0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mobile-back{display:none}
.messages{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;gap:7px;padding:24px max(28px,calc((100% - 860px)/2)) 18px;direction:ltr;scroll-behavior:smooth}
.day-pill{align-self:center;max-width:90%;padding:6px 13px;margin:11px 0 14px;border-radius:20px;background:#0b1924bf;color:#c8d7e3;font-size:11px;direction:rtl;line-height:1.5}
.msg{position:relative;direction:rtl;align-self:flex-start;max-width:min(80%,600px);min-width:115px;padding:9px 12px 8px;border-radius:13px 13px 13px 4px;background:var(--other);box-shadow:0 1px 2px #0003;line-height:1.9;text-align:right;overflow-wrap:anywhere}
.msg.mine{align-self:flex-end;background:var(--mine);border-radius:13px 13px 4px 13px}
.msg .sender{font-size:11px;font-weight:700;color:#8fc3ef;margin:0 0 3px}
.msg.mine .sender{display:none}
.msg p{white-space:pre-wrap;margin:0;unicode-bidi:plaintext;color:#f0f5f9;font-size:13.5px}
.msg .msg-meta{display:flex;direction:ltr;align-items:center;justify-content:flex-start;gap:5px;line-height:1;margin-top:5px;color:#afbfcc;font-size:10px}
.msg.mine .msg-meta{justify-content:flex-end;color:#bed9f4}
.msg-meta .icon{width:13px;height:13px}
.msg .file-action{display:flex;align-items:center;gap:8px;max-width:100%;border:0;background:#ffffff13;color:white;border-radius:9px;padding:9px 10px;margin:7px 0 3px;text-align:right;direction:rtl}
.msg .file-action:hover{background:#ffffff22}
.msg .file-action .file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.empty-messages{margin:auto;padding:9px 17px;text-align:center;color:#bdceda;font-size:12px;background:#07131cb8;border-radius:18px}
.composer{display:flex;direction:rtl;align-items:center;gap:10px;width:min(100%,910px);padding:14px 23px 22px;margin:0 auto;flex-shrink:0}
.composer-icon{border:0;background:#1b2936;border-radius:50%;height:48px;width:48px;display:grid;place-items:center;color:#9fb4c7;flex-shrink:0}
.composer-icon:hover{background:#273d53;color:white}
#messageText{flex:1;min-width:0;height:52px;border:0;border-radius:27px;background:#202d3a;padding:0 20px;color:#f1f6fa;outline:none;direction:rtl;text-align:right}
#messageText:focus{box-shadow:inset 0 0 0 1px #405e77}
#messageText::placeholder{color:#94a6b6}
.send-button{height:50px;width:50px;flex-shrink:0;border:0;color:white;border-radius:50%;background:var(--blue);display:grid;place-items:center}
.send-button:hover{background:var(--blue-hover)}
.send-button .icon{transform:rotate(180deg);width:23px;height:23px}
@media(max-width:1000px){.sidebar{width:340px;flex-basis:340px}.messages{padding-left:26px;padding-right:26px}}
@media(max-width:720px){
 .workspace{position:fixed;inset:0}
 .sidebar{width:100%;flex:1;border:0;height:100dvh}
 .sidebar-head{padding:10px 11px 7px}
 .room-list{padding-bottom:95px}
 .room-item{min-height:76px}
 .conversation{display:none}
 .workspace.chat-open .sidebar{display:none}
 .workspace.chat-open .conversation{display:flex;width:100%;flex:1}
 .mobile-back{display:grid}
 .chat-topbar{height:60px;padding:0 10px;gap:9px}
 .chat-avatar{width:40px!important;height:40px!important}
 .chat-heading strong{font-size:14px}.chat-heading small{font-size:11px}
 .messages{padding:16px 11px 18px;gap:6px}
 .msg{max-width:88%;font-size:13px}
 .composer{padding:8px 10px calc(10px + env(safe-area-inset-bottom));gap:7px}
 .composer-icon{width:43px;height:43px}.send-button{width:44px;height:44px}
 #messageText{height:46px;padding:0 14px}
 .chat-intro{display:none}
 .sidebar-footer{padding-bottom:env(safe-area-inset-bottom)}
 .auth-card{padding:28px 22px}
 .auth-screen{align-items:start;padding-top:30px}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important;animation:none!important}}

/* New chat dialogue */
.modal-overlay{position:fixed;inset:0;z-index:50;background:#000b;display:grid;place-items:center;padding:18px}
.modal-dialog{background:#213040;border:1px solid #3b4b5c;box-shadow:0 15px 75px #0009;border-radius:15px;padding:18px 22px 23px;width:min(100%,410px);display:grid;gap:14px}
.modal-dialog .field input{width:100%}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
.modal-head strong{font-size:18px}
.modal-dialog .hint{margin:0}
