:root {
  --bg: #0f1115;
  --panel: #151922;
  --panel-2: #1b2130;
  --line: #2a3142;
  --text: #e8ecf4;
  --muted: #9aa4b5;
  --bubble-in: #232a3a;
  --bubble-out: #2f6df6;
  --bubble-out-text: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
  height: 100%;
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

#meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

button {
  border: 1px solid #3a4358;
  border-radius: 10px;
  padding: 8px 12px;
  background: #20293a;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: #26324a; }
button:disabled { opacity: 0.6; cursor: default; }

.chat-viewport {
  overflow-y: auto;
  padding: 16px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-title {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.thread-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bubble {
  position: relative;
  max-width: min(78%, 760px);
  padding: 10px 12px 26px 12px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 16px;
  word-break: break-word;
  border: 1px solid transparent;
}

.bubble-text {
  white-space: pre-wrap;
  padding-right: 42px;
}

.bubble-time {
  position: absolute;
  right: 10px;
  bottom: 6px;
  display: block;
  font-size: 10px !important;
  line-height: 1;
  color: #8e99ad !important;
  pointer-events: none;
}

.bubble-meta {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sender-main { color: #67b3ff; }
.sender-plotter { color: #74e6b8; }
.sender-other { color: #f3c96b; }

.bubble-left {
  align-self: flex-start;
  background: #212839;
  color: var(--text);
  border-color: #36415a;
}

.bubble-right {
  align-self: flex-start;
  background: #1f2b24;
  color: #e9f9ef;
  border-color: #355843;
}

.bubble-system,
.bubble-other,
.bubble-unknown {
  align-self: center;
  background: #2a3140;
  color: #d3d9e6;
  border-color: #3b4458;
}

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 10vh;
}
