/* ===== DESIGN TOKENS ===== */
:root {
  color-scheme: dark;
  /* --- Base Dark Tones --- */
  --bg:                     #16191a;
  --bg-soft:                #1d1f21;
  --panel:                  #2c2c2c;
  --panel-raised:           #383838;
  --ink:                    #f8f8f2;
  --muted:                  #b1b1b1;
  --line:                   #333333;
  --line-strong:            #5a5a5a;
  /* --- Accent Colors  --- */
  --accent:                 #2a60d9;
  --accent-strong:          #487df2;
  --accent-dim:             rgba(42, 96, 217, 0.12);
  --accent-hover-dim:       rgba(42, 96, 217, 0.18);
  --accent-focus-border:    rgba(42, 96, 217, 0.6);
  --accent-focus-shadow:    rgba(42, 96, 217, 0.15);
  --accent-focus-outline:   rgba(42, 96, 217, 0.5);
  
  --gold:                   #cfc768; /* Desaturated from #e6db74 */
  --rose:                   #d3517e; /* Desaturated from #f92672 */
  --sky:                    #59b9cb; /* Desaturated from #66d9ef */
  --purple:                 #967ed1; /* Desaturated from #ae81ff */

  /* --- Component Specific Colors --- */
  --topbar-bg:              rgba(25, 26, 22, 0.98);
  --ink-on-accent:          #ffffff; /* White text for contrast on deep blue background */
  --snippet-text:           #c5c8c0;
  --keyword-meter-bg:       #2d2e27;
  --keyword-meter-fill:     var(--muted); /* Desaturated monochrome meter fill, or use var(--line-strong) */
  --keyword-word-color:     var(--ink);   /* Saturation 0, clean default ink text */
  --modal-overlay-bg:       rgba(0, 0, 0, 0.65);
  
  --row-hover-bg:           rgba(42, 96, 217, 0.06);
  --row-active-bg:          rgba(42, 96, 217, 0.10);
  
  --option-hover-bg:        rgba(42, 96, 217, 0.05);
  --option-hover-border:    rgba(42, 96, 217, 0.18);

  --secondary-btn-border:   rgba(42, 96, 217, 0.25);
  --secondary-btn-bg:       rgba(42, 96, 217, 0.06);
  --secondary-btn-hover-bg: rgba(42, 96, 217, 0.12);

  /* --- Badges --- */
  --badge-default-bg:       rgba(255, 255, 255, 0.05);
  --badge-default-border:   rgba(255, 255, 255, 0.08);
  --badge-default-text:     #a8a8a2;
  
  --badge-orbit-bg:         rgba(89, 185, 203, 0.12);
  --badge-orbit-text:       var(--sky);
  --badge-citation-bg:      rgba(207, 199, 104, 0.12);
  --badge-citation-text:    var(--gold);
  --badge-flag-bg:          rgba(207, 199, 104, 0.09);
  --badge-flag-text:        var(--gold);
  --badge-pha-bg:           rgba(211, 81, 126, 0.12);
  --badge-pha-text:         var(--rose);

  /* --- Scrollbar & Selection --- */
  --scrollbar-thumb:        #44453e;
  --scrollbar-thumb-hover:  #64655b;
  --selection-bg:           var(--accent-strong);
  --selection-color:        #191a16;

  /* --- Layout & Metrics --- */
  --header-h:       56px;
  --search-h:       72px;   /* searchbar row height */
  --tags-h:         40px;   /* filter tags row max height */
  --shadow:         0 8px 32px rgba(0,0,0,0.5);
  --radius:         10px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;           /* ← no page scroll */
}
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
h1,h2,h3,p { margin: 0; }
button, input, select { font: inherit; }
input::-webkit-search-cancel-button {
  appearance: none;
}

/* ===== TOPBAR ===== */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-logo {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}
h1 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.3px;
}
.dataset-meta {
  color: var(--muted);
  font-size: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
}
.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}
.lang-switch {
  min-height: 32px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a8a8a2'/%3E%3C/svg%3E") no-repeat right 10px center,
      var(--panel-raised);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.lang-switch:focus {
  outline: 2px solid var(--accent-focus-outline);
  border-color: var(--accent-focus-border);
}
.metric-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 4px 12px;
}
.metric-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.metric-chip strong {
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 760;
  line-height: 1.2;
}

