@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  --bg: #100e0c;
  --bg-2: #181512;
  --panel: #1f1b17;
  --line: #322c26;
  --text: #f4eee6;
  --muted: #9c9186;
  --accent: #e3a24a;
  --accent-2: #f0c27a;
  --online: #4fce78;
  --danger: #d45b4a;
  --mic: #7ec8c4;
  --glow: #2a2118;
  --scroll-track: #181512;
  --scroll-thumb: #6a5744;
}
html[data-theme="light"] {
  --bg: #f3ebe1;
  --bg-2: #fffaf3;
  --panel: #fff8ef;
  --line: #e2d3c2;
  --text: #1c1510;
  --muted: #6f6258;
  --accent: #c9842e;
  --accent-2: #9a5c12;
  --online: #2f9d54;
  --danger: #c24738;
  --mic: #3e8f8b;
  --glow: #f0dcc0;
  --scroll-track: #efe6da;
  --scroll-thumb: #c4a882;
}

* { box-sizing: border-box; }
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--scroll-track); }
*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid var(--scroll-track);
}
*::-webkit-scrollbar-thumb:hover { background: #e3a24a; }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
*::-webkit-scrollbar-corner { background: var(--scroll-track); }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--glow) 0%, transparent 50%),
    var(--bg);
  font: 15px/1.45 "IBM Plex Sans", system-ui, sans-serif;
}

