* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #fff8f3 0%, #f5f7fb 28%);
  margin: 0;
  padding: 14px;
}

.brand-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #a94d1f;
  font-weight: 600;
}

.brand-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.brand-icon.tiny {
  width: 14px;
  height: 14px;
}

.brand-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  max-width: 1380px;
  margin: 0 auto;
  align-items: start;
}

.chat-main {
  min-width: 0;
}

.side-widgets {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.box {
  width: min(520px, 96vw);
  margin: 40px auto;
  padding: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(20, 40, 80, 0.08);
}

.room-admin-box {
  width: min(1100px, 96vw);
}

.admin-top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.admin-top-actions form {
  margin: 0;
}

.tiny-link-btn {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d7dbe6;
  background: #fff;
  color: #24427d;
  text-decoration: none;
  font-size: 12px;
}

h2,
h3 {
  margin-top: 0;
}

input,
select,
button {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid #d7dbe6;
  font-size: 16px;
}

.field-label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: #334155;
}

button {
  background: #1456d8;
  color: #fff;
  border: none;
  cursor: pointer;
}

button:hover {
  background: #0d46b8;
}

.danger-btn {
  background: #c93b3b;
}

.danger-btn:hover {
  background: #a92f2f;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 12px;
}

.header-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.header-item {
  background: #fffaf5;
  border: 1px solid #f4ddcf;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 0;
}

.header-label {
  display: block;
  font-size: 11px;
  color: #5c6c8a;
  margin-bottom: 3px;
}

.header-value {
  display: block;
  font-size: 13px;
  color: #1e2a45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connectivity-widget,
.members-widget {
  width: 100%;
  background: rgba(17, 27, 47, 0.95);
  color: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.connectivity-title {
  font-size: 12px;
  opacity: 0.92;
  margin-bottom: 6px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 4px 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.status-dot.online {
  background: #24d06c;
}

.status-dot.offline {
  background: #f34a4a;
}

.status-footer {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.9;
}

.members-list {
  max-height: 260px;
  overflow-y: auto;
}

.notify-link {
  display: inline-block;
  margin-top: 6px;
  color: #9dd1ff;
  text-decoration: underline;
  font-size: 12px;
}

.member-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.member-name {
  font-size: 13px;
  font-weight: 600;
}

.member-time {
  font-size: 12px;
  opacity: 0.85;
}

.chat-box {
  height: min(64vh, 560px);
  overflow-y: auto;
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e6e9f2;
}

.older-marker {
  text-align: center;
  color: #2452c6;
  font-size: 13px;
  margin: 2px 0 10px;
  cursor: pointer;
  user-select: none;
}

.older-marker.hidden {
  display: none;
}

.bubble {
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 12px;
  max-width: 76%;
  word-break: break-word;
}

.me {
  background: #daf1dc;
  margin-left: auto;
  text-align: right;
}

.other {
  background: #eef1f6;
}

.system-line {
  margin: 10px 0;
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  background: #f0f4ff;
  color: #304b7a;
}

.upload-progress {
  border: 1px dashed #37a853;
}

.upload-progress.failed {
  border-color: #d04b4b;
}

.upload-meter {
  margin-top: 6px;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.15);
  overflow: hidden;
}

.upload-meter-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  background-size: 180% 100%;
  animation: upload-stripe 1.1s linear infinite;
  transition: width 0.2s ease;
}

.upload-progress.failed .upload-meter-fill {
  background: linear-gradient(90deg, #c53d3d, #e56c6c);
  animation: none;
}

@keyframes upload-stripe {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.file-link {
  color: #134ad7;
  text-decoration: underline;
}

.message-form {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}

#messageInput {
  flex: 1;
  margin-top: 0;
}

#sendBtn {
  width: 168px;
  margin-top: 0;
}

.attach-btn {
  width: 28px;
  min-width: 28px;
  text-align: center;
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid #d7dbe6;
  background: #f7f9ff;
  color: #264a99;
  cursor: pointer;
  user-select: none;
}

.attach-btn.active {
  background: #22a85c;
  color: #fff;
  border-color: #1d954f;
  min-width: 58px;
  width: auto;
  padding: 9px 6px;
}

.hidden-file-input {
  display: none;
}

.secondary-btn,
.logout-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
}

.secondary-btn {
  background: #4f5e79;
}

.secondary-btn.active-notify {
  background: #1f9c57;
}

.logout-form {
  margin: 0;
}

.logout-icon-btn {
  width: 38px;
  min-width: 38px;
  margin-top: 0;
  padding: 8px 0;
  border-radius: 999px;
  background: #f25e4f;
  line-height: 1;
  font-size: 16px;
}

.notify-float-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 1100;
  width: auto;
  min-width: 170px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 999px;
  background: #4f5e79;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.notify-float-btn.hidden {
  display: none;
}

.error {
  color: #b20e0e;
  margin-top: 10px;
  min-height: 18px;
}

.info {
  color: #115f35;
  background: #e6f8ef;
  border: 1px solid #bfead0;
  border-radius: 8px;
  padding: 8px 10px;
}

.hint {
  color: #55627b;
  font-size: 13px;
  margin: 6px 0 8px;
}

.admin-section {
  margin-top: 14px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.config-grid .field-full {
  grid-column: 1 / -1;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  max-width: 300px;
  overflow-wrap: anywhere;
}

.password-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}

.password-row input {
  margin-top: 0;
}

.password-row.full-width {
  flex: 1;
}

.toggle-visibility {
  margin-top: 0;
  width: 42px;
  min-width: 42px;
  padding: 9px 0;
  border: 1px solid #cfd7e6;
  background: #eef3ff;
  color: #1d417f;
}

.rooms-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e6e9f2;
  border-radius: 10px;
}

.rooms-table th,
.rooms-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #eef1f7;
  vertical-align: top;
}

.status-pill {
  display: inline-block;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
}

.status-pill.active {
  background: #ddf7e6;
  color: #1b7f48;
}

.status-pill.disabled {
  background: #f3f4f6;
  color: #666;
}

.room-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-form input {
  margin-top: 0;
  min-width: 150px;
}

.small-inline input {
  display: none;
}

.tiny-btn {
  width: auto;
  margin-top: 0;
  padding: 7px 10px;
  font-size: 12px;
}

.room-create-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.room-create-form input {
  margin-top: 0;
}

.room-create-form button {
  width: auto;
  min-width: 120px;
  margin-top: 0;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .side-widgets {
    position: static;
    order: -1;
  }

  .header {
    flex-wrap: wrap;
  }

  .header-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logout-icon-btn {
    width: 34px;
    min-width: 34px;
  }
}

@media (max-width: 680px) {
  body {
    padding: 8px;
  }

  .message-form {
    gap: 6px;
  }

  #sendBtn {
    width: 110px;
  }

  .attach-btn {
    width: 26px;
    min-width: 26px;
  }

  .bubble {
    max-width: 88%;
  }

  .header-grid {
    grid-template-columns: 1fr;
  }

  .notify-float-btn {
    left: 10px;
    right: 10px;
    bottom: 10px;
    min-width: 0;
  }

  .room-create-form,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .inline-form input {
    min-width: 0;
  }
}
