:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --card: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #06a14a;
  --accent-soft: rgba(6, 161, 74, 0.10);
  --error: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --other: #b5b3ab;
  /* 量の多さ（青の濃さ） */
  --q0: #eef2f7; --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec; --q4: #3987e5; --q5: #256abf; --q6: #184f95; --q7: #0d366b;
  /* 返信の速さ（速いほど濃い） */
  --r0: #104281; --r1: #1c5cab; --r2: #2a78d6; --r3: #5598e7; --r4: #6da7ec; --r5: #86b6ef;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #2fc96b; --accent-soft: rgba(47, 201, 107, 0.12);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --other: #5f5e59;
    --q0: #222221; --q1: #0d366b; --q2: #104281; --q3: #184f95; --q4: #256abf; --q5: #3987e5; --q6: #6da7ec; --q7: #9ec5f4;
    --r0: #b7d3f6; --r1: #86b6ef; --r2: #5598e7; --r3: #3987e5; --r4: #256abf; --r5: #184f95;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --card: #1a1a19;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #2fc96b; --accent-soft: rgba(47, 201, 107, 0.12);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --other: #5f5e59;
  --q0: #222221; --q1: #0d366b; --q2: #104281; --q3: #184f95; --q4: #256abf; --q5: #3987e5; --q6: #6da7ec; --q7: #9ec5f4;
  --r0: #b7d3f6; --r1: #86b6ef; --r2: #5598e7; --r3: #3987e5; --r4: #256abf; --r5: #184f95;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); line-height: 1.6; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--accent-soft); }
button, input, select { font: inherit; color: inherit; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
  padding: 12px max(16px, calc((100% - 1080px) / 2));
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 22px; height: 22px; fill: var(--accent); flex: none; }
.privacy { margin: 0; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.privacy::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }

/* 読み込み前 */
.intro { max-width: 640px; margin: 6vh auto 0; }
.intro h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.3; margin: 0 0 12px; letter-spacing: 0.01em; }
.lead { color: var(--text-2); margin: 0 0 24px; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 180px; padding: 24px; text-align: center; cursor: pointer;
  border: 2px dashed var(--axis); border-radius: var(--radius); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop-title { font-weight: 700; font-size: 17px; }
.drop-sub { color: var(--text-2); font-size: 14px; }
.error { color: var(--error); margin: 12px 0 0; }
.howto { margin-top: 20px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { padding-left: 1.4em; margin: 8px 0; }
.howto p { margin: 0; color: var(--text-2); font-size: 14px; }

/* レポート */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 20px;
}
.room { flex: 1 1 260px; min-width: 0; }
.room h1 { margin: 0; font-size: clamp(22px, 4vw, 28px); line-height: 1.3; overflow-wrap: anywhere; }
.room p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-2); }
select, .btn, input[type="search"] {
  height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--card);
}
.btn { cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }

.grid { display: grid; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; min-width: 0;
}
.card h2 { margin: 0 0 2px; font-size: 16px; }
.card .sub { margin: 0 0 14px; color: var(--text-2); font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.linkish { background: none; border: none; padding: 0; color: var(--text-2); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 26px; font-weight: 650; line-height: 1.25; margin-top: 2px; }
.tile .unit { font-size: 14px; font-weight: 500; margin-left: 2px; color: var(--text-2); }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 2px; }

.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* 比較（横長の分割バー） */
.compare { display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; align-items: center; }
.compare .rlabel { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.seg { display: flex; gap: 2px; height: 28px; min-width: 0; }
.seg > div {
  border-radius: 4px; display: flex; align-items: center; padding: 0 8px; min-width: 0;
  font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; cursor: default;
}
.seg > div:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.seg.empty { align-items: center; color: var(--muted); font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-2); font-weight: 600; }
.scroll-x { overflow-x: auto; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .mark { transition: opacity .12s; }
.chart.dim .mark { opacity: 0.35; }
.chart.dim .mark.on { opacity: 1; }
.chart .cursor { stroke: var(--axis); stroke-width: 1; }

/* 単語・絵文字 */
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 18px; }
.person h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14px; }
.person h3 i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rank li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; position: relative; padding: 3px 6px; border-radius: 6px; font-size: 14px; }
.rank li .bar { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--accent-soft); z-index: 0; }
.rank li > * { position: relative; z-index: 1; }
.rank li .w { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank li .n { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank button.w { background: none; border: none; padding: 0; text-align: left; cursor: pointer; }
.rank button.w:hover { text-decoration: underline; text-underline-offset: 3px; }
.emoji-rank li .w { font-size: 20px; line-height: 1.3; }
.empty-note { color: var(--muted); font-size: 13px; margin: 0; }

.quote { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--page); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.quote-meta { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* 検索 */
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-row input { flex: 1 1 220px; min-width: 0; }
.hits-summary { margin: 12px 0; font-size: 14px; color: var(--text-2); }
.hits { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 520px; overflow: auto; }
.hit-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.hit-item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.hit-item .meta i { width: 8px; height: 8px; border-radius: 2px; }
.hit-item .body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.hit-item mark { background: rgba(237, 161, 0, 0.35); color: inherit; border-radius: 3px; }
.hit-item button { margin-top: 4px; }
.context { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--grid); display: grid; gap: 4px; }
.context .line { font-size: 13px; display: grid; grid-template-columns: max-content 1fr; gap: 8px; }
.context .line.me { font-weight: 650; }
.context .who { color: var(--text-2); }

.tip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 260px;
  padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 1.5;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}
.tip b { font-weight: 650; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip .row span:last-child { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

footer.foot { margin-top: 28px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 560px) {
  .compare { grid-template-columns: 1fr; gap: 2px; }
  .compare .rlabel { margin-top: 8px; }
  .card { padding: 14px; }
}
