/* ============================================================
   climate-check — Styles
   Requires tokens.css loaded first.
   ============================================================ */

/* ============================================================
   BASE
   ============================================================ */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.9em; }
table { border-collapse: collapse; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ---- Focus ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
input:focus-visible,
.gallery-search:focus-visible,
.gallery-sort:focus-visible {
  outline: none;
}

/* ============================================================
   SHELL (header, footer, main, loader, skip-link)
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--border-muted);
}
.site-header-inner {
  max-width: var(--max-content-width); margin: 0 auto;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
}
.site-logo {
  display: flex; align-items: center; gap: var(--space-2);
  text-decoration: none; color: var(--fg);
  font-weight: 700; font-size: var(--text-lg);
}
.site-logo:hover { text-decoration: none; opacity: 0.85; }
.site-logo svg { color: var(--accent); }
.site-tagline { font-size: var(--text-base); color: var(--fg-faint); }
.header-lang { margin-left: auto; }
.lang-select {
  font-family: inherit;
  font-size: var(--text-sm); font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
}
.lang-select:disabled { opacity: 0.5; cursor: default; }

.site-main {
  flex: 1; max-width: var(--max-content-width); width: 100%;
  margin: 0 auto; padding: var(--space-4);
}

.site-footer {
  border-top: 1px solid var(--border-muted);
  padding: var(--space-2) var(--space-4);
}
.site-footer-inner {
  max-width: var(--max-content-width); margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: var(--space-2);
  font-size: var(--text-sm); color: var(--fg-faint);
}
.site-footer a { color: var(--fg-faint); }
.site-footer a:hover { color: var(--fg-muted); }
.footer-links { display: flex; gap: var(--space-3); }

.skip-link {
  position: absolute; top: -40px; left: 0;
  background: var(--accent-emphasis); color: #fff;
  padding: var(--space-2) var(--space-3); z-index: var(--z-overlay);
  font-size: var(--text-base); text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus { top: 0; }

.loader {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-6) var(--space-4); gap: var(--space-3);
}
.loader-spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* Display */
.d-flex    { display: flex; }
.d-block   { display: block; }
.d-inline-block { display: inline-block; }
.d-none    { display: none; }

/* Flexbox */
.flex-items-center  { align-items: center; }
.flex-items-start   { align-items: flex-start; }
.flex-justify-center  { justify-content: center; }
.flex-justify-between { justify-content: space-between; }
.flex-wrap   { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }

/* Gap */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* Margin */
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-1 { margin-top: var(--space-1); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.ml-1 { margin-left: var(--space-1); }
.mr-1 { margin-right: var(--space-1); }
.mr-2 { margin-right: var(--space-2); }

/* Padding */
.p-0  { padding: 0; }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-5  { padding: var(--space-5); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.pb-3 { padding-bottom: var(--space-3); }

/* Typography */
.f1 { font-size: var(--text-2xl); line-height: 1.2; }
.f2 { font-size: var(--text-xl); line-height: 1.3; }
.f3 { font-size: var(--text-lg); line-height: 1.35; }
.f4 { font-size: var(--text-lg); line-height: 1.4; }
.f5 { font-size: var(--text-base); line-height: 1.5; }
.f6 { font-size: var(--text-sm); line-height: 1.5; }

.text-bold   { font-weight: 600; }
.text-normal { font-weight: 400; }
.text-uppercase { text-transform: uppercase; letter-spacing: 0.03em; }
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }
.text-mono   { font-family: var(--font-mono); font-size: 0.9em; }

/* Semantic label (reused by filter headings, table headers, KPI labels) */
.label-xs {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--fg-muted);
}

/* Colors */
.fgColor-default   { color: var(--fg); }
.fgColor-muted     { color: var(--fg-muted); }
.fgColor-accent    { color: var(--accent-fg); }
.fgColor-danger    { color: var(--danger-fg); }
.fgColor-attention { color: var(--attention-fg); }
.fgColor-success   { color: var(--success-fg); }
.fgColor-open      { color: var(--open); }
.fgColor-faint     { color: var(--fg-faint); }

.bgColor-muted              { background-color: var(--bg-muted); }
.bgColor-accent-muted       { background-color: var(--accent-muted); }
.bgColor-accent-emphasis    { background-color: var(--accent-emphasis); }
.bgColor-danger-muted       { background-color: var(--danger-muted); }
.bgColor-danger-emphasis    { background-color: var(--danger-emphasis); }
.bgColor-attention-muted    { background-color: var(--attention-muted); }
.bgColor-attention-emphasis { background-color: var(--attention-emphasis); }
.bgColor-success-muted      { background-color: var(--success-muted); }
.bgColor-success-emphasis   { background-color: var(--success-emphasis); }
.bgColor-open-muted         { background-color: var(--open-muted); }

/* Borders */
.border        { border: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border-muted); }
.rounded-1     { border-radius: var(--radius-sm); }
.rounded-2     { border-radius: var(--radius-md); }

