/* ── Design tokens ── */
    :root {
      --glass-bg:         #1C1C1E;
      --glass-border:     rgba(255,255,255,.09);
      --card-edge-hi:     rgba(255,255,255,.16);
      --card-edge-lo:     rgba(255,255,255,.05);
      --glass-surface-bg:   rgba(51,51,51,.33);
      --glass-surface-blur: blur(12px) saturate(180%);
      --glass-rim-light:  rgba(255,255,255,.30);
      --glass-rim-dark:   rgba(255,255,255,.07);
      --label-color:      rgba(255,255,255,.90);
      --label-shadow:     0 1px 4px rgba(0,0,0,.70);
      /* The tone the labels take on a background measured as light. The shadow
         is a hairline: the colour carries the contrast, not the shadow. */
      --label-color-dark:  rgba(0,0,0,.92);
      --label-shadow-dark: 0 0 2px rgba(255,255,255,.55);
      --page-ease:        cubic-bezier(.32,.72,0,1);
      /* The page behind the wallpaper, and the boot veil over the unstyled
         first paint. */
      /* Darker than the system greys: it sits behind the wallpaper. */
      --bg-base:          #0d1117;
      /* The opaque card preset a widget can ask for by name. */
      --card-dark:        var(--sy-gray6);
      --card-graphite:    #2C2C2E;
      --card-fixed-dark:  #1C1C1E;
      --pill-ink-light:   #3C3C43;
      --search-ink-light: #636366;
      --badge-red:        var(--danger);
      --badge-blue:       var(--info);
      --badge-green:      var(--success);
    }

    /* ── Root ── */
    html {
      width:100vw; height:100vh; height:100dvh; overflow:hidden;
      overscroll-behavior:none; -webkit-text-size-adjust:100%; text-size-adjust:100%;
      -webkit-tap-highlight-color:transparent;
      background: var(--bg-color, var(--bg-base));
      font-family:var(--font-ui);
      -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
    }
    /* background, position and z-index come from tokens.css. */
    body { width:100vw; height:100vh; height:100dvh; overflow:hidden; overscroll-behavior:none; }
    /* ── Boot loading veil — fades out once boot() finishes ── */
    body::after {
      content:''; position:fixed; inset:0; z-index:9999;
      background:var(--boot-bg,var(--bg-base)); pointer-events:none;
      transition:opacity .2s ease-out;
    }
    body.ready::after { opacity:0; }
    html.wall-swap::after {
      content:''; position:fixed; inset:0; z-index:0; pointer-events:none;
      background-image:var(--bg-prev-image,none); background-size:var(--bg-prev-size,cover);
      background-position:center; background-repeat:no-repeat;
      filter:brightness(var(--bg-prev-brightness,1)); transform:translateZ(0);
      animation:wall-out .4s ease-out forwards;
    }
    @keyframes wall-out { to { opacity:0 } }
    ::view-transition-old(root), ::view-transition-new(root) { animation-duration:.3s; animation-timing-function:ease }

    /* Something is happening. boot() waits on the API and then the catalogues,
       and an empty rectangle for the whole of it reads as hung rather than as
       loading.

       Held back so the usual fast boot stays a clean fade and only a slow one
       shows anything. Wordless: the catalogue is loaded by the boot this is
       covering, so there is no sentence to show. */
    body::before {
      content:''; position:fixed; z-index:10000;
      inset-inline-start:50%; top:50%; width:28px; height:28px; margin-block:-14px 0; margin-inline:-14px 0;
      border-radius:50%; pointer-events:none;
      border:2px solid var(--label-quaternary);
      border-top-color:var(--label-secondary);
      opacity:0;
      animation:boot-wait 1s linear infinite, boot-show .3s ease .6s forwards;
    }
    body.ready::before { animation:none; opacity:0; }
    body.api-down::before { animation:none; opacity:0; }

    /* ── Page strip ── */
    #pages {
      position:fixed; inset:0; z-index:10;
      display:flex;
      transition:transform .28s var(--page-ease);
      touch-action:pan-y pinch-zoom;
    }
    .page {
      flex:0 0 100vw; width:100vw; height:100vh; height:100dvh;
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-content:start;
      overflow:hidden;
      contain:layout paint;
      /* Top clears the controls bar, bottom clears the dots and the dock:
         #dots bottom 160px plus its 30px height. The fluid horizontal
         padding keeps .grid inside the content box on a narrow-wide
         viewport. */
      padding-block:clamp(44px,4vh,70px) 204px;
      padding-inline:var(--gutter-l) var(--gutter-r);
    }
    /* Mirrored by desktopSlots() in dashboard.js. Clears #dots at bottom 24px. */
    body.no-dock .page { padding-block-end:68px }
    /* ── Desktop grid scale ──
       Six columns at every width. The grid, the gaps and the tile height are
       one proportional system derived from the viewport, so six columns stay
       square on a tablet. Above the design width the system stops: each min()
       is capped at its design value, so a large screen gets the same sizes a
       desktop has always had.

       The design width is 1041px, which over six columns and a 25px gap gives a
       152.67px column, the width the 152px tile height and every value in
       WIDGET_HEIGHTS were drawn against. Each ratio below is that value over
       1041.

       dashboard.js reads --tile-h and --row-gap back to paginate. Changing a
       ratio here without changing DESIGN_TILE there breaks the page breaks. */
    :root {
      --page-gutter:clamp(16px,4vw,270px);
      --gutter-l:max(var(--page-gutter), var(--sa-left,0px));
      --gutter-r:max(var(--page-gutter), var(--sa-right,0px));
      /* Bounded by the gutters as well as by the design reserve. A device whose
         side inset is wider than the gutter, which is any notched phone in
         landscape, otherwise leaves .grid wider than the content box, and
         .page is overflow:hidden and centred, so the outer columns are cut. */
      --grid-avail:calc(100vw - var(--gutter-l) - var(--gutter-r));
      /* Set by dashboard.js from --grid-avail. Mirrors DESKTOP_COL in
         dashboard-logic.js. */
      --cols:6;
      --grid-w:calc(var(--cols) * 152.67px + (var(--cols) - 1) * 25px);
      --col-gap:25px;
      --row-gap:30px;
      --tile-h:152px;
    }
    /* Measured by dashboard.js. An element resolves these to pixels; reading the
       custom properties themselves returns their unresolved text. */
    .gm-probe {
      position:absolute; visibility:hidden; pointer-events:none;
      width:0; height:var(--tile-h);
    }
    .gm-probe > i { display:block; height:var(--row-gap); }
    .gm-probe > b { display:block; height:0; width:var(--grid-avail); }
    .grid {
      display:grid; grid-template-columns:repeat(var(--cols),1fr);
      column-gap:var(--col-gap); row-gap:var(--row-gap);
      width:var(--grid-w); align-items:start;
    }
    /* Applied as `c${cols}` from WIDGET_COLS, so the class name never appears
       literally in the source and a scan for one will not find it. */
    .c1 { grid-column:span 1 }
    .c2 { grid-column:span 2 }
    .r2, .r3 { align-self:stretch }
    .r2 { grid-row:span 2 }
    .r3 { grid-row:span 3 }

    /* ── Widget card ── */
    .wc {
      display:flex;
      align-items:stretch;
    }
    .widget {
      position:relative;
      width:100%; border-radius:28px; overflow:hidden;
      border:1px solid var(--glass-border); background:var(--glass-bg);
    }
    .widget iframe { display:block; border:0; width:100% }
    .widget::after, .mob-widget-card::after {
      content:''; position:absolute; inset:0; border-radius:inherit;
      pointer-events:none; z-index:5; transform:translateZ(0);
      box-shadow:inset 0 1px 0 var(--card-edge-hi), inset 0 -1px 0 var(--card-edge-lo);
    }

    /* The mobile home screen builds its own card element with the same glass
       material. Its sizing stays inline. */
    .mob-widget-card {
      border:1px solid var(--glass-border); background:var(--glass-bg);
    }

    /* ── Card backgrounds ──
       A widget picks one of these by name in its manifest, so no widget is named
       here. A widget that paints its own interior declares nothing and keeps the
       default glass behind it. */
    .widget[data-card="dark"],
    .mob-widget-card[data-card="dark"] {
      background: var(--card-dark);
      -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .widget[data-card="light"],
    .mob-widget-card[data-card="light"] {
      background: var(--bg-primary-light); border-color: rgba(0,0,0,.12);
      -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .widget[data-card="graphite"],
    .mob-widget-card[data-card="graphite"] {
      background: var(--card-graphite);
      -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .widget[data-card="translucent"],
    .mob-widget-card[data-card="translucent"] {
      background: var(--glass-bg);
    }
    /* Shared by an app's link and a folder's button, so it carries the reset a
       button needs to look like the tile beside it. */
    .icon {
      font:inherit; color:inherit; background:none; border:0; padding:0;
      height:var(--tile-h,152px);
      display:flex;
      flex-direction:column;
      align-items:center;
      justify-content:center;
      text-decoration:none; cursor:pointer; grid-column:span 1;
      -webkit-tap-highlight-color:transparent;
    }

    /* ── Icon wrap (grid + dock share structure, differ in size via inline style) ── */
    .iwrap, .dwrap {
      position:relative;
      display:flex;
      align-items:center;
      justify-content:center;
      flex-shrink:0; overflow:visible;
    }
    .iwrap { border-radius:16px }
    .dwrap { border-radius:15px }

    /* No blend modes here. Safari blends before it clips the rounded edge and
       leaks a light stroke while the tile scales. */
    .plate {
      --icon-rim:         radial-gradient(46% 2% at 50% 0,rgba(255,255,255,.6),rgba(255,255,255,.25) 45%,transparent),
                          radial-gradient(46% 1.6% at 50% 100%,rgba(255,255,255,.35),rgba(255,255,255,.14) 45%,transparent);
      --icon-shade:       radial-gradient(1.2% 25% at 0 50%,rgba(0,0,0,.19),transparent),
                          radial-gradient(1.2% 25% at 100% 50%,rgba(0,0,0,.19),transparent);
      --icon-body:        linear-gradient(oklch(from var(--tc,var(--sy-gray)) calc(l + .03 + l * .05) c h) 4%,var(--tc,var(--sy-gray)) 50%,oklch(from var(--tc,var(--sy-gray)) calc(l - .03 - l * .05) c h) 96%);
      background-image:var(--icon-rim), var(--icon-shade), var(--icon-body);
      box-shadow:inset 0 .5px 0 rgba(255,255,255,.18), inset 0 -.5px 0 rgba(255,255,255,.1);
    }
    .iwrap img, .dwrap img { object-fit:contain; position:relative; z-index:3 }
    .iwrap .fb, .dwrap .fb,
    .dyn-mob-icon .fb, .dyn-dock-icon .fb { position:relative; z-index:3; font-weight:600; color:var(--on-tint) }
    /* Alpha on this ink breaks the contrast guarantee: at .85 one palette entry
       clears neither tone. */
    .fb.fb-on-light { color:var(--on-tint-dark) }

    .iwrap, .dwrap, .dyn-folder-box,
    .dyn-mob-icon > .plate, .dyn-dock-icon > .plate, .dyn-mob-btn > .dyn-box, .dyn-fold-anchor > .plate { transition:transform .2s cubic-bezier(.23,1,.32,1), filter .2s ease-out }
    @media (hover:hover) and (pointer:fine) {
      .icon:hover .iwrap,
      .icon:hover .dyn-folder-box,
      .folder-icon-link:hover .iwrap,
      .di:hover .dwrap,
      .dyn-mob-icon:hover > .plate, .dyn-dock-icon:hover > .plate, .dyn-mob-btn:hover > .dyn-box, .dyn-fold-anchor:hover > .plate { transform:scale(1.03) }
    }
    .icon:active .iwrap,
    .icon:active .dyn-folder-box,
    .folder-icon-link:active .iwrap,
    .di:active .dwrap,
    .dyn-mob-icon:active > .plate, .dyn-dock-icon:active > .plate, .dyn-mob-btn:active > .dyn-box, .dyn-fold-anchor:active > .plate {
      transform:scale(.92); filter:brightness(.88);
      transition:transform .1s ease-out, filter .1s ease-out;
    }
    .icon.settled .iwrap,
    .folder-icon-link.settled .iwrap,
    .di.settled .dwrap,
    .dyn-mob-icon.settled > .plate, .dyn-dock-icon.settled > .plate, .dyn-fold-anchor.settled > .plate { transform:none; filter:none; transition:none }
    :is(#pages, .dyn-strip).dragging :is(.plate, .dyn-box, .dyn-folder-box) { transform:none; filter:none }

    /* ── Icon label ── */
    .ilabel {
      font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote); font-weight:500; color:var(--label-color);
      text-align:center; text-shadow:var(--label-shadow); margin-top:6px;
      white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    }

    /* Labels measured against a light background. The tone is set on the
       element by the dashboard, never by the theme: the background is the
       user's, not the system's. */
    .ilabel[data-tone="dark"], .dyn-mob-label[data-tone="dark"], .dyn-fold-label[data-tone="dark"] {
      color:var(--label-color-dark); text-shadow:var(--label-shadow-dark);
    }

    /* ── Badge — reference size, scaled by --sc (desktop overrides below) ── */
    .badge {
      position:absolute;
      top:calc(-11px * var(--sc,1)); inset-inline-end:calc(-11px * var(--sc,1));
      min-width:calc(24px * var(--sc,1)); height:calc(24px * var(--sc,1));
      border-radius:50px; padding:0 calc(7px * var(--sc,1));
      display:none;
      align-items:center;
      justify-content:center;
      font-size:calc(var(--fs-callout) * var(--sc,1));letter-spacing:var(--tr-callout); font-weight:500; color:var(--on-fill); line-height:1;
      white-space:nowrap;
      max-width:calc(100% + 11px * var(--sc,1));
      gap:0;
      z-index:20; pointer-events:none;
      -webkit-touch-callout:none; touch-action:manipulation;
      /* Pins the badge to its own compositing layer. WebKit otherwise
         promotes and demotes it as its classes change, and the clipped
         corners rasterise torn. */
      transform:translateZ(0);
      /* The fill is a custom property, not `background`: the pill behind is
         painted from the same value. */
      --badge-peek:calc(7px * var(--sc,1));
      background:var(--badge-bg,transparent);
      transition:background-color .2s ease;
    }
    .badge.on  { display:flex }
    .badge-txt { flex-shrink:1; min-width:0; overflow:hidden; text-overflow:ellipsis }
    /* The pill is a corner marker. A unit makes it wider than the icon it marks,
       measured at 66px on a 72px icon. The popover names every value. */
    .badge-unit { display:none }
    .badge.red  { --badge-bg:var(--badge-red) }
    .badge.blue { --badge-bg:var(--badge-blue) }
    .badge.green { --badge-bg:var(--badge-green) }
    .badge.stale { outline:1.5px dashed var(--on-fill); outline-offset:-3px }

    /* Both pills are pseudo-elements at negative depth. That is the only order
       where one paints under the other and both stay under the label, and it
       needs the element's own background to stay clear. */
    .badge.has-more { background:none; inset-inline-end:calc(-11px * var(--sc,1) + var(--badge-peek)) }
    /* The badge is transparent to the pointer so a click reaches the tile. One
       with a popover has to take it, or nothing can hover what it opens. */
    .badge.has-pop { pointer-events:auto }
    .badge.has-pop .badge-txt::after { content:''; position:absolute; inset:min(0px, calc((100% - 24px) / 2)) }
    .badge.has-more::before, .badge.has-more::after {
      content:''; position:absolute; inset:0; border-radius:50px;
      transition:background-color .2s ease;
    }
    /* Separated from the front pill, or the peek reads as a colour fringe on one
       pill rather than as a second pill behind it. */
    /* Shifted by its own insets rather than by translateX, which has no logical
       form: the pill behind peeks towards the trailing edge, whichever side of
       the screen that is. */
    .badge.has-more::before {
      z-index:-2;
      inset-inline-start:var(--badge-peek); inset-inline-end:calc(var(--badge-peek) * -1);
      background:var(--badge-next,var(--badge-blue));
      box-shadow:0 0 0 1.5px var(--badge-stack-edge,rgba(0,0,0,.55));
    }
    .badge.has-more::after { z-index:-1; background:var(--badge-bg,var(--badge-blue)) }
    body:not(.is-mob) .badge.has-more { inset-inline-end:calc(-9px + var(--badge-peek)) }

    /* ── Badge popover — the values the pill has no room for ── */
    /* In the top layer now. The popover defaults have to be undone or they
       fight the hand-placed coordinates: inset:0 and an auto margin centre it,
       and it arrives with a border and a padding of its own. */
    .badge-pop {
      inset:auto; margin:0;
      position:fixed; z-index:900; min-width:124px; max-width:min(300px,calc(100vw - 16px));
      padding:10px 8px; border-radius:22px;
      background:rgba(30,30,32,.94);
      border:.5px solid rgba(255,255,255,.12);
      box-shadow:0 8px 48px rgba(0,0,0,.45);
      -webkit-backdrop-filter:blur(32px) saturate(180%) brightness(.72);
      backdrop-filter:blur(32px) saturate(180%) brightness(.72);
      color:#fff;
      /* SC 1.4.13 asks that hover content be hoverable. pointer-events:none put
         it out of reach and left the outside-pointerdown guard unreachable. */
      pointer-events:auto;
    }
    .badge-pop-row {
      display:flex; align-items:flex-start; gap:8px; padding:3px 8px;
      font-size:var(--fs-subheadline);line-height:var(--lh-subheadline);letter-spacing:var(--tr-subheadline);
    }
    .badge-pop-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; margin-top:.35em; background:var(--badge-blue) }
    /* Two lines, then clip. German and Persian labels run longer than English.
       The value stays on one line beside it. */
    .badge-pop-name {
      flex:1; min-width:0; color:rgba(235,235,245,.7);
      overflow-wrap:anywhere;
      display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden;
    }
    .badge-pop-val { font-weight:600; flex-shrink:0; font-variant-numeric:tabular-nums }
    /* Desktop: restore compact badge size */
    body:not(.is-mob) .badge {
      --badge-peek:6px;
      max-width:calc(100% + 9px);
      top:-9px; inset-inline-end:-9px;
      min-width:22px; height:22px; padding:0 6px;
      font-size:var(--fs-subheadline);line-height:1;letter-spacing:var(--tr-subheadline); font-weight:500;
    }


    /* ── Page dots ── */
    #dots {
      position:fixed; bottom:160px; left:50%; /* desktop only — mobile overrides bottom inline */
      transform:translateX(-50%);
      /* Keep 24px between centres. Less fails the WCAG 2.5.8 target size. */
      display:flex; gap:16px; z-index:500;
      /* The tone is sampled after the first paint. Until it lands the bar is a
         white tint, which over a light wallpaper is invisible, so it carries an
         edge that reads on either ground. */
      background:rgba(255,255,255,.14); border:.5px solid rgba(0,0,0,.18);
      -webkit-backdrop-filter:blur(24px) saturate(160%); backdrop-filter:blur(24px) saturate(160%);
      border-radius:999px; padding:8px 12px;
      align-items:center;
    }
    /* State by shape as well as fill. A tint over a wallpaper the project does
       not control cannot carry the state on its own: over a light one the whole
       indicator painted white on white and measured 1.00:1. */
    .dot {
      width:8px; height:8px; border-radius:50%;
      background:transparent; border:1.5px solid var(--dots-ink,rgba(255,255,255,.75));
      transition:background .2s,border-color .2s,transform .2s,opacity .25s;
      cursor:pointer; flex-shrink:0; box-sizing:border-box;
      padding:0; -webkit-appearance:none; appearance:none;
    }
    .dot.on { background:var(--dots-ink,var(--control-knob)); transform:scale(1.25) }
    .dot:active { opacity:.7; transition-duration:.1s }
    @media (hover:hover) and (pointer:fine) {
      .dot:not(.on):hover { background:var(--dots-ink,rgba(255,255,255,.75)); opacity:.55 }
      .dot:not(.on):active { opacity:.4 }
    }

    /* Apple's guidance for a translucent control over rich content: dim what is
       bright, leave what is dark. The tone is sampled from the wallpaper behind
       the bar, by the same pass that inks the icon labels. */
    #dots[data-tone="dark"] {
      background:rgba(0,0,0,.30); border-color:rgba(255,255,255,.30);
      --dots-ink:rgba(0,0,0,.85);
    }
    #dots[data-tone="dark"] .dot { border-color:rgba(0,0,0,.55) }
    #dots[hidden] { display:none }
    /* Mirrored by the no-dock reserve in desktopSlots(). */
    body.no-dock:not(.is-mob) #dots { bottom:24px }

    /* ── Photo credit ── */
    #photo-credit {
      position:fixed; z-index:300;
      inset-block-end:calc(14px + var(--safe-bottom)); inset-inline-start:calc(20px + var(--safe-left));
      overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
      font-weight:500;
      font-size:var(--fs-caption-2);line-height:var(--lh-caption-2);letter-spacing:var(--tr-caption-2);
      color:var(--label-color-2); text-shadow:var(--label-shadow);
      transition:color .2s;
    }
    #photo-credit[data-place="top"] { inset-block:calc(12px + var(--safe-top)) auto }
    #photo-credit[data-tone="dark"] { color:var(--label-color-2-dark); text-shadow:var(--label-shadow-dark) }
    #photo-credit:focus-within { color:var(--label-color) }
    #photo-credit[data-tone="dark"]:focus-within { color:var(--label-color-dark) }
    #photo-credit a { color:inherit; text-decoration:none }
    @media (hover:hover) and (pointer:fine) {
      #photo-credit:hover { color:var(--label-color) }
      #photo-credit[data-tone="dark"]:hover { color:var(--label-color-dark) }
      #photo-credit a:hover { text-decoration:underline }
    }
    #photo-credit a:focus-visible { outline:2px solid currentColor; outline-offset:2px; border-radius:2px }
    body.is-mob #photo-credit {
      inset-block:max(4px, calc(var(--sa-top) - 16px)) auto; inset-inline:0;
      width:fit-content; max-width:70vw; margin-inline:auto;
    }
    @media (orientation:landscape) and (max-height:500px) {
      body.is-mob #photo-credit {
        inset-block:auto calc(8px + var(--safe-bottom,0px));
        inset-inline:auto calc(12px + var(--safe-right,0px));
        max-width:22vw; margin-inline:0;
      }
    }

    /* ── Search pill — mobile only ── */
    #mob-search-pill {
      position:fixed; left:50%; z-index:500;
      transform:translateX(-50%);
      display:none; /* shown by buildMobile */
      align-items:center;
      justify-content:center;
      background:var(--glass-surface-bg);
      -webkit-backdrop-filter:var(--glass-surface-blur); backdrop-filter:var(--glass-surface-blur);
      border-radius:999px;
      border:0.5px solid rgba(255,255,255,.22);
      cursor:pointer;
      -webkit-tap-highlight-color:transparent;
      -webkit-user-select:none; user-select:none;
      -webkit-touch-callout:none;
      overflow:hidden;
      transition:clip-path .25s var(--page-ease), scale .16s ease-out;
    }
    #mob-search-pill:active { scale:.96; transition:clip-path .25s var(--page-ease), scale .1s ease-out }
    /* Search content — shown when idle */
    #mob-search-pill .msp-search {
      display:flex;
      align-items:center;
      justify-content:center;
      gap:calc(5px * var(--sc,1));
      position:absolute; inset:0;
      transition:opacity .18s ease;
      pointer-events:none;
    }
    #mob-search-pill .msp-icon {
      font-size:calc(12px * var(--sc,1)); font-weight:600; color:#FFFFFF; line-height:1;
      font-style:normal; text-shadow:var(--label-shadow);
    }
    #mob-search-pill .msp-label {
      font-size:max(11px, calc(12px * var(--sc,1)));line-height:1; font-weight:600; color:#FFFFFF; text-shadow:var(--label-shadow);
      white-space:nowrap; 
    }
    /* Dots row — shown when paging */
    #mob-search-pill .msp-dots {
      display:flex;
      align-items:center;
      justify-content:center;
      gap:calc(5px * var(--sc,1));
      position:absolute; inset:0;
      opacity:0;
      transition:opacity .18s ease;
      pointer-events:none;
    }
    /* Pill dots — must match JS _pdotSz/_pdotGap, which size the paging pill */
    #mob-search-pill .msp-dot {
      width:calc(8px * var(--sc,1)); height:calc(8px * var(--sc,1)); border-radius:50%;
      background:rgba(255,255,255,.35); flex-shrink:0;
      transition:background .18s,transform .18s;
    }
    #mob-search-pill .msp-dot.on { background:#FFFFFF; transform:scale(1.2) }
    /* State transitions */
    #mob-search-pill.paging .msp-search { opacity:0; pointer-events:none }
    #mob-search-pill.paging .msp-dots   { opacity:1; pointer-events:auto }

    /* ── Dock ── */
    #dock {
      position:fixed; bottom:12px; left:50%;
      transform:translateX(-50%);
      z-index:400;
      display:flex;
      align-items:center;
      gap:15px; padding:22px;
      isolation:isolate;
    }
    #dock.mdock {
      position:fixed; left:50%;
      transform:translateX(-50%);
      z-index:400;
      display:flex;
      align-items:center;
      justify-content:center;
      background:none; border:0; border-radius:0; box-shadow:none;
      -webkit-backdrop-filter:none; backdrop-filter:none;
    }
    .glass-layer { position:absolute; inset:0; z-index:-1; pointer-events:none }
    .glass-surface {
      background:var(--glass-surface-bg);
      -webkit-backdrop-filter:var(--glass-surface-blur); backdrop-filter:var(--glass-surface-blur);
    }
    :is(.folder-overlay, .folder-overlay-mobile) .glass-surface { -webkit-backdrop-filter:none; backdrop-filter:none }
    .glass-rim {
      position:absolute; inset:0; width:100%; height:100%; z-index:2;
      pointer-events:none; overflow:visible; fill:none;
    }
    .glass-rim-light { stop-color:var(--glass-rim-light) }
    .glass-rim-dark { stop-color:var(--glass-rim-dark) }
    .di {
      display:flex;
      align-items:center;
      justify-content:center;
      cursor:pointer; text-decoration:none;
      -webkit-tap-highlight-color:transparent;
    }

    /* ── Spotlight overlay — shared base ── */
    /* The overlay is the scrim, so the dialog defaults have to go: a modal
       dialog is otherwise capped short of the viewport, bordered, padded, and
       centred by an auto margin the reset in tokens.css has already zeroed. It
       keeps display:none while closed so the fade has somewhere to start from.

       width and height are auto, which is what a div had: the four insets then
       size the box. A dialog is fit-content by default, which ignores them, and
       a stated 100% makes the browser ignore `bottom` instead, which is how the
       mobile keyboard is kept clear. */
    #spot {
      position:fixed; inset:0; z-index:1000;
      max-width:none; max-height:none; width:auto; height:auto;
      margin:0; padding:0; border:0; color:inherit;
      display:none; opacity:0;
      transition:opacity .15s ease-out;
    }
    #spot::backdrop { background:none }
    #spot.on  { display:flex;
                flex-direction:column; }
    #spot.vis { opacity:1 }

    /* ── Spotlight — mobile layout (default, overridden for desktop below) ── */
    #spot {
      background:rgba(0,0,0,.62);
      -webkit-backdrop-filter:blur(20px) saturate(180%) brightness(.76);
      backdrop-filter:blur(20px) saturate(180%) brightness(.76);
      align-items:stretch;
      justify-content:flex-end;
      padding-bottom:0; box-sizing:border-box;
    }
    body.is-mob #spot #sres {
      flex:1 1 0;
      overflow-y:auto;
      padding:calc(var(--safe-top) + 24px) 0 4px;
      min-height:0;
    }
    body.is-mob #spot.kb #sres { padding-top:12px; }
    /* Search bar pinned to bottom on mobile */
    body.is-mob #spot #sbox {
      flex-shrink:0;
      padding-block:10px calc(var(--safe-bottom) + 12px);
      padding-inline:max(16px, var(--sa-left,0px)) max(16px, var(--sa-right,0px));
      box-sizing:border-box;
    }
    /* ── Spotlight — desktop overrides ── */
    body:not(.is-mob) #spot {
      background:rgba(0,0,0,.45);
      -webkit-backdrop-filter:blur(20px) saturate(160%);
      backdrop-filter:blur(20px) saturate(160%);
      align-items:center;
      justify-content:flex-start;
      flex-direction:column;
      padding-top:max(var(--safe-top),80px);
      box-sizing:border-box;
      transition:none;
    }
    /* Search bar as a floating card at the top */
    body:not(.is-mob) #sbox {
      width:min(680px,92vw);
      background:rgba(30,30,32,.72);
      border:.5px solid rgba(255,255,255,.12); border-radius:999px;
      box-shadow:0 8px 48px rgba(0,0,0,.45); overflow:hidden;
      flex-shrink:0; padding:0; order:-1;
    }
    /* Results as a separate card below the search bar */
    body:not(.is-mob) #sres {
      width:min(680px,92vw);
      max-height:60vh; overflow-y:auto; 
      padding:10px 8px; margin-top:10px; flex:none; min-height:0;
      background:rgba(30,30,32,.72);
      border:.5px solid rgba(255,255,255,.12); border-radius:34px;
      box-shadow:0 8px 48px rgba(0,0,0,.45);
    }
    body:not(.is-mob) #sres:empty { display:none; }

    /* ── Search bar ── */
    .spot-bar {
      display:flex;
      align-items:center;
      gap:10px; padding:13px 22px;
    }
    .spot-field { display:contents; }
    body.is-mob #spot .spot-bar {
      border-bottom:none;
      padding:0; gap:8px;
    }
    body.is-mob #spot .spot-field {
      display:flex; align-items:center; gap:8px;
      flex:1; min-width:0; min-height:48px;
      background:rgba(30,30,32,.72);
      box-shadow:inset 0 0 0 .5px rgba(255,255,255,.12);
      border-radius:999px; padding:0 16px;
      box-sizing:border-box;
    }
    .spot-icon {
      color:rgba(255,255,255,.45); flex-shrink:0;
      display:flex;
      align-items:center;
      pointer-events:none;
    }
    #sin {
      flex:1; background:transparent; border:0; outline:none;
      font-size:var(--fs-callout);line-height:var(--lh-callout);letter-spacing:var(--tr-callout); color:rgba(255,255,255,.92);
      font-family:inherit; caret-color:var(--accent);
      -webkit-appearance:none; appearance:none;
      min-height:26px; padding:0; margin:0; width:100%;
    }
    body.is-mob #spot #sin { font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body); }
    /* One default, not a rule per field. The user agent's placeholder assumes a
       light page and fails contrast on every surface here. Rules below override
       it where a field genuinely differs. */
    input::placeholder, textarea::placeholder { color:rgba(255,255,255,.6); }
    /* The panel is a scrim and a blur over a wallpaper the project does not
       control, so the ink has to clear 4.5:1 against whatever that composites
       to. At .38 it did not over a light one. */
    #sin::placeholder { color:rgba(255,255,255,.55); }
    #spot #sin::placeholder { color:rgba(235,235,245,.55); }
    /* Closed and still fading out. It must not catch input. */
    #spot:not([open]) { pointer-events:none }
    body:has(#spot[open]) #mob-search-pill { visibility:hidden }
    #spot-cancel {
      display:flex; flex-shrink:0; background:transparent; border:0;
      outline:0; cursor:pointer; -webkit-tap-highlight-color:transparent;
      font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body); color:rgba(255,255,255,.55); font-weight:400;
      padding:0 4px; white-space:nowrap;
      align-items:center;
      justify-content:center;
      transition:opacity .16s ease-out;
    }
    #spot-cancel:active { opacity:.6; transition-duration:.1s }
    body.is-mob #spot-cancel {
      min-width:44px; min-height:44px; padding:0 8px;
      color:var(--accent);
    }

    /* ── Mobile result rows — only apply on mobile ── */
    body.is-mob #sres .sr { padding:calc(10px * var(--sc,1)) calc(14px * var(--sc,1)); gap:calc(12px * var(--sc,1)); }
    body.is-mob #sres .sr + .sr { border-top:0.5px solid rgba(255,255,255,.10); }
    body.is-mob #sres .sr-section { display:none; }
    body.is-mob #sres .srn { font-size:calc(var(--fs-body) * var(--sc,1));line-height:var(--lh-body);letter-spacing:var(--tr-body); font-weight:500; }
    body.is-mob #sres .srh { display:none; }
    body.is-mob #sres .sra { display:none; }
    body.is-mob #sres .sri { width:calc(44px * var(--sc,1)); height:calc(44px * var(--sc,1)); border-radius:calc(10px * var(--sc,1)); }
    /* !important: beats the equally-important #sres .sri img rule below. */
    body.is-mob #sres .sri img { width:calc(30px * var(--sc,1)) !important; height:calc(30px * var(--sc,1)) !important; }

    /* ── Spotlight result rows ── */
    .sr-empty {
      padding:24px; text-align:center; color:rgba(235,235,245,.7);
      font-size:var(--fs-subheadline);line-height:var(--lh-subheadline);letter-spacing:var(--tr-subheadline);
    }
    .sr-section {
      font-size:var(--fs-subheadline);line-height:var(--lh-subheadline);letter-spacing:var(--tr-subheadline); font-weight:600; color:rgba(235,235,245,.7);
      padding:6px 12px 6px;
    }
    .sr {
      display:flex;
      align-items:center;
      gap:18px; padding:14px 20px; border-radius:22px; cursor:pointer; text-decoration:none;
      transition:background .12s;
    }
    .sr:active, .sr.sel { background:rgba(255,255,255,.07) }
    @media (hover:hover) and (pointer:fine) {
      .sr:hover { background:rgba(255,255,255,.07) }
    }
    /* The moving highlight replaces the row fill while it is on screen. The
       press state is not a cursor and stays. */
    #sres:has(> .fh-hl.on) .sr:hover,
    #sres:has(> .fh-hl.on) .sr.sel { background:transparent }
    #sres:has(> .fh-hl.on) .sr:active { background:rgba(255,255,255,.07) }
    .sri {
      width:44px; height:44px; border-radius:12px;
      display:flex;
      align-items:center;
      justify-content:center;
      flex-shrink:0; overflow:hidden;
    }
    .sri img { width:28px; height:28px; object-fit:contain }
    #sres .sri img { width:34px !important; height:34px !important; }
    #sres .sri img.folder-mini-img,
    body.is-mob #sres .sri img.folder-mini-img { width:72% !important; height:72% !important; }
    .srn { font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body); font-weight:400; color:rgba(255,255,255,.92); overflow-wrap:anywhere }
    .srh {
      font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote); color:rgba(255,255,255,.65); margin-top:1px;
      white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    }
    .sra { margin-inline-start:auto; color:rgba(255,255,255,.65); font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote)}
    .sra:dir(rtl) { transform:scaleX(-1) }

    /* The side reserves, used by both layouts. A device that reserves no side
       edge reports 0px, which leaves every gutter at its design value. */
    :root {
      --sa-left:  var(--safe-left);
      --sa-right: var(--safe-right);
    }

    /* ── Mobile safe area ──
       The platform reports an inset after the first paint and again after a rotation.
       These stay in CSS so the browser keeps them current. Nothing reads them
       into JavaScript. */
    body.is-mob {
      --sa-top:    max(var(--safe-top), calc(18px * var(--sc,1)));
      --sa-bottom: max(var(--safe-bottom), calc(8px * var(--sc,1)));
    }
    /* Sized by the insets, and observed. A change to either fires the layout
       rebuild. */
    .sa-probe {
      position:fixed; top:0; left:0; visibility:hidden; pointer-events:none;
      width:calc(1px + var(--sa-left,0px) + var(--sa-right,0px));
      height:calc(var(--safe-top) + var(--safe-bottom));
    }
    .mob-page {
      flex:0 0 100vw; width:100vw; height:var(--pgh,100dvh); overflow:hidden;
      contain:layout paint;
      padding-block:var(--sa-top) calc(var(--sa-bottom) + var(--dh,108px) + var(--dz,52px));
      padding-inline:max(var(--sm,18px), var(--sa-left,0px)) max(var(--sm,18px), var(--sa-right,0px));
    }
    /* The box the layout measures. */
    .mob-grid {
      width:var(--mgw,100%); height:100%; margin-inline:auto;
      display:grid;
      grid-template-columns:repeat(var(--mcols,4),1fr); grid-template-rows:repeat(var(--mrows,6),1fr);
      gap:var(--gap);
      justify-content:center; align-content:start;
    }
    .mob-cell { display:flex; align-items:center; justify-content:center; min-width:0; min-height:0; }

    /* ── Folder overlay — mobile ── */
    /* Both folder overlays are the scrim itself, filling the viewport, so the
       dialog defaults have to be undone: a modal dialog is otherwise inset from
       the edges, given a border and a padding, and centred by an auto margin
       the reset in tokens.css has already zeroed. */
    .folder-overlay, .folder-overlay-mobile {
      max-width:none; max-height:none; width:100%; height:100%;
      margin:0; padding:0; border:0; color:inherit;
    }
    .folder-overlay::backdrop, .folder-overlay-mobile::backdrop { background:none }
    .folder-overlay-mobile:not([open]) { display:block }
    :is(.folder-overlay, .folder-overlay-mobile):not([open]),
    :is(.folder-overlay, .folder-overlay-mobile):not([open]) * { pointer-events:none !important }
    :is(.folder-overlay, .folder-overlay-mobile):not([open]) {
      background:none !important; -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
    }
    .folder-overlay-mobile {
      position:fixed; inset:0; z-index:800;
      -webkit-backdrop-filter:blur(22px) brightness(.72);
      backdrop-filter:blur(22px) brightness(.72);
      background:rgba(0,0,0,.18);
    }
    .folder-title-mobile {
      font-weight:700; color:var(--label-primary);
      text-align:start; line-height:1.05;
      text-shadow:0 1px 6px rgba(0,0,0,.45);
      -webkit-user-select:none; user-select:none;
      white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
    }
    .folder-dots {
      display:flex; justify-content:center; align-items:center;
      flex-shrink:0;
    }
    .folder-dot {
      border-radius:50%; cursor:pointer; flex-shrink:0;
      border:0; -webkit-appearance:none; appearance:none; -webkit-tap-highlight-color:transparent;
      background:transparent; box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.75);
      transition:background .2s,box-shadow .2s,transform .2s;
    }
    .folder-dot.on { background:var(--control-knob); box-shadow:none; transform:scale(1.25) }
    .folder-dot { position:relative }
    .folder-dot::after { content:''; position:absolute; inset:-4px calc((var(--dsz) - 24px) / 2) calc(var(--dsz) - 20px) }

    /* ── Folder overlay — desktop ── */
    .folder-overlay {
      position:fixed; inset:0; z-index:800;
      display:flex;
      align-items:flex-start;
      justify-content:center;
      overflow:auto;
      background:rgba(0,0,0,.45);
      -webkit-backdrop-filter:blur(24px); backdrop-filter:blur(24px);
    }
    .folder-outer {
      display:flex; flex-direction:column; align-items:center;
      gap:16px; max-width:600px; width:90vw;
      margin-block:auto;
    }
    .folder-title-desktop {
      font-size:var(--fs-title-2);line-height:var(--lh-title-2);letter-spacing:var(--tr-title-2); font-weight:600; color:rgba(255,255,255,.95);
      text-shadow:0 1px 8px rgba(0,0,0,.6); text-align:center;
    }
    .folder-box-desktop {
      position:relative; isolation:isolate;
      border-radius:28px; padding:28px 32px 24px; width:100%;
      box-shadow:0 32px 80px rgba(0,0,0,.65);
    }
    .folder-icon-link {
      display:flex; flex-direction:column;
      align-items:center; justify-content:center;
      text-decoration:none; cursor:pointer;
      -webkit-tap-highlight-color:transparent;
    }

    /* ── Folder icon grid (thumbnail on main homescreen page) ── */
    .folder-icon-grid {
      position:absolute; inset:0; border-radius:16px;
      display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr);
      gap:3px; padding:10px; overflow:hidden;
    }
    .folder-mini-cell {
      display:flex; align-items:center; justify-content:center; z-index:1;
      min-width:0; min-height:0;
    }
    .folder-mini-bg {
      width:100%; height:100%; border-radius:28%;
      display:flex; align-items:center; justify-content:center;
      overflow:hidden; box-shadow:inset 0 0 0 0.5px rgba(255,255,255,.15);
    }
    .folder-mini-img { width:72%; height:72%; object-fit:contain }
    .folder-mini-fb  { font-size:50%; font-weight:700; color:var(--on-tint) }
    .folder-mini-fb.fb-on-light { color:var(--on-tint-dark) }

    /* Dynamic layout classes — pixel values set via CSS custom properties from JS */
    .dyn-box        { position:relative; flex-shrink:0; }
    .dyn-sz         { width:var(--sz); height:var(--sz); }
    .dyn-folder-box { position:relative; width:var(--iw); height:var(--iw); flex-shrink:0; }
    .dyn-grid       { display:grid; grid-template-columns:repeat(6,var(--iw)); gap:24px; justify-content:center; }
    .dyn-mob-btn    { flex:1; height:var(--rh); background:none; border:none; padding:0; display:flex; flex-direction:column; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0; -webkit-tap-highlight-color:transparent; -webkit-appearance:none; }
    .dyn-mob-icon   { display:flex; flex-direction:column; align-items:center; justify-content:center; width:var(--cw); height:var(--rh); cursor:pointer; text-decoration:none; flex-shrink:0; -webkit-tap-highlight-color:transparent; }
    .dyn-mob-label  { font-weight:500; color:#FFFFFF; text-align:center; margin-top:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 3px rgba(0,0,0,.65); font-size:var(--lfs); width:var(--lw); }
    .dyn-fold-label { font-weight:500; color:#FFFFFF; text-align:center; margin-top:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 3px rgba(0,0,0,.70); font-size:var(--lfs); width:var(--lw); }
    .dyn-fold-wrap  { position:absolute; inset:0; pointer-events:none; border-radius:var(--br); display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); gap:var(--gap); padding:var(--pad); overflow:hidden; }
    .dyn-fold-cell  { display:flex; align-items:center; justify-content:center; z-index:1; pointer-events:none; min-width:0; min-height:0; }
    .dyn-clip       { overflow:hidden; flex-shrink:0; width:var(--gw); height:var(--gh); }
    .dyn-strip      { display:flex; height:var(--gh); will-change:transform; transition:transform .28s var(--page-ease); }
    .dyn-page-grid  { flex-shrink:0; display:grid; gap:var(--gap); justify-content:center; align-content:start; width:var(--gw); height:var(--gh); padding:var(--ovh,0); overflow:hidden; grid-template-columns:repeat(3,var(--fiw)); grid-template-rows:repeat(3,var(--fiw)); }
    .dyn-dot        { border-radius:50%; cursor:pointer; flex-shrink:0; width:var(--dsz); height:var(--dsz); }
    .dyn-dots-row   { display:flex; justify-content:center; align-items:center; flex-shrink:0; width:100%; }
    /* WebKit paints its own focus ring on a script-focused anchor. Only
       :focus-visible is styled below. */
    .folder-overlay-mobile:focus, .dyn-fold-anchor:focus,
    .folder-overlay:focus, .folder-icon-link:focus { outline:none; }
    .dyn-fold-anchor { display:flex; flex-direction:column; align-items:center; gap:4px; text-decoration:none; -webkit-tap-highlight-color:transparent; }
    .dyn-fold-inner-label { font-weight:400; color:rgba(255,255,255,.90); text-align:center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 3px rgba(0,0,0,.6); font-size:var(--lfs); width:var(--fiw); }
    .dyn-title-mob  { position:absolute; pointer-events:none; font-size:var(--tfs); }
    .dyn-box-mob    { position:absolute; touch-action:pan-y pinch-zoom; display:flex; flex-direction:column; align-items:center; inset-inline-start:var(--left); width:var(--bw); height:var(--bh); top:var(--top); border-radius:var(--br); padding:var(--pt) var(--ph) var(--pb); }
    .dyn-dock-icon  { display:flex; align-items:center; justify-content:center; flex:0 1 auto; min-width:0; height:100%; cursor:pointer; text-decoration:none; -webkit-tap-highlight-color:transparent; overflow:visible; position:relative; }
    :is(.icon, .di, .folder-icon-link, .dyn-fold-anchor, .dyn-mob-icon, .dyn-mob-btn, .dyn-dock-icon) { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
    :is(#dock, #dots, #mob-search-pill, #spot, .folder-overlay, .folder-overlay-mobile) { touch-action:manipulation; }

/* Strip backdrop-filter blur for anyone who asks for reduced motion or
   transparency. */
/* The general rules for both preferences live in tokens.css. What remains here
   is only what the dashboard defines. */

/* Reduced motion: neutralize slides, springs, and lift transforms. */
@media (prefers-reduced-motion: reduce) {
  /* A ring that does not turn says nothing, so it becomes a resting dot. */
  body::before { animation:boot-show .3s ease .6s forwards; border-color:var(--label-secondary); }
  #pages { transition: none !important; }
  .icon:hover .iwrap, .folder-icon-link:hover .iwrap, .di:hover .dwrap,
  .icon:active .iwrap, .folder-icon-link:active .iwrap, .di:active .dwrap,
  .icon .dyn-folder-box, .dyn-mob-icon > .plate, .dyn-dock-icon > .plate, .dyn-mob-btn > .dyn-box, .dyn-fold-anchor > .plate,
  .dot.on { transform: none !important; }
  html.wall-swap::after, html.wall-in::before { animation-duration:.4s !important; }
  #mob-search-pill:active { scale:none; opacity:.7; }
}

/* ── Empty dashboard welcome ── */
/* Toned from the wallpaper by label-contrast.js, never by the theme. */
:root {
  --label-color-2:      rgba(235,235,245,.70);
  --label-color-2-dark: rgba(60,60,67,.85);
  --label-link:         #00D2E0;
  --label-link-dark:    #00587E;
  /* Opaque. A translucent tone falls under 4.5:1 on a mid-grey wallpaper. */
  --label-text:         #FFFFFF;
  --label-text-dark:    #000000;
}
.empty-state {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column;
  align-items: center;
  padding-inline: 24px; text-align: center;
  overflow-y: auto;
}
/* Do not centre with justify-content. An overflowing stack then starts above
   the scroll origin and cannot be reached. */
.empty-state::before, .empty-state::after { content: ''; flex: 1 0 0 }
.empty-state-mark {
  width: clamp(71px, 11vh, 112px); height: clamp(71px, 11vh, 112px);
  color: var(--label-color);
  margin-block-end: var(--sp-32);
}
.empty-state-title {
  margin: 0; font-weight: 600; color: var(--label-text); text-shadow: var(--label-shadow);
  font-size:var(--fs-title-2);line-height:var(--lh-title-2);letter-spacing:var(--tr-title-2);
}
.empty-state-sub {
  margin: 0; max-width: 38ch; color: var(--label-text); text-shadow: var(--label-shadow); font-weight: 500;
  font-size:var(--fs-title-2);line-height:var(--lh-title-2);letter-spacing:var(--tr-title-2);
}
.empty-state-btn {
  margin-block-start: var(--sp-32); padding: 15px var(--sp-32);
  border-radius: 999px; min-height: 52px;
  background: var(--glass-surface-bg); border: .5px solid rgba(255,255,255,.22);
  -webkit-backdrop-filter: var(--glass-surface-blur); backdrop-filter: var(--glass-surface-blur);
  color: var(--label-color); text-decoration: none; font-weight: 500;
  font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body);
}
.empty-state-mark[data-tone="dark"] { color: var(--label-color-dark) }
.empty-state-title[data-tone="dark"] { color: var(--label-text-dark); text-shadow: var(--label-shadow-dark) }
.empty-state-sub[data-tone="dark"] { color: var(--label-text-dark); text-shadow: var(--label-shadow-dark) }
.empty-state-hint[data-tone="dark"] { color: var(--label-link-dark) }
.empty-state-btn[data-tone="dark"] {
  background: rgba(0,0,0,.06); border-color: rgba(0,0,0,.12); color: var(--label-color-dark);
}
.empty-state-hint {
  margin-block-start: var(--sp-20); color: var(--label-link); text-decoration: none;
  font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote);
}
@media (hover:hover) and (pointer:fine) {
  .empty-state-hint:hover { text-decoration: underline }
}
@media (max-height: 480px) {
  .empty-state-mark { display: none }
  .empty-state-sub { font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body) }
  .empty-state-btn { margin-block-start: var(--sp-16) }
  .empty-state-hint { margin-block-start: var(--sp-8) }
}

