/* ===== RESET ===== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== THEME: CMD / MS-DOS STYLE ===== */

:root {
  --bg-main: #0c0c0c;
  --bg-panel: #111111;
  --bg-panel-soft: #151515;
  --border-subtle: #262626;
  --border-strong: #333333;
  --text-main: #f2f2f2;
  --text-muted: #8c8c8c;
  --text-strong: #ffffff;
  --accent: #ffffff;
  --accent-soft: #c0c0c0;
  --accent-warning: #ffd166;
  font-family: Consolas, "Cascadia Mono", "Lucida Console", monospace;
  font-size: 14px;
  color-scheme: dark;
}

html,
body {
  height: 100%;
  width: 100%;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: Consolas, "Cascadia Mono", "Lucida Console", monospace;
}

/* ===== APP LAYOUT ===== */

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 1100px;
  height: 92vh;
  display: flex;
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
  box-shadow: 0 0 0 1px #000000;
}

/* ===== SIDEBAR: USER LIST ===== */

#sidebar {
  width: 230px;
  border-right: 1px solid var(--border-subtle);
  background: #050505;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.sidebar-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.room-title {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.user-count {
  font-size: 11px;
  margin-top: 2px;
  color: var(--text-muted);
}

.user-count span {
  color: var(--text-main);
}

/* user list */
#user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  font-size: 12px;
}

#user-list li {
  padding: 3px 4px;
  border-radius: 2px;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#user-list li:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

#user-list li.user-me {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-strong);
  font-weight: 600;
}

/* ===== TERMINAL PANEL ===== */

#terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}

/* Codename setup bar */

#codename-setup {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

#codename-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.codename-label {
  font-size: 12px;
  color: var(--accent-soft);
  letter-spacing: 0.08em;
}

#codename-input {
  flex: 1;
  background: #050505;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 3px 5px;
  font: inherit;
}

#codename-input::placeholder {
  color: var(--text-muted);
}

#codename-button {
  padding: 3px 8px;
  background: #050505;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#codename-button:hover {
  background: #151515;
  border-color: var(--border-strong);
}

.codename-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Pinned bar */

.pinned-bar {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  font-size: 12px;
  display: flex;
  gap: 4px;
  align-items: baseline;
}

.pinned-label {
  color: var(--accent-warning);
  font-weight: 600;
}

.pinned-text {
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== MESSAGES AREA ===== */

.messages {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  background: var(--bg-main);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.messages::-webkit-scrollbar {
  width: 8px;
}
.messages::-webkit-scrollbar-thumb {
  background: #323232;
}

/* Messages from chat.js: .msg + who class */

.msg {
  margin-bottom: 4px;
  font-family: inherit;
  color: var(--text-main);
}

.msg.system {
  color: var(--text-muted);
}

.msg.user {
  color: var(--text-main);
}

.msg.bot {
  color: var(--accent-soft);
}

/* hyperlinks generated in boxed messages */
.chat-link {
  color: var(--accent);
  text-decoration: underline;
}

/* Chat images */

.chat-image {
  max-width: 100%;
  max-height: 260px;
  display: block;
  margin-top: 4px;
  border: 1px solid var(--border-subtle);
}

/* blinking cursor on typewriter messages */
.typing {
  border-right: 2px solid var(--accent);
  animation: blink 0.8s steps(1) infinite;
}

.cursor {
  border-right: 2px solid var(--accent);
  animation: blink 0.8s steps(1) infinite;
}

@keyframes blink {
  0% {
    border-color: var(--accent);
  }
  50% {
    border-color: transparent;
  }
  100% {
    border-color: var(--accent);
  }
}

/* ===== INPUT ROW ===== */

#chat-form {
  border-top: 1px solid var(--border-subtle);
  background: #050505;
}

#input-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  gap: 8px;
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font: inherit;
  padding: 3px 2px;
}

#input::placeholder {
  color: var(--text-muted);
}

/* image upload button */

#image-input {
  width: 80px;
  color: var(--text-muted);
  font-size: 11px;
  background: #111111;
  border: 1px solid var(--border-subtle);
  padding: 3px;
  cursor: pointer;
}

#image-input::file-selector-button {
  font: inherit;
  font-size: 11px;
  background: #151515;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  cursor: pointer;
}

#image-input:hover::file-selector-button {
  background: #222222;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 900px) {
  #app {
    flex-direction: column;
    height: 96vh;
  }

  #sidebar {
    width: 100%;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  #user-list {
    display: flex;
    flex-wrap: wrap;
    max-height: 60px;
  }

  #user-list li {
    margin-right: 8px;
    margin-bottom: 4px;
  }
}

@media (max-width: 600px) {
  .codename-label {
    display: none;
  }

  #codename-form {
    flex-wrap: wrap;
  }

  .pinned-text {
    white-space: normal;
  }
}
