:root {
  --bg: #ffffff;
  --fg: #1d2129;
  --muted: #5f6672;
  --line: #e1e4e8;
  --accent: #0b5cad;
  --badge: #fff4d6;
  --badge-fg: #7a5200;
  --error: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --fg: #e6e8eb;
    --muted: #9aa1ab;
    --line: #2c3036;
    --accent: #6cb0ff;
    --badge: #3a2f12;
    --badge-fg: #f3c969;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 32px 0 4px; }
h3 { font-size: 14px; margin: 24px 0 4px; }
main { padding: 0 16px 48px; }
#user { color: var(--muted); display: flex; gap: 12px; align-items: center; }
.note { color: var(--muted); margin: 0 0 8px; }
.error { color: var(--error); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 -16px 16px;
  padding: 12px 16px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
[role="tablist"] { display: flex; gap: 4px; }
[role="tab"] {
  padding: 8px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
[role="tab"][aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
[role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.search { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; }
.search .note { margin: 0; white-space: nowrap; }
.search input {
  width: 320px;
  max-width: 70vw;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
th { font-weight: 600; color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group-start td { border-top: 2px solid var(--line); }
td.source { white-space: normal; min-width: 240px; }

button.download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.download-cell { display: inline-flex; align-items: center; gap: 6px; }
.download-cell .note { margin: 0; }
button.download:hover { border-color: var(--accent); }
button.download:disabled { color: var(--muted); cursor: progress; }
button.download:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

th[aria-sort] { padding: 0; }
button.sort {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
button.sort::after { content: "↕"; opacity: 0.35; font-size: 11px; }
th[aria-sort="ascending"] button.sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] button.sort::after { content: "↓"; opacity: 1; }
button.sort:hover, th[aria-sort="ascending"] button.sort, th[aria-sort="descending"] button.sort { color: var(--fg); }
button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.resorted tr.group-start td { border-top-width: 1px; }

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
button.link:disabled { color: var(--muted); cursor: progress; }
a { color: var(--accent); }
.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--badge);
  color: var(--badge-fg);
  font-size: 12px;
}
