:root {
  color-scheme: light;
  --bg: #ffffff;
  --hover: #f2efeb;
  --surface: #f8f6f3;
  --fg: #1f1e1c;
  --fg-2: #625d57;
  --fg-3: #8a847e;
  --line: #ebe7e2;
  --line-2: #cdc6bf;
  --accent: #8a5f3f;
  --on-accent: #ffffff;
  --pareto: #1f1e1c;
  --sidebar-width: 256px;
  --header-height: 60px;
  --ease: cubic-bezier(.65, 0, .35, 1);
  font-family: "DM Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  font-synthesis: none;
  color: var(--fg);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --hover: #151311; --surface: #0d0c0b; --fg: #ffffff; --fg-2: #aaa39d; --fg-3: #7a746f;
    --line: #1d1b19; --line-2: #37322e; --accent: #d2b49c; --on-accent: #000000; --pareto: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --hover: #151311; --surface: #0d0c0b; --fg: #ffffff; --fg-2: #aaa39d; --fg-3: #7a746f;
  --line: #1d1b19; --line-2: #37322e; --accent: #d2b49c; --on-accent: #000000; --pareto: #ffffff;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; -webkit-user-select: none; user-select: none; transition: background-color .35s var(--ease), color .35s var(--ease); }
input { -webkit-user-select: text; user-select: text; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
button:hover, a:hover { color: var(--fg); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--on-accent); }
h2, h3 { margin: 0; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-rows: var(--header-height) minmax(0, 1fr); height: 100dvh; }

/* header */
.app-header { display: flex; align-items: center; gap: 26px; padding: 0 28px; border-bottom: 1px solid var(--line); min-width: 0; }
.brand { flex-shrink: 0; white-space: nowrap; }
.brand strong { font-size: 23px; font-weight: 450; letter-spacing: -1.1px; }
.brand strong span { color: var(--accent); transition: color .35s var(--ease); }
.section-tabs { display: flex; align-items: center; gap: 14px; padding-right: 22px; border-right: 1px solid var(--line-2); flex-shrink: 0; }
.section-tabs button { min-height: 36px; font-size: 12px; color: var(--fg-3); transition: color .2s; }
.section-tabs button.active { color: var(--fg); }
.view-tabs { position: relative; display: flex; align-items: stretch; align-self: stretch; gap: 22px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.view-tabs button { position: relative; display: flex; align-items: center; white-space: nowrap; font-size: 12.5px; color: var(--fg-2); transition: color .2s; }
.view-tabs button.active { color: var(--fg); }
.view-tabs .tab-ink { position: absolute; bottom: 0; left: 0; height: 2px; border-radius: 2px; background: var(--accent); transition: transform .45s var(--ease), width .45s var(--ease); pointer-events: none; }
.tab-divider { flex-shrink: 0; align-self: center; width: 1px; height: 14px; background: var(--line-2); }
.header-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0; }
.icon-button, .chart-settings summary { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; color: var(--fg-2); }
.icon-button svg { transition: transform .5s var(--ease); }
.icon-button:active svg { transform: rotate(90deg); }
.chart-settings { position: relative; }
.chart-settings summary { list-style: none; cursor: pointer; }
.chart-settings summary::-webkit-details-marker { display: none; }
.chart-settings[open] summary, .chart-settings summary:hover { color: var(--fg); }
.settings-popover { position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; width: 190px; padding: 16px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; animation: pop .22s var(--ease); }
.settings-popover button { font-size: 12.5px; color: var(--fg-2); }
.control-label { font-size: 11px; color: var(--fg-3); margin-bottom: -4px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* layout */
.body-layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-width); min-height: 0; }
main { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.chart-section { display: flex; flex-direction: column; min-height: 0; padding: 18px 28px 10px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; flex-shrink: 0; min-height: 32px; }
.chart-heading h2 { font-size: 16px; font-weight: 500; }
.chart-heading h2 .sub { margin-left: 10px; font-size: 12px; font-weight: 400; color: var(--fg-3); }
.chart-controls { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.pareto-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 12px; white-space: nowrap; color: var(--fg); }
.pareto-toggle[aria-pressed="true"], .pareto-toggle:hover { color: var(--accent); }
.selection { display: inline-flex; align-items: center; justify-content: center; width: 12px; height: 12px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--on-accent); transition: background-color .2s, border-color .2s; }
.selection.checked { background: var(--accent); border-color: var(--accent); }
.selection svg { width: 10px; height: 10px; }
.chart-scale { display: flex; gap: 12px; flex-shrink: 0; }
.chart-scale button { min-height: 32px; padding: 4px 2px; font-size: 12px; color: var(--fg-3); border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.chart-scale button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.chart-scale button:hover { color: var(--fg); }
.legend-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fg-2); }
.legend-chip i { width: 10px; height: 10px; border-radius: 2px; background: var(--fg-2); }
.legend-chip i.soft { opacity: .35; }

.chart-wrap { position: relative; display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.chart-canvas { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--line-2) var(--bg); }
.chart-canvas > svg { position: absolute; inset: 0 0 auto 0; display: block; width: 100%; touch-action: pan-y; }
.chart-svg text { font-family: "DM Sans", "Hiragino Sans", "Noto Sans JP", sans-serif; }

