:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1020;
  color: #eef2ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(80, 90, 230, .22), transparent 35%),
    radial-gradient(circle at bottom right, rgba(20, 180, 160, .16), transparent 35%),
    #0b1020;
}
.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.chat-shell { align-items: start; padding-top: 28px; }
.card {
  width: min(100%, 460px);
  padding: 30px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: rgba(18, 25, 48, .88);
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
  backdrop-filter: blur(12px);
}
.chat-card { width: min(100%, 900px); }
h1 { margin: 10px 0 8px; font-size: clamp(1.8rem, 5vw, 2.5rem); }
h2 { margin-top: 0; font-size: 1.15rem; }
.muted, .hint { color: #b9c2dd; line-height: 1.55; }
.hint { font-size: .9rem; }
.compact { margin-top: 4px; margin-bottom: 0; }
.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(112, 120, 255, .14);
  border: 1px solid rgba(136, 145, 255, .3);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
}
form { display: grid; gap: 15px; margin-top: 22px; }
label { display: grid; gap: 7px; font-weight: 650; font-size: .92rem; }
input, textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(5, 9, 23, .58);
  color: inherit;
  font: inherit;
  outline: none;
}
textarea { resize: vertical; min-height: 52px; max-height: 180px; }
input:focus, textarea:focus { border-color: #8d95ff; box-shadow: 0 0 0 3px rgba(126, 137, 255, .15); }
button {
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  background: #7f89ff;
  color: #080b18;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: rgba(255,255,255,.12); color: inherit; }
.hidden { display: none !important; }
.message {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(238, 91, 111, .14);
  border: 1px solid rgba(238, 91, 111, .35);
  line-height: 1.45;
}
.message.success {
  background: rgba(35, 190, 140, .14);
  border-color: rgba(35, 190, 140, .35);
}
.row { display: flex; gap: 16px; align-items: center; }
.between { justify-content: space-between; }
.panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: 14px;
  background: rgba(5, 9, 23, .42);
  border: 1px solid rgba(255,255,255,.1);
}
.chat-panel { padding: 14px; }
.messages {
  height: min(58vh, 560px);
  min-height: 330px;
  overflow-y: auto;
  padding: 8px;
  scroll-behavior: smooth;
}
.chat-message {
  width: min(82%, 650px);
  margin: 10px 0;
  padding: 11px 13px;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.08);
}
.chat-message.own {
  margin-left: auto;
  border-radius: 14px 14px 4px 14px;
  background: rgba(127,137,255,.19);
  border-color: rgba(127,137,255,.25);
}
.chat-message p { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.chat-meta { display: flex; justify-content: space-between; gap: 18px; color: #cbd1ff; font-size: .78rem; }
.chat-form { grid-template-columns: 1fr auto; align-items: end; margin: 10px 0 0; }
.chat-form button { min-width: 92px; height: 52px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.users-list { margin: 0; padding-left: 20px; color: #cbd1ff; line-height: 1.8; }
details > summary { cursor: pointer; font-weight: 750; font-size: 1.05rem; }
hr { border: 0; border-top: 1px solid rgba(255,255,255,.1); margin: 26px 0; }
.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; }
code { color: #cbd1ff; word-break: break-word; }
@media (max-width: 700px) {
  .card { padding: 20px; }
  .chat-shell { padding: 10px; }
  .chat-header { align-items: flex-start; }
  .admin-grid { grid-template-columns: 1fr; }
  .messages { min-height: 55vh; }
  .chat-form { grid-template-columns: 1fr; }
  .chat-form button { width: 100%; }
}
.wide { max-width: 1180px; }
.room-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: stretch; }
.rooms-pane { border: 1px solid var(--border, #ddd); border-radius: 14px; padding: 14px; background: rgba(127,127,127,.04); }
.rooms-list { display: grid; gap: 8px; }
.room-button { width: 100%; text-align: left; background: transparent; border: 1px solid var(--border, #ddd); color: inherit; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.room-button.active { font-weight: 700; background: rgba(127,127,127,.14); }
.chat-pane { min-width: 0; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.checkbox-list { display: grid; gap: 6px; margin: 8px 0 14px; }
.checkbox-list.compact { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 8px 0; }
.checkbox-row { display: block; font-weight: 500; }
.checkbox-row.inline { display: inline-flex; align-items: center; gap: 6px; }
.users-list { display: grid; gap: 12px; }
.user-row { border: 1px solid var(--border, #ddd); border-radius: 12px; padding: 12px; }
.user-controls { display: grid; gap: 8px; margin-top: 10px; }
.pill { display: inline-block; font-size: .82rem; padding: 2px 8px; border-radius: 999px; background: rgba(127,127,127,.16); }
.muted-pill { opacity: .75; }
.link { border: 0; background: transparent; color: inherit; text-decoration: underline; padding: 0; cursor: pointer; font: inherit; }
.danger { color: #b00020; }
.chat-message.deleted { opacity: .68; font-style: italic; }
@media (max-width: 760px) { .room-layout, .admin-grid { grid-template-columns: 1fr; } }

/* Layout repair: full-width dashboard and readable admin controls */
.shell.wide {
  width: min(100%, 1240px);
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 24px;
  padding: 28px 24px 48px;
}
.shell.wide > .card {
  width: 100%;
  max-width: none;
}
.chat-card {
  min-height: min(760px, calc(100vh - 56px));
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0;
  color: #cbd1ff;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 11px;
  background: rgba(238,91,111,.14);
  border: 1px solid rgba(238,91,111,.35);
}
.room-layout {
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 600px;
}
.rooms-pane,
.chat-pane {
  min-width: 0;
}
.rooms-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rooms-pane h2,
.chat-pane h2 {
  margin-bottom: 8px;
}
.chat-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.messages {
  height: auto;
  min-height: 430px;
  max-height: 62vh;
}
.chat-form {
  width: 100%;
}
.chat-message {
  max-width: 720px;
}

#admin-panel {
  padding: 28px;
}
#admin-panel > h2 {
  margin-bottom: 24px;
}
.admin-grid {
  grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr);
  gap: 28px;
  align-items: start;
}
.admin-grid form,
.hostname-form {
  margin-top: 0;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(5,9,23,.32);
}
.admin-grid h3,
.hostname-form h3 {
  margin: 0 0 16px;
}
select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.18);
  background: #111831;
  color: #eef2ff;
  font: inherit;
}
fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
}
legend {
  padding: 0 6px;
  color: #cbd1ff;
  font-weight: 700;
  font-size: .9rem;
}
.checkbox-list {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
}
.checkbox-row,
.checkbox-row.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: .92rem;
}
.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 0;
}
.users-list {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  margin-top: 12px;
}
.user-row {
  min-width: 0;
  background: rgba(5,9,23,.28);
}
.user-controls {
  gap: 12px;
}
.hostname-form {
  margin-top: 28px;
}
.danger {
  color: #ff718d;
}

@media (max-width: 900px) {
  .room-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .room-layout {
    min-height: 0;
  }
  .rooms-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .messages {
    min-height: 420px;
  }
}

@media (max-width: 600px) {
  .shell.wide {
    padding: 10px;
    gap: 14px;
  }
  .shell.wide > .card,
  #admin-panel {
    padding: 18px;
    border-radius: 14px;
  }
  .topbar {
    flex-direction: column;
  }
  .topbar #logout {
    width: 100%;
  }
  .chat-card {
    min-height: auto;
  }
  .messages {
    min-height: 52vh;
    max-height: none;
    padding-inline: 0;
  }
  .chat-message {
    width: 94%;
  }
  .users-list {
    grid-template-columns: 1fr;
  }
}