/* ===== SEARCH BAR ZONE ===== */
.searchbar-zone {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 16px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.searchbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
/* スクロールシャドウ用ラッパー (desktop: 無効) */
.search-scroll-container {
  position: relative;
}

/* Search input */
.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input-wrap:focus-within {
  border-color: var(--accent-focus-border);
  box-shadow: 0 0 0 3px var(--accent-focus-shadow);
}
.search-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
}
#query {
  flex: 1;
  min-height: 40px;
  border: none;
  background: transparent;
  color: var(--ink);
  outline: none;
  font-size: 14px;
}
#query::placeholder { color: var(--muted); }
.clear-kbd {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.clear-kbd:hover { background: var(--panel); color: var(--ink); }

.query-mode-select {
  min-height: 40px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a8a8a2'/%3E%3C/svg%3E") no-repeat right 12px center,
      var(--panel-raised);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  appearance: none;
    -webkit-appearance: none;
}

.query-mode-select:focus {
  outline: 2px solid var(--accent-focus-outline);
  border-color: var(--accent-focus-border);
}
/* Filter menu button */
.filter-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-raised);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.filter-menu-btn svg { width: 16px; height: 16px; }
.filter-menu-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}
.inline-reset-btn {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
  white-space: nowrap;
}
.filter-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink-on-accent);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Sort controls */
.sort-controls {
  display: flex;
  gap: 6px;
}
.sort-controls select {
  min-height: 40px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a8a8a2'/%3E%3C/svg%3E") no-repeat right 12px center,
      var(--panel-raised);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
    -webkit-appearance: none;
}
.sort-controls select:focus {
  outline: 2px solid var(--accent-focus-outline);
  border-color: var(--accent-focus-border);
}

/* ===== ACTIVE FILTER TAGS ===== */
.active-filter-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0 2px;
}
.active-filter-tags::-webkit-scrollbar { display: none; }

.query-help {
  margin: 2px 2px 0;
  color: var(--muted);
  opacity: 0.72;
  font-size: 11px;
  line-height: 1.4;
}
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}
.filter-tag:hover { border-color: var(--accent); background: var(--accent-dim); }
.filter-tag.search-tag {
  border-color: rgba(89, 185, 203, 0.45);
  background: rgba(89, 185, 203, 0.10);
}

.filter-tag.search-tag .filter-tag-kind {
  color: var(--sky);
}
.filter-tag.search-tag.search-tag-not {
  border-color: rgba(211, 81, 126, 0.55);
  background: rgba(211, 81, 126, 0.14);
}

.filter-tag.search-tag.search-tag-not .filter-tag-kind {
  color: var(--rose);
}
.filter-tag-kind {
  color: var(--muted);
  font-weight: 500;
}
.filter-tag-remove {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  margin-left: 2px;
  transition: color 0.1s;
}
.filter-tag:hover .filter-tag-remove { color: var(--rose); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  min-height: 0;     /* critical: allows flex children to scroll */
  overflow: hidden;
}

/* ===== RESULTS PANEL ===== */
.results-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  position: relative;
}
.results-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.result-summary {
  color: var(--muted);
  font-size: 12px;
}
.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
#pageLabel {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.page-selector {
  position: relative;
  display: inline-block;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  justify-content: space-between;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.page-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-strong);
}
.page-btn-icon {
  font-size: 8px;
  color: var(--muted);
  transition: transform 0.15s;
}
.page-btn[aria-expanded="true"] .page-btn-icon {
  transform: rotate(180deg);
}
.page-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  min-width: 140px;
  max-height: 260px;
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.page-dropdown-search {
  padding: 6px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  position: sticky;
  top: 0;
  background: var(--panel-raised);
  z-index: 10;
}
.page-dropdown-search input {
  flex: 1;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  padding: 0 6px;
  outline: none;
  min-width: 0;
}
.page-dropdown-search input:focus {
  border-color: var(--accent);
}
.page-dropdown-search button {
  height: 26px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--ink-on-accent);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.page-dropdown-search button:hover {
  opacity: 0.9;
}
.page-dropdown-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}
.page-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.page-dropdown-item:hover {
  background: var(--accent-dim);
  color: var(--accent-strong);
}
.page-dropdown-item.active {
  background: var(--accent);
  color: var(--ink-on-accent);
  font-weight: 700;
}
.icon-button {
  width: 30px;
  height: 30px;
  min-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}
.icon-button:hover { border-color: var(--accent); }
.icon-button:disabled { opacity: 0.35; cursor: default; }

