* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  --red: #d20b25;
  --background: #101012;
  --panel: #202024;
  --muted: #a0a0a5;
}

body {
  margin: 0;
  background: var(--background);
  color: #ffffff;
}

#chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--red);
  padding: 15px;
  gap: 10px;
}

.chat-header h1 {
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

button {
  cursor: pointer;
  border: none;
  color: white;
  background: transparent;
  font: inherit;
  border-radius: 8px;
  padding: 9px;
}

button:hover {
  background: #ffffff18;
}

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

button:focus-visible,
input:focus-visible {
  outline: 2px solid #ff5367;
}

.header-actions button {
  font-size: 21px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
  background: #171719;
  border-bottom: 1px solid #303030;
  font-size: 12px;
  color: var(--muted);
}

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

.message {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
  overflow-wrap: anywhere;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.nickname {
  font-weight: 700;
  color: #ffff00;
}

.timestamp {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message img {
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
}

.owner-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

#chat-notice {
  color: #ff7585;
  font-size: 12px;
  text-align: center;
}

#chat-notice:not(:empty) {
  padding: 8px;
}

#message-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #303030;
}

#message-input {
  flex: 1;
  min-width: 0;
  background: #252529;
  color: white;
  border: 1px solid #39393d;
  border-radius: 24px;
  padding: 12px;
  font-size: 16px;
}

#emoji-button,
#sticker-button {
  color: #ff4158;
  font-weight: bold;
}

#send-button {
  background: var(--red);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  font-size: 20px;
}

.chat-footer {
  display: flex;
  justify-content: space-between;
  background: #171719;
  padding: 5px 10px;
}

.chat-footer button {
  font-size: 12px;
  color: var(--muted);
}

dialog {
  width: min(420px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  background: #202024;
  color: white;
  border: 1px solid #444;
  border-radius: 16px;
  padding: 20px;
}

dialog::backdrop {
  background: #000000bb;
}

dialog h2 {
  margin-top: 0;
  color: #ff4158;
  font-size: 20px;
}

dialog input,
dialog select,
dialog textarea {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  background: #151517;
  border: 1px solid #444;
  border-radius: 8px;
  color: white;
  font-size: 16px;
}

dialog button {
  background: #303034;
  margin: 4px;
}

dialog button.primary {
  background: var(--red);
}

dialog p {
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 400px) {
  .chat-header {
    padding: 10px;
  }

  #message-form {
    gap: 3px;
    padding: 8px;
  }

  .message {
    padding: 10px;
  }
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.sticker-grid button {
  background: #181818;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 5px;
}

.sticker-grid img {
  width: 100%;
  height: 90px;
  object-fit: contain;
}

.chat-sticker {
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
}


.message-header {
  display: flex;
  align-items: center;
  gap: 7px;
}

.message-header .owner-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
}

.message-actions {
  background: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 5px;
  margin-left: auto;
}

.message-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-sticker {
  display: block;
  margin-top: 6px;
}

.chat-sticker[hidden] {
  display: none;
}


.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.emoji-grid button {
  font-size: 25px;
  background: #181818;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 7px 2px;
  cursor: pointer;
}

.emoji-grid button:hover {
  background: #333;
}


.management-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 12px 0;
}

.management-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid #333;
  overflow-wrap: anywhere;
}

.management-row button {
  flex-shrink: 0;
}


.report-card {
  background: #181818;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.report-card p {
  font-size: 14px;
  margin: 8px 0;
}

.report-card strong {
  color: #ff4545;
}


html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#chat-app {
  height: 100dvh;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

#messages > .message {
  flex-shrink: 0;
}

.chat-header,
.status-bar,
#message-form,
#chat-notice,
.chat-footer {
  flex-shrink: 0;
}

