* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #1a2430;
  background-color: #f4f6f8;
  background-image: linear-gradient(rgba(244, 246, 248, 0.82), rgba(244, 246, 248, 0.82)), url("sheboyganbackground.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: #14324d;
  color: #fff;
}

.navbar .brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.1rem;
}

.nav-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-links a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.nav-links a:hover {
  text-decoration: underline;
}

.theme-toggle-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 12px;
  cursor: pointer;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.weather-rotator-widget {
  margin-left: 12px;
  width: min(360px, 32vw);
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(8, 25, 43, 0.86);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(2px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weather-line {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #eaf5ff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weather-rotator-widget.weather-severe {
  background: rgba(130, 8, 8, 0.9);
  border-color: rgba(255, 170, 170, 0.55);
  box-shadow: 0 8px 22px rgba(120, 0, 0, 0.45);
}

.weather-radio-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.weather-radio-controls .weather-station-select,
.weather-radio-controls .weather-radio-toggle {
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  background: rgba(7, 38, 64, 0.82);
  color: #f4fbff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
}

.weather-radio-controls .weather-station-select {
  width: 100px;
  cursor: pointer;
}

.weather-radio-controls .weather-radio-toggle {
  width: 56px;
  cursor: pointer;
}

.weather-radio-audio {
  display: none;
}

@media (max-width: 900px) {
  .weather-rotator-widget {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    white-space: normal;
  }

  .weather-line {
    white-space: normal;
  }
}

.page {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 24px;
}

.hero {
  max-width: 640px;
  text-align: center;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  padding: 40px 32px;
}

.hero h1 {
  margin-top: 0;
  color: #14324d;
}

.button {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 22px;
  background: #1c7c8a;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 700;
}

.button:hover {
  background: #16626d;
}

.form-card {
  text-align: left;
}

.form-card h1 {
  text-align: center;
  color: #14324d;
}

.signup-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.signup-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: #14324d;
}

.signup-form input {
  padding: 10px 12px;
  border: 1px solid #c7d0d8;
  border-radius: 8px;
  font-size: 1rem;
}

.error-box {
  list-style: none;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fdecec;
  border: 1px solid #e08585;
  color: #8a1f1f;
}

.error-box a {
  color: #8a1f1f;
  font-weight: 700;
  text-decoration: underline;
}

.signup-form textarea {
  padding: 10px 12px;
  border: 1px solid #c7d0d8;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.hint {
  font-weight: 400;
  color: #5c6b78;
  font-size: 0.85rem;
}

.back-link {
  display: inline-block;
  margin-top: 16px;
  color: #1c7c8a;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.dashboard-card,
.groups-card,
.profile-page-card,
.gallery-card {
  max-width: 720px;
  align-self: flex-start;
  margin-left: 0;
}

.welcome-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 8px;
}

.welcome-photo {
  flex: 0 0 120px;
}

.welcome-photo img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.welcome-photo .profile-photo-placeholder {
  width: 120px;
  height: 120px;
}

.welcome-text h1 {
  margin: 0 0 6px;
}

.welcome-text p {
  margin: 0;
}

.dashboard-section {
  margin: 20px 0;
  padding-top: 16px;
  border-top: 1px solid #e4e9ee;
}

.dashboard-section h2 {
  margin: 0 0 8px;
  color: #14324d;
  font-size: 1.05rem;
}

.dashboard-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e4e9ee;
  border-radius: 10px;
  background: #f9fbfc;
}

.group-item h3 {
  margin: 0 0 4px;
  color: #14324d;
  font-size: 1rem;
}

.group-item p {
  margin: 0;
  color: #55636f;
  font-size: 0.88rem;
}

.group-item form {
  margin: 0;
}

.group-joined-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1c7c8a;
}

.friend-status-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: #55636f;
}

.profile-page-card {
  max-width: 780px;
}

.profile-page-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.profile-photo-col {
  flex: 0 0 160px;
}

.profile-photo-col img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.profile-photo-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background: #dbe4ea;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-photo-placeholder svg {
  width: 84px;
  height: 84px;
  fill: #8b9aa8;
}

.profile-info-col {
  flex: 1;
  min-width: 0;
}

.profile-owner-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e4e9ee;
}

