* { box-sizing: border-box; margin: 0; padding: 0; }

* {
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
*::-webkit-scrollbar {
  width: 6px;          /* vertical */
  height: 6px;         /* horizontal */
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: #333;
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: #777;
}

html, body {
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #111;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 8px 12px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
header .status { font-size: 12px; color: #888; }
header .user { font-weight: 600; display: flex; align-items: center; gap: 6px; }

#userWidget {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 10px;
}

#userInfo {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
}

#createServer {
  border-radius: 50%;
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  vertical-align: middle;
  padding: 0;
  height: 25px;
  width: 25px;
  font-size: 16px;
  aspect-ratio: 1;
}

.room-tabs {
  display: flex;
  flex: 1;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  padding: 0 8px;
  overflow-x: auto;
  min-height: 36px;
  align-self: flex-end;
}
.room-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #999;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  font-family: inherit;
  border: solid 1px #333;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}
.room-tab:hover {
  color: #ddd;
  background: #1a1a1a;
}
.room-tab.active {
  color: #e0e0e0;
  background: #333;
}
.room-tab .tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-tab .tab-close {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  line-height: 14px;
  text-align: center;
  border-radius: 3px;
  color: #666;
  font-size: 14px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.room-tab .tab-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #aaa;
}
.room-tab.private .tab-label::before {
  content: '\f023';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  margin-right: 3px;
  font-size: 10px;
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
}

aside {
  background: #161616;
  border-right: 1px solid #333;
  padding: 10px;
  overflow-y: auto;
  font-size: 13px;
}
aside h3 {
  font-size: 11px;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
aside ul { list-style: none; margin-bottom: 16px; }
aside li {
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
aside li.mod { color: #7dd3fc; }
aside li.you { font-weight: 600; }

hr {
  border: none;
  outline: none;
  height: 1px;
  background: #333;
  margin: 3px 0;
}

.avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
  flex-shrink: 0;
}
.avatar.lg { width: 40px; height: 40px; }
.msg .meta .avatar { width: 25px; height: 25px; }

.flair {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #333;
  color: #a5b4fc;
  font-weight: 500;
  margin-left: 2px;
}

#account-panel {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a2a2a;
}
#account-panel .preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
#account-panel input {
  width: 100%;
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 5px 7px;
  border-radius: 3px;
  margin-bottom: 6px;
  font-size: 12px;
}
#account-panel .row { display: flex; gap: 4px; }
#account-panel .row button { flex: 1; font-size: 12px; padding: 5px; }