/* Width */
.width-full { width: 100%; }

/* Text clamp */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Overflow */
.overflow-x { overflow-x: auto; }

/* Links */
.no-underline { text-decoration: none !important; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---- Box (card) ---- */
.Box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.Box-header {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border-muted);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.Box-body { padding: var(--space-3); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base); font-weight: 500; line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-muted);
  border-color: var(--fg-faint);
  text-decoration: none;
}
.btn-sm { padding: var(--space-1) var(--space-2); font-size: var(--text-sm); }
.btn-link {
  padding: 0;
  color: var(--accent-fg);
  background: none; border: none;
  cursor: pointer;
  font-size: inherit; font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.btn-octicon {
  display: inline-flex;
  align-items: center; justify-content: center;
  padding: var(--space-2);
  color: var(--fg-muted);
  background: none; border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.btn-octicon:hover { background: var(--bg-muted); color: var(--fg); }

/* ---- Labels / Badges ---- */
.IssueLabel {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm); font-weight: 500; line-height: 1.6;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-muted);
  white-space: nowrap;
  background-color: var(--bg-muted);
  color: var(--fg-muted);
}
/* Status-colored IssueLabels need to override default bg */
.IssueLabel.bgColor-open-muted { background-color: var(--open-muted); }
.IssueLabel.bgColor-attention-muted { background-color: var(--attention-muted); }
.IssueLabel.bgColor-danger-muted { background-color: var(--danger-muted); }
.IssueLabel.bgColor-success-muted { background-color: var(--success-muted); }
.IssueLabel.bgColor-accent-muted { background-color: var(--accent-muted); }

.IssueLabel.tag-click {
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}
.IssueLabel.tag-click:hover {
  background: var(--accent-muted);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.Counter {
  display: inline-block;
  min-width: 20px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm); font-weight: 600; line-height: 18px;
  text-align: center;
  background: var(--bg-inset);
  color: var(--fg-muted);
  border-radius: var(--radius-full);
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  font-size: var(--text-base);
  display: flex; align-items: center; gap: var(--space-2);
}
.breadcrumb a { color: var(--fg-muted); font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-1); }
.breadcrumb a:hover { color: var(--accent-fg); text-decoration: none; }
.breadcrumb-sep { color: var(--fg-faint); }

/* ---- Shared: overlay pill (category + region on card images) ---- */
.overlay-pill {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm); font-weight: 600;
  color: var(--fgColor-onEmphasis);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-fast);
  white-space: nowrap;
}
.overlay-pill:hover { background: var(--accent-emphasis); }
.cat-pill { background: rgba(0,0,0,0.55); text-transform: capitalize; }
.region-pill { background: rgba(9,105,218,0.7); }

/* ---- Shared: divider list (coverage, limitations, property types) ---- */
.divider-list {
  list-style: none; padding: 0; margin: 0;
}
.divider-list li {
  padding: var(--space-1) 0;
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border-muted);
}
.divider-list li:last-child { border-bottom: none; }

