* { box-sizing: border-box; }
:root {
  --paper: #f5f1eb;
  --surface: #fffdf9;
  --ink: #28241f;
  --muted: #817970;
  --line: #ded5ca;
  --sage: #52664e;
  --accent: #b96f55;
}
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 8% 5%, #ead9ce, transparent 30%), var(--paper); color: var(--ink); font-family: Inter, Arial, sans-serif; }
button, input, textarea { font: inherit; }
.topbar { height: 60px; padding: 0 28px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); background: rgba(255,253,249,.9); }
.brand { color: var(--ink); font-family: Georgia, serif; font-size: 1.2rem; font-weight: 700; text-decoration: none; }
.room-name { margin-right: auto; padding: 5px 9px; border-radius: 999px; background: #eee7df; color: var(--accent); font-size: .72rem; font-weight: 800; }
.presence { color: var(--sage); font-size: .75rem; font-weight: 700; }
.chat-ad { padding: 14px; display: grid; place-items: center; gap: 4px; border: 1px dashed var(--line); border-radius: 12px; background: rgba(255,253,249,.78); color: var(--muted); text-align: center; }
.chat-ad span { color: var(--accent); font-size: .54rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.chat-ad strong { color: var(--sage); font-size: .7rem; }
.chat-ad small { font-size: .58rem; }
.chat-ad-leaderboard { width: min(970px, calc(100% - 32px)); min-height: 100px; margin: 18px auto 0; }
.chat-ad-inline { min-height: 92px; margin: 0 14px 12px; }
.room { width: min(1280px, calc(100% - 32px)); min-height: calc(100vh - 60px); margin: auto; padding: 28px 0; display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 22px; }
.room-about, .chat-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,253,249,.92); box-shadow: 0 20px 60px rgba(65,50,40,.08); }
.room-about { padding: 26px; align-self: start; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .62rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, serif; font-size: 2.5rem; font-weight: 500; line-height: 1; }
.room-about > p:not(.eyebrow, .notice) { color: var(--muted); line-height: 1.6; }
.people-section { margin-top: 24px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #f8f4ef; }
.people-head { display: flex; align-items: center; justify-content: space-between; }
.people-head .eyebrow { margin: 0; }
.people-head span { min-width: 22px; padding: 3px 6px; border-radius: 999px; background: var(--sage); color: white; font-size: .62rem; font-weight: 800; text-align: center; }
.people-list { max-height: 150px; margin-top: 10px; overflow-y: auto; display: grid; gap: 7px; }
.person { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.person span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #ded5ca; color: var(--ink); font-size: .62rem; font-weight: 800; }
.person strong { overflow: hidden; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.person.is-you { color: var(--sage); }
.person.is-you span { background: var(--sage); color: white; }
.person[data-mention], .agent[data-mention] { cursor: pointer; }
.person[data-mention]:hover strong, .agent[data-mention]:hover strong { color: var(--accent); }
.agent-heading { margin-top: 22px; }
.agent-list { display: grid; gap: 9px; }
.agent { padding: 10px; display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; }
.agent > span, .message-avatar { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--agent-color); color: white; font-weight: 800; }
.agent div { display: grid; gap: 2px; }
.agent strong { font-size: .75rem; }
.agent small { color: var(--muted); font-size: .62rem; }
.notice { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .66rem; line-height: 1.5; }
.chat-card { min-height: calc(100vh - 116px); overflow: hidden; display: grid; grid-template-rows: auto minmax(300px, 1fr) auto auto auto; }
.chat-head { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-family: Georgia, serif; font-size: 1.5rem; font-weight: 500; }
.live-dot { color: var(--sage); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.live-dot::before { content: ""; width: 7px; height: 7px; margin-right: 5px; display: inline-block; border-radius: 50%; background: #62a067; }
.messages { padding: 22px; overflow-y: auto; display: grid; align-content: start; gap: 14px; }
.message { max-width: 82%; display: flex; gap: 10px; }
.message.is-user { margin-left: auto; flex-direction: row-reverse; }
.message > div { min-width: 0; }
.message-meta { margin: 0 0 4px; color: var(--muted); font-size: .58rem; font-weight: 700; }
.is-user .message-meta { text-align: right; }
.message-text { margin: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: white; font-size: .8rem; line-height: 1.55; }
.is-user .message-text { border-color: #53684f; border-radius: 14px 4px 14px 14px; background: var(--sage); color: white; }
.typing { padding: 5px 22px 10px; color: var(--muted); font-size: .65rem; font-style: italic; }
.composer { padding: 14px; display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 9px; border-top: 1px solid var(--line); background: #f8f4ef; }
.composer input, .composer textarea { width: 100%; padding: 11px; resize: none; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); outline-color: var(--sage); }
.composer button { padding: 0 17px; border: 0; border-radius: 10px; background: var(--accent); color: white; font-weight: 800; cursor: pointer; }
.composer button:disabled { opacity: .55; }
.direct-chat { width: min(480px, calc(100% - 24px)); height: min(620px, calc(100vh - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 24px 80px rgba(42,32,25,.28); }
.direct-chat::backdrop { background: rgba(38,33,28,.42); backdrop-filter: blur(4px); }
.direct-chat[open] { display: grid; grid-template-rows: auto minmax(200px, 1fr) auto auto; }
.direct-chat header { padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.direct-chat h2 { margin: 0; font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.direct-chat header button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: white; cursor: pointer; }
.direct-messages { padding: 16px; overflow-y: auto; display: grid; align-content: start; gap: 10px; }
.direct-message { max-width: 82%; display: grid; gap: 3px; }
.direct-message.is-mine { margin-left: auto; text-align: right; }
.direct-message small { color: var(--muted); font-size: .58rem; }
.direct-message p { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px 13px 13px 13px; background: white; font-size: .78rem; line-height: 1.5; text-align: left; }
.direct-message.is-mine p { border-color: var(--sage); border-radius: 13px 4px 13px 13px; background: var(--sage); color: white; }
.direct-composer { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; border-top: 1px solid var(--line); background: #f8f4ef; }
.direct-composer textarea { padding: 10px; resize: none; border: 1px solid var(--line); border-radius: 9px; }
.direct-composer button { padding: 0 14px; border: 0; border-radius: 9px; background: var(--accent); color: white; font-weight: 800; cursor: pointer; }
.direct-typing { padding-top: 8px; }
@media (max-width: 850px) {
  .chat-ad-leaderboard { min-height: 90px; margin-top: 12px; }
  .room { grid-template-columns: 1fr; }
  .room-about { display: none; }
  .chat-card { min-height: calc(100vh - 100px); }
  .composer { grid-template-columns: 1fr; }
  .composer button { min-height: 44px; }
}
