:root {
  --bg: #050805;
  --bg-elev: #0a0f0a;
  --surface: #0c120c;
  --surface-2: #121a12;
  --border: #1f331f;
  --text: #c8f0c8;
  --muted: #6a8a6a;
  --accent: #33ff66;
  --accent-press: #22cc55;
  --good: #33ff66;
  --warn: #d4c05a;
  --danger: #ff6b6b;
  --me: #14331a;
  --them: #101610;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Consolas", "Cascadia Mono", "SF Mono", ui-monospace, monospace;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

#app,
.screen {
  min-height: 100%;
}

.screen[hidden] {
  display: none !important;
}

.console-screen {
  display: block;
  padding: 0;
  height: 100vh;
}

.app-login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.app-card {
  width: min(380px, 100%);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 22px;
}

.app-title {
  color: var(--accent);
  letter-spacing: 0.16em;
  margin-bottom: 16px;
}

.field {
  display: block;
  margin: 12px 0;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
}

.err-line {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 10px;
}

.composer .btn.primary {
  width: auto;
  white-space: nowrap;
}

.btn.ghost {
  width: 100%;
  margin-top: 8px;
}

.term {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
}

.term-out {
  flex: 1;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.term-out .line {
  margin: 0 0 2px;
}

.term-out .cmd {
  color: var(--accent);
}

.term-out .err {
  color: var(--danger);
}

.term-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 0;
}

.prompt {
  color: var(--accent);
  user-select: none;
}

#term-in {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  caret-color: var(--accent);
  padding: 0;
}

.chat-screen {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  background: var(--bg);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-head,
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.eyebrow,
.peer-status,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.me-login,
.peer-login {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.search-wrap {
  display: flex;
  gap: 6px;
  padding: 12px;
}

.search-wrap input,
.composer textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
  outline: none;
}

.search-wrap input:focus,
.composer textarea:focus {
  border-color: var(--accent);
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #031006;
  border-color: var(--accent);
  font-weight: 650;
}

.btn.ghost {
  color: var(--muted);
}

.btn.sm {
  padding: 8px 10px;
  white-space: nowrap;
}

.btn.icon {
  width: 42px;
  min-width: 42px;
}

.btn.ghost {
  color: var(--muted);
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
}

.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.contact:hover,
.contact.active {
  background: var(--surface-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.online {
  background: var(--good);
}

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.peer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-chat {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
}

.bubble {
  max-width: min(72%, 640px);
  padding: 10px 12px;
  background: var(--them);
  align-self: flex-start;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
}

.bubble.me {
  background: var(--me);
  align-self: flex-end;
}

.bubble .meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.bubble img,
.bubble audio,
.bubble video {
  display: block;
  max-width: min(360px, 100%);
  margin-top: 6px;
}

.bubble img {
  cursor: zoom-in;
}

.bubble.system {
  align-self: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.composer[hidden] {
  display: none !important;
}

.composer textarea {
  resize: none;
  min-height: 42px;
  max-height: 140px;
}

.composer .btn.primary {
  width: auto;
  white-space: nowrap;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  z-index: 10;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 800px) {
  .chat-screen {
    grid-template-columns: 1fr;
  }
}
