/* ===== L-frame: sidebar + top bar are ONE frosted frame, the content is a rounded sheet inside it =====
   The sidebar already runs full height; the top bar starts at its edge. Both get the identical flat tint (no vertical
   gradients, so the two pieces can't disagree), the crossing hairlines go, and one soft fading hairline runs down the
   sidebar's inner edge, rounds the sheet's top-left corner (R = 16px) and fades out along the top bar's bottom edge.
   The corner is a fixed pseudo on .main (not on the top bar: a child of a backdrop-filter element can't blur the page),
   tinted and blurred outside the arc and masked clear inside it, so scrolled content passes under a real glass corner. */
html:root[data-look="9"] {
  --fr-c: rgba(30, 34, 40, .45);                 /* the one frame tint (≈ the old sidebar frost, flattened) */
  --fr-l1: rgba(255, 255, 255, .12);             /* hairline at the corner */
  --fr-l2: rgba(255, 255, 255, .045);            /* hairline as it fades */
  --fr-r: 16px;                                  /* = the cards' radius */
  --fr-tb: 64px;                                 /* frame top band = sheet top (68px from 901px up) */
}
html:root[data-look="9"] .app { --fr-sbw: 0px; }
@media (min-width: 901px) {
  html:root[data-look="9"] .app.side { --fr-sbw: 264px; }
  html:root[data-look="9"] body.sb-mini .app.side { --fr-sbw: 76px; }
}

/* frame pieces: same tint, same blur, no inset hairlines or edge shadows */
html:root[data-look="9"] :is(.sb, .topbar) { background-origin: border-box !important; box-shadow: none !important; -webkit-backdrop-filter: var(--fz-blur); backdrop-filter: var(--fz-blur); }
html:root[data-look="9"] .topbar {   /* no sidebar beside it (watch page, phones): a plain hairline fading at both ends */
  background: linear-gradient(90deg, transparent, var(--fr-l2) 20%, var(--fr-l2) 80%, transparent) left bottom / 100% 1px no-repeat, var(--fr-c) !important; }
html:root[data-look="9"] .status {
  background: linear-gradient(90deg, transparent, var(--fr-l2) 20%, var(--fr-l2) 80%, transparent) left top / 100% 1px no-repeat, var(--fr-c) !important;
  -webkit-backdrop-filter: var(--fz-blur); backdrop-filter: var(--fz-blur); box-shadow: none !important; }

