:root {
  color-scheme: light dark;
  --bg: #0b0d12;
  --panel: #161a22;
  --text: #e8eaed;
  --muted: #8a90a0;
  --accent: #4f8cff;
  --deny: #e05a5a;
  --border: #262c38;
}

* { box-sizing: border-box; }

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

#app { height: 100%; display: flex; flex-direction: column; }

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.view h1 { font-size: 1.2rem; margin-bottom: 8px; }
.view p { color: var(--muted); max-width: 320px; }

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 1rem;
  margin-top: 16px;
}

button.link {
  background: none;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.85rem;
  margin: 0;
}

.status { min-height: 1.2em; font-size: 0.85rem; color: var(--muted); }

#chat-view { display: none; flex: 1; padding: 0; }
#chat-view.active { display: flex; }
.view.active { display: flex; }

header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  padding-top: max(12px, env(safe-area-inset-top));
}
header span:nth-child(2) { flex: 1; font-weight: 600; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--deny);
  display: inline-block;
}
.dot.connected { background: #3ecf6e; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.35;
}
.msg.out { align-self: flex-end; background: var(--accent); color: white; }
.msg.in { align-self: flex-start; background: var(--panel); }
.msg-ts { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

.card {
  margin: 0 16px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.card-title { font-weight: 600; margin-bottom: 6px; }
.perm-tool { color: var(--accent); font-family: monospace; }
.perm-desc { color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.perm-input {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
}
.card-actions { display: flex; gap: 10px; margin-top: 10px; }
.card-actions button { flex: 1; margin: 0; }
.card-actions .deny { background: var(--deny); }

#composer {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
#msg-input {
  flex: 1;
  resize: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  max-height: 120px;
}
#send-btn { margin: 0; }