@media (max-width: 600px) {
  .profile-page-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.gallery-item {
  margin: 0;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.gallery-item img:hover {
  transform: scale(1.03);
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  padding: 40px;
}

.lightbox-overlay.is-visible {
  display: flex;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 28px;
  border: none;
  background: none;
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-caption {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #55636f;
  text-align: center;
}

.gallery-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.feed-section {
  position: fixed;
  top: 76px;
  right: calc(16px + 5in);
  width: min(360px, calc(100vw - 5in - 32px));
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  margin: 0;
}


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

.feed-section-header h2 {
  margin: 0;
}

.feed-collapse-toggle {
  border: 0;
  border-radius: 999px;
  background: #14324d;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 7px 12px;
}

.feed-collapse-toggle:hover,
.feed-collapse-toggle:focus-visible {
  background: #1f5b82;
}

.feed-section.is-collapsed {
  width: auto;
  min-width: 190px;
  max-height: 48px;
  overflow: hidden;
}

.feed-section.is-collapsed .feed-list {
  display: none;
}

.home-chat-panel {
  min-width: 0;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 1;
}

.home-columns {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr minmax(240px, 300px);
  gap: 24px;
  align-items: start;
}

.home-columns:has(.home-sidebar):not(:has(.home-chat-panel)) {
  grid-template-columns: minmax(260px, 320px) 1fr;
}

.home-columns:not(:has(.home-sidebar)):not(:has(.home-chat-panel)) {
  grid-template-columns: 1fr;
}

.home-sidebar.dashboard-card,
.home-chat-panel {
  max-width: none;
  align-self: start;
}

.home-chat-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  padding: 20px;
}

.home-chat-panel h2 {
  margin: 0 0 10px;
  color: #14324d;
}

.camera-feed-widget {
  position: fixed;
  top: 76px;
  right: 16px;
  width: 5in;
  height: 5in;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  background: #0a1622;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.camera-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #14324d;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.camera-feed-frame {
  flex: 1;
  min-height: 0;
}

.camera-feed-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

@media (max-width: 900px) {
  .camera-feed-widget {
    position: static;
    width: 100%;
    height: 320px;
    max-width: none;
    margin: 0 auto 16px;
  }

  .contacts-widget {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 auto 16px;
  }
}

.contacts-widget {
  position: fixed;
  top: calc(76px + 5in + 12px);
  right: 16px;
  width: 5in;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 76px - 5in - 28px);
  background: #0a1622;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  z-index: 899;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contacts-header {
  padding: 8px 12px;
  background: #14324d;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.contacts-list {
  overflow-y: auto;
  max-height: 220px;
  padding: 6px;
}

.contacts-list .feed-empty {
  padding: 8px;
  margin: 0;
  color: #cfe3ff;
  font-size: 0.8rem;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: none;
  color: #e6edf3;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.85rem;
}

.contact-row:hover {
  background: rgba(255, 255, 255, 0.08);
}

.contact-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.contact-dot-online {
  background: #2fbf4f;
  box-shadow: 0 0 4px #2fbf4f;
}

.contact-dot-offline {
  background: #6b7885;
}

.contact-avatar img,
.contact-avatar .feed-avatar-placeholder {
  width: 26px;
  height: 26px;
}

.contact-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #14324d;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.chat-panel-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-panel-messages {
  flex: 1;
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-panel-messages .message-bubble {
  font-size: 0.8rem;
  padding: 6px 10px;
}

.chat-panel-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-panel-form input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid #33465c;
  font-size: 0.8rem;
}

@media (max-width: 1000px) {
  .home-columns,
  .home-columns:has(.home-sidebar):not(:has(.home-chat-panel)) {
    grid-template-columns: 1fr;
  }
}

.feed-section h2 {
  color: #14324d;
  margin-bottom: 12px;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 1000px) {
  .feed-section {
    position: static;
    width: 100%;
    max-width: 640px;
    max-height: none;
    overflow: visible;
    margin: 0 auto;
  }
}

.feed-post {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 16px 18px;
}

.feed-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.feed-avatar img,
.feed-avatar-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.feed-avatar-placeholder {
  background: #dbe4ea;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feed-avatar-placeholder svg {
  width: 24px;
  height: 24px;
  fill: #8b9aa8;
}

.feed-author {
  font-weight: 700;
  color: #14324d;
  text-decoration: none;
}

.feed-author:hover {
  text-decoration: underline;
}

.feed-body {
  margin: 0 0 6px;
  white-space: pre-wrap;
}

.feed-time {
  margin: 0;
  font-size: 0.75rem;
  color: #8a97a3;
}

.feed-person-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px 52px; }
.feed-person-actions form { display: inline-flex; margin: 0; }
.feed-post-actions {
  display: flex;
  gap: 12px;
  margin: 8px 0 0;
}

.feed-action-link {
  background: none;
  border: none;
  padding: 0;
  color: #1c7c8a;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
}

.feed-action-link:hover {
  text-decoration: underline;
}

