/* Chart-first layout. Shared by the desktop shell and private web app. */
#btn-chart-layout { display: none; }
.canvas { position: relative; }
.chart-legend { position: absolute; z-index: 3; left: 4px; top: 4px; max-width: calc(100% - 12px); font-size: 11px; color: #dadada; }
.chart-legend[hidden] { display: none; }
.chart-legend[open] { z-index: 6; }
.chart-legend > summary { width: fit-content; cursor: pointer; padding: 6px; border-radius: 5px; background: #292c38dc; }
.chart-legend > .chart-legend-panel { padding: 8px; line-height: 1.5; background: #292c38f5; border: 1px solid #55576a; border-radius: 6px; max-height: min(340px,55dvh); overflow: auto; overflow-wrap: anywhere; }
.chart-legend :focus-visible { outline: 2px solid #dc7d46; outline-offset: 1px; }
.chart-legend-symbols { display: grid; gap: 3px; }
.chart-legend-symbol-row { display: grid; grid-template-columns: 26px minmax(0,1fr); align-items: center; gap: 8px; min-height: 25px; font-size: 12px; line-height: 1.35; }
.chart-legend-symbol-row[hidden] { display: none; }
.chart-legend-icon { position: relative; display: inline-block; width: 26px; height: 25px; color: #e5aa7f; }
.chart-legend-icon-shape { position: absolute; top: 2px; left: 8px; width: 10px; height: 10px; background: currentColor; }
.chart-legend-icon-caption { position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; font-size: 12px; font-weight: 700; line-height: 12px; }
.chart-legend-icon:is([data-symbol=step],[data-symbol=attempt]) .chart-legend-icon-shape { border-radius: 50%; }
.chart-legend-icon[data-symbol=long-confirmed] { color: #3dcf8e; }
.chart-legend-icon[data-symbol=short-confirmed] { color: #e85d5d; }
.chart-legend-icon:is([data-symbol=long-confirmed],[data-symbol=short-confirmed]) .chart-legend-icon-shape { top: 3px; left: 5px; width: 16px; height: 18px; clip-path: polygon(50% 0,100% 50%,70% 50%,70% 100%,30% 100%,30% 50%,0 50%); }
.chart-legend-icon[data-symbol=short-confirmed] .chart-legend-icon-shape { transform: rotate(180deg); }
.chart-legend-icon[data-symbol=discarded] { color: #a0a4b4; }
.chart-legend-icon:is([data-symbol=state-true],[data-symbol=state-false]) .chart-legend-icon-shape { top: 8px; left: 3px; width: 20px; height: 10px; }
.chart-legend-icon[data-symbol=state-true] { color: #3dcf8e; }
.chart-legend-icon[data-symbol=state-false] { color: #778093; }
.chart-legend-icon[data-symbol=state-unknown] { color: #c5a676; }
.chart-legend-icon[data-symbol=state-unknown] .chart-legend-icon-shape { top: 8px; left: 3px; width: 20px; height: 10px; box-sizing: border-box; border: 1px dashed #777b8e; background: transparent; }
.chart-legend-icon[data-symbol=state-unknown] .chart-legend-icon-caption { top: 7px; bottom: auto; line-height: 12px; }
.chart-legend-icon[data-symbol=context] { color: #9b7bb8; }
.chart-legend-icon[data-symbol=context] .chart-legend-icon-shape { top: 5px; left: 1px; width: 24px; height: 0; border-top: 1px dashed currentColor; background: none; }
.chart-legend-symbol-note { max-width: 390px; padding: 4px 0 6px; color: #b2b2b2; font-size: 11px; line-height: 1.4; }
.chart-legend-values { white-space: pre-line; border-top: 1px solid #55576a; padding-top: 7px; margin-top: 3px; }
.chart-legend-values:empty { display: none; }
.setup-dialog .info-button { box-sizing: border-box; width: 44px; height: 44px; min-width: 44px; min-height: 44px; max-height: 44px; flex: 0 0 44px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; }
.indicator-pane-bar { position: relative; z-index: 4; display: flex; align-items: flex-start; min-height: 0; box-sizing: border-box; border-top: 1px solid #464959; background: #262834; overflow: visible; }
.indicator-pane-bar[hidden], .indicator-pane-grip[hidden] { display: none; }
.indicator-pane-bar .indicator-pane-toggle { flex: 0 1 auto; min-width: 0; min-height: 0; height: 100%; padding: 0 10px; background: transparent; border: 0; color: #b2b2b2; font: inherit; font-size: 11px; white-space: nowrap; cursor: pointer; }
.indicator-pane-grip { flex: 1; height: 100%; min-width: 36px; display: grid; place-items: center; cursor: ns-resize; touch-action: none; }
.indicator-pane-grip::after { content: ''; width: 32px; height: 3px; border-top: 1px solid #9396a4; border-bottom: 1px solid #9396a4; }
.indicator-pane-bar :focus-visible { outline: 2px solid #dc7d46; outline-offset: -2px; }
.measurement-controls { width: 100%; min-width: 0; box-sizing: border-box; padding: 4px 8px; }
.measurement-toolbar { display: grid; grid-template-columns: auto minmax(60px,1fr) auto 30px; gap: 6px; align-items: center; min-width: 0; }
.measurement-collapsed .measurement-toolbar { grid-template-columns: auto; justify-content: start; }
.indicator-pane-bar .indicator-pane-toggle { min-height: 30px; padding: 0 4px; font-size: 12px; }
.indicator-pane-bar .calculation-select { box-sizing: border-box; width: 100%; min-width: 0; min-height: 30px; height: 30px; padding: 3px 6px; color: #dadada; background: #303344; border: 1px solid #55596c; border-radius: 5px; font: inherit; font-size: 12px; }
.calculation-select[hidden], .measurement-current[hidden], .calculation-details[hidden] { display: none; }
.calculation-details > summary { cursor: pointer; color: #dadada; font-size: 12px; white-space: nowrap; padding: 6px 2px; }
.calculation-status-list { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); box-sizing: border-box; max-height: min(300px,45dvh); overflow: auto; padding: 8px 12px; border: 1px solid #666b80; border-radius: 8px; background: #292c38; box-shadow: 0 -6px 24px #0008; }
.calculation-status-row { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid #464959; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.calculation-status-row:last-child { border-bottom: 0; }
.calculation-status-row > span { padding-left: 5px; }
.calculation-status-row > strong { font-size: 12px; padding-left: 5px; color: #dadada; }
.calculation-status-row[data-state=true] > strong { color: #55db9d; }
.calculation-status-row[data-state=false] > strong { color: #b7bed0; }
.calculation-status-row[data-state=unknown] > strong { color: #c5a676; }
.measurement-current { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 8px; padding-top: 4px; line-height: 1.3; }
.measurement-name { grid-column: 1 / -1; color: #dadada; font-size: 13px; overflow-wrap: anywhere; }
.measurement-value { grid-column: 1 / -1; color: #f0c7a9; font-size: 14px; font-weight: 700; }
.measurement-time { grid-column: 1 / -1; font-size: 11px; color: #b2b2b2; overflow-wrap: anywhere; }
.measurement-threshold { color: #b2b2b2; font-size: 11px; }
.indicator-pane-bar.measurement-compact .measurement-current { display: none; }
.setup-marker-key { position: absolute; z-index: 2; top: 5px; right: 7px; max-width: calc(100% - 92px); color: #cbd0dc; background: #22242fd9; padding: 4px 6px; border-radius: 4px; font-size: 11px; line-height: 1.35; pointer-events: none; }
.measurement-toolbar .indicator-pane-grip { min-width: 24px; min-height: 30px; }
.measurement-toolbar .indicator-pane-grip::after { width: 20px; }
.history-options-close { display: none; }
.history-progress { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 2px 8px; }
.history-progress:has(#history-status:empty):has(#history-cancel[hidden]) { display: none; }
.history-progress #history-status { max-height: 44px; overflow: auto; flex: 1; }
.history-progress #history-cancel { min-height: 36px; padding: 4px 8px; }
#history-view > .history-controls { padding: 6px 8px; gap: 5px; flex: 0 0 auto; }
.history-diagnostics { flex: 0 0 auto; font-size: 11px; color: #b2b2b2; padding: 4px 10px; }
.history-diagnostics > summary { cursor: pointer; }
.history-diagnostics[open] { max-height: 25%; overflow: auto; }
@media (max-width: 680px) {
  body .topbar { padding: 4px 8px; gap: 4px; }
  body .topbar .brand .logo { height: 46px; max-width: 136px; }
  body .workspace-controls { display: flex; align-items: center; padding: 2px 6px; gap: 2px; position: relative; }
  body .workspace-controls[hidden] { display: none; }
  body .chart-toolbar { flex: 1; flex-wrap: nowrap; padding: 0; gap: 2px; }
  body .chart-toolbar :is(#btn-chart-layout,#btn-autofollow,#btn-reset-view) { display: inline-grid; place-items: center; box-sizing: border-box; flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; }
  body .chart-toolbar :is(#btn-autofollow,#btn-reset-view) { font-size: 0; }
  #btn-autofollow::after { content: '◎'; font-size: 22px; }
  #btn-reset-view::after { content: '⤢'; font-size: 24px; }
  #btn-chart-layout { font-size: 24px; }
  body .chart-toolbar .panel-toggles { margin-left: auto; padding-left: 2px; gap: 0; }
  body .chart-toolbar .panel-toggles button { width: 44px; min-height: 44px; padding: 10px; }
  body .chart-toolbar .layout-picker { display: none; }
  body .chart-toolbar .layout-picker.picker-open { display: flex; position: absolute; z-index: 60; top: 100%; left: 6px; right: 6px; padding: 6px; border: 1px solid #55576a; box-shadow: 0 8px 24px #0008; }
  body #history-tools { flex: 0 0 44px; }
  body .history-panel, body .history-panel[open] { margin: 0; padding: 0; border: 0; }
  body .history-panel > summary { width: 44px; height: 44px; min-height: 44px; justify-content: center; font-size: 0; }
  body .history-panel > summary::before { content: '◷'; font-size: 25px; }
  body .history-panel[open] > summary { color: #dc7d46; }
  body .history-panel .history-toolbar { position: fixed; z-index: 80; left: 8px; right: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); max-height: 48dvh; overflow: auto; box-sizing: border-box; padding: 12px; gap: 8px; background: #292c38; border: 1px solid #626575; border-radius: 12px; box-shadow: 0 -10px 36px #0009; }
  body .history-panel .history-options-close { display: block; margin-left: auto; }
  body .history-toolbar label { order: -1; flex: 1 1 42%; }
  body .history-toolbar input[type=date] { width: 100%; }
  body > .layout { padding: 4px 6px; }
  body .chart-grid { gap: 5px; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .head { padding: 2px 6px; gap: 4px; flex-wrap: nowrap; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .head .focus-btn { display: none; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .head .fullscreen-btn { flex: 0 0 44px; width: 44px; min-height: 44px; padding: 0; font-size: 0; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .head .fullscreen-btn::after { content: '⛶'; font-size: 22px; }
  body .chart-cell .chart-tools { flex-wrap: nowrap; padding: 0 4px 2px; gap: 2px; }
  body .chart-cell .chart-tf { flex-wrap: nowrap; padding: 0; }
  body .chart-cell .chart-tf button { padding: 0 6px; min-width: 36px; min-height: 36px; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .chart-feed { font-size: 0; }
  body .chart-cell:not(.chart-expanded):not(:fullscreen) .chart-feed::after { content: '●'; font-size: 10px; }
  body .foot { padding: 3px 8px; font-size: 10px; }
  body .main-nav .area-btn { min-height: 48px; }
  #history-view { min-height: 0; }
  #history-view .history-chart-heading { padding: 5px 8px; font-size: 11px; gap: 3px; }
  #history-view .history-chart-heading strong { flex: 1 0 100%; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  #history-view #history-chart-time { margin-left: 0; }
  #history-view .history-controls { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px 54px; }
  #history-view .history-controls .history-badge { display: none; }
  #history-filter { grid-column: 1 / 4; grid-row: 1; width: 100%; }
  #history-live { grid-column: 4; grid-row: 1; padding: 4px; font-size: 11px; }
  #history-prev { grid-column: 1; grid-row: 2; }
  #history-event { grid-column: 2; grid-row: 2; width: 100%; min-width: 0; }
  #history-next { grid-column: 3; grid-row: 2; }
  #history-tf { grid-column: 4; grid-row: 2; padding: 4px; }
  #history-view .history-controls :is(button,select) { min-height: 36px; font-size: 12px; box-sizing: border-box; }
  #history-view .history-controls select { font-size: 12px !important; }
}