/* Limitations variant: muted text + amber bullet */
.divider-list.limitations li {
  color: var(--fg-muted);
  padding-left: var(--space-3);
  position: relative;
}
.divider-list.limitations li::before {
  content: '\2022';
  position: absolute; left: 2px;
  color: var(--attention-fg);
}

/* ---- Shared: clickable row ---- */
.clickable-row {
  cursor: pointer;
  transition: background var(--duration-fast);
}
.clickable-row:hover {
  background: var(--accent-muted) !important;
}

/* ---- List view table ---- */
.list-table { table-layout: fixed; }
.list-table td:nth-child(1) { width: 160px; }
.list-table td:nth-child(2) { width: 100px; }
.list-table td:nth-child(3) { width: 200px; }
.list-table td:nth-child(4) { width: 80px; }
.list-table td:nth-child(5) { width: auto; }

/* ---- Collapsible sections ---- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.chev::before {
  content: '\25B6';
  font-size: 9px;
  display: inline-block;
  transition: transform var(--duration-normal);
}
details[open] > summary .chev::before { transform: rotate(90deg); }

/* ============================================================
   APP COMPONENTS
   ============================================================ */

/* ---- Model header ---- */
.model-header h1 { line-height: 1.2; }
.model-header-img-wrap {
  width: 160px;
  min-height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  align-self: stretch;
}
.model-header-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* ---- Detail list (About tab) ---- */
.detail-list { margin: 0; }
.detail-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-muted);
  font-size: var(--text-base);
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
  width: 120px; flex-shrink: 0;
  color: var(--fg-muted); font-weight: 500;
}
.detail-row dd { color: var(--fg); margin: 0; min-width: 0; }

/* ---- Detail sliders (maturity, complexity, approach) ---- */
.detail-sliders {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-muted);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
}
.detail-slider {
  flex: 1;
  min-width: 180px;
  text-align: center;
}
.detail-slider-label {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}
.detail-slider-track-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.detail-slider-end {
  font-size: var(--text-sm);
  color: var(--fg-faint);
  white-space: nowrap;
  flex-shrink: 0;
}
.detail-slider-track {
  flex: 1;
  height: 6px;
  background: var(--border-muted);
  border-radius: var(--radius-full);
  position: relative;
}
.detail-slider-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: var(--radius-full);
  opacity: 0.25;
}
.detail-slider-mid {
  position: absolute;
  left: 50%; top: -3px; bottom: -3px;
  width: 1px;
  background: var(--fg-faint);
  opacity: 0.35;
}
.detail-slider-dot {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 2.5px solid var(--bg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-sm);
}
.detail-slider-value {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ---- Coverage map (world SVG) ---- */
.coverage-map {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-muted);
  background: var(--bg-muted);
  overflow: hidden;
}
.coverage-map svg { display: block; }
.map-country {
  fill: var(--border-muted);
  stroke: var(--bg);
  stroke-width: 0.5;
  transition: fill var(--duration-normal);
}
.map-active { fill: var(--accent) !important; opacity: 0.85; }
.map-active:hover { opacity: 1; cursor: pointer; }

/* Map tooltip */
.map-tooltip {
  display: none;
  position: absolute;
  z-index: var(--z-overlay);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-base);
  line-height: 1.4;
  pointer-events: none;
  max-width: 260px;
}

/* ---- Schema sections ---- */
.schema-section { margin-bottom: var(--space-1); }
.schema-header {
  display: flex; align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-lg); font-weight: 600;
  cursor: pointer; color: var(--fg);
}
.schema-table {
  table-layout: auto;
  width: 100%;
  border-collapse: collapse;
}
.schema-table th,
.schema-table td {
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: var(--text-sm);
  line-height: 1.5;
}
.schema-table code {
  font-size: var(--text-sm);
  background: none;
  padding: 0;
  white-space: nowrap;
}
.schema-ref-link {
  color: var(--fg-accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--fg-accent);
  cursor: pointer;
}
.schema-ref-link:hover { border-bottom-style: solid; }

