:root {
  --bg: #fbfaf7; --fg: #1d1d1b; --muted: #6b6b66; --line: #dedbd3; --panel: #ffffff;
  --accent: #2a5d9f; --warn-bg: #fff4d6; --warn-fg: #6b4d00; --edge: rgba(60,60,60,0.13); --dim: #cfccc4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a; --fg: #e9e7e2; --muted: #a09d96; --line: #34363a; --panel: #1f2023;
    --accent: #7fb0ef; --warn-bg: #3a3016; --warn-fg: #f1d68c; --edge: rgba(220,220,220,0.12); --dim: #3d3f43;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 4px; }
h1 { font-size: 1.3rem; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
button { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
.warn { margin: 8px 16px; padding: 6px 10px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; font-size: .9rem; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 6px 16px; }
.controls label { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
input, select { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
input[type=search] { width: 10em; }
#comm { max-width: 16em; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.stat { margin: 2px 16px 6px; color: var(--muted); font-size: .85rem; }
main { position: relative; display: flex; gap: 0; border-top: 1px solid var(--line); min-height: 70vh; }
#listView { flex: 1; overflow: auto; padding: 0 16px; max-height: 78vh; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: var(--bg); cursor: pointer; white-space: nowrap; user-select: none; }
th.sorted::after { content: " ▼"; font-size: .7em; }
th.sorted.asc::after { content: " ▲"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.desc { color: var(--muted); max-width: 32em; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sw { display: inline-block; width: .8em; height: .8em; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.more { color: var(--muted); font-size: .85rem; }
#graphView { flex: 1; position: relative; height: 78vh; }
canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.gtools { position: absolute; left: 10px; top: 10px; }
#tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: .85rem; max-width: 18em; }
#detail { width: 380px; flex: none; border-left: 1px solid var(--line); background: var(--panel); padding: 12px 16px; overflow: auto; max-height: 78vh; }
#detail h2 { margin: 0 0 2px; font-size: 1.2rem; }
#detail .uri { font-size: .75rem; color: var(--muted); word-break: break-all; }
#detail h3 { font-size: .95rem; margin: 14px 0 4px; }
#detail dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0; font-size: .9rem; }
#detail dt { color: var(--muted); }
#detail ul { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
#detail li { padding: 3px 0; border-bottom: 1px solid var(--line); }
#detail .close { float: right; }
#detail .tag { display: inline-block; font-size: .75rem; background: var(--warn-bg); color: var(--warn-fg); border-radius: 4px; padding: 0 6px; }
#detail .snip { color: var(--muted); font-size: .8rem; }
a { color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
footer { padding: 10px 16px 30px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.howto p { margin: 4px 0; }
@media (max-width: 760px) {
  main { flex-direction: column; }
  #detail { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  #graphView { height: 65vh; }
  td.desc, th.desc { display: none; }
}
