:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #22252a;
  background: #f4f5f7;
  --accent: #f28c18;
  --accent-dark: #ca6e07;
  --line: #dde0e5;
  --muted: #69717d;
  --panel: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(420px, calc(100vw - 32px)); padding: 40px; background: var(--panel); border-radius: 18px; box-shadow: 0 20px 50px #26364a1c; }
.brand-mark { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 24px; border-radius: 18px; color: white; background: var(--accent); font-weight: 800; }
h1, h2, p { margin-top: 0; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 6px; color: #454b54; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: white; }
input:focus, textarea:focus { outline: 3px solid #f28c1833; border-color: var(--accent); }
button { border: 0; border-radius: 10px; padding: 11px 16px; color: white; background: var(--accent); font-weight: 650; }
button:hover { background: var(--accent-dark); }
.button-secondary { color: #464c55; background: #eef0f3; }
.button-secondary:hover { background: #e0e3e8; }
.error { min-height: 1.2em; margin: 0; color: #b3261e; }

.messenger { width: 100vw; height: 100vh; grid-template-columns: 330px minmax(0, 1fr); background: var(--panel); }
.messenger:not([hidden]) { display: grid; }
.sidebar { display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); background: #f8f9fa; }
.sidebar-header, .conversation-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sidebar-header small { display: block; max-width: 190px; margin-top: 4px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
.new-room { margin: 14px; }
.room-list { overflow-y: auto; }
.room-item { display: block; width: 100%; padding: 14px 18px; border-radius: 0; color: #252a31; background: transparent; text-align: left; }
.room-item:hover, .room-item.active { background: #f28c1817; }
.room-item.active { box-shadow: inset 4px 0 var(--accent); }
.room-item small { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.conversation { display: grid; min-width: 0; grid-template-rows: auto auto 1fr auto; }
.conversation-header h2 { margin-bottom: 3px; font-size: 1.15rem; }
.conversation-header p { margin-bottom: 0; }
.status { padding: 5px 9px; border-radius: 999px; color: #56606c; background: #eef0f3; font-size: .8rem; }
.status.online { color: #176b3a; background: #e1f4e8; }
.prototype-warning { padding: 8px 20px; color: #704900; background: #fff1cf; font-size: .85rem; }
.messages { overflow-y: auto; margin: 0; padding: 24px; list-style: none; background: #f4f5f7; }
.message { max-width: min(720px, 82%); margin: 0 0 12px; padding: 11px 14px; border-radius: 6px 14px 14px; background: white; box-shadow: 0 2px 5px #1d293914; }
.message.mine { margin-left: auto; border-radius: 14px 6px 14px 14px; background: #fff3e3; }
.message-header { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: .78rem; }
.message-body { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.message a { color: #9a5200; }
.composer { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: end; padding: 14px 18px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; max-height: 130px; resize: vertical; }
.composer:has(textarea:disabled) { opacity: .55; }
.file-button { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 10px; color: #525963; background: #eef0f3; font-size: 1.5rem; cursor: pointer; }
.file-button input { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

dialog { width: min(480px, calc(100vw - 32px)); border: 0; border-radius: 16px; padding: 26px; box-shadow: 0 24px 70px #11182740; }
dialog::backdrop { background: #11182766; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 760px) {
  .messenger { grid-template-columns: 120px minmax(0, 1fr); }
  .sidebar-header { align-items: stretch; flex-direction: column; }
  .sidebar-header strong { font-size: .85rem; }
  .sidebar-header small { max-width: 90px; }
  .new-room { padding-inline: 8px; font-size: .82rem; }
  .room-item { padding-inline: 10px; }
  .message { max-width: 94%; }
}