/* ---- Tab bar ---- */
.tab-bar {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.tab-btn {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base); font-weight: 500;
  color: var(--fg-muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.tab-active {
  color: var(--fg); font-weight: 600;
  border-bottom-color: var(--accent);
}

/* ---- Tab panes ---- */
.tab-pane { display: none; }
.tab-pane-active { display: block; animation: fadeIn var(--duration-normal) ease; }
.tab-content { min-height: 200px; }
.tab-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}
.tab-empty p { margin-bottom: var(--space-1); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Gallery layout ---- */
.gallery-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-4);
  align-items: start;
}
.gallery-main { min-width: 0; }

/* ---- Filter sidebar ---- */
.filter-panel {
  position: sticky; top: calc(var(--header-height) + var(--space-2));
  padding: var(--space-3);
  background: var(--bg-muted);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
}
.filter-panel-title {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: var(--space-1);
  color: var(--fg-faint);
}
.filter-group {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-muted);
}
.filter-group:last-child { border-bottom: none; padding-bottom: 0; }
.filter-heading {
  display: flex; align-items: center; gap: var(--space-1);
  margin-bottom: var(--space-2);
  cursor: pointer;
  list-style: none;
}
.filter-heading::-webkit-details-marker { display: none; }
.filter-group:not([open]) > .filter-heading { margin-bottom: 0; }
.filter-cb {
  display: flex; align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-base); color: var(--fg);
  cursor: pointer; text-transform: capitalize;
}
.filter-cb input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0;
  accent-color: var(--accent-emphasis);
  cursor: pointer; flex-shrink: 0;
}
.filter-cb:hover { color: var(--accent-fg); }
.filter-count {
  margin-left: auto;
  font-size: var(--text-sm); color: var(--fg-faint); font-weight: 400;
}

/* ---- Search bar row ---- */
.search-bar {
  display: flex; align-items: center;
  gap: var(--space-2); flex-wrap: wrap;
}
.search-bar-controls {
  display: flex; align-items: center;
  gap: var(--space-2); flex-shrink: 0;
}

/* ---- View toggle ---- */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden; flex-shrink: 0;
}
.view-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: var(--bg); border: none;
  border-right: 1px solid var(--border-muted);
  color: var(--fg-faint); cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.view-btn:last-child { border-right: none; }
.view-btn:hover { color: var(--fg); background: var(--bg-muted); }
.view-btn-active { color: var(--accent-fg); background: var(--accent-muted); }

/* ---- Gallery sort ---- */
.gallery-sort {
  font-family: inherit; font-size: var(--text-base);
  color: var(--fg-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  cursor: pointer; flex-shrink: 0; outline: none;
  transition: border-color var(--duration-fast);
}
.gallery-sort:focus { border-color: var(--accent); }
.gallery-sort:hover { border-color: var(--fg-faint); }

/* ---- Gallery search ---- */
.gallery-search-wrap {
  position: relative; width: 100%;
  flex: 1; min-width: 0;
}
.gallery-search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint); pointer-events: none;
}
.gallery-search {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) 42px;
  font-size: var(--text-lg); font-family: inherit;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.gallery-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.gallery-search::placeholder { color: var(--fg-faint); }

/* ---- Active filter chips ---- */
.filter-bar {
  display: flex; align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex; align-items: center;
  gap: 0;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2);
  font-size: var(--text-sm); font-weight: 500; line-height: 1.6;
  color: var(--accent-fg);
  background: var(--accent-muted);
  border: 1px solid var(--borderColor-accent-muted);
  border-radius: var(--radius-full);
  text-transform: capitalize; white-space: nowrap;
}
.filter-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0;
  font-size: var(--text-sm); line-height: 1;
  color: var(--accent-fg);
  background: none; border: none; border-radius: 50%;
  cursor: pointer; opacity: 0.4;
  transition: opacity var(--duration-fast), background var(--duration-fast);
  margin-left: var(--space-1);
}
.filter-chip-x:hover { opacity: 1; background: rgba(0,0,0,0.06); }
@media (prefers-color-scheme: dark) {
  .filter-chip-x:hover { background: rgba(255,255,255,0.08); }
}
.filter-reset {
  display: inline-flex; align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm); font-weight: 500; line-height: 1.6;
  color: var(--fg-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}