.feed-action-danger {
  color: #b23a3a;
}

.feed-empty {
  color: #55636f;
}

.message-center-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
}

.message-center-link:hover {
  background: rgba(255, 255, 255, 0.22);
}

.unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #d92626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.feed-replies {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e4e9ee;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-reply {
  font-size: 0.85rem;
  color: #38444d;
}

.feed-reply-author {
  font-weight: 700;
  margin-right: 6px;
  color: #14324d;
}

.feed-reply-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.feed-reply-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #c7d0d8;
  border-radius: 999px;
  font-size: 0.85rem;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.message-item {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e4e9ee;
  background: #f9fbfc;
}

.message-item-unread {
  border-color: #d92626;
  background: #fff4f4;
}

.message-meta {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.message-body {
  margin: 0 0 6px;
}

.message-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}

.message-bubble {
  align-self: flex-start;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f1f4f7;
}

.message-bubble.message-mine {
  align-self: flex-end;
  background: #d7f0f2;
}

.post-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

body[data-theme="dark"] {
  background-color: #0f1720;
  background-image: linear-gradient(rgba(15, 23, 32, 0.86), rgba(15, 23, 32, 0.86)), url("sheboyganbackground.jpg");
  color: #e6edf3;
}

body[data-theme="dark"] .navbar {
  background: #0a1622;
}

body[data-theme="dark"] .hero,
body[data-theme="dark"] .feed-post,
body[data-theme="dark"] .group-item,
body[data-theme="dark"] .home-sidebar,
body[data-theme="dark"] .home-chat-panel {
  background: #182636;
  color: #e6edf3;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

body[data-theme="dark"] .hero h1,
body[data-theme="dark"] .dashboard-section h2,
body[data-theme="dark"] .feed-author,
body[data-theme="dark"] .group-item h3,
body[data-theme="dark"] .feed-section h2,
body[data-theme="dark"] .home-chat-panel h2 {
  color: #cfe3ff;
}

body[data-theme="dark"] .dashboard-section,
body[data-theme="dark"] .profile-owner-tools {
  border-top-color: #2b3d50;
}

body[data-theme="dark"] .signup-form input,
body[data-theme="dark"] .signup-form textarea {
  background: #0f1720;
  color: #e6edf3;
  border-color: #33465c;
}

body[data-theme="dark"] .error-box {
  background: #3a1414;
  border-color: #7a3232;
  color: #ffb3b3;
}

body[data-theme="dark"] .error-box a {
  color: #ffb3b3;
}

body[data-theme="dark"] .back-link {
  color: #7fd0da;
}

body[data-theme="dark"] .profile-photo-placeholder,
body[data-theme="dark"] .feed-avatar-placeholder {
  background: #2b3d50;
}

body[data-theme="dark"] .profile-photo-placeholder svg,
body[data-theme="dark"] .feed-avatar-placeholder svg {
  fill: #9db3c7;
}

body[data-theme="dark"] .group-item {
  border-color: #2b3d50;
  background: #16222f;
}

body[data-theme="dark"] .group-item p,
body[data-theme="dark"] .feed-time,
body[data-theme="dark"] .gallery-caption,
body[data-theme="dark"] .feed-empty,
body[data-theme="dark"] .hint {
  color: #a9bccd;
}


/* Responsive home layout: keep the large-screen fixed side panels only on wide displays. */
@media (max-width: 2000px) {
  .page {
    align-items: stretch;
    padding: 18px;
  }

  .home-columns,
  .home-columns:has(.home-sidebar):not(:has(.home-chat-panel)),
  .home-columns:not(:has(.home-sidebar)):not(:has(.home-chat-panel)) {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 18px;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
  }

  .feed-section {
    position: static;
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    max-height: 420px;
    overflow-y: auto;
    margin: 0;
  }

  .feed-section.is-collapsed {
    max-height: 48px;
  }

  .home-sidebar.dashboard-card,
  .home-chat-panel {
    width: 100%;
    max-width: none;
  }

  .home-chat-panel {
    min-height: 120px;
  }

  .camera-feed-widget,
  .contacts-widget {
    position: static !important;
    width: min(100%, 640px) !important;
    max-width: calc(100vw - 36px) !important;
    margin: 16px auto !important;
    right: auto !important;
    top: auto !important;
  }

  .camera-feed-widget {
    height: auto !important;
    aspect-ratio: 16 / 9;
    max-height: none !important;
  }

  .contacts-widget {
    max-height: none !important;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 12px;
    gap: 16px;
  }

  .home-columns,
  .home-columns:has(.home-sidebar):not(:has(.home-chat-panel)),
  .home-columns:not(:has(.home-sidebar)):not(:has(.home-chat-panel)) {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .feed-section {
    grid-column: auto;
    max-height: 360px;
  }

  .home-chat-panel {
    padding: 16px;
  }

  .camera-feed-widget,
  .contacts-widget {
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
  }
}


/* Keep the YouTube camera visible at the upper right on laptop and desktop layouts. */
@media (min-width: 901px) and (max-width: 2000px) {
  .page {
    padding-right: min(680px, 38vw);
  }

  .camera-feed-widget {
    position: fixed !important;
    top: 100px !important;
    right: 16px !important;
    width: clamp(556px, 39vw, 736px) !important;
    height: 456px !important;
    aspect-ratio: auto;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 124px) !important;
    margin: 0 !important;
    z-index: 850;
  }
}


/* Daughter-window community chat room. */
.chat-room-body {
  background: #eef3f7;
  background-image: none;
  min-height: 100vh;
}

.chat-room-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.chat-room-users,
.chat-room-main {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  min-height: 0;
}

.chat-room-users {
  overflow: hidden;
}

.chat-room-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #d9e2ea;
}

