:root {
  color-scheme: light dark;
  --bg: #f5f6f8; --card: #ffffff; --text: #16191d; --muted: #6b7280;
  --accent: #2563eb; --border: #e2e5ea;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #101418; --card: #1a2027; --text: #e8eaed; --muted: #8b93a0; --border: #2a323c; }
}
* { box-sizing: border-box; margin: 0; }
body {
  font: 16px/1.5 -apple-system, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
.view { max-width: 640px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.msg { margin-top: 12px; color: var(--muted); min-height: 1.5em; }

.login-box { margin-top: 20vh; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.login-box details { text-align: left; margin-top: 24px; }
.login-box summary { color: var(--muted); cursor: pointer; }
.login-box details > * { margin-top: 10px; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
h1 { font-size: 20px; }
h2 { font-size: 15px; color: var(--muted); font-weight: 500; margin: 20px 0 8px; }

button {
  font: inherit; border: none; border-radius: 10px; padding: 12px 16px;
  background: var(--card); color: var(--text); border: 1px solid var(--border); cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
input {
  font: inherit; width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}

.capture { display: flex; gap: 8px; margin-bottom: 12px; }
.capture button { flex: 0 0 48px; font-size: 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card p { margin-bottom: 10px; }

.feed-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.feed-item .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.feed-item .title { font-weight: 600; }
.feed-item .body { margin-top: 4px; white-space: pre-wrap; }
.feed-empty { color: var(--muted); padding: 24px 0; text-align: center; }

.view { padding-bottom: 84px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  gap: 8px; max-width: 640px; margin: 0 auto;
}
.tab { flex: 1; border: none; background: transparent; color: var(--muted); padding: 10px; }
.tab.active { color: var(--accent); font-weight: 600; }

.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chip { border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--muted); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.cand { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.cand .head { display: flex; justify-content: space-between; align-items: baseline; }
.cand .ticker { font-weight: 700; font-size: 17px; }
.cand .date { font-size: 12px; color: var(--muted); }
.cand .name { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.cand .facts { font-size: 13px; color: var(--muted); margin: 6px 0; }
.cand canvas { width: 100%; height: 90px; display: block; margin: 8px 0 4px; }
.cand .chart-note { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.ranges { display: flex; gap: 6px; margin-bottom: 8px; }
.range-btn { font-size: 12px; padding: 4px 10px; border-radius: 999px; color: var(--muted); }
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 8px; }
.actions button { flex: 1; font-size: 14px; padding: 10px 0; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }

#chat-log { display: flex; flex-direction: column; gap: 8px; padding-bottom: 70px; min-height: 40vh; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; font-size: 15px; }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.pending { align-self: flex-start; color: var(--muted); font-style: italic; }
.bubble .b-ts { display: block; font-size: 10px; opacity: 0.7; margin-top: 4px; }
.chat-input { position: fixed; bottom: calc(60px + env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: 608px; margin: 0 auto; }