h1, h2, .serif { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; }
a { color: var(--accent-2); text-decoration: none; }
button, input, textarea { font: inherit; }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(440px, 100%); padding: 28px; }
.brand { letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; color: var(--accent); }
.auth-card h1 { margin: 8px 0 6px; font-size: 36px; }
.lede { color: var(--muted); margin: 0 0 22px; }
label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
}
textarea { min-height: 72px; resize: vertical; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #1a1208;
  font-weight: 600;
}
.btn.wide { width: 100%; margin-top: 16px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.tiny { padding: 6px 8px; font-size: 12px; font-weight: 500; }
.tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.tab { padding: 6px 0; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-color: var(--accent); }
.status { min-height: 1.3em; margin-top: 12px; color: var(--muted); font-size: 13px; }
.status.bad { color: var(--danger); }
.status.ok { color: var(--online); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
}
.me { display: flex; align-items: center; gap: 10px; }
.avatar, .room-ava {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #2b241c;
  border: 1px solid var(--line);
}
.avatar.lg { width: 72px; height: 72px; }
.grid { display: grid; grid-template-columns: 280px 1fr; gap: 18px; padding-bottom: 40px; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }
.panel { padding: 18px; }
.room-list { display: grid; gap: 10px; }
.room-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
}
.room-row h3 { margin: 0; font-size: 18px; }
.room-row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.room-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  grid-template-rows: auto 1fr 64px;
}
.room-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.rooms-col {
  grid-column: 1;
  grid-row: 2 / 4;
  background: #141210;
  border-right: 1px solid var(--line);
}
.side-room {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.side-room:hover { background: var(--bg-2); }
.side-room.on { border-color: #5a4630; background: #241c16; }
.side-room b { display: block; font-size: 13px; }
.side-room p { margin: 0; color: var(--muted); font-size: 12px; }
.main-col {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.stage {
  flex: 1.4;
  min-height: 180px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  background: #0c0a09;
}
.stage:has(.screen-tile:nth-child(2)) { grid-template-columns: 1fr 1fr; }
.stage.hidden { display: none !important; }
.screen-tile {
  position: relative;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.screen-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.screen-cap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #0009;
  font-size: 12px;
}
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  border-right: 0;
}
.members {
  grid-column: 3;
  grid-row: 2 / 4;
  min-height: 0;
  border-right: 0;
  background: #161310;
}
.members-title { margin: 0 0 12px; font-size: 22px; }
.col { min-height: 0; overflow: auto; padding: 14px; }
.person {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: var(--bg-2);
  border: 1px solid transparent;
  overflow: visible;
}
.person.talk { border-color: #4fce7888; }
.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who b { font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #665;
  display: inline-block;
  flex-shrink: 0;
}
.lamp.on {
  background: var(--online);
  box-shadow: 0 0 0 0 #4fce7888;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #4fce7866; }
  70% { box-shadow: 0 0 0 8px #4fce7800; }
  100% { box-shadow: 0 0 0 0 #4fce7800; }
}
.ico { width: 16px; opacity: 0.45; }
.ico.live { opacity: 1; }
.mix {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  overflow: visible;
}
.vol-label { color: var(--muted); font-size: 11px; min-width: 3.2em; text-align: right; }
input[type="range"].vol {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #3a332c;
  cursor: pointer;
}
input[type="range"].vol::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: #3a332c;
}
input[type="range"].vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #1a1510;
  cursor: pointer;
}
input[type="range"].vol::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: #3a332c;
}
input[type="range"].vol::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.msgs {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background-color: var(--bg-2);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.msg-row { display: flex; width: 100%; }
.msg-row.theirs { justify-content: flex-start; }
.msg-row.mine { justify-content: flex-end; }
.msg {
  max-width: min(78%, 520px);
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  background: #241f1a;
  border: 1px solid var(--line);
}
.msg.mine {
  background: #3a2c1c;
  border-color: #5a4630;
  border-radius: 14px 14px 4px 14px;
}
.msg .meta { margin-bottom: 4px; }
.file-card { margin-top: 8px; display: grid; gap: 6px; }
.chat-thumb {
  max-width: 220px;
  max-height: 160px;
  border-radius: 10px;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
  border: 1px solid var(--line);
}
.file-actions { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dl-ico {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #1a1612;
}
.dl-ico svg { width: 16px; height: 16px; }
.paste-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}
.paste-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000c;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px #0008;
}
.composer { display: grid; gap: 8px; margin-top: 10px; }
.emoji { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji button { border: 0; background: transparent; cursor: pointer; font-size: 18px; padding: 2px; }
.hidden { display: none !important; }
.admin { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; grid-column: 1 / -1; }
.file { font-size: 13px; }
.btn-row { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn-row .btn { margin-top: 0; }
.composer-actions {
  justify-content: flex-end;
  margin-top: 8px;
}
.composer-actions .meta {
  margin-right: auto;
  min-height: 1em;
}
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
}
.room-dock {
  grid-column: 2;
  grid-row: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #141210;
  border-top: 1px solid var(--line);
}
.dock-user { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; cursor: pointer; }
.dock-who { min-width: 0; }
.dock-who b { display: block; font-size: 13px; }
.dock-controls { display: flex; gap: 10px; justify-self: center; }
.dock-actions { display: flex; gap: 8px; justify-self: end; }
.dock-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.dock-icon .ico { width: 22px; height: 22px; opacity: 1; }
.dock-icon.off {
  opacity: 1;
  background: #2a1c1a;
  color: #9c9186;
}
.dock-icon.off .ico { opacity: 0.45; }
.dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.dock-btn.off { opacity: 0.45; }
.dock-btn.danger { border-color: #5a2c26; color: #f0c2bc; }
.modal {
  position: fixed;
  inset: 0;
  background: #100e0ccc;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal .auth-card h2 { margin: 8px 0 6px; font-size: 28px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.rooms-col .lede { font-size: 13px; margin: 8px 0 0; }
#gate.auth-page {
  position: fixed;
  inset: 0;
  z-index: 30;
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--glow) 0%, transparent 50%),
    var(--bg);
}
.auth-card.wide { width: min(560px, 100%); max-height: 86vh; overflow: auto; }
.settings-block { margin: 16px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.settings-block h3 { margin: 0 0 8px; font-size: 16px; }
.perm-row {
  display: grid;
  gap: 6px;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}
.perm-row b { font-size: 13px; }
input[type="color"] { width: 48px; height: 36px; padding: 2px; cursor: pointer; }
.dock-icon.on {
  background: #3a2c1c;
  border-color: var(--accent);
}
@media (max-width: 1100px) {
  .room-shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto auto; }
  .chat, .members, .room-dock, .room-head, .rooms-col, .main-col { grid-column: 1; grid-row: auto; }
  .rooms-col, .members { max-height: 28vh; }
}