.chat-room-header h1 {
  color: #14324d;
  font-size: 1.15rem;
  margin: 0;
}

.chat-room-header p,
.chat-room-header span {
  color: #5b6977;
  font-size: 0.82rem;
  margin: 4px 0 0;
}

.chat-users-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding: 10px;
}

.chat-user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  color: #1a2430;
  padding: 8px;
}

.chat-room-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-room-message {
  border-bottom: 1px solid #e6edf3;
  padding: 10px 0;
}

.chat-room-message:first-child {
  padding-top: 0;
}

.chat-room-message div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.chat-room-message strong {
  color: #14324d;
}

.chat-room-message span {
  color: #728191;
  font-size: 0.78rem;
}

.chat-room-message p {
  margin: 6px 0 0;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-room-form {
  display: flex;
  gap: 10px;
  border-top: 1px solid #d9e2ea;
  padding: 12px;
}

.chat-room-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid #c5d2df;
  border-radius: 999px;
  font-size: 1rem;
  padding: 12px 14px;
}

@media (max-width: 700px) {
  .chat-room-shell {
    grid-template-columns: 1fr;
  }

  .chat-users-list {
    max-height: 160px;
  }
}


.chat-room-main-header {
  position: relative;
}

.chat-room-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.chat-room-logo {
  width: 1.5in;
  height: 1.5in;
  object-fit: cover;
  border-radius: 10px;
  background: #0a1622;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  flex: 0 0 1.5in;
}

@media (max-width: 700px) {
  .chat-room-header-actions {
    gap: 8px;
  }

  .chat-room-logo {
    width: 1.1in;
    height: 1.1in;
    flex-basis: 1.1in;
  }
}


/* Chat room dark hacker-style theme and uncropped logo. */
.chat-room-body {
  background: #020604 !important;
  color: #39ff88 !important;
  font-family: "Courier New", Consolas, monospace !important;
}

.chat-room-shell {
  background:
    linear-gradient(rgba(57, 255, 136, 0.035) 50%, rgba(0, 0, 0, 0.035) 50%),
    radial-gradient(circle at top right, rgba(57, 255, 136, 0.12), transparent 36%),
    #020604 !important;
  background-size: 100% 4px, auto, auto !important;
}

.chat-room-users,
.chat-room-main {
  background: rgba(0, 14, 8, 0.96) !important;
  border: 1px solid rgba(57, 255, 136, 0.55) !important;
  color: #39ff88 !important;
  box-shadow: 0 0 18px rgba(57, 255, 136, 0.18), inset 0 0 24px rgba(57, 255, 136, 0.05) !important;
}

.chat-room-header {
  background: rgba(0, 28, 14, 0.94) !important;
  border-bottom: 1px solid rgba(57, 255, 136, 0.45) !important;
}

.chat-room-header h1,
.chat-room-header p,
.chat-room-header span,
.chat-user-row,
.chat-room-message strong,
.chat-room-message span,
.chat-room-message p,
.chat-room-form input {
  color: #39ff88 !important;
  font-family: "Courier New", Consolas, monospace !important;
}

.chat-user-row:hover {
  background: rgba(57, 255, 136, 0.08) !important;
}

.chat-room-message {
  border-bottom: 1px solid rgba(57, 255, 136, 0.22) !important;
}

.chat-room-message p::before {
  content: "> ";
  color: #9dffbf;
}

