:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.7; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: calc(0.75rem + env(safe-area-inset-top));
}

.logo {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.crumb { color: var(--text-dim); font-size: 0.85rem; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0.75rem 1rem 4rem;
}

.page-title { font-size: 1.4rem; margin: 0.5rem 0 1rem; }
.page-title small { color: var(--text-dim); font-size: 0.9rem; font-weight: 500; }
.meta { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 0.75rem; }
.empty { color: var(--text-dim); padding: 1rem 0; }
.hidden { display: none; }

.market-list, .cand-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.market-card, .cand-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--text);
  min-height: 48px;
}

.market-card { display: flex; flex-direction: column; gap: 0.2rem; }
.market-name { font-size: 1.1rem; font-weight: 600; }
.market-meta { color: var(--text-dim); font-size: 0.9rem; }
.market-time { color: var(--text-dim); font-size: 0.75rem; }

.cand-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.cand-symbol { font-weight: 600; font-size: 1.05rem; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.cand-name { color: var(--text); font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand-ticker { color: var(--text-dim); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; }
.cand-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.cand-body .kv b {
  color: var(--text);
  font-weight: 500;
  margin-right: 0.25rem;
}

.bucket-section { margin: 1.25rem 0; }
.bucket-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bucket-count {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.05rem 0.5rem;
}

.verdict {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.verdict-buy { background: rgba(63, 185, 80, 0.12); color: var(--green); border-color: rgba(63, 185, 80, 0.3); }
.verdict-wait-for-gc, .verdict-wait { background: rgba(210, 153, 34, 0.12); color: var(--amber); border-color: rgba(210, 153, 34, 0.3); }
.verdict-skip, .verdict-pass { background: rgba(248, 81, 73, 0.12); color: var(--red); border-color: rgba(248, 81, 73, 0.3); }
.verdict-pending { color: var(--accent); border-color: rgba(88, 166, 255, 0.3); }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.kv-grid > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
}
.kv-grid > div b {
  display: block;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}
.kv-grid > div span { font-size: 1rem; font-weight: 600; }

.chart-section, .ai-section { margin: 1.25rem 0; }
.chart-section h2, .ai-section h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
#chart {
  width: 100%;
  height: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "▸";
  color: var(--text-dim);
  margin-right: 0.5rem;
  display: inline-block;
  transition: transform 120ms ease;
}
details[open] summary::before { transform: rotate(90deg); }

.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.75rem; margin: 0.5rem 0 0; }
.kv-list dt { color: var(--text-dim); font-size: 0.85rem; }
.kv-list dd { margin: 0; font-size: 0.95rem; }

.ai-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0.5rem 0 1rem;
  color: var(--text);
}
.ai-section h3 {
  font-size: 0.85rem;
  margin: 0.75rem 0 0.25rem;
  color: var(--text-dim);
  font-weight: 500;
}

.footer {
  text-align: center;
  color: var(--text-dim);
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  font-size: 0.75rem;
}

/* --- portfolio (capital_gains_v2) --- */
.pos { color: #3fb950; }
.neg { color: #f85149; }
.badge {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border: 1px solid #f85149;
  border-radius: 6px;
  padding: 0 6px;
  font-size: 0.75rem;
  align-self: center;
}

/* --- auth forms (Sprint 3) --- */
.auth-form { display: flex; flex-direction: column; gap: 0.8rem; max-width: 420px; margin: 1rem 0; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; color: #8b949e; font-size: 0.9rem; }
.auth-form input { background: #0d1117; border: 1px solid #30363d; border-radius: 6px; padding: 0.6rem; color: #e7e9ea; font-size: 1rem; }
.auth-form input:focus { border-color: #58a6ff; outline: none; }
.auth-form button { background: #238636; color: #fff; border: none; border-radius: 6px; padding: 0.7rem; font-size: 1rem; cursor: pointer; }
.auth-form button:hover { background: #2ea043; }
.form-error { background: rgba(248,81,73,.15); border: 1px solid #f85149; color: #f85149; border-radius: 6px; padding: 0.6rem 0.8rem; }
.invite-code { background: #16181c; border: 1px solid #30363d; padding: 2px 8px; border-radius: 4px; font-size: 1.05rem; }


/* --- report/legal body (Sprint 5/6) --- */
.report-body { line-height: 1.7; }
.report-body h2, .report-body h3 { margin: 1.2rem 0 0.4rem; }
.report-body table { border-collapse: collapse; margin: 0.8rem 0; width: 100%; }
.report-body th, .report-body td { border: 1px solid #30363d; padding: 0.4rem 0.6rem; font-size: 0.9rem; text-align: left; }
.report-body th { background: #16181c; }
.report-body ul { padding-left: 1.4rem; }