#chat-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  padding: 6px 10px;
  background: #1e1e1e;
  border-radius: 6px;
  position: relative;
}
.msg:after, .reply-preview:after {
  content: " ";
  position: absolute;
  left: -1px;
  top: 0;
  width: 5px;
  height: 100%;
  border-radius: 2px 0 0 2px;
  background-color: #333;
}
.msg.own:after { background-color: #3b82f6; }

.msg .meta {
  font-size: 11px;
  color: #777;
  margin-bottom: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.msg .meta .name { color: #a5b4fc; font-weight: 600; }
.msg .meta .edited { color: #666; font-style: italic; }

.msg-reply {
  display: flex;
  gap: 8px;
  margin: 4px 0 6px;
  padding: 6px 10px;
  background: #1a1a1a;
  border-left: 3px solid #333;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  max-width: 100%;
}
.msg-reply:hover { background: #222; }
.msg-reply-meta {
  font-size: 11px;
  color: #93c5fd;
  font-weight: 600;
  margin-bottom: 2px;
}
.msg-reply-text {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.msg .content {
  word-break: break-word;
  line-height: 1.45;
}
.msg .content p { margin: 0 0 0.4em; }
.msg .content p:last-child { margin-bottom: 0; }
.msg .content ul,
.msg .content ol { margin: 0.3em 0 0.3em 1.2em; }
.msg .content code {
  background: #2a2a2a;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.msg .content pre {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px;
  overflow-x: auto;
  margin: 0.4em 0;
}
.msg .content pre code {
  background: none;
  padding: 0;
}
.msg .content a { color: #7dd3fc; }
.msg .content blockquote {
  border-left: 3px solid #444;
  margin: 0.4em 0;
  padding-left: 10px;
  color: #aaa;
}
.msg .content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 4px;
  margin: 4px 0;
}

.msg .actions { margin-top: 4px; font-size: 11px; }
.msg .actions button {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 0 4px;
}
.msg .actions button:hover { color: #aaa; }

#composer {
  padding: 10px;
  border-top: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/*
#reply-preview {
  font-size: 10pt;
}
.reply-preview-body {
  
}
.reply-preview-label {

}
.reply-preview-text {
  font-family: inherit;
  font-size: 8pt;
  margin: 10px;
}
#reply-preview-cancel {
  all: unset;
  background: transparent;
  border: none;
  color: inherit;
  display: flex;
  color: #F33;
  font-size: 16px;
  padding-left: 10px;
}
*/
.reply-preview {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #1a1a1a;
  position: relative;
  border-radius: 6px;
  font-size: 12px;
}
.reply-preview-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.reply-preview-label { color: #93c5fd; }
.reply-preview-text {
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#reply-preview-cancel {
  background: transparent;
  border: none;
  color: #888;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
#reply-preview-cancel:hover { color: #eee; }

.msg.highlight-flash {
  animation: msg-flash 1.2s ease;
}
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  30% { background: rgba(59, 130, 246, 0.18); }
}


#composer .composer-row {
  display: flex;
  gap: 8px;
}
#composer textarea {
  flex: 1;
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 8px 10px;
  border-radius: 4px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  overflow-y: hidden;
  min-height: 38px;
  max-height: 160px;
}
#composer textarea:focus { border-color: #555; }

.emoji-tray {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.emoji-tray[hidden] { display: none; }
#emoji-search {
  width: 100%;
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 6px 8px;
  border-radius: 4px;
  outline: none;
  font-size: 13px;
}
#emoji-search:focus { border-color: #555; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  overflow-y: auto;
  max-height: 160px;
}
.emoji-grid button.emoji-pick {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}
.emoji-grid button.emoji-pick:hover {
  background: #2a2a2a;
}
.emoji-grid button.emoji-pick img, .emoji {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}
.msg .content .emoji {
  all: unset;
  border-radius: 0;
  height: 1.35em;
  width: auto;
  max-height: 28px;
  vertical-align: -0.25em;
  display: inline;
  margin: 0 1px;
}

button {
  background: #2563eb; /* bootstrap blue <3 */
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: #1d4ed8; }
button.secondary { background: #333; }
button.secondary:hover { background: #444; }
button.danger { background: #b91c1c; }
button.danger:hover { background: #991b1b; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#btn-send, #btn-emoji {
  font-size: 12pt;
  min-height: 38px;
  background: transparent;
  border: none;
  padding: 5px
}

.reaction-picker {
  background: #2a2a2a;
  border-radius: 4px;
  box-shadow: 2px 2px 5px #000;
  overflow: auto;
  max-width: 500px;
}
.react-pick {
  background: transparent !important;
}
.reaction-chip {
  background: #222;
  box-sizing: border-box;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.reaction-chip + .reaction-chip {
  margin-left: 5px;
}
.reaction-chip.mine {
  border: solid 2px #111;
  background: #353535;
}
.tinyEmoji {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: inline;
}
.reaction-picker .tinyEmoji {
  transition: transform 250ms linear;
}
.reaction-picker .tinyEmoji:hover {
  transform: scale(3);
}

/* Auth overlay */
#auth {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
#auth.hidden { display: none; }
#auth-box {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 24px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#auth-box h1 { font-size: 18px; margin-bottom: 4px; }
#auth-box input {
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 8px 10px;
  border-radius: 4px;
  width: 100%;
}
#auth-box .row { display: flex; gap: 8px; }
#auth-box .row button { flex: 1; }
#auth-error { color: #f87171; font-size: 13px; min-height: 18px; }

/* Room bar */
#room-bar {
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
#room-bar input {
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 6px 8px;
  border-radius: 4px;
  width: 140px;
}
#room-info, #start { font-size: 12px; color: #888; margin-left: auto; margin: 8px 12px; }

/* System notices */
.system {
  text-align: center;
  font-size: 12px;
  color: #666;
  padding: 4px 0;
}

/* icons */
.ico {
  user-select: none;
}