.result-list {
  flex: 1;
  overflow-y: auto;
}
.result-row {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: transparent;
  color: var(--ink);
  width: 100%;
  cursor: pointer;
  transition: background 0.1s, border-left-color 0.1s;
}
.result-row:hover {
  background: var(--row-hover-bg);
  border-left-color: var(--accent);
}
.result-row.active {
  background: var(--row-active-bg);
  border-left-color: var(--accent);
}
.row-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.row-title strong { font-size: 15px; font-weight: 700; }
.meta { color: var(--muted); font-size: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--badge-default-border);
  background: var(--badge-default-bg);
  color: var(--badge-default-text);
  font-size: 11px;
  font-weight: 700;
}
.badge.orbit  { background: var(--badge-orbit-bg); color: var(--badge-orbit-text); }
.badge.citation { background: var(--badge-citation-bg); color: var(--badge-citation-text); }
.badge.flag   { background: var(--badge-flag-bg); color: var(--badge-flag-text); }
.badge.pha    { background: var(--badge-pha-bg); color: var(--badge-pha-text); }
.snippet { color: var(--snippet-text); font-size: 13px; line-height: 1.45; }
.discovery-line { color: var(--muted); font-size: 12px; }
.empty { padding: 24px 16px; color: var(--muted); font-size: 13px; }

/* ===== SIDE PANEL ===== */
.side-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
.side-panel-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.side-panel-wordcloud {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: 280px;
}
.panel-title {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--panel-raised);
}
.word-count-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.detail-body .row-title { margin-bottom: 8px; }
.detail-body .row-title strong { font-size: 16px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.detail-grid div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  font-size: 12px;
  color: var(--ink);
}
.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}
.citation-text {
  margin-top: 10px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* ===== WORDCLOUD ===== */
.word-cloud {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.keyword-row {
  display: grid;
  grid-template-columns: 24px 1fr 80px 36px;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  min-height: 28px;
  border-radius: 0;
  cursor: default;
  transition: background 0.1s;
}
.keyword-row:hover { background: var(--row-hover-bg); }
.keyword-rank { color: var(--muted); font-size: 11px; font-weight: 700; text-align: right; }
.keyword-word { color: var(--keyword-word-color); font-size: 13px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keyword-meter { display: block; height: 6px; border-radius: 999px; background: var(--keyword-meter-bg); overflow: hidden; }
.keyword-meter span { display: block; height: 100%; border-radius: inherit; background: var(--keyword-meter-fill); }
.keyword-count { color: var(--muted); font-size: 11px; font-weight: 700; text-align: right; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  z-index: 999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: calc(var(--header-h) + var(--search-h) + 8px);
  backdrop-filter: blur(3px);
}
.modal-panel {
  width: min(780px, 96vw);
  max-height: calc(100vh - var(--header-h) - var(--search-h) - 30px);
  display: flex;
  flex-direction: column;
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: slide-down 0.18s ease;
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-header h2 { font-size: 16px; }
.modal-close {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  min-height: 0;
}
.modal-close:hover { background: var(--panel); color: var(--ink); }
.modal-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0;
}
.filter-section {
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.filter-section:nth-child(3n) { border-right: none; }
.filter-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.modal-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
button.secondary {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--secondary-btn-border);
  border-radius: 6px;
  background: var(--secondary-btn-bg);
  color: var(--accent-strong);
  font-weight: 650;
  cursor: pointer;
}
button.secondary:hover { background: var(--secondary-btn-hover-bg); }
button.primary {
  min-height: 36px;
  padding: 0 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink-on-accent);
  font-weight: 750;
  cursor: pointer;
  transition: opacity 0.1s;
}
button.primary:hover { opacity: 0.88; }

/* ===== CHECK LIST ===== */
.check-list {
  display: grid;
  gap: 3px;
  max-height: 200px;
  overflow: auto;
}
.check-list.compact { max-height: none; }
.check-option {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
}
.check-option:hover { background: var(--option-hover-bg); border-color: var(--option-hover-border); }
.check-option input { width: 14px; min-height: 14px; accent-color: var(--accent); }
.check-option .label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-option .count { color: var(--muted); font-size: 11px; font-weight: 650; }
/* 0件オプション: 薄く表示し、ホバー効果も無効化 */
.check-option.is-zero {
  opacity: 0.38;
  cursor: not-allowed;
}
.check-option.is-zero:hover {
  background: transparent;
  border-color: transparent;
}


/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ===== SELECTION ===== */
::selection { color: var(--selection-color); background: var(--selection-bg); }

/* ===== Focus ===== */
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-focus-outline);
  outline-offset: 2px;
}

/* ===== SNIPPET KEYWORD HIGHLIGHT ===== */
mark.hl {
  background: rgba(207, 199, 104, 0.30); /* --gold with low opacity */
  color: var(--gold);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* ===== EXTERNAL LINKS ROW (detail panel) ===== */
.ext-links {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--secondary-btn-border);
  background: var(--secondary-btn-bg);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}
.ext-link--mpc {
  color: var(--sky);
}
.ext-link--mpc:hover {
  background: var(--secondary-btn-hover-bg);
  border-color: var(--sky);
}
.ext-link--jpl {
  color: var(--gold);
}
.ext-link--jpl:hover {
  background: rgba(207, 199, 104, 0.10);
  border-color: var(--gold);
}