/* chart marks */
.tick-label { fill: var(--fg-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--fg-2); font-size: 12px; }
.gridline { stroke: var(--line-2); stroke-dasharray: 2 5; stroke-width: 1; }
.axis-line { stroke: var(--line-2); stroke-width: 1; }
.fam-line { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.leader { fill: none; stroke: var(--line-2); stroke-width: 1; }
.pt { stroke: var(--bg); stroke-width: 1.5; cursor: pointer; transition: stroke .35s var(--ease); }
.pt.partial { stroke-width: 1.8; }
.pt.frontier { stroke: var(--pareto); stroke-width: 1.8; }
.lbl { font-size: 13px; font-weight: 550; cursor: pointer; }
.lbl .harness { font-size: 10.5px; font-weight: 400; fill: var(--fg-3); }
.pareto { fill: none; stroke: var(--pareto); stroke-width: 2.2; stroke-dasharray: 5 4.5; stroke-linecap: round; pointer-events: none; }
.pareto-halo { fill: none; stroke: var(--bg); stroke-width: 6; stroke-linecap: round; pointer-events: none; opacity: .7; }
.bar-label { font-size: 12.5px; font-weight: 550; fill: var(--fg); }
.bar-effort { font-size: 11.5px; fill: var(--fg-2); }
.bar-harness { font-size: 10.5px; fill: var(--fg-3); }
.bar-value { font-size: 11.5px; fill: var(--fg-2); font-variant-numeric: tabular-nums; }
.bar-row { cursor: pointer; }
.bar-row .bar-hit { fill: transparent; }
.bar-row:hover .bar-hit { fill: var(--hover); }
.tag-partial { font-size: 10px; fill: var(--accent); }
.dimmable { transition: opacity .25s var(--ease); }
.focusing .dimmable:not(.hl) { opacity: .14; }
.focusing .fam-line.hl { stroke-width: 2.2; }

/* tooltip */
.chart-tooltip { position: absolute; z-index: 3; width: 286px; max-width: calc(100vw - 48px); padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; pointer-events: none; animation: tip .18s var(--ease); }
.chart-tooltip.scatter-tooltip { inset: auto 8px 64px auto; }
.chart-tooltip.pinned { pointer-events: auto; }
@keyframes tip { from { opacity: 0; transform: translateY(4px); } }
.tooltip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.tooltip-head strong { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; }
.tooltip-head button { width: 20px; height: 20px; font-size: 18px; color: var(--fg-3); line-height: 1; }
.chart-tooltip p { margin: 4px 0 10px; font-size: 11.5px; color: var(--fg-2); }
.tooltip-value { display: flex; justify-content: space-between; gap: 20px; padding: 3.5px 0; font-size: 12px; }
.tooltip-value span { color: var(--fg-2); }
.tooltip-value b { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.tooltip-fail { margin-top: 8px; font-size: 11px; color: var(--fg-3); line-height: 1.6; }
.tooltip-pick { color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* table */
.table-wrap { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) var(--bg); }
.sb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sb-table th { position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 10px 10px 8px; font-size: 11px; font-weight: 450; color: var(--fg-3); text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.sb-table th:first-child, .sb-table td:first-child { text-align: left; padding-left: 0; }
.sb-table th[aria-sort] { color: var(--fg); }
.sb-table th .arrow { display: inline-block; margin-left: 3px; color: var(--accent); transition: transform .3s var(--ease); }
.sb-table th[aria-sort="ascending"] .arrow { transform: rotate(180deg); }
.sb-table td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sb-table tbody tr { transition: background-color .15s; }
.sb-table tbody tr:hover { background: var(--hover); }
.sb-table tbody tr.anim { transition: transform .5s var(--ease); }
.sb-table .name { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.sb-table .muted { color: var(--fg-3); }
.sb-table .score-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.sb-table .score-bar { position: relative; width: 64px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.sb-table .score-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; transform-origin: left; animation: grow .7s var(--ease) both; }
.sb-table .pill { margin-left: 6px; font-size: 10px; font-weight: 450; color: var(--accent); }
.sb-table .fail { color: #d5604a; }
@keyframes grow { from { transform: scaleX(0); } }
.method { padding: 18px 0 8px; font-size: 11.5px; line-height: 1.8; color: var(--fg-2); max-width: 860px; }
.method summary { cursor: pointer; color: var(--fg); }
.method p { margin: 10px 0; }

footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 28px; border-top: 1px solid var(--line); font-size: 11px; color: var(--fg-3); }
.footer-links { display: flex; gap: 20px; white-space: nowrap; }

/* sidebar */
.sidebar { display: flex; flex-direction: column; gap: 18px; min-height: 0; height: 100%; padding: 16px 18px; overflow: auto; border-left: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-2) var(--bg); }
.sidebar > * { flex-shrink: 0; }
.side-heading { display: flex; align-items: center; gap: 8px; margin-bottom: -6px; }
.side-heading h2 { flex: 1; font-size: 15px; font-weight: 500; }
.side-heading h2 span { margin-left: 6px; font-size: 11px; font-weight: 400; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.side-heading button { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; color: var(--fg-3); }
.search { display: flex; align-items: center; gap: 8px; height: 32px; color: var(--fg-3); border-bottom: 1px solid var(--line-2); transition: border-color .2s; }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; color: var(--fg); background: none; border: 0; outline: none; font-size: 12.5px; }
.search input::placeholder { color: var(--fg-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { font: inherit; font-size: 11px; }
.effort-filter h3, .section-head h3 { font-size: 12px; font-weight: 550; }
.effort-filter > div { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 8px; }
.effort-filter button { font-size: 11.5px; color: var(--fg); transition: color .2s; }
.effort-filter button[aria-pressed="false"] { color: var(--fg-3); text-decoration: line-through; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.section-head h3 { flex: 1; }
.section-head span { font-size: 10.5px; color: var(--fg-3); }
.model-section + .model-section { margin-top: 14px; }
.model-row { display: flex; align-items: center; gap: 9px; width: calc(100% + 12px); min-height: 26px; margin: 0 -6px; padding: 0 6px; border-radius: 5px; font-size: 12.5px; text-align: left; color: var(--fg-3); transition: opacity .3s var(--ease), color .2s; }
@media (hover: hover) { .model-row:hover { background: var(--hover); } }
.model-row[aria-pressed="true"] { color: var(--fg); }
.model-row.hovered { background: var(--hover); }
.model-row.off-frontier { opacity: .35; }
.model-row.off-frontier:hover { opacity: 1; }
.model-row.on-frontier { font-weight: 550; }
.model-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.model-meta { font-size: 10.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.model-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px currentColor; opacity: .5; transition: background-color .2s, opacity .2s; }
.model-row[aria-pressed="true"] .model-dot { background: currentColor; opacity: 1; }
.pick-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; min-height: 26px; font-size: 12px; text-align: left; color: var(--fg); }
.pick-row span:first-child { font-size: 11px; color: var(--accent); }
.pick-row span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-note { margin: 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.7; color: var(--fg-3); }

.mobile-only { display: none !important; }

@media (width <= 1150px) {
  .app-header { gap: 18px; padding: 0 18px; }
  .brand strong { font-size: 21px; }
  .view-tabs { gap: 16px; }
  .view-tabs button { font-size: 12px; }
  .chart-section { padding-left: 18px; padding-right: 18px; }
  footer { padding: 9px 18px; }
}
@media (width <= 900px) {
  .app { display: block; height: auto; }
  .app-header { position: relative; flex-wrap: wrap; gap: 0; height: auto; padding: 0; background: var(--bg); }
  .brand { display: flex; align-items: center; height: 52px; padding-left: 16px; }
  .brand strong { font-size: 19px; }
  .section-tabs { order: 3; width: 100%; height: 40px; gap: 18px; margin: 0; padding: 0 16px; border: 0; border-top: 1px solid var(--line); }
  .section-tabs button { font-size: 13px; }
  .header-actions { order: 2; height: 52px; padding-right: 6px; }
  .mobile-filter-toggle .filter-label { display: none; }
  .view-tabs { order: 4; width: 100%; height: 42px; gap: 20px; padding: 0 16px; border-top: 1px solid var(--line); }
  .view-tabs button { font-size: 13px; }
  .mobile-only { display: inline-flex !important; align-items: center; gap: 6px; }
  .mobile-filter-toggle { height: 40px; padding: 0 6px; font-size: 13px; color: var(--fg); }
  .mobile-filter-toggle span + span { font-size: 12px; color: var(--fg-3); }
  .body-layout, main { display: block; }
  .chart-section { height: auto; padding: 18px 16px 24px; }
  .chart-heading { flex-wrap: wrap; gap: 4px 16px; }
  .chart-heading h2 { flex: 1 0 100%; font-size: 17px; }
  .chart-controls { flex: 1 0 100%; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
  .pareto-toggle, .chart-scale button { min-height: 40px; }
  .chart-wrap { display: block; }
  .chart-canvas { flex: none; overflow: visible; }
  .chart-canvas > svg { position: relative; }
  .chart-tooltip, .chart-tooltip.scatter-tooltip { position: sticky; inset: auto; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 7; width: auto; max-width: none; margin-top: 12px; }
  .table-wrap { overflow-x: auto; }
  .sidebar { position: fixed; inset: 0; z-index: 10; display: none; height: 100dvh; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); background: var(--bg); border-left: 0; }
  .sidebar.open { display: flex; animation: sheet .3s var(--ease); }
  .side-heading { position: sticky; top: 0; z-index: 1; height: 56px; margin: 0 -16px -6px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .side-heading .sheet-done { width: auto; height: 40px; padding: 0 4px 0 12px; font-size: 15px; font-weight: 550; color: var(--accent); }
  .search { height: 42px; }
  .search input { font-size: 16px; }
  .search kbd { display: none; }
  .effort-filter button { min-height: 32px; font-size: 14px; }
  .model-row { min-height: 42px; font-size: 15px; }
  .pick-row { min-height: 38px; font-size: 14px; }
  footer { padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
