/* Phase 3i knowledge-graph page (/explorer), in the briefing (ink-on-paper) style of home.css. */
:root {
  --paper: #f3eee4;
  --ink: #1c1612;
  --rule: #d4c8b6;
  --muted: #6a6156;
  --faint: #8a8176;
  --major: #8e1e18;
  --major-bg: #f7ebe6;
  --card: #faf7f1;
  --track: #e3d9cb;
  --sample: #a8741f;
  --serif: "Newsreader", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", "Noto Serif JP", serif;
  --sans: "IBM Plex Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
  /* Node palette: mirrors THEMES.paper.nodes in graph.js. */
  --n-company: #1c1612; --n-person: #5d6f78; --n-technology: #7a6884;
  --n-paper: #a27b3e; --n-product: #9b5a48; --n-event: #5f7b62;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible,
#graph-canvas:focus-visible { outline: 2px solid var(--major); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, select, input { font: inherit; color: inherit; }

.app { max-width: 1440px; min-height: 100vh; margin: 0 auto; padding: 0 48px; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- masthead (as on the home page) */
.mast {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 22px 0 14px; border-bottom: 3px solid var(--ink);
}
.mast h1 { font-family: var(--serif); font-size: 36px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.mast h1 a:hover { color: var(--major); }
.mast .kicker { font-size: 11px; letter-spacing: 0.16em; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.mast-page { display: flex; align-items: baseline; gap: 18px; }
.mast .back { font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: 1px; }
.mast .back:hover { color: var(--major); border-color: var(--major); }
.page-title { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: 0.02em; line-height: 1; }

/* ---------------------------------------------------------------- layout: graph first, details on the right */
.graph-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; padding: 14px 0 20px; }
.stage { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
#graph {
  position: relative; height: calc(100vh - 210px); min-height: 460px; max-height: 920px;
  background: var(--card); border: 1px solid var(--rule); overflow: hidden;
}
#graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.graph-message {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center; color: var(--muted); pointer-events: none;
}
.graph-message h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); }
.graph-message .empty-orbit { display: none; }
.graph-message button { pointer-events: auto; }
.graph-tooltip {
  position: absolute; z-index: 3; max-width: 240px; padding: 6px 9px; pointer-events: none;
  background: #fffdf8; border: 1px solid var(--rule); box-shadow: 0 2px 8px #1c161214; font-size: 12px; font-weight: 600;
}
.graph-tooltip small { display: block; font-weight: 400; color: var(--muted); }
.graph-controls { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; border: 1px solid var(--rule); background: var(--paper); }
.graph-controls button {
  width: 32px; height: 32px; border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--ink);
}
.graph-controls button + button { border-top: 1px solid var(--rule); }
.graph-controls button:hover { color: var(--major); background: var(--major-bg); }
.layout-status { font-size: 11px; color: var(--faint); white-space: nowrap; }
.stage-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.caption { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats { display: flex; gap: 18px; font-size: 12px; }
.stats div { display: flex; gap: 6px; align-items: baseline; }
.stats dt { color: var(--muted); }
.stats dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.data-source-indicator { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 12px; color: var(--muted); }
.data-source-indicator strong {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border: 1px solid var(--ink);
  color: var(--ink); font-size: 11px; letter-spacing: 0.04em; font-weight: 600;
}
.data-source-indicator[data-source="sample"] strong, .data-source-indicator[data-source="mixed"] strong { border-color: var(--sample); color: var(--sample); }
.data-source-indicator[data-source="unknown"] strong { border-color: var(--major); color: var(--major); }
.sample-message { font-size: 12px; color: var(--muted); }
.sample-message[data-state="sample"], .sample-message[data-state="error"] { color: var(--major); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--rule); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-note { margin-left: auto; color: var(--faint); }
kbd { font-family: var(--sans); font-size: 11px; border: 1px solid var(--rule); padding: 0 4px; background: var(--card); }

.dot, .type-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; vertical-align: middle; }
.dot.company, .type-dot.company { background: var(--n-company); box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 2.5px var(--major); }
.dot.person, .type-dot.person { background: var(--n-person); }
.dot.technology, .type-dot.technology { background: var(--n-technology); }
.dot.paper, .type-dot.paper { background: var(--n-paper); }
.dot.product, .type-dot.product { background: var(--n-product); }
.dot.event, .type-dot.event { background: var(--n-event); }
.edge { display: inline-block; width: 18px; height: 0; border-top: 2px solid #b3a690; vertical-align: middle; }
.edge.announces { border-top-color: var(--major); }
.edge.cites { border-top: 2px dotted #a89a86; }
.edge.hires_for { border-top: 2px dashed #ad9c86; }
.edge.partners { border-top: 2px dashed #8f7d68; }

/* ---------------------------------------------------------------- side panel */
.side { min-width: 0; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--rule); padding-left: 24px; }
.side-label { display: block; font-size: 11px; letter-spacing: 0.12em; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.search-wrap { position: relative; }
#graph-search {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ink); background: #fffdf8; border-radius: 0; font-size: 14px;
}
.search-results {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; list-style: none; max-height: 360px; overflow: auto;
  background: #fffdf8; border: 1px solid var(--ink); border-top: 0; box-shadow: 0 6px 16px #1c16121f;
}
.search-results button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--track);
  background: transparent; text-align: left; cursor: pointer;
}
.search-results button:hover, .search-results button:focus { background: var(--major-bg); outline: none; }
.result-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-type { font-size: 11px; color: var(--muted); white-space: nowrap; }
.search-none { padding: 8px 10px; font-size: 12px; color: var(--muted); }

.graph-scope { padding: 10px 12px; border: 1px solid var(--major); background: var(--major-bg); font-size: 13px; display: grid; gap: 6px; }
.scope-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; color: var(--major); }
.scope-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
select { height: 32px; padding: 0 6px; border: 1px solid var(--rule); background: #fffdf8; border-radius: 0; }
.text-button { border: 0; background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--ink); padding: 0 0 1px; }
.text-button:hover { color: var(--major); border-color: var(--major); }

