:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #202435;
  --muted: #8b90a0;
  --soft: #f7f8fb;
  --line: #ebedf3;
  --purple: #6356df;
  --purple-dark: #5145d0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: #f5f6fa; color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Access dialog */
.gate-screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(ellipse 780px 600px at 50% -20%, #eceafd 0%, transparent 76%), #f8f9fc; }
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; font-weight: 700; letter-spacing: -.5px; font-size: 18px; }
.brand-mark, .room-icon { display: grid; place-items: center; background: var(--purple); color: white; border-radius: 12px; width: 40px; height: 40px; }
.brand-mark svg, .room-icon svg { width: 24px; height: 24px; }
.gate-dialog { background: #fff; width: min(100%, 420px); border: 1px solid #eff0f5; border-radius: 20px; padding: 36px 34px 34px; box-shadow: 0 18px 60px rgba(52,56,97,.055); text-align: center; }
.gate-illustration { display: grid; place-items: center; margin: 0 auto 24px; height: 58px; width: 58px; border-radius: 19px; background: #f0eeff; color: var(--purple); font-size: 30px; }
.gate-dialog h1 { margin: 0 0 10px; font-weight: 700; font-size: 23px; letter-spacing: -.8px; }
.gate-dialog p { font-size: 14px; color: var(--muted); line-height: 1.65; margin: 0 0 27px; }
.gate-dialog label { display: block; font-size: 13px; font-weight: 650; text-align: left; margin-bottom: 9px; }
.gate-dialog input { width: 100%; border: 1px solid #e5e7ef; border-radius: 11px; background: #fff; outline: none; padding: 14px 15px; font-size: 15px; color: var(--ink); }
.gate-dialog input:focus, .compose-box:focus-within { border-color: #aaa4f5; box-shadow: 0 0 0 4px rgba(99,86,223,.08); }
.primary-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 17px; border: 0; border-radius: 11px; background: var(--purple); color: white; font-size: 14px; font-weight: 650; min-height: 48px; }
.primary-button:hover { background: var(--purple-dark); }
.gate-dialog .gate-error { color: #c43c53; margin: 14px 0 0; font-size: 13px; }
.gate-footer { margin: 23px 0 0; font-size: 12px; color: #a0a3b0; }

/* Chat layout */
.chat-shell { display: flex; flex-direction: column; position: relative; max-width: 940px; height: calc(100dvh - 48px); min-height: 420px; margin: 24px auto; background: white; border: 1px solid #ebedf4; border-radius: 17px; box-shadow: 0 14px 64px rgba(36,43,72,.04); overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; height: 78px; padding: 0 28px; border-bottom: 1px solid var(--line); z-index: 3; background: #fff; }
.room-heading { display: flex; align-items: center; gap: 13px; min-width: 0; }
.room-icon { width: 43px; height: 43px; flex-shrink: 0; }
.room-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.room-titles strong { font-size: 15.5px; font-weight: 750; letter-spacing: -.3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.room-subtitle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.connection-dot { width: 7px; height: 7px; background: #f2b94f; border-radius: 50%; }
.connection-dot.connected { background: #2dbd83; }
.header-actions { display: flex; align-items: center; gap: 11px; }
.my-username { color: #7d8392; font-weight: 600; font-size: 12px; margin-right: 6px; max-width: 165px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid #eef0f5; color: #6d7282; border-radius: 10px; background: white; min-height: 38px; min-width: 39px; padding: 0 10px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover { background: #f7f7fc; color: var(--purple); }
.people-button span { font-size: 13px; font-weight: 650; }
.people-wrap { position: relative; }
.people-menu { position: absolute; top: 48px; right: 0; z-index: 15; min-width: 210px; max-width: 270px; border: 1px solid var(--line); background: white; border-radius: 13px; padding: 16px; box-shadow: 0 14px 35px rgba(30,35,70,.12); }
.people-title { font-size: 12px; font-weight: 700; margin-bottom: 11px; }
.people-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow: auto; }
.people-person { display: flex; align-items: center; gap: 9px; font-size: 13px; word-break: break-word; }
.people-person::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #2dbd83; }

.messages-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; background: #fcfcfe; }
.messages-container { max-width: 824px; margin: 0 auto; min-height: 100%; padding: 26px 27px 36px; }
.message-list { display: flex; flex-direction: column; gap: 17px; }
.day-divider { color: #a0a4b1; text-align: center; font-size: 11px; font-weight: 650; letter-spacing: .2px; padding: 13px 0 5px; }
.message { max-width: 83%; min-width: 0; display: flex; flex-direction: column; align-self: flex-start; }
.message.mine { align-self: flex-end; }
.message-meta { display: flex; align-items: baseline; gap: 10px; margin: 0 8px 6px; }
.message.mine .message-meta { justify-content: flex-end; }
.message-author { color: #656b80; font-size: 12px; font-weight: 720; }
.message.mine .message-author { color: var(--purple); }
.message-time { color: #a4a8b4; font-size: 10.5px; }
.bubble { border: 1px solid #eceef4; background: #fff; padding: 11px 14px; border-radius: 13px 13px 13px 4px; width: fit-content; max-width: 100%; color: #34384a; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 2px 3px rgba(30,38,60,.012); }
.message.mine .bubble { border-color: #e7e3ff; background: #f0eeff; border-radius: 13px 13px 4px 13px; }
.bubble a { color: #5649c9; text-decoration: underline; text-decoration-color: #b1aaf1; text-underline-offset: 2px; overflow-wrap: anywhere; }
.file-bubble { white-space: normal; padding: 10px; min-width: min(280px, 75vw); }
.file-link { display: flex; gap: 12px; align-items: center; color: inherit !important; text-decoration: none !important; min-width: 0; }
.file-badge { display: grid; place-items: center; flex-shrink: 0; width: 43px; height: 43px; border-radius: 10px; background: #f1f0fb; color: #6559d8; }
.message.mine .file-badge { background: #e1dcff; }
.file-badge svg { width: 23px; height: 23px; }
.file-information { flex: 1; min-width: 0; }
.file-name { display: block; font-size: 13px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.file-detail { display: block; font-size: 11px; color: #9296a4; margin-top: 3px; }
.file-download { flex-shrink: 0; width: 20px; height: 20px; color: var(--purple); }
.older-button { display: block; margin: 0 auto 13px; border: 1px solid #e7e9f4; background: white; color: #6c60ca; border-radius: 20px; padding: 8px 15px; font-size: 12px; }
.older-button:hover { background: #f6f4ff; }
.empty-state { text-align: center; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 45vh; padding: 25px; color: #84899c; }
.empty-icon { color: #bcb6ed; display: block; font-size: 36px; margin-bottom: 6px; }
.empty-state h2 { font-size: 17px; letter-spacing: -.3px; margin: 9px 0 4px; color: #474d62; }
.empty-state p { font-size: 13px; line-height: 1.6; max-width: 270px; }
.new-message-button { position: absolute; right: 34px; bottom: 158px; z-index: 3; border: 1px solid #d9d3fc; border-radius: 30px; padding: 10px 15px; background: #fff; box-shadow: 0 4px 15px #1f24551a; color: var(--purple); font-size: 12px; font-weight: 650; }

.compose-area { flex-shrink: 0; padding: 15px 27px 20px; background: #fff; border-top: 1px solid var(--line); }
.compose-box { border-radius: 13px; border: 1px solid #e9eaf1; transition: box-shadow .1s, border-color .1s; }
.compose-box textarea { display: block; width: 100%; border: 0; outline: none; resize: none; min-height: 43px; max-height: 150px; background: transparent; padding: 16px 17px 6px; color: var(--ink); font-size: 14px; line-height: 1.5; }
.compose-box textarea::placeholder { color: #a6aabb; }
.compose-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 3px 8px 8px 9px; }
.attachment-actions, .send-actions { display: flex; align-items: center; gap: 4px; }
.attach-button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 9px; color: #858a9c; font-size: 12px; cursor: pointer; border-radius: 7px; user-select: none; }
.attach-button svg { width: 16px; height: 16px; }
.attach-button:hover { color: var(--purple); background: #f6f5fd; }
.keyboard-hint { color: #a4a6b4; font-size: 10.5px; margin-right: 11px; }
.send-button { width: 37px; height: 35px; padding: 0; border: 0; border-radius: 9px; color: white; background: var(--purple); display: grid; place-items: center; }
.send-button svg { width: 17px; height: 17px; }
.send-button:hover:not(:disabled) { background: var(--purple-dark); }
.upload-status { padding: 0 3px 10px; font-size: 12px; color: #6d60cf; }
.drop-overlay { display: grid; place-items: center; position: absolute; inset: 0; z-index: 18; background: rgba(247,246,255,.91); border: 3px dashed #aba4f2; pointer-events: none; }
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 13px; color: #6d63b4; }
.drop-symbol { font-size: 53px; }
.drop-card strong { font-size: 22px; color: #5146af; }
.drop-card > span:last-child { color: #8b85b3; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 25px); padding: 12px 18px; background: #2d3041; color: white; border-radius: 11px; box-shadow: 0 12px 40px rgba(0,0,0,.14); z-index: 99; font-size: 13px; text-align: center; }

@media (max-width: 700px) {
  body { background: white; }
  .chat-shell { max-width: none; height: 100dvh; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .topbar { height: 70px; padding: 0 15px; }
  .room-icon { width: 40px; height: 40px; }
  .header-actions { gap: 7px; }
  .my-username { display: none; }
  .messages-container { padding: 15px 14px 26px; }
  .message { max-width: 91%; }
  .compose-area { padding: 9px 12px max(12px, env(safe-area-inset-bottom)); }
  .compose-box textarea { padding-top: 12px; }
  .keyboard-hint { display: none; }
  .attach-button { font-size: 11.5px; padding: 9px 6px; }
  .new-message-button { right: 16px; bottom: 135px; }
  .people-menu { right: -50px; }
  .gate-screen { padding: 18px; }
  .gate-dialog { padding: 31px 24px; }
}
@media (max-width: 365px) {
  .room-titles strong { max-width: 140px; }
  .attach-button { gap: 4px; }
  .attach-button svg { width: 15px; height: 15px; }
}