@media (min-width: 901px) {
  /* sidebar: hairline on the inner edge, starting where the corner arc ends and fading down */
  html:root[data-look="9"] .app.side .sb {
    background: linear-gradient(180deg, transparent calc(var(--fr-tb) + var(--fr-r)), var(--fr-l1) calc(var(--fr-tb) + var(--fr-r)), var(--fr-l2) 45%, transparent 88%) right top / 1px 100% no-repeat, var(--fr-c) !important; }
  /* top bar: hairline picks up where the arc ends and fades to the right */
  html:root[data-look="9"] .app.side .main > .topbar {
    background: linear-gradient(90deg, var(--fr-l1), var(--fr-l2) 40%, transparent 92%) left var(--fr-r) bottom 0 / calc(100% - var(--fr-r)) 1px no-repeat, var(--fr-c) !important; }
  /* bottom bar: part of the frame; under the sidebar it lets the sidebar's own tint through (no double frost), and its
     top hairline is the sheet's bottom edge only */
  html:root[data-look="9"] .app.side .main > .status {
    background: linear-gradient(90deg, var(--fr-l2), transparent 75%) left var(--fr-sbw) top 0 / calc(100% - var(--fr-sbw)) 1px no-repeat,
      linear-gradient(90deg, transparent var(--fr-sbw), var(--fr-c) var(--fr-sbw)) !important; }

  /* the rounded inner corner (21×21, overlapping the sidebar's last column and the top bar's last row by 1px so the arc
     meets both hairlines tangentially). Fill is offset 1px so those overlapped pixels aren't frosted twice. */
  html:root[data-look="9"] .app.side > .main::before {
    content: ""; position: fixed; z-index: 21; pointer-events: none;
    left: calc(var(--fr-sbw) - 1px); top: calc(var(--fr-tb) - 1px); width: calc(var(--fr-r) + 1px); height: calc(var(--fr-r) + 1px);
    transition: left .22s ease;
    background:
      radial-gradient(circle at calc(100% - 1px) calc(100% - 1px), transparent calc(var(--fr-r) - .7px), var(--fr-l1) calc(var(--fr-r) - .4px), var(--fr-l1) calc(var(--fr-r) + .4px), transparent calc(var(--fr-r) + .7px)),
      linear-gradient(var(--fr-c), var(--fr-c)) 1px 1px / 100% 100% no-repeat;
    /* mask = the frosted area outside the arc (minus the 1px overlap, so the blur never re-frosts the neighbours' edge
       pixels with sheet content) + the arc stroke itself */
    --fr-ring: radial-gradient(circle at calc(100% - 1px) calc(100% - 1px), transparent calc(var(--fr-r) - .7px), #000 calc(var(--fr-r) - .4px), #000 calc(var(--fr-r) + .4px), transparent calc(var(--fr-r) + .7px));
    --fr-out: radial-gradient(circle at calc(var(--fr-r) - 1px) calc(var(--fr-r) - 1px), transparent calc(var(--fr-r) - .7px), #000 calc(var(--fr-r) - .4px)) 1px 1px / 100% 100% no-repeat;
    -webkit-mask: var(--fr-ring), var(--fr-out);
    mask: var(--fr-ring), var(--fr-out);
    -webkit-backdrop-filter: var(--fz-blur); backdrop-filter: var(--fz-blur); }

  /* docked Wallets / Marketplace fill the sheet: same top-left radius */
  html:root[data-look="9"] .ov.docked, html:root[data-look="9"] .ov.docked :is(.ov-panel, .ov-body) { border-top-left-radius: var(--fr-r); }
  html:root[data-look="9"] .ov.docked { overflow: hidden; }
}

@media (prefers-reduced-transparency: reduce) {
  html:root[data-look="9"] { --fr-c: #1a1e24; }
  html:root[data-look="9"] .app.side > .main::before { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Brand sits on the top bar's centre line (64px bar → centre 32px): collapsed flame and expanded wordmark alike. */
html:root:is([data-look]) .sb .brand { padding-top: 0 !important; padding-bottom: 0 !important; min-height: 64px; align-content: center; }
html:root:is([data-look]) body.sb-mini .sb .brand { min-height: 64px; display: grid; place-items: center; margin-top: -16px; }
html:root:is([data-look]) body.sb-mini .sb .mini-mark { padding: 0 !important; }
html:root:is([data-look]) body:not(.sb-mini) .sb .brand { margin-top: -12px; }

/* ===== One 12px rhythm (≥901px, sidebar beside the sheet) =====
   Top bar 56px; the brand (flame collapsed / wordmark expanded) sits on its centre line (28px) with 12px above and below;
   a faint glass hairline closes the sidebar's header at 56px; the frame runs 12px further down before the sheet starts,
   so sheet top = 56 + 12 = 68px = the first item of the runner list (first avatar collapsed, search field expanded).
   The top bar's box is 68px tall (56 bar + 12px frame band as padding) so the band is frosted and sticky with it. */
@media (min-width: 901px) {
  html:root[data-look="9"] { --fr-tb: 68px; }
  html:root[data-look] .app.side .main > .topbar { height: 68px; padding-bottom: 12px; border-bottom: 0; }
  html:root[data-look] .app.side :is(.tstrip, .ag-id) { top: 68px; }

  html:root[data-look] .app.side .sb { --sb-gap: 16px; row-gap: var(--sb-gap); padding-top: 0; }
  html:root[data-look] .app.side .sb .brand { height: 56px; min-height: 56px; margin: 0 0 calc(12px - var(--sb-gap)) !important; }
  /* collapsed: a 32px flame (12px to the top edge, 12px to the header line); the optical 2.5px x-nudge stays */
  html:root[data-look] body.sb-mini .app.side .mini-mark .mm { width: 32px; height: 32px; }
  html:root[data-look] body.sb-mini .app.side .mini-mark .mm-live { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
  /* collapsed list: the first avatar's top on the sheet's top edge (row = 1px border + 6px padding above the avatar) */
  html:root[data-look] body.sb-mini .app.side .sb > .rl { margin-top: -7px; padding-top: 0; }
  /* the sidebar column's header line */
  html:root[data-look] .app.side .sb::before { content: ""; position: absolute; left: 0; right: 0; top: 55px; height: 1px; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--fr-l2) 22%, var(--fr-l2) 78%, transparent); }
}
@media (min-width: 901px) and (max-height: 900px) {
  html:root[data-look] .app.side .sb { --sb-gap: 10px; }
}
/* How fits one screen under the 12px band: the sheet's own 12px already clears the bar, so the page's top padding gives
   back the difference (tracker flame stays 12px clear of the sheet edge); short windows also tighten the stack gaps */
@media (min-width: 1251px) {
  html:root[data-look] .app.side .page.how { padding-top: 8px; padding-bottom: 12px; }
}
@media (min-width: 1251px) and (max-height: 840px) {
  html:root[data-look] .app.side .page.how { gap: 6px; }
  html:root[data-look] .app.side .page.how > .save-row { padding-top: 8px; padding-bottom: 8px; }
}

/* The sheet's top edge sits ON the sidebar header line (56px): one continuous horizontal line from the sidebar into the
   sheet; the runner list starts 12px below it. */
@media (min-width: 901px) {
  html:root[data-look="9"] { --fr-tb: 56px; }
  html:root[data-look] .app.side .main > .topbar { height: 56px; padding-bottom: 0; }
  html:root[data-look] .app.side :is(.tstrip, .ag-id) { top: 56px; }
}

/* Collapsed sidebar is as wide as the top bar is tall (56px), so the frame is one even L. */
@media (min-width: 901px) {
  html:root[data-look] body.sb-mini .app.side { grid-template-columns: 56px minmax(0, 1fr) !important; --fr-sbw: 56px; }
  html:root[data-look="9"] body.sb-mini #run-bg { --sbw: 56px; }
  html:root[data-look] body.sb-mini .app.side .sb { padding-left: 6px !important; padding-right: 6px !important; }
  html:root[data-look] body.sb-mini .app.side .sb .brand { justify-items: center; }
  /* the sidebar header line: born at the sheet's edge, fading out toward the window edge (continues the sheet's top line) */
  html:root[data-look] .app.side .sb::before { background: linear-gradient(90deg, transparent 0%, rgba(201,220,242,.05) 35%, var(--fr-l2) 100%) !important; }
}

/* ===== Even L, take 2: the top bar is as thick as the collapsed sidebar is wide (76px); a square 76×76 brand corner
   holds a larger flame centred in it; the long header line is replaced by a tiny centred glass dash under the brand. */
@media (min-width: 901px) {
  html:root[data-look] body.sb-mini .app.side { grid-template-columns: 76px minmax(0, 1fr) !important; --fr-sbw: 76px; }
  html:root[data-look="9"] body.sb-mini #run-bg { --sbw: 76px; }
  html:root[data-look] body.sb-mini .app.side .sb { padding-left: 10px !important; padding-right: 10px !important; }
  html:root[data-look="9"] { --fr-tb: 76px; }
  html:root[data-look] .app.side .main > .topbar { height: 76px; padding-bottom: 0; }
  html:root[data-look] .app.side :is(.tstrip, .ag-id) { top: 76px; }
  html:root[data-look] .app.side .sb .brand { height: 76px; min-height: 76px; }
  html:root[data-look] body.sb-mini .app.side .mini-mark .mm { width: 42px; height: 42px; }
  html:root[data-look] body.sb-mini .app.side .mini-mark .mm-live { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
  /* tiny centred dash instead of the long line */
  html:root[data-look] .app.side .sb::before { top: 75px !important; left: 50% !important; right: auto !important; width: 18px !important; margin-left: -9px; height: 1px; border-radius: 1px;
    background: linear-gradient(90deg, transparent, rgba(214,234,255,.55), transparent) !important; box-shadow: 0 0 6px rgba(127,184,255,.35); }
}
/* How keeps fitting under the 76px bar in short windows */
@media (min-width: 1251px) and (max-height: 840px) {
  html:root[data-look] .app.side .page.how { padding-top: 2px; gap: 5px; }
}
/* expanded: the dash sits under the wordmark's centre (wordmark is left-aligned with the nav) */
@media (min-width: 901px) { html:root[data-look] body:not(.sb-mini) .app.side .sb::before { left: 91px !important; } }

/* Top bar trimmed to 64px (sidebar stays 76px); brand centred on the 64px bar, dash on the bar's bottom line. */
@media (min-width: 901px) {
  html:root[data-look="9"] { --fr-tb: 64px; }
  html:root[data-look] .app.side .main > .topbar { height: 64px; }
  html:root[data-look] .app.side :is(.tstrip, .ag-id) { top: 64px; }
  html:root[data-look] .app.side .sb .brand { height: 64px; min-height: 64px; }
  html:root[data-look] .app.side .sb::before { top: 63px !important; }
}

/* Expanded: the dash scales with the brand — same proportion as under the flame (≈ 45% of the mark's width), centred
   under the RUN / NER wordmark, and it grows/shrinks smoothly with the sidebar. */
@media (min-width: 901px) {
  html:root[data-look] .app.side .sb::before { transition: left .3s ease, width .3s ease, margin-left .3s ease; }
  html:root[data-look] body:not(.sb-mini) .app.side .sb::before { left: 91px !important; width: 56px !important; margin-left: -28px !important; }
}
/* Expanded: the line runs the full width of the wordmark, from the first R to the last R, soft only at its very ends. */
@media (min-width: 901px) {
  html:root[data-look] body:not(.sb-mini) .app.side .sb::before { left: 29px !important; width: 124px !important; margin-left: 0 !important;
    background: linear-gradient(90deg, rgba(214,234,255,0), rgba(214,234,255,.5) 10%, rgba(214,234,255,.55) 50%, rgba(214,234,255,.5) 90%, rgba(214,234,255,0)) !important; }
}

/* expanded sidebar: no line under the wordmark; Search Runners' top edge sits exactly on the top-bar line (64px)
   so the frame line runs straight into it. Collapsed keeps the small centred dash under the flame. */
@media (min-width: 901px) {
  html:root[data-look] .app.side .sb::before { transition: left .3s ease, width .3s ease, margin-left .3s ease, opacity .25s ease !important; }
  html:root[data-look] body:not(.sb-mini) .app.side .sb::before { opacity: 0 !important; }
  html:root[data-look] body:not(.sb-mini) .app.side .sb .rl-q { margin-top: -12px; }
}