.chat-room-form {
  background: rgba(0, 20, 10, 0.94) !important;
  border-top: 1px solid rgba(57, 255, 136, 0.45) !important;
}

.chat-room-form input {
  background: #020604 !important;
  border-color: rgba(57, 255, 136, 0.65) !important;
  caret-color: #39ff88 !important;
}

.chat-room-form input::placeholder {
  color: rgba(57, 255, 136, 0.62) !important;
}

.chat-room-body .button,
.chat-room-body .button.secondary {
  background: #063d20 !important;
  border: 1px solid rgba(57, 255, 136, 0.7) !important;
  color: #39ff88 !important;
  font-family: "Courier New", Consolas, monospace !important;
  text-shadow: 0 0 5px rgba(57, 255, 136, 0.45) !important;
}

.chat-room-logo {
  width: 1.5in !important;
  height: 1.5in !important;
  flex: 0 0 1.5in !important;
  object-fit: contain !important;
  object-position: center center !important;
  padding: 6px !important;
  border: 1px solid rgba(57, 255, 136, 0.65) !important;
  border-radius: 10px !important;
  background: #000 !important;
  box-shadow: 0 0 14px rgba(57, 255, 136, 0.28) !important;
}

@media (max-width: 700px) {
  .chat-room-logo {
    width: 1.5in !important;
    height: 1.5in !important;
    flex-basis: 1.5in !important;
  }
}


/* Final chat logo placement: no outline, no glow, logo occupies the old refresh area. */
.chat-room-header-actions {
  justify-content: flex-end !important;
}

.chat-room-logo {
  object-fit: contain !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 4px !important;
}


/* Chat room online-user thumbnails. */
.chat-user-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 28px;
  background: rgba(57, 255, 136, 0.08);
}

.chat-user-thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(57, 255, 136, 0.4);
  color: #39ff88;
  font-size: 0.82rem;
  font-weight: 700;
}


/* Main page laptop/desktop: narrow the Community Feed so it fits between content and YouTube. */
@media (min-width: 901px) and (max-width: 2000px) {
  body:not(.chat-room-body) .page {
    align-items: flex-start !important;
    padding-right: calc(clamp(556px, 39vw, 736px) + 316px) !important;
  }

  body:not(.chat-room-body) .home-columns,
  body:not(.chat-room-body) .home-columns:has(.home-sidebar):not(:has(.home-chat-panel)),
  body:not(.chat-room-body) .home-columns:not(:has(.home-sidebar)):not(:has(.home-chat-panel)) {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: min(560px, calc(100vw - clamp(556px, 39vw, 736px) - 352px)) !important;
    margin-left: 24px !important;
    margin-right: 0 !important;
  }

  body:not(.chat-room-body) .feed-section {
    position: fixed !important;
    top: 100px !important;
    right: calc(16px + clamp(556px, 39vw, 736px) + 136px) !important;
    width: clamp(220px, 14vw, 280px) !important;
    max-width: 280px !important;
    max-height: calc(100vh - 124px) !important;
    overflow-y: auto !important;
    margin: 0 !important;
    z-index: 840 !important;
  }

  body:not(.chat-room-body) .feed-section.is-collapsed {
    width: 190px !important;
    max-height: 48px !important;
  }
}


/* Main page laptop width: keep the feed off the left profile/content column. */
@media (min-width: 901px) and (max-width: 1700px) {
  body:not(.chat-room-body) .feed-section {
    left: calc(24px + min(560px, calc(100vw - clamp(556px, 39vw, 736px) - 352px)) + 48px) !important;
    right: auto !important;
  }
}


