.icon { width: 17px; height: 17px; flex: none; vertical-align: middle; }
.button, .segment-button, .icon-button, .select, .field { border: 1px solid var(--line); border-radius: 9px; background: var(--white); min-height: 37px; padding: 7px 11px; }
.button, .segment-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.4; font-weight: 650; }
.button:hover, .segment-button:hover, .icon-button:hover { border-color: #93C5FD; color: #1D4ED8; background: #F8FBFF; }
.button-primary { color: var(--white); background: var(--blue); border-color: var(--blue); }
.button-primary:hover { color: var(--white); background: #1D4ED8; }
.button-warning { color: #BE123C; }
.icon-button { min-width: 37px; padding: 4px; font-size: 20px; }
.select { max-width: 100%; padding-right: 24px; }
.field::placeholder { color: #64748B; }
.segments { display: inline-flex; align-items: stretch; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--page); border: 1px solid var(--line); border-radius: 11px; }
.segment-button { border-color: transparent; min-height: 31px; background: transparent; color: var(--muted); font-size: 13px; }
.segment-button[aria-pressed="true"] { border-color: #BFDBFE; color: #1D4ED8; background: #FFFFFF; box-shadow: 0 1px 3px #1E40AF12; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 7px; padding: 3px 8px; color: #334155; background: #F1F5F9; font: 700 11px/1.45 var(--sans); overflow-wrap: anywhere; }
.domain-badge { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, white); border: 1px solid color-mix(in srgb, var(--accent) 20%, white); }
.tone-S, .tone-resnet { color: #047857; background: #ECFDF5; }
.tone-A, .tone-frontier_high { color: #1D4ED8; background: #EFF6FF; }
.tone-B, .tone-lighthouse, .tone-giant { color: #92400E; background: #FFFBEB; }
.tone-core_ref { color: #5B21B6; background: #F5F3FF; }
.tone-deprecated { color: #BE123C; background: #FFF1F2; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent, var(--blue)); vertical-align: middle; margin-right: 4px; flex: none; }
.priority-S { --accent: #059669; } .priority-A { --accent: #2563EB; } .priority-B { --accent: #EA580C; }
.local-state { color: #047857; background: #ECFDF5; border: 1px solid #A7F3D0; border-radius: 60px; padding: 5px 10px; font-weight: 650; font-size: 12px; white-space: nowrap; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 13px; padding: 15px 16px; min-width: 0; }
.kpi-icon { display: grid; place-items: center; align-self: start; width: 39px; min-width: 39px; height: 39px; border-radius: 11px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, white); }
.kpi-icon .icon { width: 21px; height: 21px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-number { font-size: clamp(20px, 2.3vw, 28px); line-height: 1.18; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-number small { font-size: 12px; font-weight: 650; color: var(--muted); margin-left: 5px; }
.kpi-extra { margin-left: 11px; white-space: nowrap; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(238px, .33fr); gap: 16px; align-items: stretch; margin-bottom: 24px; }
.opportunity-panel, .watch-panel, .distribution-panel, .governance-section { padding: 17px 19px; min-width: 0; }
.opportunity-panel .section-heading { margin-bottom: 3px; }
.opportunity-chart { height: 330px; }
.chart-foot { display: flex; align-items: center; justify-content: space-between; gap: 9px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.dot-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.watch-panel { display: flex; flex-direction: column; }
.watch-panel > p { margin-top: 5px; font-size: 12px; }
.ranked-list { display: grid; margin: 11px 0 14px; }
.rank-row { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 50px; padding: 7px 2px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); }
.rank-row:hover strong { color: #1D4ED8; }
.rank-id, .chain-code { flex: none; color: #1D4ED8; background: #EFF6FF; border: 1px solid #DBEAFE; padding: 3px 7px; border-radius: 6px; font-size: 12px; font-weight: 750; }
.rank-info { flex: 1; }
.rank-info strong, .rank-info small { display: block; }
.rank-info small { color: var(--muted); font-size: 11px; }
.rank-score { color: #047857; font-weight: 750; }
.watch-panel > .button { margin-top: auto; align-self: start; }
.chain-section .toolbar { margin-bottom: 14px; }
.chain-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.chain-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 17px; }
.chain-card h3 { font-size: clamp(16px, 1.7vw, 20px); }
.chain-insight { display: grid; gap: 7px; }
.insight { padding: 9px 11px; border-radius: 8px; background: #EFF6FF; }
.insight strong, .risk-card strong { display: inline-flex; gap: 5px; align-items: center; }
.insight strong { color: #1D4ED8; }
.insight p { margin-top: 3px; }
.insight.solution { background: #ECFDF5; }
.insight.solution strong { color: #047857; }
.score-list { display: grid; gap: 5px; }
.score-row { display: grid; grid-template-columns: 95px minmax(50px, 1fr) 32px; align-items: center; gap: 6px; font-size: 12px; }
.score-track { height: 7px; border-radius: 9px; background: #EAF0F8; overflow: hidden; }
.score-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.score-row strong { font-size: 12px; color: var(--ink); text-align: right; }
.score-row.low strong { color: #BC3216; }
.risk-card { background: #FFF1F2; border: 1px solid #FECDD3; border-left: 4px solid var(--rose); border-radius: 9px; color: #881337; padding: 10px 12px; margin-top: auto; }
.risk-card > strong { margin-bottom: 3px; }
.risk-card ol { padding-left: 22px; }
.risk-card li + li { margin-top: 5px; }
.card-footer { display: flex; justify-content: flex-end; }
.chart-text { margin-top: 5px; }

.drawer { position: fixed; inset: 0 0 0 auto; width: min(750px, 100%); height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; padding: 0; background: var(--white); color: var(--ink); border: 0; border-left: 1px solid var(--line); box-shadow: -12px 0 48px #0F172A21; overflow: auto; overscroll-behavior: contain; }
.drawer[open] { display: flex; flex-direction: column; animation: slide-in 160ms ease-out; }
.drawer::backdrop { background: #1E293B47; }
@keyframes slide-in { from { transform: translateX(35px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }
.drawer-bar { position: sticky; top: 0; z-index: 3; min-height: 56px; padding: 8px 21px; display: flex; justify-content: space-between; align-items: center; background: var(--white); border-bottom: 1px solid var(--line); }
.drawer-label { font-weight: 800; }
.drawer-body { padding: 21px; }
body:has(dialog[open]) { overflow: hidden; }
.chain-drawer, .audit-drawer { width: min(1120px, 100%); }
.star-drawer { width: min(550px, 100%); }
.dossier-header h1, .doc-header h1 { margin: 10px 0 8px; font-size: clamp(20px, 3vw, 32px); }
.dossier-header .risk-card { margin-top: 13px; }
.dossier-meta, .summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 8px; margin: 12px 0; }
.metric, .summary-cell { padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--accent, var(--blue)) 16%, white); border-radius: 8px; background: color-mix(in srgb, var(--accent, var(--blue)) 5%, white); overflow-wrap: anywhere; }
.metric dt, .summary-cell dt { color: var(--accent, #1D4ED8); font-size: 11px; font-weight: 750; }
.metric dd, .summary-cell dd { font-weight: 650; margin-top: 3px; }
.dossier-section { margin-top: 20px; padding: 15px; }
.dossier-section > h2 { font-size: 18px; margin: 0 0 12px; }
.dossier-charts, .risk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.value-chart, .radar-chart { height: 268px; }
.step-grid, .execution-flow, .bowling-flow, .timeline { list-style: none; padding: 0; }
.step-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.step-card { background: var(--white); padding: 13px; display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 10px; }
.step-card h3 { margin-bottom: 5px; }
.step-no { flex: none; color: var(--accent, var(--blue)); font: 800 22px/1.2 var(--mono); }
.execution-flow { display: grid; gap: 9px; }
.execution-flow .step-card { border-left: 4px solid var(--accent); }
.execution-flow .first-order { border: 2px solid #059669; border-left-width: 6px; background: #F0FDF8; }
.bowling-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bowling-flow li { border-radius: 9px; border: 1px solid #BFDBFE; padding: 10px; background: #F8FBFF; }
.bowling-flow h3, .scenario h3 { margin-bottom: 5px; }
.timeline { margin-left: 9px; border-left: 2px solid #BFDBFE; }
.timeline li { position: relative; padding: 0 0 12px 15px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 8px; border-radius: 50%; width: 10px; height: 10px; background: var(--blue); border: 1px solid white; }
.phase { color: #1D4ED8; font-weight: 800; }
.test-card, .historical-card, .audit-case { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.test-card { border-color: #6EE7B7; background: #F0FDF8; }
.test-card ol, .historical-card ul { padding-left: 19px; }
.test-card li, .historical-card p { margin-top: 6px; }
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 134px), 1fr)); gap: 7px; margin: 9px 0; }
.scenario { padding: 8px; border: 1px solid #DBEAFE; border-radius: 8px; background: #F5FAFF; font-size: 12px; }
.scenario.stress { background: #FFF7ED; border-color: #FED7AA; }
.audit-cases { display: grid; gap: 7px; }
.audit-case summary, .story-details summary { cursor: pointer; font-weight: 750; color: #1D4ED8; }
.audit-case[open] > summary, .story-details[open] summary { margin-bottom: 10px; }
.evidence-list, .relationship-list { display: grid; gap: 6px; margin-top: 8px; }
.evidence-row { display: flex; align-items: center; text-align: left; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.evidence-row:hover { background: #EFF6FF; border-color: #BFDBFE; }

.gallery-tabs { margin-bottom: 14px; }
.gallery-filter { padding: 13px; margin-bottom: 15px; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 15px; }
.gallery-card { overflow: hidden; min-width: 0; }
.gallery-cover { display: grid; width: 100%; aspect-ratio: 16 / 9; place-items: center; position: relative; overflow: hidden; background: var(--white); border-bottom: 1px solid var(--line); }
.gallery-cover img, .gallery-cover .cover-art { position: absolute; width: 100%; height: 100%; inset: 0; object-fit: cover; }
.gallery-cover img[hidden] { display: none; }
.cover-caption { z-index: 1; border: 1px solid color-mix(in srgb, var(--accent) 25%, white); border-radius: 8px; padding: 3px 8px; background: var(--white); color: var(--accent); font-weight: 800; }
.gallery-body { padding: 15px; display: grid; gap: 10px; }
.gallery-body h2 { font-size: clamp(17px, 2vw, 22px); }
.alias-strip { padding: 7px 9px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, white); border-radius: 6px; font-weight: 700; }
.hard-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; font-size: 12px; }
.hard-metrics .metric:last-child { grid-column: 1 / -1; }
.story-details { border-top: 1px solid var(--line); padding-top: 8px; }
.story-flow { list-style: none; padding: 0; display: grid; gap: 8px; }
.story-flow li { padding: 7px 9px; border-left: 2px solid #A7F3D0; background: #F0FDF8; border-radius: 5px; }
.story-flow h3 { color: #047857; font-size: 13px; margin-bottom: 4px; }
.gallery-body .button { justify-self: start; }
.gallery-body .source-note { color: var(--muted); font-size: 12px; }

.method-section, .governance-section { margin-top: 17px; }
.gate-grid, .method-library, .coverage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: 9px; list-style: none; padding: 0; }
.gate-grid li, .method-card, .coverage-card { padding: 13px; }
.method-card { display: grid; align-content: start; gap: 8px; }
.method-card .button, .method-card .badge { justify-self: start; }
.governance-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(215px, .45fr); gap: 15px; }
.coverage-progress { width: 100%; accent-color: var(--green); }
.distribution-chart { height: 170px; }
.distribution-legend > div { display: flex; align-items: center; gap: 4px; }
.distribution-legend strong { margin-left: auto; }
.governance-queue { display: grid; gap: 7px; }
.queue-row { display: flex; gap: 12px; justify-content: space-between; padding: 10px; border: 1px solid var(--line); border-radius: 8px; flex-wrap: wrap; }
.queue-tools, .tier-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-header { margin-bottom: 16px; }
.markdown { overflow-wrap: anywhere; font-size: 14px; }
.markdown > * + * { margin-top: 12px; }
.markdown :is(h1,h2,h3,h4,h5,h6) { scroll-margin-top: 70px; }
.markdown h1 { font-size: 23px; }
.markdown h2 { font-size: 19px; }
.markdown ol, .markdown ul { padding-left: 23px; }
.markdown li + li { margin-top: 4px; }
.markdown blockquote { border-left: 3px solid #93C5FD; background: #EFF6FF; padding: 9px 12px; color: #1E3A8A; }
.markdown pre { white-space: pre-wrap; padding: 10px; }
.markdown code, .markdown pre { background: #F1F5F9; border-radius: 4px; }
.markdown hr { border: 0; border-top: 1px solid var(--line); }
.md-image { max-width: 100%; height: auto; border-radius: 8px; }
.md-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 8px; }
.md-record { padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.md-record dt { color: #1D4ED8; font-weight: 750; }
.md-record dd { margin-bottom: 5px; }

@media (max-width: 1050px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { gap: 7px; padding: 12px; }
}
@media (max-width: 850px) {
  .overview-grid, .governance-layout { grid-template-columns: 1fr; }
  .watch-panel .ranked-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (max-width: 630px) {
  .gallery-grid, .chain-grid, .dossier-charts, .risk-grid, .step-grid, .bowling-flow { grid-template-columns: 1fr; }
  .toolbar-count { margin-left: 0; }
  .drawer-body { padding: 13px; }
  .drawer-bar { padding-inline: 13px; }
  .opportunity-panel, .watch-panel { padding: 11px; }
  .opportunity-chart { height: 325px; }
  .chart-foot { font-size: 11px; }
  .kpi-number { font-size: 18px; }
  .kpi-extra { margin-left: 5px; }
}
@media (prefers-reduced-motion: reduce) { .drawer[open] { animation: none; } }


.gallery-cover img.cover-loading { opacity: 0; }
.gallery-filter + .section-heading { margin-bottom: 3px; }
.gallery-grid { margin-top: 10px; }
.watch-panel .rank-score { min-width: 23px; }
.audit-cases { margin-top: 13px; }

.gallery-cover .legacy-cover { filter: invert(1) hue-rotate(180deg) saturate(.75) brightness(1.05); }
.story-flow p + p { margin-top: 6px; }
