/* Shared interactive parts: bottom sheet, toast, ask dialog, steppers, switch, segmented control,
   chips, rings, bars, charts. Motion rules: transform and opacity only, ease-out, under 300 ms for UI,
   press feedback on :active, hover only behind (hover:hover), a reduced-motion variant for each. */

/* ---------- layers ---------- */
#layers{position:fixed;inset:0;z-index:50;pointer-events:none}
#layers > *{pointer-events:auto}
.scrim{position:absolute;inset:0;background:var(--scrim);opacity:0;transition:opacity 240ms ease}
.scrim.on{opacity:1}
.sheet{position:absolute;inset-inline:0;bottom:0;margin-inline:auto;width:100%;max-width:560px;max-height:88%;display:flex;flex-direction:column;background:var(--tile);border-radius:22px 22px 0 0;box-shadow:var(--lift);transform:translateY(100%);transition:transform 380ms var(--ease-drawer)}
.sheet.on{transform:none}
.sheet.drag,.scrim.drag{transition:none}
.sheet-top{flex:none;touch-action:none;cursor:grab;padding-block:8px 10px}
.grab{width:38px;height:5px;border-radius:999px;background:var(--line-2);margin:0 auto 10px}
.sheet-h{display:flex;align-items:center;justify-content:space-between;gap:10px}
.sheet-h h2{min-width:0}
.x{width:36px;height:36px;flex:none;border-radius:50%;background:var(--tile-2);display:grid;place-items:center;color:var(--ink-2);transition:transform 120ms var(--ease-out)}
.x:active{transform:scale(.94)}
.x svg{width:14px;height:14px}
.sheet-b{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-bottom:max(22px, env(safe-area-inset-bottom, 0px));display:flex;flex-direction:column;gap:14px}
.sheet-b:focus{outline:none}
.sheet-f{flex:none;padding-top:10px;padding-bottom:max(14px, env(safe-area-inset-bottom, 0px));border-top:1px solid var(--line);display:flex;gap:10px}

/* a centred question: confirm or a short text */
.ask{position:absolute;inset:0;display:grid;place-items:center;padding:24px}
.ask-box{position:relative;width:100%;max-width:380px;background:var(--tile);border-radius:22px;padding:20px;display:flex;flex-direction:column;gap:14px;box-shadow:var(--float);opacity:0;transform:scale(.96);transition:opacity 180ms ease,transform 180ms var(--ease-out)}
.ask.on .ask-box{opacity:1;transform:none}
.ask-box p{color:var(--ink-2)}
.ask-acts{display:flex;gap:10px}

.toast{position:absolute;left:50%;bottom:calc(var(--tabs-h) + 22px + env(safe-area-inset-bottom, 0px));display:flex;align-items:center;gap:14px;transform:translate(-50%,10px);opacity:0;pointer-events:none !important;max-width:calc(100% - 32px);background:var(--toast-bg);color:var(--toast-ink);padding:10px 16px;border-radius:999px;font-size:.875rem;font-weight:500;transition:opacity 200ms ease,transform 200ms var(--ease-out)}
.toast.on{opacity:1;transform:translate(-50%,0);pointer-events:auto !important}
.toast.bad{background:var(--danger);color:#fff}
.toast button{flex:none;font-weight:700;color:var(--toast-act)}
.toast span{min-width:0}

.install-banner{position:fixed;inset-inline:12px;bottom:calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom, 0px));z-index:40;max-width:536px;margin-inline:auto;display:flex;align-items:center;gap:12px;padding:12px;border-radius:16px;background:var(--tile);box-shadow:var(--float)}
.install-banner .row-t{flex:1}
.steps-list{margin:0;padding-inline-start:1.6em;list-style:decimal;display:flex;flex-direction:column;gap:10px;font-size:.94rem}
.steps-list li::marker{font-weight:700;color:var(--ink-3)}

