:root {
  --bg: #1e2230;
  --panel: #2a3042;
  --room: #343b52;
  --room-hover: #3e4762;
  --room-mine: #2f5d50;
  --border: #4a5370;
  --text: #e8ebf4;
  --muted: #9aa3bd;
  --accent: #5cc8a0;
  --error: #ff7a7a;
  --op: #f5c542;
  font-family: system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }

/* Login */
.panel {
  max-width: 340px; margin: 15vh auto 0; padding: 2rem;
  background: var(--panel); border-radius: 12px;
}
.panel h1 { margin-top: 0; }
#login-form { display: flex; flex-direction: column; gap: .6rem; }
input, button {
  font: inherit; padding: .55rem .8rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
button { background: var(--accent); color: #10261e; border: none; font-weight: 600; cursor: pointer; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); font-weight: 500; }
.map-id { color: var(--muted); font-size: .85rem; margin-top: -.5rem; word-break: break-all; }
.error { color: var(--error); min-height: 1.2em; margin: 0; }

/* Office */
#office { display: flex; flex-direction: column; height: 100vh; }
#office header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--panel);
}
.brand { font-weight: 700; }
#status { color: var(--muted); flex: 1; }
#office header select, #office header input { padding: .35rem .5rem; }
#status-text { width: 14rem; max-width: 100%; }
.workspace { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-width: 0; padding: 1rem; }

/* Chat */
#chat {
  width: 320px; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border);
}
#chat h2 { font-size: 1rem; margin: 0; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
#chat-log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .4rem; }
#chat-log li { overflow-wrap: anywhere; line-height: 1.35; }
#chat-log .time { color: var(--muted); font-size: .75rem; margin-right: .4rem; }
#chat-log .who { font-weight: 600; margin-right: .3rem; }
#chat-log .mine .who { color: var(--accent); }
#chat-log .system { color: var(--muted); font-size: .85rem; font-style: italic; }
#chat-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
#chat-input { flex: 1; min-width: 0; }

@media (max-width: 800px) {
  .workspace { flex-direction: column; }
  #chat { width: auto; height: 40vh; border-left: none; border-top: 1px solid var(--border); }
}

.room rect { fill: var(--room); stroke: var(--border); stroke-width: 2; rx: 10; cursor: pointer; transition: fill .15s; }
.room:hover rect { fill: var(--room-hover); }
.room.mine rect { fill: var(--room-mine); stroke: var(--accent); }
.room-label { fill: var(--muted); font-size: 16px; font-weight: 600; pointer-events: none; }
.room-count { fill: var(--muted); font-size: 13px; pointer-events: none; }

.avatar { pointer-events: none; transition: transform .45s ease, opacity .2s; }
.avatar .body { fill: #6b7bd6; stroke: #fff3; stroke-width: 2; }
.avatar.me .body { fill: var(--accent); stroke: #fff; }
.avatar.disconnected { opacity: .35; }
@media (prefers-reduced-motion: reduce) { .avatar { transition: none; } }

/* Status badge */
.badge circle { stroke: var(--bg); stroke-width: 2.5; }
.status-available .badge circle { fill: #3ecf7a; }
.status-busy .badge circle, .status-dnd .badge circle { fill: #e5484d; }
.status-away .badge circle { fill: #f5c542; }
.badge .dnd-bar { fill: #fff; display: none; }
.status-dnd .badge .dnd-bar { display: inline; }
.avatar .initials { fill: #fff; font-size: 15px; font-weight: 700; }
.avatar .name { fill: var(--text); font-size: 12px; }
.avatar.op .name { fill: var(--op); font-weight: 600; }
/* Only clickable for the op (others' avatars); clicks otherwise fall through to the room. */
.avatar.actionable { pointer-events: auto; cursor: pointer; }
.avatar.actionable:hover .body { stroke: var(--op); }

/* Op menu */
#avatar-menu {
  position: fixed; z-index: 10; min-width: 11rem; padding: .5rem;
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px #0008;
}
#avatar-menu[hidden] { display: none; }
#avatar-menu-name { margin: .1rem .3rem .3rem; font-weight: 600; overflow-wrap: anywhere; }
#avatar-menu button { text-align: left; }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); font-weight: 500; }
