:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2230;
  --muted: #5f6878;
  --border: #e1e4ea;
  --accent: #2563eb;
  --accent-soft: #e7eefd;
  --good: #16794a;
  --good-soft: #e2f3ea;
  --bad: #b42318;
  --bad-soft: #fcebea;
  --star: #f0a020;
  --star-off: #d9dde4;
  --hot: #c2410c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --text: #e5e8ed;
    --muted: #9aa3b2;
    --border: #2a303a;
    --accent: #7aa7ff;
    --accent-soft: #1c2944;
    --good: #52c78e;
    --good-soft: #14281e;
    --bad: #ff8078;
    --bad-soft: #2e1817;
    --star-off: #3a414d;
    --hot: #fb923c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em;
  background: var(--surface-2);
  padding: .1em .35em;
  border-radius: 4px;
  word-break: break-all;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* ---- header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  min-height: 54px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.site-header nav { display: flex; gap: 14px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.site-header nav a:hover { color: var(--accent); }
.site-header nav.langs { gap: 8px; }
.site-header nav.langs a { font-size: 13px; }
.site-header nav.langs a.active { color: var(--accent); font-weight: 700; }
.whoami { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.whoami input {
  width: 130px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 8px;
}

main.wrap { padding-top: 20px; padding-bottom: 80px; }

/* ---- common ---- */
.page-head h1, .report-head h1 { font-size: 24px; line-height: 1.45; margin: 4px 0 10px; }
.lead, .muted { color: var(--muted); }
.notice {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.hint { color: var(--muted); font-size: 13.5px; margin-top: -4px; }

.chip {
  display: inline-block;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.6;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.chip.active, .chip.static { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.static { cursor: default; font-weight: 600; }

/* ---- index ---- */
.run-status { font-size: 14px; color: var(--muted); }
.run-status.failed { color: var(--bad); }
.run-status .error { display: block; font-size: 13px; }
.report-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.report-list a {
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.report-list a:hover { border-color: var(--accent); }
.report-list .date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.report-list .headline { font-weight: 600; }
.report-list .meta { font-size: 13px; color: var(--muted); }

/* ---- report ---- */
.pager { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.pager a { text-decoration: none; }
.eyebrow { margin: 0; color: var(--muted); font-size: 13px; }
.overview { margin: 0 0 8px; }
.stats { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.ai-models { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; color: var(--muted); font-size: 13px; margin: -6px 0 12px; }
.ai-models .label { font-weight: 600; }
.ai-models b { color: var(--text); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }

.topic, .panel, .extras, .report-comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.topic[hidden] { display: none; }
.topic-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.topic-meta .reactions { margin-left: auto; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.topic-meta .reactions.hot { color: var(--hot); }
.importance { display: inline-flex; gap: 3px; }
.importance i { width: 9px; height: 9px; border-radius: 50%; background: var(--star-off); display: inline-block; }
.importance i.on { background: var(--star); }
.topic h2 { font-size: 19px; line-height: 1.5; margin: 8px 0 10px; }
.summary { margin: 0 0 8px; }
.points { margin: 0 0 8px; padding-left: 1.3em; }
.points li { margin: 2px 0; }
.followup { margin-left: .4em; color: var(--hot); font-size: .85em; font-weight: 700; white-space: nowrap; }
.digest {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 22px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.digest-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.digest h2 { font-size: 17px; margin: 0; }
.copy-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.digest-head .copy-tools { margin: 0; }
.copy-btn {
  font: inherit;
  font-size: 13px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-status { font-size: 13px; color: var(--muted); }
.copy-btn.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.copy-btn.subtle { font-size: 12px; color: var(--muted); }
.pick-label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); cursor: pointer; }
.digest .pick { margin-right: 4px; }
.digest .pick input, .pick-label input { cursor: pointer; }
.select-bar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  justify-content: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.select-bar[hidden] { display: none; }
.select-count { font-weight: 600; font-size: 14px; }
.digest ul { margin: 0; padding-left: 1.3em; }
.digest li { margin: 3px 0; }
.digest a { color: var(--text); text-decoration: none; }
.digest a:hover { color: var(--accent); text-decoration: underline; }
/* 目次から移動したとき、固定のヘッダーに見出しが隠れないようにする */
.topic, .digest { scroll-margin-top: calc(var(--header-height, 56px) + 12px); }
.to-digest { display: inline-block; margin-top: 8px; font-size: 13px; text-decoration: none; }
.why {
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 14px;
}
.why strong { color: var(--accent); margin-right: .6em; }
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; margin-bottom: 6px; }
.sources .label { color: var(--muted); font-size: 12.5px; }
.sources a {
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 8px;
}
.sources a::after { content: " ↗"; font-size: .85em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.tags span, .tags a { background: var(--surface-2); border-radius: 6px; padding: 0 8px; text-decoration: none; }

/* media */
.media-grid {
  display: grid;
  gap: 4px;
  border-radius: 10px;
  overflow: hidden;
  margin: 6px 0 12px;
  background: var(--surface-2);
}
.media-grid.n2, .media-grid.n4 { grid-template-columns: 1fr 1fr; }
.media-grid.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 148px 148px; }
.media-grid.small.n3 { grid-template-rows: 88px 88px; }
.media-grid.n3 > :first-child { grid-row: span 2; }
.media-grid a { display: block; min-height: 0; }
.media-grid img, .media-grid video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-height: 300px;
  background: #000;
}
.media-grid.n1 img, .media-grid.n1 video { object-fit: contain; max-height: 460px; background: var(--surface-2); }
.media-grid.small { max-width: 360px; }
.media-grid.small img, .media-grid.small video { max-height: 180px; }
/* 動画は切り取らずに全体を見せる */
.media-grid video { object-fit: contain; }
/* 1本だけのときは枠を動画の縦横比にする。再生前(preload="none")は縦横比が分からず 2:1 の枠に
   なるため、Xの元の幅・高さから style で aspect-ratio を指定している */
.media-grid.n1 video { height: auto; }
/* 3つ並びは行の高さを固定し、左の縦長のマス(2行分)も含めてマス全体を使う */
.media-grid.n3 img, .media-grid.n3 video { max-height: none; }

/* posts */
.posts { margin: 8px 0; }
.posts > summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.tweet {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 14px;
}
.tweet-head { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.who { display: flex; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.who .name { font-weight: 600; }
.handle { color: var(--muted); text-decoration: none; font-size: 13px; }
.tweet-head time { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.tweet-text { margin: 6px 0; overflow-wrap: anywhere; }
.quoted {
  border-left: 3px solid var(--border);
  padding: 2px 10px;
  color: var(--muted);
  font-size: 13.5px;
  margin: 6px 0;
  overflow-wrap: anywhere;
}
.link-card {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  margin: 6px 0;
}
.link-card img { width: 96px; height: 64px; object-fit: cover; flex: none; }
.link-card-body { display: grid; padding: 6px 10px 6px 0; font-size: 13px; min-width: 0; }
.link-card-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card-body span { color: var(--muted); }
.tweet-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.open-x { margin-left: auto; text-decoration: none; }

/* feedback */
.feedback { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.report-comment .feedback { border-top: 0; margin-top: 0; padding-top: 0; }
.fb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fb-btn, .fb-toggle, .fb-save {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
}
.fb-btn:hover, .fb-toggle:hover, .fb-save:hover { border-color: var(--accent); }
.fb-btn .count:not(:empty) { margin-left: 6px; font-weight: 600; }
.fb-btn.good.active { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.fb-btn.bad.active { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.fb-status { font-size: 12.5px; color: var(--muted); }
.fb-comment { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.fb-comment[hidden] { display: none; }
.fb-comment textarea {
  flex: 1;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  resize: vertical;
  min-width: 0;
}
.fb-save { border-radius: 8px; white-space: nowrap; }
.fb-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13.5px; }
.fb-list li { padding: 4px 0; }
.fb-list b { margin-right: .6em; }
.fb-list:empty { display: none; }

/* extras */
.extras h2, .report-comment h2, .panel h2 { font-size: 17px; margin: 0 0 6px; }
.extra { border-top: 1px solid var(--border); padding: 12px 0 4px; }
.ai-note { font-size: 13.5px; margin: 0 0 4px; }
.ai-note .score {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0 8px;
  margin-right: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.usage { color: var(--muted); font-size: 12.5px; text-align: right; }
.fb-voters { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.fb-voters:empty { display: none; }

/* feedback list */
.filters a.chip { text-decoration: none; }
.fb-group { margin: 22px 0; }
.fb-group h2 .count { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 6px; }
.fb-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 10px 0;
  box-shadow: var(--shadow);
}
.fb-item-meta { margin: 0; font-size: 12.5px; color: var(--muted); }
.fb-item-title { margin: 4px 0; font-weight: 600; }
.fb-item-text { margin: 4px 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.fb-item-voters { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font-size: 13.5px; }

/* source candidates */
.cand {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 10px 0;
  box-shadow: var(--shadow);
}
.cand-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cand-handle { font-weight: 700; text-decoration: none; }
.cand-name { color: var(--muted); }
.verdict {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.verdict.v-good { background: var(--good-soft); color: var(--good); }
.verdict.v-hold { color: var(--star); }
.cand-meta, .cand-stats { margin: 4px 0; font-size: 13px; color: var(--muted); }
.cand-bio { margin: 4px 0; font-size: 14px; overflow-wrap: anywhere; }
.cand-examples { margin: 6px 0; padding-left: 1.2em; font-size: 13.5px; }
.cand-decision { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.cand-pending { font-size: 14px; padding-left: 1.2em; }

/* AIへの質問 */
.qa { margin-top: 10px; }
.qa summary { cursor: pointer; font-size: 14px; color: var(--accent); font-weight: 600; }
.qa .count { margin-left: 4px; font-size: 12px; color: var(--muted); }
.qa-list { list-style: none; padding: 0; margin: 8px 0; }
.qa-item { border-left: 3px solid var(--accent-soft); padding: 4px 0 4px 10px; margin: 10px 0; }
.qa-q, .qa-a { display: flex; gap: 8px; margin: 4px 0; }
.qa-q { font-weight: 600; }
.qa-label { flex: none; width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.qa-a.error .qa-answer { color: var(--bad); }
.qa-answer { min-width: 0; overflow-wrap: anywhere; line-height: 1.7; }
.qa-form { display: flex; gap: 8px; align-items: flex-start; }
.qa-form textarea { flex: 1; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; }
.qa-where { margin-top: 16px; font-size: 13px; }

/* login / access / users */
.auth-panel { max-width: 560px; margin: 32px auto; }
.auth-panel h1 { margin-top: 0; }
.auth-btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 8px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.auth-btn:hover { filter: brightness(1.08); }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.access-form { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.access-form textarea, .user-add input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.user-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-add input { width: auto; flex: 1; min-width: 220px; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--hot); color: #fff; font-size: 11px; text-align: center; }
.privacy h2 { font-size: 16px; margin: 18px 0 6px; }

/* profile */
.panel h3 { font-size: 14.5px; margin: 16px 0 6px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.history { padding-left: 1.2em; }
.history li { margin-bottom: 8px; }
.history time { display: block; color: var(--muted); font-size: 12.5px; }
.sources-list { padding-left: 1.2em; font-size: 14px; }
.sources-list li { margin-bottom: 4px; }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topic, .panel, .extras, .report-comment { padding: 14px 14px; border-radius: 10px; }
  .page-head h1, .report-head h1 { font-size: 20px; }
  .topic h2 { font-size: 17px; }
  .whoami { margin-left: 0; width: 100%; }
  .whoami input { flex: 1; }
  .columns { grid-template-columns: 1fr; }
  .fb-comment { flex-direction: column; align-items: stretch; }
}
