/* Oct 18, 2026: Tools side tabs and slide-out panel (js/tools.js). Right edge on wider screens, a bottom tab bar on phones.
   Colors come from the site variables, so Low-glare and Sensory-friendly mode are dark with no bright white. */
:root{ --railw:88px; --railh:58px; --panelw:470px; }
.tl-rail{ position:fixed; right:0; top:50%; transform:translateY(-50%); z-index:66; width:var(--railw); display:flex; flex-direction:column; gap:6px; padding:8px 6px;
  background:var(--card,#fff); border:2px solid var(--line); border-right:0; border-radius:14px 0 0 14px; box-shadow:var(--shadow,none); }
.tl-rail[hidden], .tl-panel[hidden], .tl-note[hidden]{ display:none; }
.tl-tab{ position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; min-height:64px; width:100%; margin:0; padding:6px 2px;
  border:2px solid var(--accent); border-radius:10px; background:var(--paper); color:var(--ink); font:inherit; font-size:.8rem; font-weight:600; line-height:1.1; cursor:pointer; box-shadow:none; }
.tl-tab .tl-ico{ width:22px; height:22px; }
.tl-tab.on{ background:var(--accent); color:var(--accent-ink,#fff); }
.tl-tab.locked{ border:2px dashed var(--line); background:transparent; color:var(--muted); cursor:not-allowed; font-weight:500; }
.tl-tab.locked .tl-ico{ opacity:.55; }
.tl-tab .tl-lk{ position:absolute; top:4px; right:4px; width:15px; height:15px; }
.tl-tab:focus-visible, .tl-b:focus-visible, .tl-k:focus-visible, .tl-hb:focus-visible, .tl-cv:focus-visible, .tl-panel h2:focus-visible{ outline:3px solid var(--focus); outline-offset:2px; }
.tl-note{ position:fixed; z-index:73; max-width:min(320px,calc(100vw - 16px)); display:flex; gap:8px; align-items:flex-start; padding:10px 12px; border-radius:10px;
  background:var(--soft2,#f3eee2); color:var(--ink); border:2px solid var(--line); font-size:.95rem; line-height:1.35; }
.tl-note .tl-lk-n{ flex:0 0 auto; width:18px; height:18px; margin-top:1px; }
.tl-panel{ position:fixed; z-index:67; right:var(--railw); top:8px; bottom:8px; width:min(var(--panelw),calc(100vw - var(--railw) - 12px)); overflow:auto; overscroll-behavior:contain;
  background:var(--card,#fff); color:var(--ink); border:2px solid var(--accent); border-radius:14px; padding:0 14px 14px; box-shadow:0 6px 24px rgba(0,0,0,.18); }
.tl-head{ position:sticky; top:0; z-index:1; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 0 8px; background:var(--card,#fff); border-bottom:1px solid var(--line); margin-bottom:8px; }
.tl-head h2{ margin:0; font-size:1.15rem; }
.tl-b{ min-height:44px; min-width:44px; margin:0; padding:0 12px; border:2px solid var(--accent); background:var(--paper); color:var(--ink); border-radius:10px; font:inherit; box-shadow:none; }
.tl-b[aria-pressed="true"]{ background:var(--accent); color:var(--accent-ink,#fff); font-weight:700; }
.tl-muted{ color:var(--muted); }
.tl-h3{ font-size:1rem; margin:.8em 0 .3em; }
.tl-in{ width:100%; box-sizing:border-box; min-height:44px; font-size:1.1rem; padding:6px 10px; border:2px solid var(--line); border-radius:8px; background:var(--paper); color:var(--ink); }
.tl-in:focus-visible{ outline:3px solid var(--focus); outline-offset:1px; }
/* Calculator */
.tl-deg{ display:flex; gap:6px; margin:0 0 8px; }
.tl-disp{ border:2px solid var(--line); border-radius:10px; padding:6px; background:var(--paper); margin-bottom:8px; }
.tl-disp .tl-in{ border:0; font-size:1.25rem; text-align:right; font-variant-numeric:tabular-nums; background:transparent; }
.tl-out{ display:block; min-height:1.6em; text-align:right; font-size:1.3rem; font-weight:700; padding:0 10px 4px; overflow-wrap:anywhere; }
.tl-out.bad{ font-size:.95rem; font-weight:500; color:var(--bad); text-align:left; }
.tl-keys{ display:grid; grid-template-columns:repeat(5,1fr); gap:6px; }
.tl-k{ min-height:46px; margin:0; padding:0 2px; border:2px solid var(--line); border-radius:10px; background:var(--paper); color:var(--ink); font:inherit; font-size:1.05rem; box-shadow:none; }
.tl-k-n{ background:var(--card,#fff); font-weight:700; font-size:1.15rem; }
.tl-k-op{ border-color:var(--accent); }
.tl-k-op, .tl-eq, .tl-k-fn{ font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
.tl-k[data-k="÷"], .tl-k[data-k="×"], .tl-k[data-k="−"], .tl-k[data-k="+"]{ font-size:1.45rem; font-weight:600; }
.tl-k-fn{ border-color:var(--muted); }
.tl-eq{ grid-column:1 / -1; background:var(--accent); color:var(--accent-ink,#fff); border-color:var(--accent); font-weight:700; font-size:1.5rem; }
.tl-hist{ margin:0; padding-left:1.4em; }
.tl-hb{ background:none; border:0; color:var(--ink); text-align:left; min-height:32px; padding:2px 4px; font:inherit; box-shadow:none; margin:0; }
/* Graph */
.g-eq{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin:.3em 0; } .g-eq .g-in{ flex:1 1 90px; width:auto; min-width:0; } .g-eq .tl-err{ flex-basis:100%; min-height:0; color:var(--bad); }
.g-sw{ width:14px; height:14px; border-radius:3px; display:inline-block; }
.g-ctl, .tl-tools{ display:flex; flex-wrap:wrap; gap:6px; margin:.5em 0; }
.g-deg{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-left:auto; }   /* Oct 30: Graph angle unit */
.tl-cv{ display:block; touch-action:none; border:1px solid var(--line); border-radius:8px; }
/* fix/graph-labels: where the equations cross, right above the graph so it shows without scrolling */
.g-res{ margin:.1em 0 .5em; padding:6px 10px; border-left:4px solid var(--accent); border-radius:6px; background:var(--paper); color:var(--ink); font-size:1.05rem; font-weight:600; line-height:1.35; }
.g-res:empty{ padding:0; margin:0; border:0; } .g-res span{ display:block; }
.g-cv{ cursor:grab; } .g-sum{ margin-top:.4em; } .g-sum ul{ margin:.2em 0; padding-left:1.2em; }
/* Sketch: graph paper drawn by CSS under the ink, so the eraser shows the paper again */
.tl-paper{ cursor:crosshair; background-color:var(--card,#fff);
  background-image:linear-gradient(var(--line) 1px,transparent 1px),linear-gradient(90deg,var(--line) 1px,transparent 1px); background-size:20px 20px; }
.tl-lab2{ display:block; font-weight:600; margin:.6em 0 .2em; }
.tl-notes{ min-height:5.5em; resize:vertical; font-size:1rem; line-height:1.4; }
/* Reference */
.tl-ref{ list-style:none; margin:0; padding:0; display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.tl-rc{ border:1px solid var(--line); border-radius:10px; padding:8px; display:flex; flex-direction:column; gap:4px; background:var(--paper); }
.tl-rc h3{ font-size:.92rem; margin:0 0 2px; line-height:1.25; }
.tl-fig{ width:100%; max-width:150px; height:auto; align-self:center; fill:none; stroke:currentColor; stroke-width:2; stroke-linejoin:round; }
.tl-fig text{ fill:currentColor; stroke:none; font:15px Georgia,"Times New Roman",serif; }
.tl-fig .dash{ stroke-dasharray:4 4; stroke-width:1.5; } .tl-fig .dot{ fill:currentColor; }
.tl-f{ margin:0; font:1.12rem/1.5 Georgia,"Times New Roman",serif; }
.tl-f var{ font-style:italic; }
/* pre-beta #20 (Chris: on the reference sheet "w" looked like "u"): variables use a classic math serif italic, the
   kind on the printed SAT reference sheet, where w, u, v and l are clearly different. Reading comfort's upright mode still applies. */
.tl-f var, .tl-fig tspan[font-style="italic"]{ font-family:"Cambria Math","STIX Two Math","STIX Two Text",Cambria,"Times New Roman",Times,"Liberation Serif","DejaVu Serif",serif; }
.tl-f var{ font-size:1.12em; padding:0 .04em; }
.tl-fr{ display:inline-flex; flex-direction:column; vertical-align:middle; text-align:center; font-size:.75em; line-height:1.05; margin:0 2px; }
.tl-fr > span:first-child{ border-bottom:1px solid currentColor; padding:0 2px; }
.tl-facts{ margin:0 0 .8em; padding-left:1.2em; }
/* Room so the tabs never sit on question text */
body.has-rail .qm-wrap{ padding-right:calc(var(--railw) + 2vw); }
@media (max-width:1100px){ body.has-rail main{ padding-right:calc(var(--railw) + 12px); } }
@media (min-width:1101px){ /* wide screens: the open panel pushes the question left instead of covering it */
  body.has-rail.tools-open .qm-wrap{ padding-right:calc(var(--railw) + var(--panelw) + 16px); }
  body.has-rail.tools-open main{ margin-left:16px; max-width:min(820px,calc(100vw - var(--railw) - var(--panelw) - 40px)); } }
/* Phones (and very short screens): a bottom tab bar just above the Focus/Help strip; the panel becomes a bottom sheet */
@media (max-width:640px), (max-height:500px){
  .tl-rail{ top:auto; transform:none; left:0; right:0; bottom:calc(var(--pillbar,0px) + env(safe-area-inset-bottom,0px)); width:auto; height:var(--railh); flex-direction:row; gap:4px; padding:4px 4px;
    border:0; border-top:2px solid var(--line); border-radius:0; box-shadow:none; }
  .tl-tab{ flex:1 1 0; min-height:0; height:100%; font-size:.78rem; padding:2px; gap:1px; }
  .tl-tab .tl-ico{ width:20px; height:20px; }
  .tl-panel{ left:0; right:0; width:auto; top:auto; bottom:calc(var(--pillbar,0px) + var(--railh) + env(safe-area-inset-bottom,0px)); max-height:min(74vh,calc(100vh - var(--pillbar,0px) - var(--railh) - 40px));
    border-radius:14px 14px 0 0; border-bottom:0; padding:0 10px 10px; }
  body.has-rail .qm-wrap, body.has-rail:has(#helpBtn:not([hidden])) .qm-wrap, body.has-rail:has(#ftFab) .qm-wrap{ padding-right:0; bottom:calc(var(--pillbar,0px) + var(--railh) + env(safe-area-inset-bottom,0px)); }
  body.has-rail main{ padding-right:18px; padding-bottom:calc(var(--pillbar,0px) + var(--railh) + 40px); }
  /* Nov 1 (Release 3 review): keyboard focus and scroll-into-view stop above the bottom Tools bar, so a Check button is never hidden under it (set_end_nt, chrome 390) */
  html:has(body.has-rail #toolsRail:not([hidden])){ scroll-padding-bottom:calc(var(--tabh,60px) + var(--railh) + 16px + env(safe-area-inset-bottom,0px)); }
  html:has(body.has-rail #toolsRail:not([hidden])):has(#helpBtn:not([hidden])), html:has(body.has-rail #toolsRail:not([hidden])):has(#ftFab){ scroll-padding-bottom:calc(80px + var(--tabh,60px) + var(--railh) + 16px + env(safe-area-inset-bottom,0px)); }
  .tl-k{ min-height:44px; }
  .tl-ref{ grid-template-columns:1fr 1fr; gap:6px; } .tl-rc{ padding:6px; }
}
@media (max-width:360px){ .tl-ref{ grid-template-columns:1fr; } }
/* calm: the panel just appears (no slide) for reduced motion, calm motion and sensory mode */
@media (prefers-reduced-motion:no-preference){ body:not(.calmmotion):not(.sensory) .tl-panel{ animation:tlIn .14s ease-out; } }
@keyframes tlIn{ from{ opacity:.6; translate:12px 0; } to{ opacity:1; translate:0 0; } }
body.sensory .tl-panel, body.sensory .tl-rail{ box-shadow:none; }
@media print{ .tl-rail, .tl-panel, .tl-note{ display:none !important; } }
