/* 設計メモ
   一言で: サーキットの計時シート。紙に黒罫、数字は等幅で淡々と並ぶ
   書体: BIZ UDPGothic(計時表の読みやすさ) + IBM Plex Mono(タイムと数値)
   色: 地 紙色 / 文字 墨 / A 朱 / B 藍。A と B の 2 色だけで「どちらのラップか」を示す
   形: 角丸 3px まで、罫線 1px、影なし
   動き: なし。カーソルの追従だけ
   記憶に残るもの: 区間ごとの差で塗り分けたコース図
   オシロのチャンネルだけは多数を見分けるため、dataviz の検証済みの 8 色と線の種類を使う */
:root {
  --paper: #f6f5f0;
  --panel: #fdfcf8;
  --ink: #1c1b18;
  --muted: #5e5b52;
  --rule: #cfccc2;
  --rule-strong: #1c1b18;
  --a: #c8321a;
  --b: #0f62a8;
  --on-accent: #ffffff;
  --neutral-cell: #e4e2da;
  --err: #a3200c;
  --ch1: #2a78d6;
  --ch2: #eb6834;
  --ch3: #1baf7a;
  --ch4: #eda100;
  --ch5: #e87ba4;
  --ch6: #008300;
  --ch7: #6250d6;
  --ch8: #e34948;
  --critical: #d03b3b;
  --warning: #fab219;
  --warning-text: #8f6100;
  --good-text: #006300;
  --sans: 'BIZ UDPGothic', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161614;
    --panel: #1e1e1b;
    --ink: #ecebe4;
    --muted: #a8a59a;
    --rule: #3a3934;
    --rule-strong: #ecebe4;
    --a: #e5573b;
    --b: #3c9be6;
    --on-accent: #161614;
    --neutral-cell: #2c2b27;
    --err: #ff8b73;
    --warning-text: #fab219;
    --good-text: #4cc94c;
    --ch1: #3987e5;
    --ch2: #d95926;
    --ch3: #199e70;
    --ch4: #c98500;
    --ch5: #d55181;
    --ch6: #008300;
    --ch7: #9085e9;
    --ch8: #e66767;
  }
}
:root[data-theme="dark"] {
  --paper: #161614;
  --panel: #1e1e1b;
  --ink: #ecebe4;
  --muted: #a8a59a;
  --rule: #3a3934;
  --rule-strong: #ecebe4;
  --a: #e5573b;
  --b: #3c9be6;
  --on-accent: #161614;
  --neutral-cell: #2c2b27;
  --err: #ff8b73;
  --warning-text: #fab219;
  --good-text: #4cc94c;
  --ch1: #3987e5;
  --ch2: #d95926;
  --ch3: #199e70;
  --ch4: #c98500;
  --ch5: #d55181;
  --ch6: #008300;
  --ch7: #9085e9;
  --ch8: #e66767;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
}
h1, h2, h3, p { margin: 0; }
h1 { flex: none; font-size: 16px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; margin-top: 28px; }
.panel > h3:first-child { margin-top: 0; }
.lead, .note, .hint { color: var(--muted); font-size: 13px; text-wrap: pretty; }
.note { margin: 2px 0 8px; }
.error { color: var(--err); margin-top: 12px; }