/* Main page middle feed: remove frame chrome and suppress horizontal scrolling. */
body:not(.chat-room-body) .feed-section {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

body:not(.chat-room-body) .feed-list {
  min-width: 0 !important;
  width: 100% !important;
  overflow-x: hidden !important;
}

body:not(.chat-room-body) .feed-post {
  background: transparent !important;
  border: 0 !important;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.55) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 14px 0 !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

body:not(.chat-room-body) .feed-post-header,
body:not(.chat-room-body) .feed-body,
body:not(.chat-room-body) .feed-replies,
body:not(.chat-room-body) .feed-reply-form {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

body:not(.chat-room-body) .feed-reply-form input {
  min-width: 0 !important;
  max-width: 100% !important;
}


/* Chat room: fixed-height daughter window, with only internal panes scrolling. */
.chat-room-body {
  height: 100vh !important;
  min-height: 100vh !important;
  overflow: hidden !important;
}

.chat-room-shell {
  height: 100vh !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

.chat-room-users,
.chat-room-main {
  height: calc(100vh - 32px) !important;
  min-height: 0 !important;
  max-height: calc(100vh - 32px) !important;
}

.chat-room-users {
  display: flex !important;
  flex-direction: column !important;
}

.chat-users-list {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.chat-room-main {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.chat-room-main > .chat-room-header,
.chat-room-form {
  flex: 0 0 auto !important;
}

.chat-room-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

@media (max-width: 700px) {
  .chat-room-body {
    overflow: auto !important;
  }

  .chat-room-shell {
    height: auto !important;
    min-height: 100vh !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .chat-room-users,
  .chat-room-main {
    height: auto !important;
    max-height: none !important;
  }

  .chat-users-list {
    max-height: 160px !important;
  }

  .chat-room-messages {
    height: 55vh !important;
    max-height: 55vh !important;
  }
}


/* Chat room: keep Community Chat header and logo pinned above the scrolling messages. */
.chat-room-main > .chat-room-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 5 !important;
  flex: 0 0 auto !important;
}

.chat-room-logo {
  position: relative !important;
  flex-shrink: 0 !important;
}


/* Chat room top header: MyTown-Sheboygan black title band. */
.chat-room-main > .chat-room-header,
.chat-room-main-header {
  background: #000 !important;
  border-bottom-color: rgba(57, 255, 136, 0.65) !important;
}


/* Chat room top header: dark blue/black blend matching the CyberChat logo. */
.chat-room-main > .chat-room-header,
.chat-room-main-header {
  background:
    radial-gradient(circle at 88% 42%, rgba(13, 83, 132, 0.42), transparent 34%),
    linear-gradient(135deg, #02060b 0%, #061727 48%, #000 100%) !important;
  border-bottom-color: rgba(37, 138, 205, 0.62) !important;
}


/* Chat logo: slightly larger opaque blue/black frame so the animated linework is not clipped. */
.chat-room-logo {
  width: 1.72in !important;
  height: 1.72in !important;
  flex: 0 0 1.72in !important;
  object-fit: contain !important;
  object-position: center center !important;
  padding: 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: linear-gradient(135deg, #02060b 0%, #061727 54%, #000 100%) !important;
  opacity: 1 !important;
}

@media (max-width: 700px) {
  .chat-room-logo {
    width: 1.5in !important;
    height: 1.5in !important;
    flex-basis: 1.5in !important;
  }
}


/* Chat logo: fill the surrounding video area with the same blue/black blend. */
.chat-room-header-actions {
  background:
    radial-gradient(circle at 55% 42%, rgba(13, 83, 132, 0.42), transparent 38%),
    linear-gradient(135deg, #02060b 0%, #061727 54%, #000 100%) !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

.chat-room-logo {
  display: block !important;
  background:
    radial-gradient(circle at 55% 42%, rgba(13, 83, 132, 0.42), transparent 38%),
    linear-gradient(135deg, #02060b 0%, #061727 54%, #000 100%) !important;
}

/* Profile photo picker and management grid */
.profile-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.profile-photo-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

[data-theme="dark"] .profile-photo-option {
  background: rgba(255, 255, 255, 0.06);
}

.profile-photo-option.is-active {
  border-color: #2e69a3;
  background: rgba(46, 105, 163, 0.08);
}

.current-profile-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  color: #2e69a3;
  background: #e6f0fa;
  padding: 3px 8px;
  border-radius: 12px;
}

[data-theme="dark"] .current-profile-badge {
  background: #142840;
  color: #64b5f6;
}

.chat-home-btn {
  background: #063d20 !important;
  border: 1px solid rgba(57, 255, 136, 0.7) !important;
  color: #39ff88 !important;
  font-family: "Courier New", Consolas, monospace !important;
  text-shadow: 0 0 5px rgba(57, 255, 136, 0.45) !important;
  border-radius: 6px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-home-btn:hover {
  background: #0a5c30 !important;
  box-shadow: 0 0 8px rgba(57, 255, 136, 0.6) !important;
}

@media (max-width: 700px) {
  .chat-home-btn {
    padding: 6px 12px !important;
    font-size: 0.8rem !important;
  }
}

/* Center the friends feed between the profile/sidebar and right-side tools. */
@media (min-width: 1701px) {
  body:not(.chat-room-body) .page {
    align-items: stretch !important;
    padding-left: clamp(24px, 3vw, 56px) !important;
    padding-right: calc(clamp(556px, 39vw, 736px) + clamp(28px, 3vw, 56px)) !important;
  }

  body:not(.chat-room-body) .home-columns {
    display: grid !important;
    grid-template-columns: minmax(260px, 320px) minmax(360px, 1fr) minmax(240px, 300px) !important;
    gap: clamp(20px, 2vw, 40px) !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  body:not(.chat-room-body) .feed-section {
    position: static !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - 124px) !important;
    margin: 0 !important;
  }

  body:not(.chat-room-body) .home-sidebar { grid-column: 1 !important; grid-row: 1 !important; }
  body:not(.chat-room-body) .home-chat-panel { grid-column: 3 !important; grid-row: 1 !important; }
}

/* Laptop layout: keep the feed central, with the chat tools below the columns. */
@media (min-width: 901px) and (max-width: 1700px) {
  body:not(.chat-room-body) .page {
    align-items: stretch !important;
    padding-left: 18px !important;
    padding-right: calc(clamp(556px, 39vw, 736px) + 32px) !important;
  }

  body:not(.chat-room-body) .home-columns {
    display: grid !important;
    grid-template-columns: minmax(240px, 300px) minmax(320px, 1fr) !important;
    gap: 20px !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  body:not(.chat-room-body) .home-sidebar { grid-column: 1 !important; grid-row: 1 !important; }
  body:not(.chat-room-body) .feed-section {
    position: static !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - 124px) !important;
    margin: 0 !important;
  }

  body:not(.chat-room-body) .home-chat-panel {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
  }
}

/* Keep the desktop friends feed close to a five-inch reading width. */
@media (min-width: 901px) {
  body:not(.chat-room-body) .feed-section {
    width: min(100%, 480px) !important;
    max-width: 480px !important;
    justify-self: center !important;
  }
}

/* On very wide displays (about 23 inches and up), keep contacts and chat at bottom right. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .contacts-widget {
    top: auto !important;
    right: 16px !important;
    bottom: 16px !important;
    width: min(5in, 24vw) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: min(520px, calc(100vh - 32px)) !important;
  }

  body:not(.chat-room-body) .contacts-list {
    max-height: 180px;
  }

  body:not(.chat-room-body) .chat-panel-messages {
    max-height: 260px;
  }
}

/* Keep the Friends list directly below YouTube on desktop-sized screens. */
@media (min-width: 901px) {
  body:not(.chat-room-body) .contacts-widget {
    top: calc(100px + 456px + 12px) !important;
    right: 16px !important;
    bottom: auto !important;
    width: min(5in, 39vw) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 100px - 456px - 28px) !important;
  }
}

.embedded-chat-widget {
  display: none;
}

/* On 23-inch-class and larger displays, keep the full Chat room visible bottom-right. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .camera-feed-widget {
    top: 100px !important;
    right: 16px !important;
    width: min(5in, 24vw) !important;
    height: 456px !important;
    max-width: calc(100vw - 32px) !important;
    max-height: none !important;
  }

  body:not(.chat-room-body) .contacts-widget {
    top: calc(100px + 456px + 12px) !important;
    right: 16px !important;
    width: min(5in, 24vw) !important;
    max-height: 220px !important;
  }

  body:not(.chat-room-body) .embedded-chat-widget {
    position: fixed;
    display: flex;
    flex-direction: column;
    right: 16px;
    bottom: 16px;
    width: min(5in, 24vw);
    height: min(560px, 42vh);
    max-width: calc(100vw - 32px);
    background: #0a1622;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 905;
  }

  body:not(.chat-room-body) .embedded-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: #14324d;
    color: #fff;
    font-size: 0.82rem;
  }

  body:not(.chat-room-body) .embedded-chat-header span {
    color: #cfe3ff;
    font-size: 0.72rem;
  }

  body:not(.chat-room-body) .embedded-chat-widget iframe {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
    background: #eef3f7;
  }
}

/* Stack the large-screen right rail: YouTube, Friends, then full Chat. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    top: calc(100px + 456px + 220px + 36px) !important;
    bottom: 16px !important;
    height: auto !important;
    min-height: 280px !important;
    max-height: calc(100vh - 100px - 456px - 220px - 52px) !important;
  }
}

/* Chat room: pin the title/logo and composer; only the message list may scroll. */
.chat-room-main {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.chat-room-main > .chat-room-header,
.chat-room-main > .chat-room-form {
  flex: 0 0 auto !important;
  position: relative !important;
  z-index: 6 !important;
}

.chat-room-main > .chat-room-header {
  position: sticky !important;
  top: 0 !important;
}

.chat-room-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

/* Add about one inch of usable height to the embedded chat on large displays. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    height: min(656px, 50vh) !important;
  }

  body:not(.chat-room-body) .embedded-chat-widget .chat-room-body,
  body:not(.chat-room-body) .embedded-chat-widget iframe {
    min-height: 0;
  }
}

/* Embedded chat frame: narrow iframe widths must still keep header and composer fixed. */
.embedded-chat-room-body {
  height: 100% !important;
  min-height: 100% !important;
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-shell {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
  padding: 10px !important;
  grid-template-columns: 190px minmax(0, 1fr) !important;
}

.embedded-chat-room-body .chat-room-users,
.embedded-chat-room-body .chat-room-main {
  height: calc(100% - 20px) !important;
  min-height: 0 !important;
  max-height: calc(100% - 20px) !important;
}

.embedded-chat-room-body .chat-room-main {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-main > .chat-room-header,
.embedded-chat-room-body .chat-room-main > .chat-room-form {
  flex: 0 0 auto !important;
  position: relative !important;
  z-index: 10 !important;
}

.embedded-chat-room-body .chat-room-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

@media (max-width: 700px) {
  .embedded-chat-room-body .chat-room-shell {
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
    grid-template-columns: 1fr !important;
  }

  .embedded-chat-room-body .chat-room-users {
    display: none !important;
  }

  .embedded-chat-room-body .chat-room-main {
    height: 100% !important;
    max-height: 100% !important;
  }

  .embedded-chat-room-body .chat-room-messages {
    height: auto !important;
    max-height: none !important;
  }
}

/* One more inch of height for the large-screen embedded chat frame. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    height: min(752px, calc(100vh - 100px - 456px - 220px - 52px)) !important;
  }
}

/* Embedded Chat is three compartments: fixed header, scrolling messages, fixed composer. */
.embedded-chat-room-body,
.embedded-chat-room-body .chat-room-shell,
.embedded-chat-room-body .chat-room-main {
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-main {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
}

.embedded-chat-room-body .chat-room-fixed-header,
.embedded-chat-room-body .chat-room-fixed-composer {
  position: relative !important;
  z-index: 20 !important;
  flex: none !important;
}

.embedded-chat-room-body .chat-room-scroll-region {
  grid-row: 2 !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
}

.embedded-chat-room-body .chat-home-btn {
  display: none !important;
}

/* Large embedded frame: the height is owned by the outer frame, not clipped by the rail. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    height: min(8.5in, calc(100vh - 100px - 456px - 220px - 36px)) !important;
    max-height: none !important;
    min-height: 752px !important;
  }

  body:not(.chat-room-body) .embedded-chat-widget iframe {
    height: 100% !important;
    min-height: 0 !important;
  }
}

/* 32-inch and larger display fix: anchor the embedded room from the top and give its iframe a definite canvas. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    top: calc(100px + 456px + 220px + 36px) !important;
    bottom: auto !important;
    height: min(8.5in, calc(100vh - 100px - 456px - 220px - 52px)) !important;
    min-height: 752px !important;
    max-height: none !important;
  }

  body:not(.chat-room-body) .embedded-chat-widget iframe {
    display: block !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
  }
}

/* The iframe needs a definite viewport height for the middle grid track to scroll. */
.embedded-chat-room-body {
  width: 100vw !important;
  height: 100vh !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-shell {
  width: 100% !important;
  height: 100vh !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-main {
  height: calc(100vh - 20px) !important;
  min-height: 0 !important;
  max-height: calc(100vh - 20px) !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  overflow: hidden !important;
}

.embedded-chat-room-body .chat-room-scroll-region {
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
}

/* Embedded iframe: size the internal chat canvas to the iframe, not the monitor viewport. */
html:has(body.embedded-chat-room-body),
html:has(body.embedded-chat-room-body) body.embedded-chat-room-body {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

body.embedded-chat-room-body .chat-room-shell {
  height: calc(100% - 20px) !important;
  min-height: 0 !important;
  max-height: calc(100% - 20px) !important;
}

body.embedded-chat-room-body .chat-room-main {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
}

body.embedded-chat-room-body .chat-room-scroll-region {
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
}

/* Move the complete embedded Chat window upward by one inch on 23-inch-plus displays. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    top: calc(100px + 456px + 220px + 36px - 1in) !important;
    bottom: auto !important;
  }
}

/* Reduce the complete embedded Chat window by two inches vertically. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    height: 6.5in !important;
    min-height: 0 !important;
    max-height: 6.5in !important;
  }

  body:not(.chat-room-body) .embedded-chat-widget iframe {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
  }
}

/* Reduce the complete embedded Chat window by one additional half inch. */
@media (min-width: 2200px) {
  body:not(.chat-room-body) .embedded-chat-widget {
    height: 6in !important;
    max-height: 6in !important;
  }
}
