/* Shared pieces: cards, badges, rows, charts, notes, fields, choices, lists and the designed states, from
   docs/mockups/redesign/widgets.css. Colours come from the tokens in style.css only. The mockup's names that the
   screens before the redesign already use for something else are renamed: its list row is .lrow, its chart .gchart,
   its spark .mspark, its bar .mbar, its column .vstack and its pulse .orb.pulsing. Where both use a name for the
   same thing (card, badge, note, segment, chip, key-value list, progress bar) the new look applies to both. */

/* cards: the look everywhere; the column with its gap only on a redesigned screen, where the old margins go */
/* A card (section 6.5): --card-bg, a 1 px --card-edge (none in light, a line in dark), 16 px inside, a small shadow */
.card{background:var(--card-bg);border:1px solid var(--card-edge);border-radius:var(--r);padding:var(--s-4);box-shadow:var(--shadow-sm)}
:is(#app,#pane).screen .card{display:flex;flex-direction:column;gap:14px;margin:0}
.card.flat{box-shadow:none}
.card.tap{width:100%;text-align:start;cursor:pointer}
.cardhead{display:flex;align-items:center;gap:10px}
.cardhead .sec{flex:1}
.link{color:var(--a);font-weight:700;font-size:.88rem;min-height:48px;display:inline-flex;align-items:center;gap:4px;background:none;border:0;padding:0;cursor:pointer;text-decoration:none}

/* A badge always carries a word or a number: never colour alone. */
.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:var(--pill);font-size:.76rem;font-weight:800;white-space:nowrap;background:var(--a-soft);color:var(--a)}
.badge.ok,.badge.good{background:var(--c-soft);color:var(--c)}
.badge.hi,.badge.warn{background:var(--d-soft);color:var(--d)}
.badge.lo{background:var(--b-soft);color:var(--b)}
.badge.bad{background:var(--red-t);color:var(--red)}
.badge.acc{background:var(--a-soft);color:var(--a)}
.badge .ic,.badge .i{width:14px;height:14px;stroke-width:2.6}
/* a made-up demo entry's mark (views/sample-mark.js), small beside the entry's name: in a row's column of name and
   line (.what, .tt) a flex item would stretch to the column's width, so it keeps its own width and the column becomes
   a grid that sets it on the name's line, the lines under both */
.badge.sample-mark{padding:1px 7px;font-size:.7rem;vertical-align:middle;align-self:center;justify-self:start;inline-size:max-content}
:is(.what,.tt):has(> b + .sample-mark){display:grid;grid-template-columns:minmax(0,max-content) auto;justify-content:start;align-items:center;gap:2px 6px}
:is(.what,.tt):has(> b + .sample-mark) > :not(b,.sample-mark){grid-column:1 / -1}

/* List rows: time, text once, one small visual. The text takes the full remaining width and clamps at two lines,
   so a long Hebrew meal never wraps one word per line. */