.filter-reset:hover { color: var(--danger-fg); border-color: var(--danger); }

/* ---- Scatter plot view ---- */
.scatter-wrap {
  position: relative;
  height: 500px;
  background: var(--bg);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.scatter-wrap:fullscreen {
  height: 100vh;
  border: none;
  border-radius: 0;
  padding: var(--space-4);
}
.scatter-wrap canvas { width: 100% !important; height: 100% !important; }
.scatter-toolbar {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.scatter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border-muted);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.scatter-btn:last-child { border-bottom: none; }
.scatter-btn:hover { background: var(--bg-muted); color: var(--fg); }

/* ---- Gallery map view ---- */
.gallery-map-view { min-height: 300px; max-height: 500px; overflow: hidden; }

/* ---- Gallery count ---- */
.gallery-count {
  text-align: center; font-size: var(--text-base); color: var(--fg-faint);
  padding: var(--space-4) 0 var(--space-2);
}

/* ---- Gallery empty ---- */
.gallery-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--fg-muted);
}
.gallery-empty p { margin-bottom: var(--space-2); }

/* ---- Model grid ---- */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}
.model-card {
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal), transform var(--duration-normal);
  cursor: pointer;
}
.model-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.model-card-img-wrap { position: relative; overflow: hidden; }
.model-card-img { width: 100%; height: 140px; object-fit: cover; }
.model-card-cats {
  position: absolute;
  top: var(--space-2); left: var(--space-2); right: 60px;
  display: flex; gap: var(--space-1); flex-wrap: wrap;
}
.model-card-region {
  position: absolute;
  top: var(--space-2); right: var(--space-2);
  display: flex; gap: var(--space-1);
}

/* ---- API docs ---- */
.api-header { border-bottom: 1px solid var(--border-muted); padding-bottom: var(--space-4); }
.api-base-url {
  padding: var(--space-3);
  background: var(--bg-muted);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.api-base-url code { font-size: var(--text-base); color: var(--accent-fg); word-break: break-all; }
.api-section h2 { border-bottom: 1px solid var(--border-muted); padding-bottom: var(--space-2); }

.api-endpoint {
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  overflow: hidden;
}
.api-endpoint-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  list-style: none;
}
.api-endpoint-header::-webkit-details-marker { display: none; }
.api-endpoint[open] .api-endpoint-header {
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-muted);
}
.api-method {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.api-method-get { background: var(--accent-muted); color: var(--accent-fg); }
.api-method-post { background: var(--success-muted); color: var(--success-fg); }
.api-path { font-size: var(--text-base); color: var(--fg); font-weight: 500; }
.api-endpoint-body { padding: var(--space-3); }
.api-params { margin-bottom: var(--space-3); }
.api-params table { border: 1px solid var(--border-muted); border-radius: var(--radius-md); }
.api-code {
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: var(--fg);
  margin: 0;
}

/* ---- Try It layout ---- */
.tryit-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.tryit-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.tryit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-decoration: none;
}
.tryit-link:hover { color: var(--fgColor-accent); }
.tryit-link svg { flex-shrink: 0; }
.tryit-links > p { text-align: center; }

/* ---- Processing console ---- */
.console {
  display: none;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
  font-size: var(--text-xs);
  line-height: 1.6;
  background: var(--bg-inset, var(--bg-subtle));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  max-height: 200px;
  overflow-y: auto;
  margin-top: var(--space-3);
}
.console.console-active { display: block; }
.console-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-ts {
  color: var(--fg-faint, var(--fg-muted));
  margin-right: var(--space-2);
  user-select: none;
}
.console-ok  { color: var(--success-fg); }
.console-warn { color: var(--attention-fg); }
.console-err { color: var(--danger-fg); }
.console-dl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--border);
}
.console-dl a { color: var(--fgColor-accent); text-decoration: none; }
.console-dl a:hover { text-decoration: underline; }