#dock[hidden] { display: none }

/* API error screen — no inline styles, CSP-safe */
.api-error-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); font-family: inherit; gap: 16px; z-index: 10000;
  padding-inline: max(24px, var(--safe-left), var(--safe-right)); text-align: center;
}
.api-error-sub { max-width: 32em }
.api-error-title { font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body); font-weight: 600; margin: 0; }
.api-error-sub   { font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote); color: rgba(255,255,255,.6); margin: 0; }
.api-error-btn   {
  margin-top: 8px; padding: 13px 24px; border-radius: 999px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  background: var(--glass-surface-bg); border: .5px solid rgba(255,255,255,.22);
  -webkit-backdrop-filter: var(--glass-surface-blur); backdrop-filter: var(--glass-surface-blur); font-weight: 500;
  color: var(--label-primary); font-size:var(--fs-subheadline);line-height:var(--lh-subheadline);letter-spacing:var(--tr-subheadline); cursor: pointer; font-family: inherit;
}

/* ── Accessibility layer (added in Phase 3) ── */

/* Screen-reader-only utility (used by the search results live region) */
.visually-hidden {
  position:absolute !important; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* Visible keyboard focus for all interactive elements. */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible,
.icon:focus-visible, .di:focus-visible, .sr:focus-visible,
.dot:focus-visible, .dyn-mob-icon:focus-visible, .dyn-mob-btn:focus-visible,
.dyn-dock-icon:focus-visible, .dyn-fold-anchor:focus-visible,
.folder-icon-link:focus-visible {
  outline:2px solid var(--accent); outline-offset:3px;
}
:is(.icon, .di, .dot, .dyn-mob-icon, .dyn-mob-btn, .dyn-dock-icon, .dyn-fold-anchor, .folder-icon-link):focus-visible {
  outline-offset:2px; box-shadow:0 0 0 2px rgba(0,0,0,.72);
}
:is(.icon, .di, .dyn-mob-icon, .dyn-mob-btn, .dyn-dock-icon, .dyn-fold-anchor, .folder-icon-link):focus-visible { border-radius:8px; }
#sin:focus-visible { outline:none; }
/* On the box, not the bar. The box clips everything inside it. */
body:not(.is-mob) #sbox:has(#sin:focus-visible) { outline:2px solid var(--accent); outline-offset:2px; }
body.is-mob .spot-field:focus-within { outline:2px solid var(--accent); outline-offset:2px; }
#spot-cancel:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; border-radius:8px; }

/* Larger tap/click area for page dots without changing their visual size */
.dot { position:relative; }
.dot::after { content:''; position:absolute; inset:-11px; }

/* 44px is the minimum tap target, and a dot is 8px of it. */
@media (pointer:coarse) {
  .dot::after { inset:-18px; }
}

/* Increased-contrast mode. */
@media (prefers-contrast: more) {
  :root {
    --glass-bg:      rgba(0,0,0,.62);
    --glass-border:  rgba(255,255,255,.30);
    --glass-surface-bg: rgba(40,40,44,.55);
    --label-color:   var(--label-primary);
    --label-shadow:  0 1px 4px rgba(0,0,0,.95);
  }
  .ilabel, .dyn-mob-label, .dyn-fold-label, .dyn-fold-inner-label { color:#FFFFFF; }
  .ilabel[data-tone="dark"], .dyn-mob-label[data-tone="dark"], .dyn-fold-label[data-tone="dark"] {
    color:#000000; text-shadow:0 0 2px rgba(255,255,255,.95);
  }
  .empty-state-mark, .empty-state-title, .empty-state-btn { color:#FFFFFF; }
  .empty-state-mark[data-tone="dark"], .empty-state-title[data-tone="dark"], .empty-state-btn[data-tone="dark"] { color:#000000; }
  #photo-credit { color:#FFFFFF; }
  #photo-credit[data-tone="dark"] { color:#000000; }
  .srn  { color:var(--label-primary); }
  .srh, .sr-section { color:rgba(235,235,245,.85); }
  .widget, .mob-widget-card { border-color:rgba(255,255,255,.35); }
  /* A translucent card cannot honour a contrast request and stay translucent. */
  .widget[data-card="translucent"], .mob-widget-card[data-card="translucent"] {
    background:rgba(0,0,0,.62);
    -webkit-backdrop-filter:blur(22px) saturate(140%); backdrop-filter:blur(22px) saturate(140%);
  }
  .widget[data-card="light"], .mob-widget-card[data-card="light"] { border-color:rgba(0,0,0,.45); }
  .dot { border-width:2px; }
  .badge { box-shadow:0 0 0 1.5px rgba(0,0,0,.85); }
}

/* The wallpaper and the blur are handled in tokens.css. What remains is the
   state this page carries in colour alone. */
@media (forced-colors: active) {
  #dots { background:Canvas; border:1px solid CanvasText; }
  #dock, #dock.mdock, .folder-box-desktop, .dyn-box-mob, .folder-icon-grid, .dyn-fold-wrap { border:1px solid CanvasText; }
  /* State by shape, not by fill: forced colors paints both dots the same. */
  .dot { background:Canvas; border:1px solid CanvasText; }
  .dot.on { background:Highlight; border-color:Highlight; }
  /* The one opt-out. A status colour is information, and the system palette has
     no way to say "needs attention". The border keeps the pill a shape once the
     fill is no longer trusted to. */
  .badge { forced-color-adjust:none; border:1px solid CanvasText; }
  .sr.sel { outline:2px solid Highlight; outline-offset:-2px; }
}

/* Do not add `container-type:size` here. It applies size containment and
   collapses the desktop .widget, which has no explicit height, to 0. */

/* The dialog is the scrim itself, so the dialog defaults have to be undone:
   a modal dialog is otherwise inset from the edges, bordered, and centred by
   an auto margin the reset in tokens.css has already zeroed. */
.setup-prompt {
  max-width: none; max-height: none; width: 100%; height: 100%;
  margin: 0; border: 0; color: inherit;
  position: fixed; inset: 0; z-index: 10001;
  display: flex; align-items: safe center; justify-content: center; overflow-y: auto;
  background: rgba(0,0,0,.48);
  font-family: inherit; padding: 24px;
}
.setup-prompt::backdrop { background: none }
.setup-card {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px;
  padding: 22px 14px 14px; border-radius: 34px;
  background: rgba(30,30,32,.9); border: .5px solid rgba(255,255,255,.12);
  -webkit-backdrop-filter: blur(32px) saturate(180%); backdrop-filter: blur(32px) saturate(180%);
  box-shadow: 0 8px 48px rgba(0,0,0,.45);
  color: var(--label-primary);
}
.setup-title { font-size:var(--fs-headline);line-height:var(--lh-headline);letter-spacing:var(--tr-headline); font-weight: var(--fw-headline); margin: 0; padding-inline: 8px; }
.setup-sub   { font-size:var(--fs-subheadline);letter-spacing:var(--tr-subheadline); line-height: 1.4; color: rgba(235,235,245,.7); margin: 0 0 6px; padding-inline: 8px; }
.setup-pw {
  width: 100%; box-sizing: border-box; min-height: 52px; padding: 0 16px; border-radius: 26px;
  background: rgba(118,118,128,.2); border: 0;
  color: var(--label-primary); font-size:var(--fs-body);line-height:var(--lh-body);letter-spacing:var(--tr-body); font-weight: 500; font-family: inherit; outline: none;
}
.setup-pw:focus { box-shadow: 0 0 0 2px var(--accent); }
@media (forced-colors: active) {
  .setup-pw { border:1px solid CanvasText; }
  .setup-pw:focus { outline:2px solid Highlight; }
}
.setup-field { position: relative; display: flex; align-items: center; }
.setup-field .setup-pw { padding-inline-end: 52px; }
.setup-reveal {
  position: absolute; inset-inline-end: 6px; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: none; border-radius: 50%;
  background: none; color: rgba(235,235,245,.6); cursor: pointer;
}
@media (hover:hover) and (pointer:fine) {
  .setup-reveal:hover { color: rgba(255,255,255,.9); }
}
.setup-reveal[aria-pressed="true"] { color: var(--accent); }
.setup-bars { display: flex; gap: 4px; padding-inline: 8px; }
.setup-bars .pwbar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); transition: background .15s; }
.setup-hint { font-size:var(--fs-caption-1);line-height:var(--lh-caption-1);letter-spacing:var(--tr-caption-1); min-height: 14px; color: rgba(235,235,245,.6); padding-inline: 8px; }
.setup-err  { display: none; font-size:var(--fs-footnote);line-height:var(--lh-footnote);letter-spacing:var(--tr-footnote); color: var(--sy-red-hi); padding-inline: 8px; }
.setup-btns { display: flex; gap: 8px; margin-top: 6px; }
.setup-btn {
  flex: 1; min-height: 48px; padding: 13px 16px; border-radius: 24px; border: 0; cursor: pointer; font-family: inherit;
  font-size:var(--fs-headline);line-height:var(--lh-headline);letter-spacing:var(--tr-headline); font-weight: var(--fw-headline);
}
.setup-btn-skip { background: rgba(118,118,128,.32); color: var(--label-primary); }
.setup-btn-set  { background: var(--accent); color: var(--on-fill); }
.setup-btn-set:disabled { opacity: .4; cursor: default; }
:is(.empty-state-btn, .api-error-btn, .setup-btn) { transition: transform .16s ease-out; }
:is(.empty-state-btn, .api-error-btn, .setup-btn):not(:disabled):active { transform: scale(.97); transition-duration: .1s; }
.folder-dot:active, .setup-reveal:active, .empty-state-hint:active { opacity: .7; }
@media (prefers-reduced-motion: reduce) {
  :is(.empty-state-btn, .api-error-btn, .setup-btn):not(:disabled):active { transform: none; opacity: .7; }
}
html[data-theme="light"] .setup-card { background: rgba(255,255,255,.95); border-color: rgba(0,0,0,.08); box-shadow: 0 8px 48px rgba(0,0,0,.18); }
html[data-theme="light"] .setup-sub,
html[data-theme="light"] .setup-hint,
html[data-theme="light"] .setup-reveal,
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: rgba(60,60,67,.85); }
@media (hover:hover) and (pointer:fine) {
  html[data-theme="light"] .setup-reveal:hover { color: var(--label-primary); }
}
html[data-theme="light"] .setup-reveal[aria-pressed="true"] { color: var(--accent); }
html[data-theme="light"] .setup-pw,
html[data-theme="light"] .setup-btn-skip { background: rgba(118,118,128,.12); }
html[data-theme="light"] .setup-bars .pwbar { background: rgba(0,0,0,.1); }

/* ── RTL ──
   The grid and dock are symmetric, and flexbox rows reverse on their own. What
   remains uses logical properties, so it follows the text direction without an
   override: `text-align: start` is left in English and right in Persian, and
   `inset-inline-end` is the end of the line rather than a fixed side.

   The override block that used to be here listed the cases someone had noticed,
   which is a list that can only ever be incomplete: any new rule with
   `margin-left` in it needed a matching entry, and forgetting meant Persian
   quietly looked wrong. Logical properties remove the need for the list. */

/* ── Moving pill ── */
#sres { position:relative }
/* The rows only need a position to paint above the pill, which precedes them.
   No z-index: one on a row makes it a stacking context and traps any overlay
   inside it behind the rows that follow. */
#sres > .sr, #sres > .sr-section { position:relative }
/* pointer-events:none, or the pill swallows every hover and click in the list. */
.mp {
  position:absolute; top:0; inset-inline-start:0;
  pointer-events:none;
  opacity:0; transition:opacity .14s ease;
}
.mp.on {
  opacity:1;
  transition:opacity .14s ease,
             transform .19s cubic-bezier(.22,1,.36,1);
}
.mp.mp-snap { transition:opacity .14s ease }
.fh-hl { background:rgba(255,255,255,.07) }
@media (prefers-reduced-motion: reduce) {
  .mp, .mp.on { transition:none }
}

.sy-sprite{position:absolute;width:0;height:0;overflow:hidden}
.sy-icon{flex-shrink:0;--icon-accent:var(--accent)}
.sy-i{fill:currentColor}
.sy-i2{fill:currentColor;fill-opacity:.18}
.sy-i3{fill:currentColor;fill-opacity:.4}
.sy-a{fill:var(--icon-accent,currentColor)}
.sy-is{stroke:currentColor}
.sy-i3s{stroke:currentColor;stroke-opacity:.4}
.sy-as{stroke:var(--icon-accent,currentColor)}
@media (forced-colors:active){.sy-icon{--icon-accent:CanvasText}}

.plate.plate-clear { background-image:none; box-shadow:none }

html[data-theme="light"] {
  --bg-base:           #E5E5EA;
  --glass-bg:          #FFFFFF;
  --glass-border:      rgba(0,0,0,.06);
  --card-edge-hi:      rgba(255,255,255,.9);
  --card-edge-lo:      rgba(0,0,0,.05);
  --glass-surface-bg:  rgba(153,153,153,.33);
  --glass-surface-blur: blur(24px) saturate(180%);
  --glass-rim-light:   rgba(255,255,255,1);
  --glass-rim-dark:    rgba(255,255,255,.4);
  --glass-lift:        0 12px 32px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.08);
  --card-dark:         #FFFFFF;
}
html[data-theme="light"] .widget[data-card="translucent"],
html[data-theme="light"] .mob-widget-card[data-card="translucent"] { background:#FFFFFF }
html[data-theme="light"] #mob-search-pill { background:rgba(255,255,255,.72); border-color:rgba(0,0,0,.08) }
html[data-theme="light"] #mob-search-pill .msp-icon,
html[data-theme="light"] #mob-search-pill .msp-label { color:var(--pill-ink-light); text-shadow:none }
html[data-theme="light"] #mob-search-pill .msp-dot { background:rgba(60,60,67,.3) }
html[data-theme="light"] #mob-search-pill .msp-dot.on { background:rgba(0,0,0,.8) }
html:not([data-theme="light"]) #mob-search-pill[data-tone="dark"] { background:rgba(255,255,255,.72); border-color:rgba(0,0,0,.08) }
html:not([data-theme="light"]) #mob-search-pill[data-tone="dark"] :is(.msp-icon, .msp-label) { color:var(--pill-ink-light); text-shadow:none }
html:not([data-theme="light"]) #mob-search-pill[data-tone="dark"] .msp-dot { background:rgba(60,60,67,.3) }
html:not([data-theme="light"]) #mob-search-pill[data-tone="dark"] .msp-dot.on { background:rgba(0,0,0,.8) }
html[data-theme="light"] #spot { background:rgba(242,242,247,.9) }
html[data-theme="light"] body:not(.is-mob) #spot { background:rgba(242,242,247,.5) }
html[data-theme="light"] body.is-mob #spot {
  -webkit-backdrop-filter:blur(20px) saturate(180%); backdrop-filter:blur(20px) saturate(180%);
}
html[data-theme="light"] body:not(.is-mob) #sbox,
html[data-theme="light"] body:not(.is-mob) #sres {
  background:rgba(255,255,255,.92); border-color:rgba(0,0,0,.1); box-shadow:0 20px 60px rgba(0,0,0,.18);
}
html[data-theme="light"] .spot-bar { border-bottom-color:rgba(0,0,0,.08) }
html[data-theme="light"] body.is-mob #spot .spot-field { background:rgba(118,118,128,.14) }
html[data-theme="light"] .spot-icon { color:rgba(60,60,67,.66) }
html[data-theme="light"] #sin, html[data-theme="light"] .srn { color:var(--label-primary) }
html[data-theme="light"] #sin::placeholder,
html[data-theme="light"] #spot #sin::placeholder,
html[data-theme="light"] #spot-cancel { color:var(--search-ink-light) }
html[data-theme="light"] body.is-mob #spot-cancel { color:var(--accent-strong) }
html[data-theme="light"] body.is-mob #spot #sin::placeholder { color:rgba(60,60,67,.85) }
html[data-theme="light"] .sr-empty { color:rgba(60,60,67,.85) }
html[data-theme="light"] .sr-section, html[data-theme="light"] .srh { color:rgba(60,60,67,.85); border-color:rgba(0,0,0,.08) }
html[data-theme="light"] .sra { color:rgba(60,60,67,.85) }
html[data-theme="light"] .sr:active,
html[data-theme="light"] .sr.sel, html[data-theme="light"] .fh-hl { background:rgba(0,0,0,.06) }
@media (hover:hover) and (pointer:fine) {
  html[data-theme="light"] .sr:hover { background:rgba(0,0,0,.06) }
}
html[data-theme="light"] body.is-mob #sres .sr + .sr { border-top-color:rgba(0,0,0,.08) }
html[data-theme="light"] .badge-pop {
  background:rgba(255,255,255,.96); border-color:rgba(0,0,0,.1); color:#000;
  box-shadow:0 18px 44px rgba(0,0,0,.2),0 0 0 .5px rgba(0,0,0,.06);
}
html[data-theme="light"] .badge-pop-name { color:rgba(60,60,67,.8) }
html[data-theme="light"] .folder-overlay { background:rgba(255,255,255,.55) }
html[data-theme="light"] .folder-overlay-mobile {
  background:rgba(255,255,255,.55);
  -webkit-backdrop-filter:blur(22px); backdrop-filter:blur(22px);
}
html[data-theme="light"] .folder-title-desktop { color:rgba(0,0,0,.88); text-shadow:0 1px 8px rgba(255,255,255,.6) }
html[data-theme="light"] .folder-title-mobile { text-shadow:none }
html[data-theme="light"] .folder-box-desktop { box-shadow:0 32px 80px rgba(0,0,0,.2) }
html[data-theme="light"] .folder-dot { box-shadow:inset 0 0 0 1.5px rgba(0,0,0,.55) }
html[data-theme="light"] .folder-dot.on { background:rgba(0,0,0,.8); box-shadow:none }
html[data-theme="light"] .dyn-fold-inner-label { color:rgba(0,0,0,.88); text-shadow:0 0 2px rgba(255,255,255,.55) }
html[data-theme="light"] .api-error-btn { background:rgba(0,0,0,.06); border-color:rgba(0,0,0,.12) }
html[data-theme="light"] .api-error-screen { color:rgba(0,0,0,.7) }
html[data-theme="light"] .api-error-sub { color:rgba(0,0,0,.6) }
html[data-theme="light"] .folder-overlay .ilabel { color:var(--label-color-dark); text-shadow:var(--label-shadow-dark) }
html[data-theme="light"] #dock:not(.mdock) { border-radius:38px; box-shadow:var(--glass-lift) }
html[data-theme="light"] .folder-icon-grid,
html[data-theme="light"] .dyn-fold-wrap,
html[data-theme="light"] .plate-clear { box-shadow:0 4px 14px rgba(0,0,0,.12) }
html[data-theme="light"] #dock.mdock { border-radius:calc(38px * var(--sc,1)); box-shadow:var(--glass-lift) }
html[data-theme="light"] .widget[data-appearance="dark"],
html[data-theme="light"] .mob-widget-card[data-appearance="dark"] {
  --glass-bg:var(--card-fixed-dark); --glass-border:rgba(255,255,255,.09); --card-dark:var(--card-fixed-dark);
  --card-edge-hi:rgba(255,255,255,.16); --card-edge-lo:rgba(255,255,255,.05);
}
html[data-theme="light"] .widget[data-appearance="dark"][data-card="translucent"],
html[data-theme="light"] .mob-widget-card[data-appearance="dark"][data-card="translucent"] { background:var(--card-fixed-dark) }
html:not([data-theme="light"]) .widget[data-appearance="light"],
html:not([data-theme="light"]) .mob-widget-card[data-appearance="light"] {
  --glass-bg:#FFFFFF; --glass-border:rgba(0,0,0,.06); --card-dark:#FFFFFF;
  --card-edge-hi:rgba(255,255,255,.9); --card-edge-lo:rgba(0,0,0,.05);
}
@media (prefers-contrast: more) {
  html[data-theme="light"] { --glass-bg:rgba(255,255,255,.97); --glass-border:rgba(0,0,0,.35) }
  html[data-theme="light"] .widget:not([data-appearance="dark"]),
  html[data-theme="light"] .mob-widget-card:not([data-appearance="dark"]) { border-color:rgba(0,0,0,.35) }
}

/* Keep after the theme rules. Earlier, the light theme overrides win and the
   surfaces stay see-through. */
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-surface-blur: none; --glass-surface-bg:rgba(44,44,46,.94); }
  html[data-theme="light"] { --glass-surface-blur: none; --glass-surface-bg:rgba(242,242,247,.94); }
  .folder-overlay-mobile, .folder-overlay { background:rgba(0,0,0,.82); }
  html[data-theme="light"] .folder-overlay-mobile, html[data-theme="light"] .folder-overlay { background:rgba(255,255,255,.92); }
  #spot, body:not(.is-mob) #spot { background:rgba(0,0,0,.82); }
  html[data-theme="light"] #spot, html[data-theme="light"] body:not(.is-mob) #spot { background:rgba(242,242,247,.94); }
  #dots { background:rgba(44,44,46,.94); }
  html[data-theme="light"] #mob-search-pill { background:rgba(255,255,255,.94); }
}