.lrows{display:flex;flex-direction:column}
.lrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;padding:13px 0;min-height:60px;width:100%;border:0;border-top:1px solid var(--line);background:none;text-align:start;cursor:pointer}
.lrow:first-child{border-top:0;padding-top:2px}
.lrow:last-child{padding-bottom:2px}
.lrow .when{font-size:.82rem;font-weight:700;color:var(--mut);min-width:42px}
.lrow .what{display:flex;flex-direction:column;gap:2px;min-width:0}
.lrow .what b{font-weight:700;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
/* an English name in a Hebrew row (dir=auto) keeps the row's side, level with the Hebrew line under it */
[dir=rtl] .lrow .what [dir=auto]:dir(ltr){text-align:end}
.lrow .what small{color:var(--mut);font-size:.8rem}
.lrow .resp{display:flex;align-items:center;gap:8px}
.lrow .rise{font-weight:800;font-size:.92rem}
/* a figure that leads its row (Meal rises' short lists) keeps one width, so each name starts at the same place
   whether the figure is '+37' or '0' */
.lrow .rise.lead{min-inline-size:3.6ch;text-align:center}
.rowic{width:36px;height:36px;border-radius:12px;display:grid;place-items:center;background:var(--surface2);color:var(--a)}
/* A tile (section 6.5): a card that is a door on a root, two across, at least 96 px tall; its icon is 24 px in a
   40 px square tinted with the tab's place colour. Body, Food and Train draw theirs with these. */
:is(.body-tile,.fd-tile,.trn-tile){min-height:96px;border:1px solid var(--card-edge);border-radius:var(--r);background:var(--card-bg);box-shadow:var(--shadow-sm)}
/* One form on every root (Body's): the icon square beside the name, at most two lines under them, and the tiles of a
   row as tall as the tallest (the grid stretches them). A longer second line is cut at two lines, so a row never grows
   for one tile. Body's pill line is css/body.css. */
:is(.body-tile,.fd-tile,.trn-tile){display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:12px;min-inline-size:0;color:var(--ink);font:inherit;text-align:start;cursor:pointer}
:is(.body-tile-top,.fd-tile-top,.trn-tile-top){display:flex;align-items:center;gap:8px;min-inline-size:0}
:is(.body-tile-top,.fd-tile-top,.trn-tile-top) b{font-size:.95rem;line-height:1.2;min-inline-size:0}
:is(.body-tile,.fd-tile,.trn-tile) small{color:var(--mut);font-size:.8rem;line-height:1.35;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden}
:is(.body-tile,.fd-tile,.trn-tile) .rowic{flex:none;inline-size:40px;block-size:40px;border-radius:12px;display:grid;place-items:center;background:color-mix(in srgb,var(--place) 16%,transparent);color:var(--place)}
:is(.body-tile,.fd-tile,.trn-tile) .rowic .i{inline-size:24px;block-size:24px}
.again{width:48px;height:48px;border-radius:50%;display:grid;place-items:center;border:1px solid var(--edge);background:none;color:var(--a);cursor:pointer}
.chev{color:var(--mut)}

/* Charts (public/lib/gchart.js). The line and the area take their gradient from an inline style: a gradient id is
   unique per chart, so no rule here can name it. */
.gchart{display:block;width:100%;height:auto;overflow:visible}
.gchart .band{fill:var(--band)}
.gchart .grid{stroke:var(--line);stroke-width:1}
.gchart .dash{stroke:var(--mut);stroke-width:1;stroke-dasharray:3 5}
.gchart .line{fill:none;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.gchart .line.thin{stroke-width:1.8}
.gchart .line.ghost{stroke:var(--mut);stroke-width:1.6;stroke-dasharray:2 5}
.gchart .line.quiet{stroke:var(--mut);stroke-width:1.2}
.gchart text{fill:var(--mut);font-size:10.5px;font-weight:600;font-family:var(--sans)}
.gchart text.val{fill:var(--ink);font-size:12px;font-weight:800}
.gchart .dot{fill:var(--surface);stroke:var(--b);stroke-width:2.4}
.gchart .now{fill:var(--a)}
.gchart .halo{fill:var(--a);opacity:.22}
.gchart .peak{fill:var(--d)}
.gchart .gap{fill:var(--surface2)}
.gchart .cursor{stroke:var(--ink2);stroke-width:1}
.mspark{width:54px;height:24px;flex:none}
.mspark path{fill:none;stroke:var(--a);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
/* a legend stands on the card's ground, also where it sits between cards (P9) */
.legend{display:flex;flex-wrap:wrap;gap:4px 16px;padding:6px 10px;border-radius:var(--rm);background:var(--card-bg);font-size:.78rem;color:var(--mut);font-weight:600}
.legend span{display:inline-flex;align-items:center;gap:6px}
.legend i:not(.sw){width:16px;height:3px;border-radius:2px;background:linear-gradient(90deg,var(--a),var(--b))}
.legend i.m:not(.sw){width:9px;height:9px;border-radius:50%;background:var(--surface);border:2px solid var(--b)}
.legend i.r:not(.sw){height:9px;background:var(--band);border:1px solid var(--c)}

/* Three plain numbers under a chart */
.facts{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.fact{background:var(--surface2);border-radius:var(--rm);padding:12px 10px;display:flex;flex-direction:column;gap:2px;min-width:0}
.fact span{font-size:.72rem;font-weight:700;color:var(--mut);line-height:1.25}
.fact b{font-size:1.3rem;font-weight:800;line-height:1.2}
.fact small{font-size:.72rem;color:var(--ink2);overflow-wrap:anywhere;line-height:1.3}

/* Notes: what happened and what to do */
.note{display:flex;gap:12px;align-items:flex-start;padding:14px 16px;border-radius:var(--rm);background:var(--surface2);color:var(--ink2);font-size:.9rem}
.note .ic,.note>.i{margin-top:2px;color:var(--a)}
.note.warn{background:var(--d-soft)}.note.warn .ic,.note.warn>.i{color:var(--d)}
.note.done,.note.good{background:var(--c-soft)}.note.done .ic,.note.good>.i{color:var(--c)}
.note.bad{background:var(--red-t)}.note.bad>.i{color:var(--red)}
/* A note with a bold title then its text (<span><b>title</b>text</span>): the title is its own line, so the two never run together. */
.note>span>b:first-child{display:block;margin-block-end:2px;color:var(--ink)}
.note b{color:var(--ink)}
.note .ic+div b,.note .ic+span b{display:block}

/* Fields and choices */
.field{width:100%;min-height:52px;padding:14px 16px;border-radius:var(--rm);border:1px solid var(--line);background:var(--surface2);color:var(--ink)}
.field::placeholder{color:var(--mut)}
textarea.field{min-height:112px;resize:none;font-size:1.1rem;line-height:1.45}
.search{position:relative}
/* The magnifier sits at the inline start of the field's box and the clear button at its end, both in the page's
   direction: the input keeps that direction (dir="auto" would turn the box over for Latin text in Hebrew and put
   the clear button under the magnifier), so typed text starts beside the magnifier in either script and the bidi
   algorithm still runs a Latin word left to right inside the Hebrew field. */
.search>.i{position:absolute;inset-inline-start:14px;top:16px;color:var(--mut);pointer-events:none}
.search .field{direction:inherit;unicode-bidi:isolate;padding-inline-start:44px;border-radius:var(--pill)}
.seg{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(max-content,1fr);padding:4px;gap:4px;border-radius:var(--pill);background:var(--surface2);border:1px solid var(--line)}
.seg button{min-height:48px;border:0;background:none;border-radius:var(--pill);text-align:center;font:700 .88rem/1.2 var(--sans);color:var(--mut);padding-inline:12px;cursor:pointer;white-space:nowrap}
.seg button[aria-pressed=true],.seg button.on{background:var(--surface);color:var(--ink);box-shadow:0 0 0 1px var(--a) inset}
.chips{display:flex;gap:8px;overflow-x:auto;padding:4px 2px 8px;margin:0 -2px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chips.wrap{flex-wrap:wrap;overflow:visible}
/* A chip (section 6.5): 40 px drawn, 48 px to the touch (style.css), an --edge outline; chosen, it fills with --ink */
.chip{flex:none;display:inline-flex;align-items:center;gap:7px;min-height:40px;padding:0 14px;border-radius:var(--pill);border:1px solid var(--edge);background:var(--surface);color:var(--ink);font:700 .9rem/1.25 var(--sans);white-space:nowrap;cursor:pointer}
.chip.on,.chip[aria-pressed=true]{background:var(--ink);border-color:var(--ink);color:var(--surface)}
.chip.on :is(.ic,.i),.chip[aria-pressed=true] :is(.ic,.i){color:var(--surface)}
.chip.food{min-height:34px;font-weight:600;background:var(--a-soft);border-color:transparent;color:var(--ink)}
.chip.food small{color:var(--mut);font-weight:600}
.chip .ic,.chip .i{width:17px;height:17px;color:var(--a)}
details.fold{border-top:1px solid var(--line)}
details.fold summary{display:flex;align-items:center;gap:8px;min-height:48px;cursor:pointer;font-weight:700;color:var(--ink2);list-style:none}
details.fold summary::-webkit-details-marker{display:none}
/* the paper's pad rule (paper.css) sizes a loose summary to its text, which leaves the arrow just after the label;
   a fold's summary keeps its whole row, so the arrow sits at the row's end (the pad, at no specificity, still
   paints behind it); the arrow is the fold's own summary's, never a details' nested inside it */
details.fold>summary{width:auto}
details.fold>summary::after{content:'';margin-inline-start:auto;width:8px;height:8px;border-inline-end:2px solid var(--mut);border-bottom:2px solid var(--mut);transform:rotate(45deg)}
details.fold[open]>summary::after{transform:rotate(-135deg)}
[dir=rtl] details.fold>summary::after{transform:rotate(-45deg)}
[dir=rtl] details.fold[open]>summary::after{transform:rotate(135deg)}
details.fold .inside{padding-bottom:12px;display:flex;flex-direction:column;gap:10px;color:var(--ink2);font-size:.9rem}
/* key and value: the mockup's spans and the older dl with dt and dd look the same */
.kv{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px 14px;font-size:.88rem;margin:0}
.kv span,.kv dt{color:var(--mut)}
.kv b,.kv dd{margin:0;font-weight:700;text-align:end;font-variant-numeric:tabular-nums;min-width:0;overflow-wrap:anywhere}

/* Settings and More lists */
.list{display:flex;flex-direction:column}
.item{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:14px;align-items:center;min-height:60px;padding:10px 0;border:0;border-top:1px solid var(--line);background:none;width:100%;text-align:start;cursor:pointer}
.item:first-child{border-top:0}
.item .tt{display:flex;flex-direction:column;min-width:0}
.item .tt b{font-weight:700}.item .tt small{color:var(--mut);font-size:.8rem}
.item .val{color:var(--mut);font-weight:700;font-size:.88rem;display:inline-flex;align-items:center;gap:4px}
.switch{display:block;width:46px;height:28px;border-radius:var(--pill);background:var(--surface2);border:1px solid var(--line);position:relative;flex:none;padding:0;cursor:pointer}
.switch::after{content:'';position:absolute;top:3px;inset-inline-start:3px;width:20px;height:20px;border-radius:50%;background:var(--mut)}
.switch[aria-checked=true]{background:var(--a-soft);border-color:var(--a)}
.switch[aria-checked=true]::after{inset-inline-start:21px;background:var(--a)}

/* Designed states: empty, working, done, failed */
.state{align-items:center;text-align:center;padding:30px 22px;gap:12px}
.state h3{margin:0;font-size:1.25rem;font-weight:800;color:var(--ink);text-transform:none;letter-spacing:0}
.state p{margin:0;color:var(--ink2);max-width:30ch}
.orb{width:84px;height:84px;border-radius:50%;display:grid;place-items:center;border:0;background:var(--primary);color:var(--on-primary)}
.orb.done{background:var(--c-soft);color:var(--c);box-shadow:none;border:1px solid var(--c)}
.orb.warn{background:var(--d-soft);color:var(--d);box-shadow:none;border:1px solid var(--d)}
.orb .ic,.orb .i{width:34px;height:34px}
.orb.pulsing{animation:orbpulse 1.6s ease-in-out infinite}
@keyframes orbpulse{50%{box-shadow:0 0 0 14px var(--a-soft)}}
/* progress (.bar, an older screen's span inside) and a ranked list's bar (.mbar) */
.bar,.mbar{width:100%;height:8px;border-radius:8px;background:var(--surface2);overflow:hidden}
.bar>span,.bar i,.mbar i{display:block;height:100%;border-radius:8px;background:linear-gradient(90deg,var(--p1),var(--p2));transition:width .3s}
.vstack{display:flex;flex-direction:column;gap:10px}
.rowbtns{display:flex;gap:10px}
.rowbtns .btn{flex:1;padding-inline:12px}

/* The rows (.mrow) and the navigation rows (.navrow) a screen lists; the closed cards are css/fold.css. The score pill
   (.sp) and the due badge (.due) sit at the end of a row. */
.mrow .tt,.navrow .tt{display:flex;flex-direction:column;min-width:0}
.mrow .tt b,.navrow .tt b{font-weight:700;overflow-wrap:anywhere}
.mrow .tt small,.navrow .tt small{color:var(--mut);font-size:.8rem}
/* a left-to-right value in a Hebrew row (dir=auto: '70–140 mg/dL', an English name) stays by its label, on the row's side */
[dir=rtl] :is(.mrow,.navrow) .tt [dir=auto]:dir(ltr){text-align:end}
.mrow{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:10px;min-height:58px;padding:8px 0;border-block-start:1px solid var(--line);inline-size:100%;text-align:start}
.mrow .rt{display:flex;flex-direction:column;align-items:flex-end;gap:4px}
.mrow .val{font-weight:800;font-size:.95rem;unicode-bidi:plaintext}
.navrow{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;min-height:64px;padding:10px 16px;inline-size:100%;text-align:start;border:1px solid var(--line);border-radius:var(--r);background:var(--card-bg)}
.navrow.quiet{background:var(--surface)} /* solid behind its text, and no dashed edge (section 6.5 retires the dashed row) */
.sp{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:var(--pill);background:var(--surface2);font-size:.78rem;font-weight:800;white-space:nowrap;color:var(--ink)}
.sp::before{content:'';inline-size:9px;block-size:9px;border-radius:50%;background:var(--mut)}
.sp.b0::before{background:var(--gauge-0)}.sp.b1::before{background:var(--gauge-1)}.sp.b2::before{background:var(--gauge-2)}
.sp.b3::before{background:var(--gauge-3)}.sp.b4::before{background:var(--gauge-4)}
.sp.none{color:var(--mut);font-weight:700}.sp.none::before{display:none}
.due{display:inline-flex;padding:2px 9px;border-radius:var(--pill);background:var(--d-soft);color:var(--d);font-size:.72rem;font-weight:800;white-space:nowrap}
/* Compact rows on a phone: a measure row keeps one line. The grade's word gives way to its dot and
   number there (font-size 0 hides the word's text, the number keeps its size; wider screens show it); the line under
   a name never wraps. */
.mrow .tt small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mrow .rt{flex-direction:row;align-items:center;gap:8px}
@media (max-width:639px){.mrow .sp{font-size:0;gap:6px}.mrow .sp .num{font-size:.8rem}}

/* The app's time picker (lib/time-pick.js): a panel over the page and over an open sheet, one tap for the hour and
   one for the minutes. Chips, not a dial: the hours a field asks for most are first and larger (Fraunces numerals,
   which also read in Hebrew: digits are Latin), the other hours a quieter row under them. The chosen one wears the
   gradient of the primary button. The numbers run left to right on an RTL page. */
.tpk-field{cursor:pointer;caret-color:transparent;text-align:center}
.tpk-field:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.tpk-root{position:fixed;inset:0;z-index:var(--z-controls);display:flex;align-items:flex-end;justify-content:center}
.tpk-scrim{position:absolute;inset:0;background:var(--scrim);animation:tpkfade .18s ease-out}
.tpk{position:relative;width:100%;max-width:480px;max-height:92vh;overflow-y:auto;padding:0 20px calc(env(safe-area-inset-bottom) + 22px);background:var(--surface);border:1px solid var(--line);border-bottom:0;border-radius:var(--r) var(--r) 0 0;box-shadow:var(--shadow);animation:tpkup .22s cubic-bezier(.2,.8,.2,1)}
.tpk-head{position:relative;display:flex;align-items:center;gap:10px;padding:20px 0 0;min-height:48px}
.tpk-head .sec{flex:1;margin:0}
.tpk-big{display:flex;align-items:baseline;justify-content:center;gap:2px;margin:2px 0 0;font:600 3.6rem/1.05 var(--serif);font-variant-numeric:tabular-nums;color:var(--mut)}
.tpk-big b{font-weight:600;min-width:1.25em;text-align:center;opacity:.55}
.tpk-big span{opacity:.4;transform:translateY(-.06em)}
.tpk-big .on,.tpk-hour{opacity:1;background:linear-gradient(100deg,var(--a),var(--b));-webkit-background-clip:text;background-clip:text;color:transparent}
.tpk-hour{min-width:1.25em;min-height:48px;padding:0 4px;border:0;border-radius:var(--rm);font:inherit;cursor:pointer;text-decoration:underline dotted 2px var(--line);text-underline-offset:10px}
.tpk-hour:focus-visible{outline:2px solid var(--focus)}
.tpk-ask{margin:2px 0 14px;text-align:center;font-size:.92rem;font-weight:600;color:var(--ink2)}
.tpk-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.tpk-rest{grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}
.tpk-sec{margin:18px 0 8px}
.tpk-chip{display:flex;align-items:center;justify-content:center;min-height:48px;padding:0;border:1px solid var(--line);border-radius:var(--rm);background:var(--surface2);color:var(--ink);font:600 1.15rem/1 var(--serif);font-variant-numeric:tabular-nums;cursor:pointer;transition:transform .12s,background-color .12s}
.tpk-chip.lg{min-height:58px;font-size:1.45rem}
.tpk-chip.sm{min-height:48px;background:transparent;color:var(--mut);font:600 .98rem/1 var(--sans)}
.tpk-chip i{font-style:normal;opacity:.45;margin-inline-end:1px}
.tpk-chip:active{transform:scale(.95)}
.tpk-chip:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.tpk-chip[aria-pressed=true]{border-color:transparent;background:var(--primary);color:var(--on-primary)}
.tpk-chip[aria-pressed=true] i{opacity:.7}
.tpk-body[data-step] .tpk-grid{animation:tpkfade .16s ease-out}
@keyframes tpkup{from{transform:translateY(40px);opacity:.4}}
@keyframes tpkfade{from{opacity:0}}
@media (min-width:900px){.tpk-root{align-items:center}.tpk{border-radius:var(--r);border-bottom:1px solid var(--line);padding-bottom:22px}}
/* The app's date-and-time field (lib/date-time-pick.js): the date beside the time picker's field, on one line at 390 px. */
.dtp{display:flex;gap:6px;min-width:0}
.dtp>input{min-width:0}
.dtp-d{flex:1 1 9rem}
.dtp-t{flex:0 0 6.5rem}
.grid2>.dtp-f{grid-column:1/-1}
.row>.dtp-f{flex:1 1 15rem;min-width:min(100%,21rem)}
.chip.food .auto-mark{font:600 .7rem/1 var(--sans);color:var(--mut);border:1px dashed var(--line);border-radius:var(--pill);padding:3px 6px}
.comp-hint .auto-mark{font:600 11px/1 var(--sans);color:var(--mut);background:none;border:1px dashed var(--line);border-radius:var(--pill);padding:3px 7px;cursor:pointer;position:relative}
.comp-hint .auto-mark::after{content:"";position:absolute;inset:min(0px,calc(50% - 22px))}
