/* The sensor history chart (sensorchart.js): tabs, range menu, plot and tooltip. Colours are
   base.css's custom properties. */
/* The UA's [hidden] rule covers HTML only, so the chart's hover marker needs its own. */
svg [hidden] { display: none; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.tabs button { border: 1px solid var(--rule); background: none; border-radius: 999px; padding: 2px 12px;
               font-size: 13px; cursor: pointer; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
/* A long press opens the context menu or selects text on touch, and starts the overlay here. */
.tabs button { -webkit-touch-callout: none; user-select: none; }
/* Overlaid, the two pressed tabs double as the legend: a dot in each line's colour. */
.tabs.overlay button[aria-pressed="true"]::before { content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--line); margin-right: 6px; }
.tabs.overlay button.second::before { background: var(--line2); }
/* Top right of the chart card, in the strip above the plot that only the unit label uses.
   right = #chartwrap's 8px padding + the chart's PAD.right, so the arrow ends where the plot does. */
#chart-controls { position: absolute; top: 8px; right: 16px; display: flex; align-items: center; gap: 6px; }
#chart-controls > * { border: 0; background: var(--surface); border-radius: 6px; padding: 2px 0 2px 4px;
                      font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
#interval::after { content: "▾"; margin-left: 4px; color: var(--muted); }
#chart-controls > :focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }
/* Compare: an icon that, pressed, swaps the range menu for two day pickers and zoom. Each picker takes
   its line's colour, so the pair doubles as the legend. */
#compare, #zoom { padding: 3px 5px; color: var(--muted); line-height: 0; }
#compare[aria-pressed="true"], #zoom[aria-pressed="true"] { background: var(--rule); color: var(--text); }
/* Zoom pressed: a drag across the chart picks the stretch, so it neither scrolls the page nor
   selects the axis labels. */
#chart.selecting { cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
#day-a { color: var(--line); }
#day-b { color: var(--line2); }
/* The range menu: a popover (Esc and outside clicks close it), groups split by a rule.
   Absolute in the top layer means page coordinates, so it scrolls with the button. */
#interval-menu { position: absolute; inset: auto; margin: 0; min-width: 180px; padding: 4px;
                 background: var(--surface); color: var(--text); border: 1px solid var(--rule); border-radius: 10px;
                 box-shadow: 0 6px 24px rgb(0 0 0 / .12); }
#interval-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit;
                        font-size: 15px; color: inherit; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
#interval-menu button:hover, #interval-menu button[aria-current="true"] { background: var(--rule); }
#interval-menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px -4px; }

#chartwrap { position: relative; background: var(--surface); border: 1px solid var(--rule);
             border-radius: 8px; padding: 12px 8px 4px; }
/* pan-y keeps vertical page scrolling while horizontal drags read the chart */
#chart { width: 100%; height: 240px; display: block; touch-action: pan-y; }
#tip { position: absolute; pointer-events: none; transform: translate(-50%, -100%);
       background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.3;
       padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#chart-note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
#tip b { display: block; font-size: 14px; font-weight: 500; }
