:root{color-scheme:light;--line:#e5e7eb;--muted:#6b7280;--text:#111827;--bg:#EDEDED;--panel:#ffffff;--accent:#CCEBFF;}
*{box-sizing:border-box;}
[hidden]{display:none!important;}
body{margin:0;height:100%;min-height:100vh;min-height:100dvh;overflow:hidden;color:var(--text);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;touch-action:pan-x pan-y;}
.home .app,
.home .drawer-shade,
.home .context-menu,
.home .image-lightbox{display:none!important;}
html{height:100%;overflow:hidden;-webkit-text-size-adjust:100%;text-size-adjust:100%;touch-action:pan-x pan-y;}
button,
input{font:inherit;}
button{border:0;border-radius:6px;color:#fff;background:var(--accent);cursor:pointer;}
button:hover{filter:brightness(0.96);}
.drawer-shade,
.users-toggle,
.side-close{display:none;}
.app{display:grid;grid-template-columns:minmax(0,1fr) 220px;height:100vh;height:100dvh;overflow:hidden;}
.chat{display:grid;grid-template-rows:auto minmax(0,1fr) auto;height:100vh;height:100dvh;min-height:0;overflow:hidden;border-right:1px solid var(--line);background:var(--bg);}
.top{position:sticky;top:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid var(--line);background:var(--panel);padding:0px 20px;height:56px;}
.top h1{display:flex;align-items:center;font-size:18px;}
.top h1 #roomText{color:#aba8a8;font-size:16px;margin-left:10px}
h1,
h2,
p{margin:0;}
h1{font-size:20px;}
h2{font-size:15px;}
p,
.meta,
.empty{color:var(--muted);}
.top-actions{display:flex;align-items:center;gap:5px;}
.top-actions button{font-size:13px;display:inline-block;padding:8px 12px;background:#111827;}
.top-actions button#usersBtn{display:none}
.side-top{position:sticky;top:0;z-index:6;display:flex;align-items:center;gap:5px;justify-content:space-between;border-bottom:1px solid var(--line);background:var(--panel);padding:0px 20px;height:56px}
.side-top-but{display:flex;gap:10px;}
.dissolve-btn{padding:3px 8px;font-size:12px;background:#111827;}
.messages{min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:18px 20px;}
.empty{padding-top:24px;text-align:center;}
.msg{width:fit-content;max-width:80%;margin-bottom:20px;}
.meta{display:flex;gap:8px;align-items:center;margin-bottom:6px;font-size:12px;}
.dot{width:15px;height:15px;border-radius:50%;background:currentColor;}
.bubble{display:inline-block;max-width:100%;padding:12px 12px;border-radius:8px;white-space:pre-wrap;overflow-wrap:anywhere;background:#fff;margin-left:21px;touch-action:manipulation;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;}
.message-text{white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:1.8;}
.quote{display:grid;gap:6px;margin-bottom:10px;padding:6px 8px;max-width:100%;color:var(--muted);border-left:3px solid var(--line);border-radius:4px;font-size:12px;line-height:1.4;overflow-wrap:anywhere;background:#f8fafc;}
.quote img{display:block;width:72px;max-height:72px;border-radius:4px;object-fit:cover;background:#fff;}
.image-bubble{max-width:min(100%,360px);padding:6px;background:#fff;}
.image-bubble img{display:block;width:100%;max-height:360px;border-radius:6px;object-fit:contain;cursor:zoom-in;}
.image-caption{padding:8px 3px 2px;color:var(--text);white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:1.8;}
.mine{margin-left:auto;text-align:right;}
.mine .meta{justify-content:flex-end;}
.mine .bubble{color:#333;border-color:var(--accent);background:var(--accent);text-align:left;}
.mine .quote{border-left-color:#93d0f7;}
.mine .image-bubble{color:var(--text);border-color:var(--line);background:#fff;}
.mine .image-bubble .quote{color:var(--muted);border-left-color:var(--line);background:#f8fafc;}
.composer{position:sticky;bottom:0;z-index:5;display:grid;gap:10px;padding-bottom:max(16px,env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--panel);padding:12px 15px;}
.composer-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:7px;align-items:center;}
.composer input:not([type="file"]),
.identity input:not([type="checkbox"]){width:100%;min-width:0;padding:10px 12px;border:1px solid var(--line);border-radius:6px;outline:none;font-size:16px;}
.composer input:focus,
.identity input:focus{border-color:var(--accent);}
.composer-row > button:not(.icon-btn),.identity button{padding:8px 16px;font-size:14px;background:#000;}
.icon-btn{width:40px;height:40px;padding:0;color:var(--text);border:1px solid var(--line);background:#fff;}
.image-preview{position:relative;width:fit-content;max-width:180px;}
.image-preview img{display:block;max-width:180px;max-height:110px;border:1px solid var(--line);border-radius:8px;object-fit:contain;background:#fff;}
.image-preview button{position:absolute;top:-8px;right:-8px;width:22px;height:22px;padding:0;border:1px solid #fff;border-radius:50%;background:#111827;}
.reply-preview{display:flex;flex-wrap:wrap;align-items:center;gap:8px;width:max-content;max-width:94vw;padding:7px 9px;color:var(--muted);border:1px solid var(--line);border-radius:6px;font-size:12px;background:#f8fafc;}
.reply-preview img{width:34px;height:34px;border-radius:4px;object-fit:cover;}
.reply-preview span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.reply-preview button{width:22px;height:22px;padding:0;color:var(--text);border:1px solid var(--line);background:#fff;}
.context-menu{position:fixed;z-index:80;display:grid;width:max-content;padding:4px;border:1px solid var(--line);border-radius:6px;background:#fff;box-shadow:0 12px 28px rgb(17 24 39 / 0.14);}
.context-menu button{padding:5px 10px;color:var(--text);font-size:13px;text-align:left;background:transparent;}
.context-menu button:hover{background:#f3f4f6;filter:none;}
.context-menu button:disabled{cursor:default;color:#047857;}
.image-lightbox{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:18px;background:transparent;}
.image-window{max-width:min(100%,1200px);max-height:calc(100dvh - 36px);border-radius:8px;overflow:hidden;transform:translate(var(--drag-x,0),var(--drag-y,0));}
.image-titlebar{display:flex;align-items:center;height:25px;cursor:move;user-select:none;touch-action:none;background:#e2e2e2;}
.image-lightbox img{display:block;max-width:100%;max-height:calc(100dvh - 57px);object-fit:contain;background:#fff;}
.image-lightbox button{width:15px;height:15px;color:#FE5F57;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;margin:3px 2px 2px 5px;}
.side{height:100vh;height:100dvh;min-height:0;overflow-y:auto;background:var(--panel);}
.users{display:grid;gap:10px;padding:18px 20px;font-size:13px;}
.user{display:flex;align-items:center;gap:8px;min-width:0;color:var(--muted);}
.user span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
dialog{width:min(360px,calc(100vw - 32px));padding:0;border:1px solid var(--line);border-radius:8px;}
dialog::backdrop{background:rgb(16 21 30 / 60%);}
.about{display:grid;gap:12px;padding: 16px;font-size:13px;line-height:1.7;}
.about-head,
.market-head{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.about-head button,
.market-head button{width:24px;height:24px;padding:0;color:var(--text);border:1px solid var(--line);background:#fff;}
.about ul{margin:0;background: #f5f5f5;border-radius: 8px;list-style: none;padding: 20px;line-height: 2.2;}
.about li+li{margin-top:4px;}
.market{display:grid;gap:12px;padding:16px 18px;font-size:13px;}
.market-list{display:grid;gap:8px;max-height:60vh;overflow:auto;}
.market-room{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 10px;color:var(--text);border:1px solid var(--line);background:#fff;text-align:left;}
.market-room span,
.market-empty{color:var(--muted);}
.room-field{display:grid;gap:6px;color:var(--muted);font-size:13px;}
.field-head{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.private-field{display:inline-flex;align-items:center;gap:6px;padding:3px 8px;color:var(--text);border:1px solid var(--line);border-radius:999px;background:#fff;cursor:pointer;}
.private-field input{appearance:none;width:24px;height:14px;margin:0;border-radius:999px;background:#d1d5db;box-shadow:inset 0 0 0 2px #d1d5db;}
.private-field input::before{content:"";display:block;width:10px;height:10px;margin:2px;border-radius:50%;background:#fff;transition:transform 0.16s ease;}
.private-field input:checked{background:#111827;box-shadow:inset 0 0 0 2px #111827;}
.private-field input:checked::before{transform:translateX(10px);}
.identity{display:grid;gap:14px;padding:18px;}
.identity > label{display:grid;gap:6px;color:var(--muted);font-size:13px;}
.admin-page{min-height:100vh;padding:24px;background:var(--bg);}
.admin-top{display:flex;align-items:center;justify-content:space-between;gap:16px;max-width:860px;margin:0 auto 16px;}
.admin-top a{color:var(--text);font-size:13px;text-decoration:none;}
.admin-login{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;max-width:860px;margin:0 auto 14px;padding:14px;border:1px solid var(--line);border-radius:8px;background:#fff;}
.admin-login input{min-width:0;padding:10px 12px;border:1px solid var(--line);border-radius:6px;outline:none;font-size:16px;}
.admin-login button{padding:8px 14px;background:#111827;}
.admin-status{max-width:860px;margin:0 auto 12px;color:var(--muted);font-size:13px;}
.admin-rooms{display:grid;gap:10px;max-width:860px;margin:0 auto;}
.admin-room{display:grid;gap:8px;padding:14px;border:1px solid var(--line);border-radius:8px;background:#fff;}
.admin-room-head{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.admin-room-head a{color:var(--text);font-weight:700;text-decoration:none;}
.room-tag{padding:3px 8px;color:#047857;border-radius:999px;background:#ecfdf5;font-size:12px;}
.room-tag.private{color:#be123c;background:#fff1f2;}
.admin-room-meta,.admin-room-users{color:var(--muted);font-size:13px;line-height:1.6;}
@media (max-width:720px){
  .app{grid-template-columns:1fr;grid-template-rows:1fr;}
  .chat{border-right:0;}
  .top h1 #roomText{font-size: 14px}
  .top-actions{flex-wrap:wrap;justify-content:flex-end;}
  .top-actions button{font-size:12px;padding:7px 8px;}
  .top-actions button#usersBtn{display:block;}
  .side{position:fixed;top:0;right:0;z-index:20;width:min(82vw,300px);height:100vh;height:100dvh;border-left:1px solid var(--line);box-shadow:-18px 0 40px rgb(17 24 39 / 0.18);transform:translateX(100%);transition:transform 0.2s ease;}
  .side .side-top{padding:13px 20px;}
  .users-open .side{transform:translateX(0);}
  .drawer-shade{display:block;position:fixed;inset:0;z-index:19;opacity:0;pointer-events:none;background:rgb(17 24 39 / 0.24);transition:opacity 0.2s ease;}
  .users-open .drawer-shade{opacity:1;pointer-events:auto;}
  .users-toggle{font-size:13px;display:inline-block;padding:8px 12px;background:#111827;}
  .side-close{display:block;width:32px;height:32px;padding:0;color:var(--text);border:1px solid var(--line);background:#fff;}
  .admin-page{padding:14px;}
  .admin-login{grid-template-columns:1fr;}
}
