:root {
  --bg-app: #f2f0ea;
  --surface: #ffffff;
  --surface-alt: #f8f7f4;
  --surface-dark: #1b1f26;
  --surface-dark-sub: #262c36;
  --text-main: #14171c;
  --text-muted: #575e6a;
  --text-inverse: #f4f6f8;
  --border-main: #cec9bc;
  --border-light: #e4e0d5;
  --border-dark: #373e4b;
  --accent-navy: #1d466c;
  --accent-blue: #4ea1db;
  --notice-bg: #faf7ef;
  --notice-border: #d8cfb9;
  --notice-text: #734d17;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font: 13.5px/1.6 var(--font-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 1. 最上部ヘッダー ---------- */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  background: var(--surface-dark);
  color: var(--text-inverse);
  border-bottom: 1px solid #101318;
  flex-shrink: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: #2a313d;
  color: var(--accent-blue);
  padding: 3px 6px;
  border-radius: 2px;
  border: 1px solid #3c4554;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-main {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10.5px;
  color: #9ba4b2;
}

/* 統計サマリー（#stats） */
.stats-ribbon {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 3px;
}

.stat b {
  font-size: 16px;
  color: var(--accent-blue);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat span {
  font-size: 11.5px;
  color: #dbe0e8;
  font-weight: 500;
}

.stat small {
  font-size: 10px;
  color: #8c96a4;
  margin-left: 2px;
}

/* タブ切り替え（#tabs） */
.nav-switcher {
  display: flex;
  gap: 3px;
  background: #111419;
  padding: 3px;
  border-radius: 4px;
  border: 1px solid #282f3a;
}

#tabs button {
  border: 0;
  background: transparent;
  color: #9aa4b2;
  padding: 5px 12px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: none;
}

#tabs button.on {
  background: var(--surface-dark-sub);
  color: #ffffff;
  font-weight: 600;
}

/* ---------- 2. 水平コントロールコンソール ---------- */
.control-console {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 20px;
  background: #e7e4dc;
  border-bottom: 1px solid var(--border-main);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.filter-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.search-cell {
  flex: 1 1 260px;
}

.slider-cell {
  width: 170px;
}

.check-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.action-cell {
  margin-left: auto;
  align-self: flex-end;
}

.ctrl-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ctrl-label-wrap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.range-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
}

#q {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border-main);
  background: var(--surface);
  border-radius: 3px;
  font-size: 12.5px;
  color: var(--text-main);
}

#q:focus {
  outline: none;
  border-color: var(--accent-navy);
}

.slider {
  width: 100%;
  margin: 3px 0;
  cursor: pointer;
}

.chk {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  padding: 3px 0;
}

.btn-reset, #reset {
  padding: 6px 12px;
  border: 1px solid var(--border-main);
  background: var(--surface);
  color: var(--text-main);
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-reset:hover, #reset:hover {
  background: #dbd7cb;
}

/* ---------- 3. メインワークスペース（2カラム） ---------- */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  flex: 1;
  min-height: 0;
  background: var(--bg-app);
}

.content-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border-main);
}

.pane-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 学術的注意事項バナー */
.academic-notice-banner {
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-border);
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-main);
  flex-shrink: 0;
}

.notice-title {
  display: block;
  font-size: 11px;
  color: var(--notice-text);
  margin-bottom: 3px;
}

.rule-list {
  margin: 0;
  padding-left: 16px;
}

.rule-list li {
  margin-bottom: 2px;
}

.rule-list strong {
  color: var(--notice-text);
}

.guide-rules {
  background: rgba(0, 0, 0, 0.035);
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  max-width: 290px;
}

.guide-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.guide-text {
  margin: 0;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* キャンバス領域 */
.cv-stage-wrap, #cvwrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #e9e7df;
}

#cv {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#cv:active {
  cursor: grabbing;
}

/* 左上フローティングズームボタン */
.map-ctrl-floating {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-main);
}

.map-ctrl-floating button {
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border-light);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
}

.map-ctrl-floating button:last-child {
  border-bottom: none;
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 9px;
}

.map-ctrl-floating button:hover {
  background: #eae7dd;
}