/* ===== SITE FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 10px 16px;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.site-footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.site-footer a:hover {
  color: var(--ink);
}

/* ===== SIDE PANEL MOBILE HEADER (desktop: hidden) ===== */
.side-panel-mobile-header {
  display: none;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 44px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-raised);
  gap: 8px;
}
.side-tabs {
  display: flex;
  gap: 4px;
}
.side-tab {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.side-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent-focus-border);
  color: var(--accent-strong);
}
.close-side-panel {
  width: 32px; height: 32px;
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  min-height: 0;
}
.close-side-panel:hover { background: var(--panel); color: var(--ink); }

/* Mobile overlay behind bottom sheet */
.mobile-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ===== RESPONSIVE: <= 740px ===== */
@media (max-width: 740px) {

  /* ---------- Header: Updated & Named Objects 非表示 ---------- */
  .dataset-meta,
  .metric-chip {
    display: none;
  }

  /* ---------- Search bar: 2段レイアウト ---------- */
  .searchbar-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  /* 1段目: 検索ボックス全幅 */
    .search-input-wrap {
    flex: 1 1 100%;
  }
    /* 2段目: ラッパーが横スクロールコンテキスト */
    .search-scroll-container {
      flex: 1 1 100%;
      position: relative;
      overflow: hidden;
      /* シャドウのはみ出しをクリップ */
    }
  
    .search-scroll-container::before,
    .search-scroll-container::after {
      content: "";
      position: absolute;
      top: 0;
      bottom: 0;
      width: 18px;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s;
      z-index: 10;
    }
  
    .search-scroll-container::before {
      left: 0;
      background: linear-gradient(to right, rgba(255, 255, 255, 0.12), transparent);
    }
  
    .search-scroll-container::after {
      right: 0;
      background: linear-gradient(to left, rgba(255, 255, 255, 0.12), transparent);
    }
  
    .search-scroll-container.can-scroll-left::before {
      opacity: 1;
    }
  
    .search-scroll-container.can-scroll-right::after {
      opacity: 1;
    }
  
    /* 2段目: コントロールを横スクロール1行に */
    .search-controls-row {
    overflow-x: auto;
      scrollbar-width: none;
      flex-wrap: nowrap;
      padding-bottom: 2px;
  }
    .search-controls-row::-webkit-scrollbar {
      display: none;
    }

  /* ---------- body: スクロール許可（モバイルでは高さ固定解除） ---------- */
  html, body {
    overflow: auto;
    height: auto;
  }
  body {
    min-height: 100dvh;
    /* 常時表示のミニタブバー分のパディング */
      padding-bottom: 44px;
  }

    /* ---------- メインコンテンツ: 縦１列 ---------- */
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow: visible;
    height: auto;
    min-height: 60vh;
  }

  /* 検索結果は全幅 */
  .results-panel {
    border-right: none;
    overflow: visible;
    min-height: 60vh;
  }
  .result-list {
    overflow: visible;
  }

    /* ---------- サイドパネル: 常時表示ミニタブ + ボトムシート ---------- */
  .side-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72vh;
    max-height: 72vh;
    z-index: 200;
    border-radius: 16px 16px 0 0;
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
      /* デフォルト: タブバー分のみ表示 */
      transform: translateY(calc(100% - 44px));
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    overflow: hidden;
  }
  .side-panel.is-open {
    transform: translateY(0);
  }

  /* モバイルヘッダー表示 */
  .side-panel-mobile-header {
    display: flex;
    cursor: pointer;
      /* タップで展開できることを示唆 */
  }

  /* デスクトップ用タイトルを非表示（タブで代替） */
  .side-panel-detail > .panel-title,
  .side-panel-wordcloud > .panel-title {
    display: none;
  }

  /* タブパネルの表示/非表示 */
  .side-panel-detail,
  .side-panel-wordcloud {
    display: none;
    flex: 1;
    min-height: 0;
  }
  .side-panel-detail.tab-active,
  .side-panel-wordcloud.tab-active {
    display: flex;
    flex-direction: column;
  }
  /* キーワード頻度パネルは固定高を解除 */
  .side-panel-wordcloud.tab-active {
    height: auto;
  }

  /* ---------- フィルターモーダル: 1カラム ---------- */
  .modal-overlay {
    padding-top: calc(var(--header-h) + 8px);
    align-items: flex-start;
  }
  .modal-panel {
    max-height: calc(100dvh - var(--header-h) - 16px);
    border-radius: 10px;
  }
  .modal-body {
    grid-template-columns: 1fr;
  }
  .filter-section:nth-child(3n) { border-right: 1px solid var(--line); }
  .filter-section:last-child { border-right: none; }
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 18, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
  border-radius: 8px;
}
.loading-overlay[hidden] {
  display: none;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}