/* ---- Upload drop zone ---- */
.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal);
  cursor: pointer;
  padding: var(--space-5);
  text-align: center;
}
.drop:hover,
.drop.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
  border-style: solid;
}
.drop-icon {
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}
.drop:hover .drop-icon { color: var(--accent); }
.drop input[type=file] { display: none; }

/* ---- KPI accents ---- */
.kpi-d { border-left: 4px solid var(--danger) !important; }
.kpi-a { border-left: 4px solid var(--attention) !important; }
.kpi-s { border-left: 4px solid var(--success) !important; }

/* ---- Portfolio table ---- */
.ptable-wrap { max-height: 460px; overflow-y: auto; }
.ptable-wrap th {
  position: sticky; top: 0; z-index: var(--z-base);
  cursor: pointer; user-select: none;
  background: var(--bg-muted);
}
.ptable-wrap tbody tr.sel {
  background: var(--accent-muted) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sa { opacity: 0.3; margin-left: var(--space-1); font-size: 10px; }
th.sorted .sa { opacity: 1; }

/* ---- Risk distribution bar ---- */
.rbar {
  display: flex; height: 28px;
  border-radius: var(--radius-md); overflow: hidden;
}
.rbar > div {
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: 700; color: var(--fgColor-onEmphasis); min-width: 24px;
}
.rbar .rd { background: var(--danger-emphasis); }
.rbar .ra { background: var(--attention-emphasis); }
.rbar .rs { background: var(--success-emphasis); }

/* ---- Timeline bar ---- */
.tbar {
  display: flex; height: 20px;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--border);
}
.tbar .tok { background: var(--success-muted); }
.tbar .tst { background: var(--danger-muted); position: relative; }
.tbar .tst::before {
  content: ''; position: absolute;
  left: 0; top: -1px; bottom: -1px; width: 3px;
  background: var(--danger-emphasis); border-radius: 2px;
}

/* ---- Charts ---- */
.cht { position: relative; height: 320px; }
.cht canvas { width: 100% !important; height: 100% !important; }

/* ---- Insight panel ---- */
.ins {
  background: var(--accent-muted);
  border: 1px solid var(--borderColor-accent-muted);
  border-radius: var(--radius-md);
}

/* ---- Legend dots ---- */
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: var(--radius-sm);
  margin-right: var(--space-1);
  vertical-align: middle;
}

/* ---- Animations ---- */
.slideup { animation: slideup var(--duration-normal) ease; }
@keyframes slideup {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Grids ---- */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.gk { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-2); }

/* ---- Excess row ---- */
tr.xr { background: var(--danger-muted) !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .site-header-inner { padding: var(--space-2) var(--space-3); }
  .site-tagline { display: none; }
  .site-main { padding: var(--space-3); }
  .gallery-layout { grid-template-columns: 1fr; gap: var(--space-3); }
  .filter-panel {
    position: static;
    max-height: 48px; overflow: hidden;
    transition: max-height var(--duration-normal) ease;
  }
  .filter-panel.filter-panel-open { max-height: 2000px; }
  .filter-panel-title { cursor: pointer; }
  .filter-panel-title::after { content: ' \25BE'; font-size: 10px; }
  .filter-panel-open .filter-panel-title::after { content: ' \25B4'; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .gk { grid-template-columns: 1fr 1fr; }
  .model-grid { grid-template-columns: 1fr; }
  .model-header-img-wrap { width: 100px; }
  .detail-row { flex-direction: column; gap: var(--space-1); }
  .detail-row dt { width: auto; }
}

@media print {
  .site-header, .site-footer, .drop, .filter-panel,
  .search-bar, .tab-bar, button, .overlay-pill { display: none !important; }
  .Box { break-inside: avoid; }
}