/* ---------- 4. 論文一覧ペイン ---------- */
#pane-list, #pane-data {
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--surface-alt);
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--border-main);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.list-title-group strong {
  font-size: 15px;
  color: var(--text-main);
}

.panel-desc {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.counter-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-navy);
  font-variant-numeric: tabular-nums;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-main);
  border-left: 4px solid #737c8b;
  border-radius: 3px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card:hover {
  border-color: var(--accent-navy);
  border-left-color: var(--accent-navy);
}

.card.on {
  border-color: var(--accent-navy);
  border-left: 5px solid var(--accent-navy);
  background: #f4f7fa;
}

.card .t {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-main);
}

.warn {
  margin-left: 6px;
  font-size: 10px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 2px;
  padding: 1px 5px;
  font-weight: 600;
}

.card .m {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 3px;
}

.pair {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.dom {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 500;
}

.arrow {
  color: var(--text-muted);
  font-size: 11px;
}

.m2 {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag {
  font-size: 10.5px;
  border: 1px solid var(--border-main);
  background: var(--surface-alt);
  border-radius: 2px;
  padding: 1px 6px;
  color: var(--text-muted);
}

.badge {
  font-size: 10.5px;
  border-radius: 2px;
  padding: 1px 6px;
  font-weight: 500;
}

.badge.ok {
  background: #def7ec;
  color: #03543f;
  border: 1px solid #bcf0da;
}

.badge.machine {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

.empty {
  background: var(--surface);
  border: 1px solid var(--border-main);
  border-radius: 3px;
  padding: 28px 16px;
  text-align: center;
  margin: 20px 0;
}

.empty .big {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 6px;
}

.empty .muted.small {
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- 5. 統計・データペイン ---------- */
#pane-data h3 {
  font-size: 14px;
  margin: 18px 0 8px;
  color: var(--text-main);
  border-bottom: 2px solid var(--border-main);
  padding-bottom: 4px;
}

#pane-data h3:first-child {
  margin-top: 0;
}

/* ---------- 6. 右側インスペクタパネル ---------- */
.right-inspector {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  min-height: 0;
}

.inspector-section {
  padding: 14px 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-header h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.section-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.group-filter-box {
  border-bottom: 1px solid var(--border-main);
  background: var(--surface-alt);
  flex-shrink: 0;
}

.group-chips-grid, #groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--c);
  background: var(--surface);
  color: var(--c);
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  line-height: 1.25;
}

.chip.on {
  background: var(--c);
  color: #ffffff;
}

.chip .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip .ct {
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  padding: 1px 4px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}

.chip.on .ct {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.hint {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 8px 0 0;
}

/* 詳細内訳（#detail） */
.detail-box, aside.right {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
}

#detail h3 {
  margin: 0 0 5px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-main);
  font-weight: 700;
}

#detail .muted {
  color: var(--text-muted);
}

#detail .small {
  font-size: 11.5px;
  line-height: 1.45;
  margin: 4px 0 8px;
}

.kvs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
  background: var(--surface-alt);
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 3px;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 3px 0;
  border-top: 1px solid #eae7dd;
}

.kv:first-child {
  border-top: none;
}

.kv .k {
  color: var(--text-muted);
  font-weight: 500;
}

.kv .v {
  color: var(--text-main);
  word-break: break-word;
}

.mini {
  border-top: 1px solid var(--border-light);
  padding: 8px 0;
  cursor: pointer;
}

.mini:first-of-type {
  border-top: none;
}

.mini .t {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-navy);
  line-height: 1.4;
}

.mini:hover .t {
  text-decoration: underline;
}

.mini .m {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.doi {
  display: inline-block;
  font-size: 11.5px;
  color: var(--accent-navy);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-navy);
  margin-bottom: 8px;
}

/* ---------- 7. フッター ---------- */
.app-footer, #foot {
  background: #171a20;
  color: #8892a0;
  padding: 7px 20px;
  font-size: 11px;
  line-height: 1.4;
  border-top: 1px solid #0f1216;
  flex-shrink: 0;
}

/* ---------- 8. レスポンシブ ---------- */
@media (max-width: 1024px) {
  body {
    overflow: auto;
  }
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .content-stage {
    border-right: none;
  }
  .right-inspector {
    border-top: 1px solid var(--border-main);
  }
  #cvwrap {
    height: 55vh;
  }
}