/* ---------- controls ---------- */
.seg{position:relative;display:grid;grid-auto-flow:column;grid-auto-columns:1fr;padding:3px;border-radius:11px;background:var(--line)}
.seg i{position:absolute;top:3px;bottom:3px;inset-inline-start:3px;border-radius:8px;background:var(--tile);transition:transform 220ms var(--ease-out)}
.seg button{position:relative;height:36px;font-size:.9rem;font-weight:600;color:var(--ink-2)}
.seg button[aria-pressed="true"]{color:var(--ink)}
.chips{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;margin-inline:calc(-1 * var(--gut));padding-inline:var(--gut)}
.chips::-webkit-scrollbar{display:none}
.chip{flex:none;padding:7px 14px;border-radius:999px;background:var(--tile);font-size:.84rem;font-weight:600;color:var(--ink-2);transition:background-color 160ms ease,color 160ms ease}
.chip[aria-pressed="true"]{background:var(--accent);color:var(--on-accent)}
/* a chip that is one choice of several (role="radio", role="tab") says so with its own state, and is lit the same */
.chip[aria-checked="true"],.chip[aria-selected="true"]{background:var(--accent);color:var(--on-accent)}
.chips.sm .chip{padding:5px 12px;font-size:.78rem}
/* in a sheet (a column that shrinks its children to fit) a scrolling row would be squeezed to nothing */
.chips{flex:none}
.tile .chip:not([aria-pressed="true"]):not([aria-checked="true"]):not([aria-selected="true"]),.sheet .chip:not([aria-pressed="true"]):not([aria-checked="true"]):not([aria-selected="true"]){background:var(--tile-2)}
.sw{position:relative;flex:none;width:52px;height:32px;border-radius:999px;background:var(--line-2);transition:background-color 180ms ease}
.sw::after{content:"";position:absolute;top:3px;inset-inline-start:3px;width:26px;height:26px;border-radius:50%;background:#fff;transition:transform 180ms var(--ease-out)}
.sw[aria-checked="true"]{background:var(--accent)}
.sw[aria-checked="true"]::after{transform:translateX(-20px)}
[dir="ltr"] .sw[aria-checked="true"]::after{transform:translateX(20px)}
.sw[disabled]{opacity:.45;cursor:default}
/* − value + : numbers read left to right, so the control is LTR inside the RTL page */
.stp{direction:ltr;display:grid;grid-template-columns:46px minmax(0,1fr) 46px;align-items:center;background:var(--tile-2);border-radius:12px;overflow:hidden}
.stp button{height:50px;font-size:1.5rem;font-weight:500;color:var(--secondary-text);transition:background-color 120ms ease}
.stp button:active{background:var(--wash)}
.stp input{width:100%;min-width:0;height:50px;border:0;background:transparent;text-align:center;font:inherit;font-size:1.375rem;font-weight:700;color:var(--ink);font-variant-numeric:tabular-nums;appearance:textfield;-moz-appearance:textfield}
.stp input:focus{outline:none;background:var(--wash);box-shadow:inset 0 0 0 2px var(--secondary-text)}
.stp input::-webkit-outer-spin-button,.stp input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.stp.mini{grid-template-columns:42px minmax(52px,auto) 42px;border-radius:10px}
.stp.mini button{height:42px;font-size:1.3rem}
.stp.mini input{height:42px;font-size:1rem}
.acts{display:flex;flex-direction:column}
.acts button{display:flex;align-items:center;gap:12px;min-height:52px;text-align:start;font-size:1rem;font-weight:500;padding:0 2px;transition:background-color 120ms ease}
.acts button + button{border-top:1px solid var(--line)}
.acts button:active{background:var(--tile-2)}
.acts button[disabled]{color:var(--ink-3);opacity:.6;cursor:default}
.acts .danger{color:var(--danger)}
.acts svg{width:20px;height:20px;flex:none;color:var(--ink-3)}
.acts .danger svg{color:var(--danger)}

/* ---------- rings, bars, charts ---------- */
.ring{position:relative;flex:none}
.ring svg{width:100%;height:100%}
.r-t{fill:none;stroke:var(--line)}
.r-f{fill:none;stroke:var(--accent);stroke-linecap:round}
.ring.sec .r-f{stroke:var(--secondary)}
.ring-in{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;line-height:1.15}
.pbar{height:7px;border-radius:999px;background:var(--line);overflow:hidden}
.pbar i{display:block;height:100%;border-radius:999px;background:var(--accent);transform-origin:right center}
[dir="ltr"] .pbar i{transform-origin:left center}
.pbar.sec i{background:var(--secondary)}
.pbar.dec i{background:var(--decor)}
.wk-t,.wk-f{fill:none;stroke-width:13;stroke-linecap:round}
.wk-t{stroke:var(--line-2)}
.wk-f{stroke:var(--accent)}
.wk-n{stroke:var(--secondary)}
.segs{display:inline-flex;gap:3px}
.segs i{width:10px;height:5px;border-radius:3px;background:var(--line-2)}
.segs i.on{background:var(--accent)}
.chart{width:100%;height:auto;direction:ltr}
.chart .grid{stroke:var(--line);stroke-width:1}
.chart .ax{fill:var(--ink-3);font-size:10px;font-family:var(--font)}
.chart .val{fill:var(--ink);font-weight:700;font-size:11px}
.chart .area{fill:var(--wash);opacity:.7;stroke:none}
.chart .line{fill:none;stroke:var(--accent);stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.chart .dot{fill:var(--accent);stroke:var(--tile);stroke-width:2.5}
.chart .bar{fill:var(--secondary)}
.chart .bar.last{fill:var(--accent)}
.chart-wrap{position:relative}
.chart-tip{position:absolute;transform:translateX(-50%);pointer-events:none;white-space:nowrap;background:var(--toast-bg);color:var(--toast-ink);font-size:.75rem;font-weight:600;padding:3px 9px;border-radius:999px;direction:rtl}

@media (hover: hover) and (pointer: fine){
  .stp button:hover{background:var(--wash)}
  .acts button:not([disabled]):hover{background:var(--tile-2)}
}
@media (min-width: 900px){
  .toast{bottom:28px}
}
@media (prefers-reduced-motion: reduce){
  .sheet,.scrim,.ask-box,.toast{transition-duration:.01s}
  .seg i,.sw::after{transition:none}
  .x:active{transform:none}
}

/* ---------- the guided tour (ui/tour.js): a spotlight on the real screen and a note beside it ---------- */
.tour{position:absolute;inset:0;pointer-events:auto}
.tour-spot{position:absolute;border-radius:18px;box-shadow:0 0 0 200vmax rgba(8,12,20,.62);pointer-events:none}
.tour-tip{position:absolute;inset-inline:16px;margin-inline:auto;max-width:420px;display:flex;flex-direction:column;gap:6px;padding:16px;border-radius:18px;background:var(--tile);color:var(--ink);box-shadow:var(--float);outline:none}
.tour-tip b{font-size:17px}
.tour-tip p{margin:0;color:var(--ink-2);line-height:1.5}
.tour-n{font-size:13px;color:var(--ink-3)}
.tour-acts{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:8px}
/* a head that sticks inside a sheet (the programme view, the portion sheet): keyboard focus moved
   to a row above is scrolled clear of it, not left underneath */
.sheet-b:has(.cc-pv-head),.sheet-b:has(.nu-pt){scroll-padding-top:128px}
