:root {
  --bg: #101118;
  --panel: #171a24;
  --panel-soft: #1f2433;
  --text: #e6ebff;
  --muted: #9ca7d1;
  --accent: #10d2a2;
  --danger: #ff516c;
  --border: #2d3550;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Barlow", sans-serif;
  background: radial-gradient(circle at 15% 0%, #1e2753 0%, var(--bg) 35%, #0b0d14 100%);
  color: var(--text);
  min-height: 100vh;
}

.container {
  width: min(1200px, 96%);
  margin: 20px auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  font-family: "Chakra Petch", sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
}

.pill {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.grid {
  display: grid;
  gap: 12px;
}

.home-layout {
  grid-template-columns: 300px 1fr;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

h2,
h3 {
  margin: 0 0 10px 0;
  font-family: "Chakra Petch", sans-serif;
}

input,
textarea,
select,
button {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111523;
  color: var(--text);
  padding: 9px 10px;
  margin-bottom: 8px;
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, #0f7059, var(--accent));
  border: 0;
  color: #071211;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost {
  background: #151a28;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: linear-gradient(135deg, #8d1c33, var(--danger));
  color: #fff;
}

.muted {
  color: var(--muted);
}

.profile-header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  border: 1px solid var(--border);
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #141a29;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.room-title {
  font-weight: 700;
}

.room-desc {
  min-height: 34px;
}

.faq-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.home-rooms-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
}

.home-room-card {
  background: #141a29;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.home-room-icon-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #364066;
  border-radius: 8px;
  overflow: hidden;
  background: #0f1422;
}

.home-room-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-room-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9fb0dd;
  font-weight: 700;
}

.room-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 8px;
  height: calc(100vh - 72px);
  position: relative;
}

.room-surface {
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  padding: 8px;
  position: relative;
  --room-overlay-bg: rgba(15, 20, 34, 0.72);
  --room-overlay-border: rgba(45, 53, 80, 0.72);
}

.room-surface .card,
.room-surface .messages,
.room-surface .user-list {
  background: var(--room-overlay-bg);
  border-color: var(--room-overlay-border);
  backdrop-filter: blur(3px);
}

.room-surface.room-theme-light {
  color: #0f1528;
}

.room-surface.room-theme-light .muted {
  color: #35476f;
}

.room-surface.room-theme-light input,
.room-surface.room-theme-light textarea,
.room-surface.room-theme-light select {
  background: rgba(255, 255, 255, 0.86);
  color: #0e1426;
  border: 1px solid rgba(18, 24, 42, 0.25);
}

.room-surface.room-theme-light button.ghost {
  background: rgba(255, 255, 255, 0.72);
  color: #0e1426;
  border: 1px solid rgba(18, 24, 42, 0.25);
}

.cams-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 6px;
  align-content: start;
}

.cam-slot {
  background: #222;
  border: 1px solid #3f4662;
  aspect-ratio: 16 / 9;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cam-slot.active {
  background: linear-gradient(180deg, #263760, #17253f);
  border-color: #55d9bc;
}

.placeholder {
  text-align: center;
  color: #b7c0e1;
  font-weight: 600;
}

.cam-user {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #4e5a84;
  border-radius: 999px;
  padding: 2px 8px;
}

.cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.chat-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 8px;
  height: 290px;
  min-height: 290px;
}

.announcement-area {
  padding: 8px;
}

.announcement-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.announcement-text {
  min-height: 20px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.announcement-input {
  margin: 0;
  flex: 1;
  height: 34px;
  white-space: nowrap;
  overflow: hidden;
}

.messages {
  background: #0f1422;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  overflow-y: auto;
  font-size: 14px;
  min-height: 0;
}

.message {
  margin-bottom: 8px;
}

.message b {
  color: #72f2cf;
}

.right-col {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.user-list {
  background: #0f1422;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  overflow-y: auto;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid #232a3f;
  padding: 6px 0;
}

.user-row:last-child {
  border-bottom: 0;
}

.danger-inline {
  width: auto;
  padding: 4px 7px;
  margin: 0 0 0 4px;
  font-size: 12px;
}

.role-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid #466099;
  border-radius: 999px;
  color: #b7c6f5;
}

.username-link {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  width: auto;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.dm-name {
  font-weight: 700;
}

.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
}

.profile-modal {
  width: min(680px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}

.dm-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dm-window {
  position: absolute;
  width: 320px;
  max-width: calc(100% - 16px);
  background: rgba(15, 20, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.dm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(22, 30, 52, 0.9);
  border-bottom: 1px solid #33406a;
  cursor: move;
}

.dm-body {
  height: 180px;
}

.dm-compose {
  display: flex;
  gap: 6px;
  padding: 8px;
}

.dm-close-btn {
  width: auto;
  min-width: 32px;
  padding: 4px 8px;
  margin: 0;
}

.mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #2a3350;
  padding: 6px 0;
}

.mod-row:last-child {
  border-bottom: 0;
}

.owner-room-preview {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #425184;
}

@media (max-width: 900px) {
  .home-layout {
    grid-template-columns: 1fr;
  }
  .room-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .cams-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
  .home-rooms-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}