/* ---------- 調整（Gemini案への追記） ----------
   上部の帯と注記が縦を食い、キャンバスが 146px まで潰れていた。
   マップは読めることが第一なので最低高さを与え、足りなければページ側をスクロールさせる。 */
body { overflow: auto; height: auto; min-height: 100vh; }
.body.workspace-grid { align-items: stretch; }
#cvwrap, .cv-stage-wrap { min-height: 520px; }
.academic-notice-banner { padding-top: 10px; padding-bottom: 10px; }
.rule-list { margin: 4px 0 0; }
.rule-list li { margin-bottom: 2px; }
/* 右インスペクタは長くなるので、画面内で個別にスクロールさせる */
.right-inspector { max-height: none; }
.detail-box { max-height: 60vh; overflow: auto; }

/* 尺度の表示 */
.sub-h { margin: 16px 0 4px; font-size: 13px; border-top: 1px solid var(--border-main); padding-top: 10px; }
.mini .ref { font-size: 11px; color: var(--text-muted); word-break: break-all; }
.mini .warnnote { color: var(--notice-text); background: var(--notice-bg); border-left: 2px solid var(--notice-border); padding: 3px 6px; margin-top: 3px; font-size: 11.5px; }

/* Detailed exploration */
[hidden] { display: none !important; }
button, select, input { font: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, [role="button"]:focus-visible { outline: 3px solid #489bd2; outline-offset: 3px; }
.top-nav { flex-wrap: wrap; padding-block: 14px; }
.brand-main { font-size: 18px; }
.brand-sub { margin-top: 5px; }
#tabs button { padding: 8px 12px; white-space: nowrap; }
.stats-ribbon { margin-left: auto; }
.control-console { gap: 16px; }
.control-console select { background: white; border: 1px solid var(--border-main); padding: 7px 9px; border-radius: 4px; max-width: 180px; }
.survey-mode .workspace-grid { display: block; }
.survey-mode .right-inspector { display: none; }
.survey-mode .content-stage { border: none; }
#pane-survey { display: block; }
.survey-jump { display: block; width: 100%; text-align: left; padding: 10px 12px; background: #edf5fb; border: 1px solid #b6cfe3; color: #1d466c; border-radius: 5px; margin: 12px 0; cursor: pointer; }
.mini a.t, .card a.t, a.paper-title { display: block; color: #163f60; text-decoration: none; }
.mini a.t:hover, .card a.t:hover, a.paper-title:hover { text-decoration: underline; }
.paper-details { border: 1px solid #cad5dc; color: #34566e; background: #f4f8fa; border-radius: 4px; padding: 4px 9px; margin-top: 8px; font-size: 11px; cursor: pointer; }
#pane-matrix { padding: 22px; background: var(--surface-alt); overflow: hidden; }
#matrixpane { min-width: 0; }
#matrixpane h2 { font-size: 23px; margin: 0 0 5px; }
.matrix-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--border-main); margin-top: 20px; }
.relation-matrix { border-collapse: separate; border-spacing: 0; background: white; font-variant-numeric: tabular-nums; }
.relation-matrix th, .relation-matrix td { border-right: 1px solid #e4e0d5; border-bottom: 1px solid #e4e0d5; }
.relation-matrix thead th { position: sticky; top: 0; background: #f1f4f7; z-index: 2; border-top: 4px solid #1d466c; font-size: 10px; min-width: 53px; max-width: 80px; padding: 6px; height: 100px; writing-mode: vertical-rl; text-align: left; }
.relation-matrix th:first-child { position: sticky; left: 0; background: #f1f4f7; z-index: 1; white-space: nowrap; text-align: left; font-size: 11px; padding: 7px 12px; }
.relation-matrix thead th:first-child { writing-mode: horizontal-tb; z-index: 3; }
.relation-matrix td { color: #ccd2d9; text-align: center; min-width: 48px; height: 39px; }
.relation-matrix td button { width: 100%; min-height: 39px; border: 0; cursor: pointer; font-weight: 700; }
.relation-matrix td button:hover { outline: 2px solid #123551; outline-offset: -2px; }
.relation-matrix .matrix-domain { writing-mode: inherit; font: inherit; color: inherit; padding: 4px; border: 0; background: transparent; cursor: pointer; text-align: inherit; }
.relation-matrix .matrix-domain:hover { color: #1d466c; text-decoration: underline; }
.list-actions { display: flex; align-items: center; gap: 14px; }
#pane-list .list-container { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,360px),1fr)); gap: 12px; }
#pane-list .card { margin: 0; }
#pane-list .card.on { background: #eaf3fa; }
@media (max-width: 760px) {
  .top-nav { padding: 16px; gap: 14px; }
  .stats-ribbon { margin-left: 0; flex-wrap: wrap; }
  .stat small { display: none; }
  .nav-switcher { width: 100%; overflow-x: auto; }
  #tabs button { flex: 1; padding: 8px; }
  .control-console { padding: 14px; gap: 12px; }
  .academic-notice-banner { display: block; }
  .guide-rules { margin-top: 10px; max-width: none; }
  .detail-box { max-height: none; }
  #pane-matrix { padding: 16px; }
  .brand-main { font-size: 16px; }
  .list-actions { flex-wrap: wrap; gap: 7px; justify-content: end; }
}

/* Theme coverage and papers without assigned themes */
.paper-topics { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.paper-authors { margin: 10px 0; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.kv .v { white-space: pre-line; }
.unmapped-papers { flex-shrink: 0; padding: 10px 18px; background: var(--surface-alt); border-top: 1px solid var(--border-main); font-size: 12px; }
.unmapped-papers summary { cursor: pointer; font-weight: 600; }
.unmapped-paper-cards { max-height: 30vh; overflow: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 10px; margin-top: 10px; }
.unmapped-paper-cards .mini { margin: 0; padding: 12px; background: white; border: 1px solid var(--border-main); border-radius: 4px; }
.unmapped-paper-cards .m { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 6px; }
#paper-search-summary { align-items: center; }
#paper-search-summary button { flex-shrink: 0; }
#paper-search-summary button:disabled { opacity: .5; cursor: default; }
@media (max-width: 760px) {
  .stat:nth-child(2) small { display: block; }
  #paper-search-summary button { margin-top: 8px; }
  .unmapped-papers { padding: 12px 14px; }
  .unmapped-paper-cards { max-height: 45vh; }
}

/* ---------- テーマ配色（wesanderson Zissou1 を基本に、白地・黒の塗りなし。https://github.com/karthik/wesanderson） ---------- */
:root {
  --bg-app: #f7f6f4;
  --surface-alt: #faf9f7;
  --text-main: #2f3437;
  --text-muted: #5e666c;
  --border-main: #d9d4d0;
  --border-light: #ebe7e3;
  --accent-main: #3b9ab2;   /* Zissou1 */
  --accent-deep: #23707f;   /* Zissou1 #3B9AB2 の暗色（小さい文字の可読性のため） */
  --accent-tint: #e3f1f5;
  --accent-hl: #f21a00;     /* Zissou1。選択中・起点の強調だけに使う */
  --accent-hl-tint: #fde6e2;
  --zissou-band: linear-gradient(90deg, #3b9ab2 0 20%, #78b7c5 20% 40%, #ebcc2a 40% 60%, #e1af00 60% 80%, #f21a00 80% 100%);
  --accent-navy: #23707f;
  --accent-blue: #3b9ab2;
  --notice-bg: #fdf9ea;
  --notice-border: #ecdca0;
  --notice-text: #6b5300;
}
.top-nav { background: #ffffff; color: var(--text-main); border-top: 0; box-shadow: inset 0 5px 0 -0px transparent; border-bottom: 1px solid var(--border-main); position: relative; padding-top: 13px; }
.top-nav::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--zissou-band); }
.brand-badge { background: var(--accent-main); color: #ffffff; border-color: var(--accent-main); }
.brand-sub { color: var(--text-muted); }
.stat { background: var(--surface-alt); border-color: var(--border-light); }
.stat b { color: var(--accent-main); }
.stat span { color: var(--text-main); }
.stat small { color: var(--text-muted); }
.nav-switcher { background: #f3f1ef; border-color: var(--border-light); }
#tabs button { color: var(--text-muted); }
#tabs button:hover { color: var(--accent-deep); }
#tabs button.on { background: #ffffff; color: var(--accent-deep); box-shadow: inset 0 -3px 0 var(--accent-main); }
.control-console { background: #f1efec; }
.slider { accent-color: var(--accent-main); }
input[type="checkbox"] { accent-color: var(--accent-main); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, [role="button"]:focus-visible { outline-color: var(--accent-blue); }
.survey-jump { background: #eaf4f7; border-color: #b4d6e0; color: var(--accent-navy); }
.mini a.t, .card a.t, a.paper-title { color: #1f6475; }
.relation-matrix thead th { border-top-color: var(--accent-main); background: #f5f3f1; }
.relation-matrix th:first-child { background: #f5f3f1; }
.relation-matrix .matrix-domain:hover { color: var(--accent-deep); }
#pane-list .card.on { background: var(--accent-tint); }
.app-footer, #foot { background: #f1efec; color: var(--text-muted); border-top: 1px solid var(--border-main); }
.cv-stage-wrap, #cvwrap { background: #ffffff; }
.chip { color: color-mix(in srgb, var(--c) 55%, #2f3437); border-left-width: 4px; }
.chip.on { color: #1a1f23; }
.relation-matrix td button:hover { outline-color: var(--accent-hl); }
.card { border-left-color: var(--accent-blue); }
.card:hover { border-left-color: var(--accent-main); }
.badge.ok { background: #e3f1f5; color: #1f5f6e; border-color: #b4d6e0; }

/* ---------- 論文のつながり ---------- */
:root { --canvas-ink: #2f3437; --canvas-edge: #8fa3aa; --canvas-node-edge: #ffffff; --canvas-label-bg: rgba(255,255,255,.88); }
#pane-links { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.links-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border-light); background: var(--surface); }
.links-title strong { font-size: 15px; }
.links-title .panel-desc { margin: 2px 0 0; }
.links-seed { position: relative; display: flex; flex-direction: column; gap: 3px; width: min(420px, 100%); }
.links-seed input { padding: 7px 10px; border: 1px solid var(--border-main); border-radius: 4px; background: var(--surface); color: var(--text-main); font: inherit; }
.link-suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--border-main); border-radius: 4px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 340px; overflow: auto; }
.link-suggest button { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border-light); background: transparent; color: var(--text-main); padding: 7px 10px; cursor: pointer; }
.link-suggest button:hover { background: var(--accent-tint); }
.links-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); }
.links-stage { position: relative; min-height: 480px; background: var(--surface); }
#lcv { width: 100%; height: 100%; display: block; cursor: grab; }
.links-legend { position: absolute; left: 12px; bottom: 10px; max-width: 360px; background: var(--canvas-label-bg); border: 1px solid var(--border-light); border-radius: 4px; padding: 6px 9px; font-size: 10.5px; color: var(--text-muted); }
.links-legend p { margin: 4px 0 0; line-height: 1.5; }
.legend-years { display: flex; align-items: center; gap: 6px; }
.legend-ramp { display: inline-block; width: 120px; height: 8px; border-radius: 4px; }
.link-list { overflow: auto; padding: 12px 14px; border-left: 1px solid var(--border-light); background: var(--surface-alt); }
.link-seed-card { padding: 10px 12px; border: 1px solid var(--border-light); border-left: 4px solid var(--accent-hl); border-radius: 4px; background: var(--surface); margin-bottom: 6px; }
.lr-k { font-size: 10px; font-weight: 700; color: var(--accent-hl); letter-spacing: .08em; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--border-light); background: transparent; color: var(--text-main); }
.link-row.on { background: var(--accent-tint); }
button.link-row { cursor: pointer; display: flex; flex-direction: column; }
.link-row .lr-t, .link-suggest .lr-t { font-size: 12px; line-height: 1.45; font-weight: 600; color: var(--text-main); }
.link-row button.lr-t { grid-column: 1; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.link-row button.lr-t:hover { color: var(--accent-deep); text-decoration: underline; }
.link-row .lr-m, .link-suggest .lr-m { grid-column: 1; font-size: 10.5px; color: var(--text-muted); }
.link-row .lr-go { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 10.5px; padding: 3px 7px; border: 1px solid var(--border-main); border-radius: 3px; background: var(--surface); color: var(--accent-navy); cursor: pointer; white-space: nowrap; }
.link-row .lr-go:hover { border-color: var(--accent-main); color: var(--accent-deep); }
.theme-toggle { margin-left: 8px; padding: 5px 11px; font-size: 11.5px; border: 1px solid var(--border-main); border-radius: 14px; background: var(--surface); color: var(--text-main); cursor: pointer; white-space: nowrap; }
.theme-toggle:hover { border-color: var(--accent-main); color: var(--accent-deep); }
@media (max-width: 900px) { .links-body { grid-template-columns: 1fr; } .link-list { border-left: 0; border-top: 1px solid var(--border-light); } .links-stage { min-height: 420px; } }
.links-body { grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.links-stage, .link-list { min-height: 0; }
.links-stage { height: 100%; }
@media (max-width: 900px) { .links-body { grid-template-rows: 420px auto; overflow: visible; } }
.links-body { display: block; position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; }
.links-stage { position: absolute; top: 0; bottom: 0; left: 0; right: 360px; height: auto; min-height: 0; }
.link-list { position: absolute; top: 0; bottom: 0; right: 0; width: 360px; }
@media (max-width: 900px) {
  .links-body { overflow: visible; flex: none; }
  .links-stage { position: relative; right: auto; height: 420px; }
  .link-list { position: static; width: auto; }
}

/* ---------- ダークモード（黒ではなく深いスレートを地にし、Zissou1 の淡青を強調に） ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-app: #1a1f23;
  --surface: #22282d;
  --surface-alt: #1e2428;
  --text-main: #e4e7e9;
  --text-muted: #a3acb2;
  --border-main: #3a444b;
  --border-light: #2f383e;
  --accent-main: #78b7c5;
  --accent-deep: #9fd3df;
  --accent-tint: #1f3339;
  --accent-hl: #f21a00;
  --accent-hl-tint: #3d1f1a;
  --accent-navy: #7cc4d6;
  --accent-blue: #5fb3c9;
  --notice-bg: #2a2718;
  --notice-border: #5a4f22;
  --notice-text: #e8d27a;
  --canvas-ink: #e4e7e9;
  --canvas-edge: #6d8088;
  --canvas-node-edge: #22282d;
  --canvas-label-bg: rgba(34,40,45,.88);
}
:root[data-theme="dark"] body { background: var(--bg-app); color: var(--text-main); }
:root[data-theme="dark"] .top-nav { background: var(--surface); }
:root[data-theme="dark"] .nav-switcher { background: var(--surface-alt); }
:root[data-theme="dark"] #tabs button.on { background: var(--surface); }
:root[data-theme="dark"] .control-console, :root[data-theme="dark"] .app-footer, :root[data-theme="dark"] #foot { background: #1e2428; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] button { color: var(--text-main); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select { background: var(--surface); border-color: var(--border-main); }
:root[data-theme="dark"] .cv-stage-wrap, :root[data-theme="dark"] #cvwrap { background: var(--surface); }
:root[data-theme="dark"] .mini a.t, :root[data-theme="dark"] .card a.t, :root[data-theme="dark"] a.paper-title { color: #8fd0e0; }
:root[data-theme="dark"] .survey-jump { background: #1f3339; border-color: #2f5560; color: #9fd6e4; }
:root[data-theme="dark"] .paper-details { background: #1f3339; border-color: #2f5560; color: #9fd6e4; }
:root[data-theme="dark"] .relation-matrix thead th, :root[data-theme="dark"] .relation-matrix th:first-child { background: #262d32; }
:root[data-theme="dark"] .relation-matrix th, :root[data-theme="dark"] .relation-matrix td { border-color: var(--border-light); }
:root[data-theme="dark"] .relation-matrix td { color: #4b565d; }
:root[data-theme="dark"] .badge.ok { background: #1f3339; color: #9fd6e4; border-color: #2f5560; }
:root[data-theme="dark"] .badge.machine, :root[data-theme="dark"] .tag { background: #2a3136; color: var(--text-muted); border-color: var(--border-main); }
:root[data-theme="dark"] .chip { background: var(--surface); color: color-mix(in srgb, var(--c) 70%, #ffffff); }
:root[data-theme="dark"] .chip.on { background: var(--c); color: #1a1f23; }
:root[data-theme="dark"] .stat { background: var(--surface-alt); }

/* 使い方タブ */
.guide-mode .workspace-grid { display: block; }
.guide-mode .right-inspector { display: none; }
#pane-guide { overflow: auto; }
.guide { max-width: 860px; margin: 0 auto; padding: 24px 20px 48px; line-height: 1.8; }
.guide h3 { letter-spacing: .06em; color: var(--accent-deep); font-size: 16px; margin: 28px 0 8px; border-bottom: 1px solid var(--border-main); padding-bottom: 4px; }
.guide h3:first-child { margin-top: 0; }
.guide dl { margin: 0; }
.guide dt { font-weight: 700; color: var(--accent-deep); margin-top: 10px; }
.guide dd { margin: 2px 0 0 1em; }
.guide ol, .guide ul { padding-left: 1.4em; }
.guide li { margin: 4px 0; }
.guide .guide-foot { color: var(--text-muted); font-size: 12px; margin-top: 20px; }

.guide table.howto { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0 4px; }
.guide table.howto th, .guide table.howto td { border: 1px solid var(--border-main); padding: 8px 10px; vertical-align: top; text-align: left; }
.guide table.howto th { background: var(--surface-alt); color: var(--accent-deep); font-weight: 700; white-space: nowrap; }
.guide table.howto td:nth-child(2) { white-space: nowrap; }
.guide table.howto a.tab-jump, .guide a.paper-jump { font-weight: 700; color: var(--accent-deep); }
.guide ol.steps li { margin: 8px 0; }
.guide details.guide-full { margin-top: 12px; border: 1px solid var(--border-main); padding: 8px 12px; background: var(--surface-alt); }
.guide details.guide-full summary { cursor: pointer; font-weight: 700; color: var(--accent-deep); }
.guide .guide-body { margin-top: 10px; }
.guide .guide-body h2 { font-size: 17px; margin: 22px 0 6px; }
.guide .guide-body h3 { font-size: 15px; border: 0; margin: 16px 0 4px; }
.guide .guide-body h4 { font-size: 14px; margin: 12px 0 4px; }
.guide .guide-body .tbl { overflow-x: auto; }
.guide .guide-body table { border-collapse: collapse; font-size: 12.5px; }
.guide .guide-body th, .guide .guide-body td { border: 1px solid var(--border-main); padding: 4px 8px; }
@media (max-width: 760px) { .guide table.howto td:nth-child(2) { white-space: normal; } }

/* ガイドの代表論文（JACSIS/JASTIS 以外） */
.badge.guide { background: #fdf3e3; color: #7a4b12; border-color: #e6c48f; }
.card .guide-why { margin: 6px 0 0; font-size: 12.5px; color: var(--text-muted); }
:root[data-theme="dark"] .badge.guide { background: #3a2f1e; color: #f2d5a4; border-color: #6b5230; }
/* ガイド全文: 数式と見出し */
.guide .guide-body p.formula { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 14px; background: var(--surface); border: 1px solid var(--border-main); padding: 8px 12px; overflow-x: auto; }
.guide .guide-body sub { font-size: .75em; }
.guide .guide-body h2 { font-size: 18px; margin: 26px 0 8px; color: var(--accent-deep); border-bottom: 1px solid var(--border-main); padding-bottom: 4px; }
.guide .guide-body h3 { font-size: 16px; margin: 20px 0 6px; color: var(--accent-deep); border: 0; }
.guide .guide-body h4 { font-size: 15px; margin: 14px 0 4px; color: var(--text-main); }
.guide .guide-body h5 { font-size: 14px; margin: 12px 0 4px; color: var(--text-main); }

#foot a.foot-updates { color: inherit; opacity: .75; text-decoration: underline; text-underline-offset: 2px; }
#foot a.foot-updates:hover { opacity: 1; }
