:root {
  --bg: #1e1f22;
  --bar: #16171a;
  --border: #2b2d31;
  --text: #e4e4e7;
  --muted: #71717a;
  --green: #22c55e;
  --cyan: #38bdf8;
  --amber: #f59e0b;
  --red: #ef4444;
  --font: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

.term-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
}

/* Top bar */
.term-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.bar-left, .bar-right, .mode-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  color: var(--green);
  font-weight: 700;
}

.tab, .cmd-btn {
  color: var(--muted);
  font-size: 13px;
  transition: color 0.12s;
}

.tab:hover, .cmd-btn:hover {
  color: var(--text);
}

.tab.active, .cmd-btn.active {
  color: var(--green);
  font-weight: 700;
}

.cmd-btn.accent {
  color: var(--cyan);
}

.cmd-btn.danger:hover {
  color: var(--red);
}

.online-stat {
  font-size: 12px;
  color: var(--muted);
}

/* Sub-bar */
.sub-bar {
  padding: 7px 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.sub-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sub-group[hidden] {
  display: none;
}

.sub-status {
  color: var(--muted);
  font-size: 12px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-input {
  width: 96px;
  padding: 2px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}

.inline-input.code-in {
  width: 64px;
  text-transform: uppercase;
}

.inline-input:focus {
  border-bottom-color: var(--green);
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-actions[hidden] {
  display: none;
}

.sep {
  color: var(--border);
}

.accent-text {
  color: var(--green);
}

.public-rooms-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

/* Terminal body */
.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 28px;
  cursor: text;
  scrollbar-width: none;
}

.term-body::-webkit-scrollbar {
  display: none;
}

.term-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  word-break: break-word;
  white-space: pre-wrap;
}

.log-sys {
  color: var(--muted);
  font-size: 13px;
}

.log-err {
  color: var(--red);
  font-size: 13px;
}

.prompt-user.me {
  color: var(--green);
  font-weight: 700;
}

.prompt-user.them {
  color: var(--cyan);
  font-weight: 700;
}

.prompt-user.other {
  color: var(--amber);
  font-weight: 700;
}

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

.map-link {
  color: var(--cyan);
  text-decoration: underline;
  margin-left: 6px;
}

.term-img-wrap {
  margin-top: 4px;
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  max-width: 280px;
}

.term-img {
  display: block;
  max-width: 280px;
  max-height: 220px;
  object-fit: contain;
  transition: filter 0.18s ease;
}

.term-img.blurred {
  filter: blur(16px) brightness(0.7);
}

.img-hint {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 6px;
  background: var(--bar);
}

/* Live input line with green block cursor */
.prompt-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
}

.prompt-line .prompt-user {
  flex-shrink: 0;
}

.input-mirror-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.input-mirror {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.block-cursor {
  display: inline-block;
  width: 8px;
  height: 1.15em;
  background: #00e639;
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.prompt-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  caret-color: transparent;
}

@media (max-width: 600px) {
  html, body {
    font-size: 13px;
  }
  .term-bar {
    height: auto;
    min-height: 36px;
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .bar-left, .bar-right {
    flex-wrap: wrap;
    gap: 8px;
  }
  .cmd-btn, .tab {
    padding: 4px 6px;
  }
  .term-img-wrap, .term-img {
    max-width: min(280px, 85vw);
  }
  .prompt-input, .inline-input {
    font-size: 16px;
  }
  .term-body {
    padding: 10px 12px calc(24px + env(safe-area-inset-bottom));
  }
}
