* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #111;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body, html {
  overscroll-behavior: none;
}

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; }

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; }

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
  flex-shrink: 0;
}
.avatar.lg { width: 40px; height: 40px; }
.msg .meta .avatar { width: 18px; height: 18px; }

.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 {
  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 .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%;
  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;
  gap: 8px;
}
#composer input {
  flex: 1;
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 8px 10px;
  border-radius: 4px;
  outline: none;
}
#composer input:focus { border-color: #555; }

button {
  background: #2563eb;
  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; }

/* 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 {
  padding: 8px 12px;
  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 { font-size: 12px; color: #888; margin-left: auto; }

/* System notices */
.system {
  text-align: center;
  font-size: 12px;
  color: #666;
  padding: 4px 0;
}
