:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --sidebar: #111820;
  --panel: #151c25;
  --panel-2: #1b2430;
  --line: #2a3544;
  --text: #f4f7fb;
  --muted: #9aa8ba;
  --blue: #37b9f4;
  --green: #26d07c;
  --red: #ff637d;
  --bubble-user: #263241;
  --bubble-assistant: #141b23;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.sidebar {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #00131c;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
}

.app,
.tools button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.app {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  padding: 0 12px;
  margin-bottom: 8px;
  text-align: left;
}

.app.active {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.app span {
  font-weight: 800;
}

.app small {
  color: var(--muted);
}

.tools {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121922;
}

.tools button {
  height: 40px;
  margin-bottom: 8px;
  background: var(--panel-2);
  font-weight: 750;
}

.tools button:last-child {
  margin-bottom: 0;
}

.meta {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161e;
}

.label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#targetUrl {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.conversation-list {
  display: grid;
  gap: 8px;
}

.conversation,
.conversation-empty {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.conversation {
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
}

.conversation.active {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.conversation span {
  display: block;
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.conversation-empty,
.event-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.log-panel {
  margin-bottom: 16px;
}

.event-log {
  display: grid;
  gap: 8px;
}

.event-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f151d;
}

.event-row.error {
  border-color: rgba(255, 99, 125, 0.55);
}

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.event-message {
  margin-top: 4px;
  color: var(--text);
  font-size: 12px;
  word-break: break-word;
}

.chat-shell {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) auto;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, 0.92);
}

.chat-header h2 {
  font-size: 19px;
}

.chat-header p {
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-width: 86px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.status.ok {
  color: var(--green);
}

.status.error {
  color: var(--red);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 22px 18px;
}

.empty {
  max-width: 560px;
  margin: 18vh auto 0;
  text-align: center;
  color: var(--muted);
}

.empty h3 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 22px;
}

.message-row {
  display: flex;
  max-width: 860px;
  margin: 0 auto 18px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(720px, 78%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.error {
  border-color: rgba(255, 99, 125, 0.7);
}

.message-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.user .bubble {
  border-color: #354459;
  background: var(--bubble-user);
  border-bottom-right-radius: 6px;
}

.assistant .bubble {
  background: var(--bubble-assistant);
  border-bottom-left-radius: 6px;
}

.bubble.pending::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 0.9s infinite;
  vertical-align: middle;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.composer {
  width: min(860px, calc(100% - 44px));
  min-height: 56px;
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  gap: 8px;
  align-items: end;
  margin: 0 auto 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #111820;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.24);
}

.composer button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

#sendButton {
  background: var(--blue);
  color: #00131c;
}

textarea {
  min-height: 38px;
  max-height: 160px;
  resize: none;
  padding: 8px 4px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

@media (max-width: 820px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}
