:root {
  color-scheme: dark;
  --bg: #141414;
  --panel: #1b1b1b;
  --panel-2: #202020;
  --line: #404040;
  --line-soft: #2d2d2d;
  --text: #d7d7d7;
  --muted: #858585;
  --accent: #d29b45;
  --home: #89c46f;
  --varm: #6ba7d6;
  --danger: #e07070;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 14px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

button, input, textarea { font: inherit; }

a { color: #a8bee0; text-decoration: none; }
a:hover { color: #d5e3f7; text-decoration: underline; }

.topbar {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #191919;
}

.brand { color: var(--accent); font-weight: 700; letter-spacing: .04em; }
.brand:hover { text-decoration: none; }

.identity {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.identity-home { color: var(--home); }
.identity-varm { color: var(--varm); }

.shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: calc(100vh - 38px);
}

.sidebar {
  padding: 12px;
  border-right: 1px solid var(--line);
  background: #181818;
}

.section-label, label, .panel-title {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.topic-list { margin: 0 -5px 16px; }

.topic-link {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 7px;
  color: var(--text);
  border-left: 2px solid transparent;
}

.topic-link:hover { background: var(--panel-2); text-decoration: none; }
.topic-link.is-active { border-left-color: var(--accent); background: #24211c; }
.topic-link small { color: var(--muted); }

.field-row { display: flex; gap: 6px; }

input, textarea {
  width: 100%;
  color: var(--text);
  background: #101010;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
}

input { min-height: 30px; padding: 4px 7px; }
textarea { padding: 8px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--accent); }

button {
  min-height: 30px;
  padding: 4px 9px;
  color: var(--text);
  background: #282828;
  border: 1px solid #555;
  border-radius: 0;
  cursor: pointer;
}

button:hover { background: #333; border-color: #777; }
button:disabled { cursor: wait; opacity: .55; }

.new-topic, .devices, .logout {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.devices summary { color: var(--muted); cursor: pointer; margin-bottom: 8px; }
.invite-result { margin-top: 10px; }
.logout button { width: 100%; color: var(--muted); }
.empty-small, .empty-stream, .muted { color: var(--muted); }

.workspace { min-width: 0; }

.topic-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.prompt { color: var(--accent); }
.stream { padding: 10px 14px 4px; }

.message {
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line-soft);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.message-meta time { color: var(--muted); font-size: 12px; }
.message-meta .ghost { margin-left: auto; }

.ghost {
  min-height: auto;
  padding: 1px 5px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line-soft);
  font-size: 11px;
}

.message-text { max-width: 980px; overflow-wrap: anywhere; }
.message-text p { margin: 0 0 8px; }
.message-text h2, .message-text h3, .message-text h4, .message-text h5 { margin: 12px 0 6px; font-size: 1em; color: #ededed; }
.message-text h2::before, .message-text h3::before, .message-text h4::before, .message-text h5::before { content: "# "; color: var(--accent); }
.message-text ul { margin: 5px 0 8px 20px; padding: 0; }
.message-text blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--accent); color: #bfbfbf; }
.message-text code { padding: 1px 4px; color: #dfc58d; background: #0d0d0d; }
.message-text pre { margin: 8px 0; padding: 9px; overflow: auto; background: #0d0d0d; border: 1px solid var(--line-soft); }
.message-text pre code { padding: 0; }

.message-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.image-frame { display: block; max-width: min(520px, 100%); border: 1px solid var(--line); }
.image-frame img { display: block; max-width: 100%; max-height: 480px; object-fit: contain; }

.composer {
  position: sticky;
  bottom: 0;
  margin: 12px 14px 14px;
  padding: 10px;
  background: #191919;
  border: 1px solid var(--line);
  box-shadow: 0 -12px 24px rgba(0,0,0,.25);
}

.paste-zone {
  margin-top: 6px;
  padding: 5px 7px;
  color: var(--muted);
  border: 1px dashed var(--line);
  font-size: 12px;
}

.paste-zone.is-active { color: var(--accent); border-color: var(--accent); }
.image-queue { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.queued-image { position: relative; width: 88px; height: 66px; border: 1px solid var(--line); background: #0c0c0c; }
.queued-image img { width: 100%; height: 100%; object-fit: cover; }
.queued-image button { position: absolute; top: 1px; right: 1px; min-height: 20px; padding: 0 5px; background: #111; }

.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.status { color: var(--muted); font-size: 12px; }
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--home); }

.claim, .empty-state {
  min-height: calc(100vh - 38px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.panel { width: min(520px, 100%); padding: 16px; border: 1px solid var(--line); background: var(--panel); }
.panel p { margin: 0; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .composer { position: static; }
  .message-meta { flex-wrap: wrap; }
}