.side-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--ink); padding-bottom: 6px; margin-bottom: 10px; }
.side-head h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; }
/* The heading receives focus after a search result is chosen (tabindex="-1"). */
#details-title:focus:not(:focus-visible) { outline: none; }
#details-title:focus-visible { outline: 2px solid var(--major); outline-offset: 2px; }
.details { scroll-margin-top: 8px; }
.icon-button { width: 28px; height: 28px; border: 1px solid var(--rule); background: transparent; cursor: pointer; font-size: 16px; }
.icon-button:hover { color: var(--major); border-color: var(--major); }
#node-details { font-size: 13px; overflow-wrap: anywhere; }
.details-empty, .compact-empty { color: var(--muted); font-size: 13px; }
.details-empty.error, .inline-error { color: var(--major); }
.node-type { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 0.1em; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.node-title { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.2; margin: 4px 0 6px; }
.sample-badge, .data-badge, .verification-badge, .badge {
  display: inline-flex; align-items: center; height: 19px; padding: 0 6px; margin: 2px 4px 2px 0;
  border: 1px solid var(--rule); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); background: var(--card);
}
.sample-badge, .data-badge.data-sample, .data-badge.data-mixed { border-color: var(--sample); color: var(--sample); }
.data-badge.data-real { border-color: var(--ink); color: var(--ink); }
.data-badge.data-unknown { border-color: var(--major); color: var(--major); }
.detail-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0; font-size: 12.5px; }
.detail-meta > div { display: contents; }
.detail-meta dt { color: var(--muted); }
.detail-note, .field-hint, .source-warning { font-size: 12px; color: var(--muted); margin: 6px 0; }
.source-warning, .sample-note { color: var(--major); }
.source-link, #node-details a { color: var(--major); border-bottom: 1px solid currentColor; }
.button, .expand-button, .inline-retry {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 2px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--ink); background: transparent; font-size: 12.5px; font-weight: 600;
}
.button:hover { background: var(--ink); color: var(--paper); }
/* 接続ノード sits right under the title: grouped by node type, newest few per type, one row per repository. */
.neighbors { margin: 10px 0 12px; padding-top: 8px; border-top: 1px solid var(--rule); }
.neighbors > h3 { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
#neighbor-list { display: grid; gap: 8px; }
.neighbor-group { display: grid; gap: 4px; }
.neighbor-type { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); }
.neighbor-type-count { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.neighbor-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.neighbor-button {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-height: 26px; padding: 3px 8px; cursor: pointer;
  border: 1px solid var(--rule); background: #fffdf8; font-size: 12px; text-align: left;
}
.neighbor-button:hover { border-color: var(--major); color: var(--major); }
.neighbor-versions { color: var(--muted); }
.neighbor-more {
  min-height: 26px; padding: 3px 4px; cursor: pointer; border: 0; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.neighbor-more:hover { color: var(--major); }
#neighbor-list .field-hint { margin: 0; }
.feature-details, .aggregate-hub, .major-classification, .label-evidence { margin-top: 10px; font-size: 12px; }
.feature-details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.edge-detail-list { list-style: none; display: grid; gap: 8px; margin-top: 6px; }
.edge-detail-list li { padding-left: 8px; border-left: 2px solid var(--track); }

.filters { border-top: 1px solid var(--rule); padding-top: 10px; }
.filters summary { cursor: pointer; font-family: var(--serif); font-size: 18px; font-weight: 600; }
#filter-form { display: grid; gap: 8px; margin-top: 10px; }
#company-filter { width: 100%; }
fieldset { border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
fieldset legend { grid-column: 1 / -1; }
fieldset label, .check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--major); width: 15px; height: 15px; }
.hint { font-size: 12px; color: var(--muted); }
#filter-form .text-button { justify-self: start; }

.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 0 22px;
  border-top: 1px solid var(--rule); font-size: 11.5px; color: var(--faint);
}
.lab-link { color: var(--faint); border-bottom: 1px dotted var(--faint); }
.lab-link:hover { color: var(--major); border-color: var(--major); }
.noscript { padding: 24px; }

@media (max-width: 1100px) {
  .app { padding: 0 28px; }
  .graph-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
  .side { padding-left: 18px; }
}

/* ---------------------------------------------------------------- mobile: search and details, then the graph */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .app { padding: 0 16px; }
  .mast { padding: 14px 0 10px; align-items: flex-end; gap: 12px; }
  .mast .kicker { margin-bottom: 4px; }
  .mast .kicker-ja { display: none; }
  .mast h1 { font-size: 26px; }
  .mast-page { flex-direction: column; align-items: flex-end; gap: 6px; }
  .page-title { font-size: 18px; }
  .graph-layout { display: flex; flex-direction: column; gap: 0; padding: 10px 0 18px; }
  /* Search and node details first, then the graph with its stats, provenance note and legend
   * (DOM order stays graph-first for desktop; only the visual order changes). */
  .side { order: -1; border-left: 0; padding-left: 0; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 3px solid var(--ink); }
  #graph { height: 50vh; min-height: 300px; max-height: none; }
  .legend-note { margin-left: 0; }
  #graph-search { height: 42px; font-size: 16px; }
  .graph-controls button { width: 38px; height: 38px; }
}