.top {
  display: flex; gap: 20px; align-items: center;
  padding: 4px 16px;
  border-bottom: 2px solid var(--rule-strong);
}
.load { display: flex; gap: 8px; margin-left: auto; }
.load .btn { min-height: 30px; font-size: 13px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px;
  font: 700 14px var(--sans); color: var(--ink);
  background: transparent; border: 1px solid var(--rule-strong); border-radius: 3px;
  cursor: pointer; transition: background-color 120ms;
}
.btn:hover { background: var(--neutral-cell); }
.btn:active { background: var(--rule); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { opacity: .88; }
.btn:disabled { opacity: .4; cursor: default; background: transparent; }
.btn.small { min-height: 32px; font-size: 13px; }
.btn:has(input:focus-visible), button:focus-visible, select:focus-visible, input:focus-visible, .link:focus-visible {
  outline: 2px solid var(--b); outline-offset: 2px;
}
.link { background: none; border: 0; padding: 0 4px; color: var(--b); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }

select, input[type=number] {
  min-height: 34px; padding: 0 8px; font: 14px var(--sans); color: var(--ink);
  background: var(--panel); border: 1px solid var(--rule); border-radius: 3px;
}
input[type=number] { width: 84px; font-family: var(--mono); }

.empty { margin-bottom: 20px; padding: 48px 32px; border: 1px dashed var(--muted); border-radius: 3px; }
.empty-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
body.dragging .empty, body.dragging .sheet { outline: 2px solid var(--a); outline-offset: -2px; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.sheet { padding: 16px; border-right: 1px solid var(--rule); position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.work { padding: 12px 24px 48px; min-width: 0; }

.file-head { margin: 14px 0 4px; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.file-head small { display: block; font-weight: 400; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.lap-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 13px; }
.lap-table td { border-top: 1px solid var(--rule); padding: 2px 4px; }
.lap-table .n { color: var(--muted); width: 2.4em; }
.lap-table .t { font-weight: 400; }
.lap-table tr.best .t { font-weight: 600; }
.lap-table tr.best .t::after { content: ' 最速'; font-family: var(--sans); font-size: 11px; font-weight: 700; }
.lap-table .pick { width: 72px; text-align: right; white-space: nowrap; }
.pick button {
  width: 30px; height: 28px; margin-left: 3px; font: 600 12px var(--mono); color: var(--muted);
  background: transparent; border: 1px solid var(--rule); border-radius: 3px; cursor: pointer;
}
.pick button:hover { border-color: var(--ink); color: var(--ink); }
.pick button[data-slot=a][aria-pressed=true] { background: var(--a); border-color: var(--a); color: var(--on-accent); }
.pick button[data-slot=b][aria-pressed=true] { background: var(--b); border-color: var(--b); color: var(--on-accent); }

.tabs { display: flex; flex: 1 1 auto; min-width: 0; gap: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  padding: 5px 0 3px; font: 700 13px var(--sans); color: var(--muted); white-space: nowrap;
  background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }

.versus { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline; margin-bottom: 14px; font-family: var(--mono); }
.versus .who { font-size: 13px; color: var(--muted); font-family: var(--sans); }
.versus b { font-size: 24px; font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 4px; border-radius: 2px; vertical-align: baseline; }
.sw-a { background: var(--a); }
.sw-b { background: var(--b); }
.sw-n { background: var(--neutral-cell); border: 1px solid var(--rule); }

.overview { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
#map { width: 100%; aspect-ratio: 4 / 3; display: block; border: 1px solid var(--rule); background: var(--panel); }
.segs h3 { margin-top: 0; margin-bottom: 6px; }
.seg-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; height: 34px; }
.seg-strip button { padding: 0; border: 0; border-radius: 1px; cursor: pointer; }
.seg-strip button:hover { outline: 1px solid var(--ink); }
.seg-legend { margin-top: 6px; font-size: 12px; color: var(--muted); }
.seg-legend .sw { margin-left: 10px; }
.seg-legend .sw:first-child { margin-left: 0; }
.seg-top { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.seg-top li { padding: 3px 0; border-top: 1px solid var(--rule); font-family: var(--mono); }
.seg-top button { all: unset; cursor: pointer; display: block; width: 100%; }
.seg-top button:hover { text-decoration: underline; }
.seg-top button:focus-visible { outline: 2px solid var(--b); }

.plot-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 18px 0 8px; font-size: 13px; }
.plot { border-top: 1px solid var(--rule); padding-top: 4px; margin-bottom: 4px; }
.plot-head { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: baseline; font-size: 13px; min-height: 24px; }
.plot-name { font-weight: 700; }
.plot-unit { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.plot-values { font-family: var(--mono); display: flex; flex-wrap: wrap; gap: 0 12px; }
.plot-close { margin-left: auto; width: 26px; height: 26px; color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 16px; }
.plot-close:hover { color: var(--ink); }
.plot-canvas { position: relative; height: 104px; touch-action: pan-y; cursor: crosshair; }
.plot-canvas.tall { height: 150px; }
.plot-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.scroll { overflow-x: auto; }
table.data { border-collapse: collapse; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
table.data th { font: 700 12px var(--sans); text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--rule-strong); vertical-align: bottom; white-space: normal; min-width: 62px; }
table.data td { padding: 3px 8px; text-align: right; border-bottom: 1px solid var(--rule); }
table.data tr.is-a td:first-child { box-shadow: inset 4px 0 0 var(--a); }
table.data tr.is-b td:first-child { box-shadow: inset 4px 0 0 var(--b); }

.code-row { display: grid; grid-template-columns: 11em 1fr; gap: 8px; align-items: center; font-family: var(--mono); font-size: 13px; padding: 2px 0; border-top: 1px solid var(--rule); }
.code-label b { font-weight: 600; }
.code-bars { display: grid; gap: 2px; }
.code-bar { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.code-bar i { display: block; height: 8px; border-radius: 0 2px 2px 0; }
.code-bar .a { background: var(--a); }
.code-bar .b { background: var(--b); }

/* オシロは横幅が要るので、ラップ一覧を隠して全幅で使う。ラップは「移動」で選ぶ */
.scope-tools { margin-top: 0; }
#scope-file { max-width: 130px; }
#scope-jump { max-width: 96px; }
#scope-preset { max-width: 130px; }
.scope-tb { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); }
.scope-tb b { min-width: 7.5em; text-align: center; font-weight: 600; font-size: 15px; }
.scope-mini {
  min-width: 28px; height: 28px; padding: 0 4px; font: 600 14px var(--mono); color: var(--ink);
  background: transparent; border: 1px solid var(--rule); border-radius: 3px; cursor: pointer;
}
.scope-mini:hover { border-color: var(--ink); }
.scope-mini:active { background: var(--neutral-cell); }
.scope-mini:disabled { opacity: .4; cursor: default; }
.scope-main { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.scope-screen { position: relative; height: min(62vh, 560px); min-height: 300px; border: 1px solid var(--rule-strong); touch-action: none; }
.scope-side { min-width: 0; }
.scope-laf { margin-top: 6px; }
.scope-laf-error { position: absolute; margin: 16px 0 0; padding: 6px 8px; font-size: 11px; line-height: 1.4; color: var(--ink); max-width: 260px; }
.scope-laf { position: relative; }
.scope-laf-head, .scope-laf-foot { display: flex; justify-content: space-between; gap: 8px; height: 16px; font: 11px/16px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; }
.scope-laf-head b { color: var(--ink); font: 700 11px/16px var(--sans); }
.scope-laf-foot .sw { width: 8px; height: 8px; }
.scope-laf-foot span:last-child { margin-left: auto; }
#scope-laf-mini { display: block; width: 100%; height: 112px; }
#scope-map { display: block; width: 100%; aspect-ratio: 4 / 3; border: 1px solid var(--rule); }
.scope-where-name { height: 26px; margin-top: 6px; font-size: 18px; font-weight: 700; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-where-time { margin-bottom: 8px; height: 18px; font: 12px var(--mono); color: var(--muted); white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.scope-live { width: 100%; border-collapse: collapse; table-layout: fixed; }
.scope-live th { overflow: hidden; text-overflow: ellipsis; }
.scope-compare { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.scope-compare b { font-size: 13px; }
#scope-compare { max-width: 118px; }
#scope-compare-align { max-width: 104px; }
.scope-live.is-compare .scope-live-value, .scope-live.is-compare .scope-live-ref { width: 21%; font-size: 12px; text-align: right; white-space: nowrap; overflow: hidden; }
.scope-live.is-compare .scope-live-ref { color: var(--muted); font-weight: 400; font-family: var(--mono); }
.scope-live-head th, .scope-live-head td { font: 11px var(--mono); color: var(--muted); text-align: right; }
.scope-live-head th { color: var(--ink); text-align: left; white-space: nowrap; overflow: visible; }
.scope-status { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 18px 15px; align-items: center; gap: 0 8px; height: 42px; margin-bottom: 4px; padding: 4px 8px; font-size: 13px; color: var(--muted); border: 1px solid var(--rule); border-radius: 3px; }
.scope-status-label { font: 600 11px var(--mono); white-space: nowrap; }
.scope-status-text { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-status-sub { grid-column: 1 / -1; font: 11px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-status.is-on { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.scope-status-mil.is-on { color: #fff; background: var(--critical); border-color: var(--critical); }
.scope-mil-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 8px; padding: 8px 12px; font-size: 13px; color: #fff; background: var(--critical); border-radius: 3px; }
.scope-mil-alert .btn { color: #fff; border-color: #fff; }
.scope-mil-alert .btn:hover { color: var(--critical); background: #fff; }
.scope-fixed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(6, auto); grid-auto-flow: column; gap: 0 12px; margin: 6px 0; font: 12px var(--mono); }
.scope-fixed div { display: flex; justify-content: space-between; gap: 6px; padding: 1px 0; border-top: 1px solid var(--rule); }
.scope-fixed span { color: var(--muted); white-space: nowrap; }
.scope-fixed b { font-weight: 600; }
.scope-live th, .scope-live td { padding: 1px 0; border-top: 1px solid var(--rule); font-family: var(--mono); }
.scope-live th { font-size: 12px; font-weight: 400; text-align: left; white-space: nowrap; }
.scope-live-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.scope-live-unit { width: 3.6em; padding-left: 6px !important; font-size: 11px; color: var(--muted); white-space: nowrap; }
.scope-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scope-flags { display: block; width: 100%; position: sticky; top: 0; z-index: 2; border: 1px solid var(--rule-strong); border-bottom: 0; }
.scope-flag-list li { display: block; padding: 6px 0; }
.scope-flag-cond { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px 0; }
.scope-flag-join { flex: none; width: 74px; font-size: 12px; text-align: right; color: var(--muted); }
.scope-flag-join select { width: 100%; }
.scope-flag-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 2px 0 0 82px; }
.scope-flag-summary { flex: 1 1 auto; margin: 0; }
.scope-flag-list select { max-width: 130px; font: 12px var(--mono); }
.scope-flag-list input[type=number] { width: 80px; min-height: 30px; }
#scope-over { cursor: grab; }
#scope-over:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }
.scope-overview { display: block; width: 100%; height: 44px; margin-top: 6px; border: 1px solid var(--rule); touch-action: none; cursor: pointer; }
.scope-foot { display: flex; align-items: center; gap: 4px 16px; min-height: 32px; margin-top: 4px; }
.scope-info { flex: 0 1 auto; min-width: 0; display: flex; gap: 2px 20px; font: 12px var(--mono); white-space: nowrap; overflow: hidden; }
.scope-foot-status { flex: 1 1 0; min-width: 0; margin: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#scope-measure-toggle { flex: none; }
.scope-compare-summary { display: inline-block; min-width: 25em; height: 18px; font: 600 12px/18px var(--mono); white-space: nowrap; }
#compare-detail .versus b { font-size: 18px; }
.scope-trigger b { font-size: 13px; }
.scope-trigger input[type=number] { width: 58px; }
.scope-trigger { gap: 4px 10px; }
#scope-trig-source { max-width: 104px; }
#scope-trig-slope { max-width: 100px; }
#scope-trig-range { max-width: 104px; }
.scope-edit-open { width: 100%; justify-content: center; margin-bottom: 6px; }
.scope-editor { width: min(860px, 94vw); max-height: 88vh; padding: 0; color: var(--ink); background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 3px; }
.scope-editor::backdrop { background: rgba(0, 0, 0, .45); }
.scope-editor-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--rule); }
.scope-editor-head h2 { font-size: 15px; }
.scope-editor-body { padding: 8px 16px 18px; }
#scope-preset-status, #scope-link-status { flex-basis: 100%; min-height: 1.6em; margin: 0; }
.scope-editor input[type=text] { min-height: 34px; width: 200px; padding: 0 8px; font: 14px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; }
.scope-info b { font-weight: 600; }
.scope-table td, .scope-table th { padding: 3px 6px; }
.scope-name { text-align: left !important; font-family: var(--mono); white-space: nowrap; }
.scope-ctl { white-space: nowrap; }
.scope-handle { display: inline-block; width: 18px; color: var(--muted); text-align: center; cursor: grab; touch-action: none; user-select: none; }
.scope-handle:hover { color: var(--ink); }
#scope-edit tr.scope-drop { outline: 2px solid var(--b); outline-offset: -2px; }
.scope-ctl .scope-mini { min-width: 24px; height: 24px; font-size: 12px; margin: 0 1px; }
.scope-perdiv { display: inline-block; min-width: 3.2em; text-align: center; }
.scope-link { min-height: 26px; padding: 0 4px; font: 12px var(--mono); max-width: 96px; }
.scope-links { margin: 6px 0 0; padding: 0; list-style: none; font: 13px var(--mono); }
.scope-links li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; min-height: 28px; border-top: 1px solid var(--rule); }
.scope-links li:last-child { border-bottom: 1px solid var(--rule); }
.scope-links .link { min-height: 24px; }
.scope-count { display: inline-block; font: 12px var(--mono); min-width: 6.5em; }
.scope-peaks { margin: 8px 0 4px; padding: 0; list-style: none; font: 13px var(--mono); min-height: 20px; }

.summary-files tr[tabindex] { cursor: pointer; }
.summary-files tr[tabindex]:hover td { background: var(--neutral-cell); }
.summary-files tr.is-selected td { background: var(--neutral-cell); }
.summary-files tr[tabindex]:focus-visible { outline: 2px solid var(--b); outline-offset: -2px; }
.summary-file { text-align: left !important; font-family: var(--mono); white-space: nowrap; }
.summary-status { text-align: left !important; font-family: var(--sans); white-space: nowrap; }
.summary-text { text-align: left !important; font-family: var(--sans); white-space: normal; }
.summary-mark { display: inline-block; width: 1.3em; font-weight: 700; }
.summary-status.is-bad .summary-mark { color: var(--critical); }
.summary-status.is-warn .summary-mark { color: var(--warning-text); }
.summary-status.is-ok .summary-mark, .summary-status.is-fixed .summary-mark, .summary-ok .summary-mark { color: var(--good-text); }
.summary-status.is-bad { font-weight: 700; }
.summary-ok { font-size: 14px; }
#summary-sus { width: 100%; min-width: 760px; }
.summary-offset { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; font-size: 13px; }

.load-status { position: fixed; z-index: 30; top: 52px; right: 16px; width: min(380px, calc(100vw - 32px)); padding: 10px 14px; color: var(--ink); background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 3px; opacity: 1; transition: opacity .6s; cursor: pointer; }
.load-status[data-kind=loading] { cursor: default; }
.load-status.fading { opacity: 0; pointer-events: none; }
.load-status-line { display: flex; gap: 8px; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.load-status[data-kind=loading] .load-status-line { font-family: var(--mono); }
.load-status-mark { flex: none; }
.load-status-mark:empty { display: none; }
.load-status[data-kind=ok] .load-status-mark { color: var(--good-text); }
.load-status[data-kind=warn] .load-status-mark { color: var(--warning-text); }
.load-status[data-kind=error] .load-status-mark { color: var(--err); }
.load-status-file { margin-top: 2px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.load-status-track { height: 3px; margin-top: 8px; background: var(--neutral-cell); }
.load-status-track i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; }

.record-dialog { width: min(420px, 92vw); padding: 20px; color: var(--ink); background: var(--panel); border: 1px solid var(--rule-strong); border-radius: 3px; }
.record-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.record-kicker { font-size: 14px; font-weight: 700; }
.record-time { margin: 2px 0 6px; font: 600 38px/1.1 var(--mono); }
.record-previous { margin: 8px 0 14px; font-size: 14px; }
.record-name { display: block; font-size: 13px; }
.record-name input { display: block; width: 100%; min-height: 36px; margin-top: 4px; padding: 0 8px; font: 14px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; }
.record-name input:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }
.record-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.corner-message { padding: 24px 0; color: var(--muted); }
.corner-foot { margin-top: 8px; }
.corner-table th { min-width: 44px; }
.corner-table td { padding: 3px 6px; }
.corner-table tr.is-selected td { background: var(--neutral-cell); }
.corner-table tr.corner-b td { color: var(--muted); }
.corner-table .corner-gap, .corner-table tr.is-selected td.corner-gap { color: var(--ink); vertical-align: middle; }
.corner-name-cell { text-align: left !important; vertical-align: middle; }
.corner-name { padding: 2px 0; font: 700 13px var(--sans); color: var(--ink); text-align: left; white-space: nowrap; background: none; border: 0; cursor: pointer; }
.corner-name:hover { text-decoration: underline; }
.corner-slot { font-size: 11px; white-space: nowrap; }
table.corner-laps th { font-size: 11px; white-space: nowrap; }
table.corner-laps th.is-selected { color: var(--ink); font-weight: 600; }
table.corner-laps th.lap-a { color: var(--a); font-weight: 600; }
table.corner-laps th.lap-b { color: var(--b); font-weight: 600; }
table.corner-laps td { min-width: 52px; }
table.corner-laps td.corner-cell { cursor: pointer; }
table.corner-laps td.corner-cell:hover { outline: 1px solid var(--ink); outline-offset: -1px; }

.sus-phase { text-align: left !important; font-family: var(--sans); white-space: nowrap; }
.sus-sub { margin-top: 14px; }
table.sus-depth th { white-space: nowrap; }

table.heat { border-collapse: separate; border-spacing: 1px; font-family: var(--mono); font-size: 11px; }
table.heat th { font-weight: 400; color: var(--muted); padding: 2px 4px; white-space: nowrap; text-align: right; }
table.heat td { width: 38px; min-width: 38px; height: 24px; text-align: center; color: var(--ink); }
table.heat td.nodata { background: transparent; }
table.heat td:focus-visible { outline: 2px solid var(--b); outline-offset: -2px; }
table.heat td.laf-empty { width: auto; height: auto; padding: 32px 0; text-align: left; font: 14px var(--sans); color: var(--muted); }

.seg-switch { display: inline-flex; flex-wrap: wrap; margin-bottom: 10px; }
.seg-switch button {
  min-height: 34px; padding: 0 12px; margin-left: -1px;
  font: 700 13px var(--sans); color: var(--muted);
  background: transparent; border: 1px solid var(--rule); cursor: pointer;
}
.seg-switch button:first-child { margin-left: 0; border-radius: 3px 0 0 3px; }
.seg-switch button:last-child { border-radius: 0 3px 3px 0; }
.seg-switch button:hover { color: var(--ink); }
.seg-switch button[aria-pressed=true] { position: relative; color: var(--paper); background: var(--ink); border-color: var(--ink); }
.laf-readout { min-height: 22px; line-height: 1.5; margin-top: 6px; font: 13px var(--mono); }
.laf-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.laf-settings textarea {
  width: 100%; padding: 8px; font: 12px/1.4 var(--mono); color: var(--ink); white-space: pre; overflow: auto;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; resize: vertical;
}
.laf-settings textarea:focus-visible, .laf-more summary:focus-visible { outline: 2px solid var(--b); outline-offset: 2px; }
.laf-more { margin-top: 24px; border-top: 1px solid var(--rule); padding-top: 12px; }
.laf-more summary { font-weight: 700; cursor: pointer; }
.laf-rules { display: grid; gap: 2px; font-size: 13px; }
.laf-rules label { display: flex; align-items: center; gap: 6px; min-height: 26px; }
.laf-rule-sec { color: var(--muted); font-family: var(--mono); font-size: 12px; }

.form { display: grid; gap: 12px; max-width: 720px; justify-items: start; }
.form label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.form select { max-width: 100%; }
.form fieldset { border: 1px solid var(--rule); border-radius: 3px; padding: 8px 12px 12px; width: 100%; margin: 0; }
.form legend { font-size: 13px; padding: 0 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 2px 8px; }
.checks label { font: 12px var(--mono); gap: 4px; min-height: 24px; }

/* PC ではオシロのタブを画面の高さに収めて、ページをスクロールさせない。
   右側と下の測定表は枠の中だけでスクロールする */
@media (min-width: 861px) {
  body.scope-open { height: 100dvh; overflow: hidden; overscroll-behavior: none; display: flex; flex-direction: column; }
  body.scope-open .btn { min-height: 30px; }
  body.scope-open .sheet { position: static; max-height: none; min-height: 0; overflow-y: auto; }
  body.scope-open #app { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  body.scope-open .work { display: flex; flex-direction: column; min-height: 0; padding: 8px 16px; }
  body.scope-open #tab-scope { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.scope-open .scope-tools { flex: none; margin-bottom: 6px; column-gap: 10px; }
  body.scope-open .scope-mil-alert { flex: none; padding: 4px 12px; margin-bottom: 6px; }
  body.scope-open .scope-main { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  body.scope-open .scope-screen-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow-y: auto; }
  body.scope-open .scope-flags { flex: none; }
  body.scope-open .scope-screen { flex: 1 1 0; height: auto; min-height: 0; }
  /* 高さが足りる間は数値のリストだけをスクロールさせて、LAF マップを常に下に見せる。
     それでも収まらない低い画面では、右カラムごとスクロールして下まで届くようにする */
  body.scope-open .scope-side { display: flex; flex-direction: column; height: 100%; overflow-y: auto; }
  body.scope-open .scope-side > * { flex: none; }
  body.scope-open .scope-live-wrap { flex: 1 1 0; min-height: 44px; overflow-y: auto; scrollbar-gutter: stable; }
  body.scope-open #scope-map { aspect-ratio: 2 / 1; }
  body.scope-open .scope-status { margin-bottom: 3px; }
  body.scope-open .scope-where-name { margin-top: 3px; }
  body.scope-open .scope-fixed { margin: 3px 0; }
  body.scope-open .scope-overview { flex: none; height: 36px; margin-top: 4px; }
  body.scope-open .scope-lower { flex: none; max-height: 34vh; margin-top: 6px; overflow-y: auto; }
  body.scope-open #compare-detail { max-height: 46vh; }
  body.scope-open .scope-tools { margin-top: 0; }
  body.scope-open .scope-trigger { margin-bottom: 6px; }
}

/* 高さの低いノート PC では、制御と MIL を横に並べてコース図も低くし、数値のリストの高さを確保する */
@media (min-width: 861px) and (max-height: 900px) {
  body.scope-open #scope-map { aspect-ratio: 5 / 2; }
  body.scope-open .scope-status-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  body.scope-open .scope-status-row .scope-status { margin-bottom: 0; }
  body.scope-open #scope-laf-mini { height: 96px; }
}

@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 2px 12px; padding: 6px 16px 0; }
  .tabs { order: 3; flex: 1 0 100%; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .scope-compare { flex-wrap: wrap; }
  .scope-compare-summary { min-width: 0; flex: 1 0 100%; }
  .sheet { position: static; max-height: 280px; border-right: 0; border-bottom: 1px solid var(--rule); }
  body.scope-open .sheet { max-height: 170px; }
  .work { padding: 12px 16px 48px; }
  .overview { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .laf-settings { grid-template-columns: minmax(0, 1fr); }
  .scope-main { grid-template-columns: minmax(0, 1fr); }
  .scope-screen { height: 340px; }
  .scope-side { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0 12px; }
  #scope-map { grid-row: 1 / span 3; }
  .scope-where-name { margin-top: 0; font-size: 17px; }
  .scope-foot { flex-wrap: wrap; }
  .scope-info { flex: 1 0 100%; flex-direction: column; }
  /* スマホ幅は名前と値を別の行に固定して、カーソルを動かしても高さが変わらないようにする */
  .plot-head { position: relative; display: block; height: 42px; padding-right: 26px; }
  .plot-head > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plot-name { display: block; }
  .plot-values { flex-wrap: nowrap; height: 20px; overflow: hidden; }
  .plot-close { position: absolute; top: 0; right: 0; }
  .laf-readout { min-height: 40px; }
  .scope-status-row, .scope-fixed, .scope-live-wrap, .scope-laf, .scope-edit-open { grid-column: 1 / -1; }
  .hint { display: none; }
  .empty { padding: 32px 20px; }
}
