/* Round 6 polish: loading states, Studio tiles, Files, Agents gutter, Settings rows, Brain and Connect second rows.
   Loaded last, so these rules win without touching app.css or the section files. Tokens come from app.css :root. */

/* ---------- shared: a surface card with a soft inner highlight and a 1px top light edge ---------- */
.sp-surface, .br-card, .br-latest, .br-state, .cx-intro, .cx-keys, .cx-form, .cx-reveal { position: relative;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .09), inset 0 0 0 1px rgb(255 255 255 / .025), 0 1px 2px rgb(0 0 0 / .4), 0 18px 48px rgb(0 0 0 / .45); }
.sp-surface::before, .br-card::after, .br-latest::before, .br-state::before, .cx-intro::before, .cx-keys::before, .cx-form::before, .cx-reveal::before {
  content: ""; position: absolute; inset: 0 var(--s4) auto; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / .22), transparent); }

/* ---------- Home: Studio cards that did not answer ---------- */
.hnoans { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3) var(--s3); color: var(--dim); font-size: var(--fs-sm); }
.hretry { min-height: 44px; padding-inline: var(--s4); flex: none; }
.hphead .hseeall { color: var(--dim); font-weight: 600; }
@media (hover: hover) { .hphead .hseeall:hover { color: var(--ink); } }

/* ---------- Studio review tiles: one box, one fallback ---------- */
.st-thumbs { align-items: start; }
.st-rv .st-thumb.poster { aspect-ratio: 9 / 16; position: relative; overflow: hidden; display: block; padding: 0; border-radius: var(--r-md);
  background: radial-gradient(120% 80% at 18% 0%, hsl(var(--ph, 30) 55% 46% / .38), transparent 62%), linear-gradient(160deg, hsl(var(--ph, 30) 22% 17%), hsl(var(--ph, 30) 16% 9%));
  box-shadow: inset 0 0 0 1px hsl(var(--ph, 30) 30% 80% / .12); }
.st-rv .st-fb { position: absolute; inset: 0; display: grid; place-items: center; }
.st-rv .st-vglyph { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: hsl(var(--ph, 30) 60% 82%);
  background: hsl(var(--ph, 30) 30% 100% / .07); box-shadow: inset 0 0 0 1px hsl(var(--ph, 30) 40% 80% / .16); }
.st-rv .st-vglyph svg { width: 22px; height: 22px; }
.st-rv .st-thumb.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 260ms var(--ease, ease), transform 240ms var(--ease, ease); }
.st-rv .st-thumb.poster.loaded img { opacity: 1; }
.st-rv .st-thumb.poster.loaded .st-fb { visibility: hidden; }
.st-rv .st-thumb.poster .st-dur { position: absolute; top: auto; bottom: 8px; right: 8px; z-index: 2; background: rgb(0 0 0 / .6); color: #fff; padding: 2px 7px; border-radius: 6px; }
.st-rv .st-thumb.poster::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; pointer-events: none; z-index: 1; background: linear-gradient(to top, rgb(0 0 0 / .55), transparent); }
.st-rv .st-rvmeta { min-height: calc(2 * 1.35em + 2px + 1.4em + var(--s2)); }
.st-rv .st-rvtitle { min-height: calc(2 * 1.35em); }
@media (max-width: 760px) { .st-thumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); } }
@media (prefers-reduced-motion: reduce) { .st-rv .st-thumb.poster img { transition: none; } }

/* ---------- Files: full-width rows, aligned gutters, drop zone, recent strip ---------- */
.sec-files .fx-crumbs { padding-inline: calc(var(--pgpad) - var(--s2)); }
.sec-files .fx-body { padding-inline: var(--pgpad); }
.sec-files .fx-items.list, .sec-files .fx-resulthead { max-width: none; width: 100%; }
.sec-files .fx-items.list { margin-inline: calc(var(--s3) * -1); width: calc(100% + 2 * var(--s3)); }
.sec-files .fx-item { border-radius: var(--r-md); }
@media (min-width: 761px) {
  .sec-files .list .fx-main { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .sec-files .list .fx-meta { margin-left: auto; justify-content: flex-end; }
}
.sec-files .fx-cam { display: none; }
.sec-files .fx-dz { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: var(--s3); align-items: center; text-align: left; width: 100%; min-height: 88px;
  margin-top: var(--s4); padding: var(--s4); border-radius: var(--r-lg); border: 1.5px dashed rgb(10 132 255 / .38); color: var(--dim);
  background: linear-gradient(180deg, rgb(255 255 255 / .035), transparent); transition: border-color 160ms var(--ease, ease), background-color 160ms var(--ease, ease), transform 120ms var(--ease, ease); }
.sec-files .fx-dz:active { transform: scale(.995); }
.sec-files .fx-dz:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) { .sec-files .fx-dz:hover { border-color: rgb(10 132 255 / .7); background-color: rgb(10 132 255 / .06); } }
.sec-files .fx-dzic { grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--accent);
  background: rgb(10 132 255 / .1); box-shadow: inset 0 0 0 1px rgb(10 132 255 / .22); }
.sec-files .fx-dzic svg.i { width: 22px; height: 22px; }
.sec-files .fx-dztxt { color: var(--ink); font-weight: 600; align-self: end; }
.sec-files .fx-dztxt b { color: var(--accent); }
.sec-files .fx-dzsub { font-size: var(--fs-xs); align-self: start; }
.sec-files .fx-recent { margin-top: var(--s5); }
.sec-files .fx-recenth { margin: 0 0 var(--s2); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.sec-files .fx-recentrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s3); }
.sec-files .fx-rc { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s3); text-align: left; border-radius: var(--r-md);
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgb(255 255 255 / .06); min-width: 0; transition: background-color 120ms var(--ease, ease), transform 120ms var(--ease, ease); }
.sec-files .fx-rc:active { transform: scale(.985); }
.sec-files .fx-rc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .sec-files .fx-rc:hover { background: var(--raise); } }
.sec-files .fx-rcic { flex: none; width: 36px; height: 36px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--dim); background: var(--raise); }
.sec-files .fx-rcic svg.i { width: 18px; height: 18px; }
.sec-files .fx-rctx { min-width: 0; display: flex; flex-direction: column; }
.sec-files .fx-rctx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sec-files .fx-rctx span { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .sec-files .fx-crumbs { padding-inline: calc(var(--gut) - var(--s2)); }
  .sec-files .fx-body { padding-inline: var(--gut); }
  .sec-files .fx-cam { display: inline-grid; }
  .sec-files .iconbtn, .sec-files .fx-head .fx-ghost, .sec-files .fx-head .fx-primary { min-height: 44px; height: 44px; }
  .sec-files .iconbtn { width: 44px; }
  .sec-files .fx-head .fx-ghost, .sec-files .fx-head .fx-primary { width: 44px; padding: 0; }
  .sec-files .fx-head .fx-primary .fx-btxt { display: none; }
  .sec-files .fx-tab { min-height: 44px; }
  .sec-files .fx-search { min-height: 44px; }
  .sec-files .fx-crumb { min-height: 44px; }
  .sec-files .fx-up { width: 44px; height: 44px; min-height: 44px; }
  .sec-files .fx-recentrow { grid-template-columns: minmax(0, 1fr); }
  .sec-files .fx-dz { min-height: 96px; }
}

/* ---------- Agents: top bar on the shared gutter, phone model chip ---------- */
.sec-agents .ag-head { padding-left: var(--gut); padding-right: max(var(--gut), calc((100vw - var(--rail) - var(--pgmax)) / 2)); }
.sec-agents .ag-titlewrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sec-agents .ag-kicker { display: none; }
.sec-agents .ag-chip, .sec-agents .ag-menu { display: none; }
@media (max-width: 760px) {
  .sec-agents .ag-head { padding-left: var(--s2); padding-right: var(--gut); flex-wrap: nowrap; row-gap: 0; gap: var(--s1); }
  .sec-agents .ag-kicker { display: block; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); line-height: 1.1; }
  .sec-agents .ag-title { font-size: var(--fs-md); line-height: 1.25; }
  .sec-agents .ag-seg { display: none; }
  .sec-agents .ag-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 var(--s3); border-radius: 999px; flex: none; font-weight: 700; font-size: var(--fs-sm);
    color: var(--accent); background: rgb(10 132 255 / .12); box-shadow: inset 0 0 0 1px rgb(10 132 255 / .25); }
  .sec-agents .ag-chip[hidden] { display: none; }
  .sec-agents .ag-chipchev { width: 14px; height: 14px; transition: transform 160ms var(--ease, ease); }
  .sec-agents .ag-chip[aria-expanded="true"] .ag-chipchev { transform: rotate(180deg); }
  .sec-agents .ag-menu { display: flex; flex-direction: column; position: absolute; right: var(--gut); top: calc(100% - var(--s1)); z-index: 12; min-width: 220px; padding: var(--s1); border-radius: var(--r-md); background: var(--solid); animation: sheetin 160ms var(--ease); }
  .sec-agents .ag-menu[hidden] { display: none; }
  .sec-agents .ag-menu button { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 52px; padding: 0 var(--s3); border-radius: var(--r-sm); text-align: left; color: var(--ink); }
  .sec-agents .ag-menu button.on { background: rgb(10 132 255 / .1); color: var(--accent); }
  .sec-agents .ag-menu button svg.i { width: 18px; height: 18px; flex: none; }
  .sec-agents .ag-mtx { display: flex; flex-direction: column; }
  .sec-agents .ag-mtx span { font-size: var(--fs-xs); }
  .sec-agents .ag-head { position: relative; }
}

/* ---------- Settings: one trailing control per row ---------- */
.setgroup .setrow { min-height: 56px; gap: var(--s3); }
.setgroup .setlabs { display: flex; flex-direction: column; min-width: 0; }
.setgroup .setlabs b { font-weight: 600; }
.setgroup .setlab { min-width: 0; font-weight: 600; }
.setgroup .settap { cursor: pointer; border-radius: var(--r-md); }
.setgroup .pillbtn.setchev { display: inline-grid; place-items: center; width: 44px; min-height: 44px; padding: 0; background: transparent; color: var(--faint); flex: none; }
.setgroup .pillbtn.setchev svg { width: 20px; height: 20px; }
@media (hover: hover) { .setgroup .settap:hover .setchev { color: var(--ink); } }
.setgroup .devrow .tag.src { margin-left: 0; font-weight: 600; color: var(--faint); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.setgroup .devrow .dact .pillbtn, .setgroup .devrow .dact select { min-height: 44px; }
.setgroup .devrow .dact .pillbtn { padding-inline: var(--s4); }
#setDevice { color: var(--dim); }

/* ---------- Brain: equal-height columns, a quiet second row ---------- */
.br-grid { align-items: stretch; }
.br-main > .br-state { flex: 1; justify-content: center; }
.br-side { position: relative; top: auto; }
.br-recent { margin-top: var(--s5); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); border-radius: var(--r-lg); }
.br-rhead { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.br-rhead h3 { margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.br-rempty { margin: 0; color: var(--dim); font-size: var(--fs-sm); }
.br-rlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); }
.br-ritem { display: flex; flex-direction: column; gap: 2px; padding: var(--s3); border-radius: var(--r-md); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.br-rtext { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.br-rmeta { font-size: var(--fs-xs); color: var(--faint); }
@media (max-width: 760px) { .br-side { position: static; } .br-rlist { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Connect: equal-height columns, sample setup row ---------- */
.sec-connect .cx-body { align-items: stretch; }
.sec-connect .cx-col > .cx-keys { flex: 1; }
.sec-connect .cx-setup { grid-column: 1 / -1; padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); border-radius: var(--r-lg); }
.sec-connect .cx-sethead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.sec-connect .cx-sethead h3 { margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.sec-connect .cx-setnote { font-size: var(--fs-xs); color: var(--faint); }
.sec-connect .cx-setblocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s3); }
@media (max-width: 760px) { .sec-connect .cx-setup { padding: var(--s4); } .sec-connect .cx-setblocks { grid-template-columns: minmax(0, 1fr); } }

/* Den glass (round 7): something to see through, and a real glass material on every surface.
   A web approximation of Apple's materials (backdrop-filter + a masked gradient rim + highlights + shadows), not an
   Apple asset. It sits at the end of sections-polish.css (the last stylesheet), so it wins without editing the section files
   and needs no new file in the service worker's shell.
   Layers, bottom to top:
     .ambient (index.html)  warm light fields + the logo's halo arc + grain, fixed behind the app, drifting 60-120 s
     thin glass             rail / phone tab bar / section headers / chat columns / call bar: thin tint, high blur
     card glass             Home cards, Calendar, Studio, Files, Ops, Agents, Brain, Connect, call tiles + controls
     thick glass            Settings, Voice & video, More sheet, menus, dialogs: heavy blur + enough tint for AA
   Chromium adds an SVG refraction (#den-liquid) to the tab bar and the call controls (html.liquid, set by
   the glass block at the end of polish.js); Safari / iOS keep the plain blur. No backdrop-filter: solid warm panels (bottom of this file). */

/* ---------- tokens ---------- */
@property --sheen { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --mx { syntax: "<length-percentage>"; inherits: true; initial-value: 50%; }
@property --my { syntax: "<length-percentage>"; inherits: true; initial-value: -60%; }
:root {
  /* grain: an 160px tile of fine fractal noise, light specks at 2-4% (inline SVG, no request) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .88 .11 0 0 0 -.03'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  /* the rim: 1px light that catches the top-left corner and fades round the sides */
  --rim: linear-gradient(140deg, rgb(255 255 255 / .30) 0%, rgb(255 255 255 / .12) 18%, rgb(255 255 255 / .05) 42%, rgb(255 255 255 / .03) 70%, rgb(255 255 255 / .09) 100%);
  --spec: linear-gradient(180deg, rgb(255 255 255 / .065) 0, rgb(255 255 255 / .02) 28px, rgb(255 255 255 / 0) 64px);
  --sheen-rgb: 255 240 214;

  --glass-thin-tint: rgb(12 12 16 / .5);
  --glass-thin-blur: 26px;
  --glass-thin-filter: blur(var(--glass-thin-blur)) saturate(175%) brightness(1.04);
  --glass-card-tint: rgb(26 26 30 / .42);
  --glass-card-blur: 18px;
  --glass-card-filter: blur(var(--glass-card-blur)) saturate(165%) brightness(1.05);
  --glass-thick-tint: rgb(20 20 24 / .64);
  --glass-thick-blur: 40px;
  --glass-thick-filter: blur(var(--glass-thick-blur)) saturate(170%) brightness(1.04);

  --glass-in: inset 0 1px 0 rgb(255 255 255 / .09), inset 0 -18px 24px -22px rgb(0 0 0 / .6);
  --glass-out-card: 0 1px 1px rgb(0 0 0 / .3), 0 22px 56px -16px rgb(0 0 0 / .72);
  --glass-out-thick: 0 1px 1px rgb(0 0 0 / .35), 0 30px 90px -10px rgb(0 0 0 / .8);

  /* older tokens now point at the tiers, so anything still using them matches */
  --glass: var(--glass-card-tint); --glass-2: var(--glass-thick-tint); --blur: var(--glass-card-filter);
  --sheet-solid: var(--glass-thick-tint);
}

/* ---------- 1. the ambient layer: something behind the glass ---------- */
body::before { content: none; }   /* the old static aurora; the ambient's halo replaces it */
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.ambient > i { position: absolute; display: block; border-radius: 50%; will-change: transform; }
/* warm light fields: amber high right, copper low left, a cream wash low right. Each one's peak stays well under
   the AA ceiling for --faint text sitting straight on it (tested in e2e-glass). */
.ambient .b1 { width: 78vmax; height: 78vmax; right: -30vmax; top: -34vmax;
  background: radial-gradient(closest-side, rgb(10 132 255 / .13), rgb(10 132 255 / .065) 45%, rgb(10 132 255 / .025) 72%, transparent);
  animation: am-a 96s linear infinite alternate; animation-timing-function: steps(384); }
.ambient .b2 { width: 70vmax; height: 70vmax; left: -28vmax; bottom: -36vmax;
  background: radial-gradient(closest-side, rgb(191 90 242 / .16), rgb(191 90 242 / .07) 50%, transparent);
  animation: am-b 118s linear infinite alternate; animation-timing-function: steps(472); }
.ambient .b3 { width: 56vmax; height: 56vmax; right: -12vmax; bottom: -30vmax;
  background: radial-gradient(closest-side, rgb(255 255 255 / .07), rgb(255 255 255 / .025) 55%, transparent);
  animation: am-c 74s linear infinite alternate; animation-timing-function: steps(296); }
/* the logo's halo: one thin luminous arc low across the top, fading out at both ends. Crisp on bare black,
   softened wherever a glass panel crosses it, which is how you can tell the panels are glass. */
.ambient .halo { width: 150vw; height: 96vh; left: -25vw; top: -58vh;
  background:
    radial-gradient(closest-side, transparent 97.6%, rgb(100 170 255 / .15) 99.1%, rgb(100 170 255 / .05) 99.7%, transparent 100%),
    radial-gradient(closest-side, transparent 86%, rgb(10 132 255 / .045) 97%, transparent 100.2%);
  -webkit-mask-image: linear-gradient(90deg, transparent 8%, #000 34%, #000 66%, transparent 92%);
  mask-image: linear-gradient(90deg, transparent 8%, #000 34%, #000 66%, transparent 92%);
  animation: am-h 88s linear infinite alternate; animation-timing-function: steps(352); }
/* grain over the whole ambient, fixed, never on a scrolling box */
.ambient::after { content: ""; position: absolute; inset: 0; background: var(--grain) 0 0 / 160px 160px; opacity: .8; }
/* stepped at ~4 updates a second: the drift is far below a pixel per step, so it still reads as continuous, but the
   glass above only re-blurs 4 times a second instead of 60 */
@keyframes am-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-9vw, 7vh, 0) scale(1.08); } }
@keyframes am-b { from { transform: translate3d(0, 0, 0) scale(1.04); } to { transform: translate3d(11vw, -8vh, 0) scale(.96); } }
@keyframes am-c { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-8vw, -6vh, 0); } }
@keyframes am-h { from { transform: translate3d(-2vw, 0, 0) rotate(-1.2deg); } to { transform: translate3d(2vw, 2.5vh, 0) rotate(1.2deg); } }
@media (prefers-reduced-motion: reduce) { .ambient > i { animation: none !important; will-change: auto; } }
/* phone: the arc sits high, mostly behind the frosted section header, so it glows through the header's blur */
@media (max-width: 760px) {
  .ambient .halo { width: 230vw; left: -65vw; height: 42vh; top: -36vh; }
  .ambient .b1 { right: -44vmax; top: -40vmax; }
}

/* ---------- 2. the material ---------- */
/* hosts the rim and sheen are positioned against (zero specificity: any real position rule wins) */
:where(.glass, .jcard, .composer, .controls, .sheet, .popover, .txpanel, .rail, .sechead, .mainhead, .side, .members, .ctlmenu) { position: relative; }

/* the shared fill: pointer sheen, top specular, grain, then the tier's tint */
.glass, .jcard, .composer, .controls, .tiles .tile, .popover, .toast, .txpanel, .autofocus, .netbar, .sec-agents .ag-menu,
.sheetwrap .sheet, .sheetwrap .sheet.mediasheet, .moresheet .sheet, .moresheet .sheet.moresheetbody, .ctlmenu, .sec-files .fx-preview, .sec-files .fx-dlg,
.sec-files .fx-dock, .sec-files .fx-menu {
  --tint: var(--glass-card-tint);
  background:
    radial-gradient(320px circle at var(--mx) var(--my), rgb(var(--sheen-rgb) / calc(var(--sheen) * .055)), transparent 70%),
    var(--spec), var(--grain) 0 0 / 160px 160px, var(--tint);
  border: 1px solid transparent;
  -webkit-backdrop-filter: var(--glass-card-filter); backdrop-filter: var(--glass-card-filter);
  box-shadow: var(--glass-in), var(--glass-out-card);
  transition: --sheen 240ms var(--ease), transform 160ms var(--ease), opacity 200ms var(--ease);
}
/* the rim: a masked 1px gradient ring (+ the pointer's sheen running along it on desktop) */
.glass::after, .jcard::after, .composer::after, .controls::after, .tiles .tile::before, .popover::after, .toast::after, .txpanel::after,
.sheetwrap .sheet::after, .moresheet .sheet::after, .ctlmenu::after, .sec-agents .ag-menu::after,
.sec-files .fx-preview::after, .sec-files .fx-dlg::after, .sec-files .fx-dock::after, .sec-files .fx-menu::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2; padding: 1px;
  background: radial-gradient(200px circle at var(--mx) var(--my), rgb(var(--sheen-rgb) / calc(var(--sheen) * .5)), transparent 70%), var(--rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  height: auto; width: auto; transform: none; opacity: 1;
}
/* glass inside glass would only see its parent: keep the tint, drop the second blur (also halves the layer count) */
:is(.glass, .sheet, .ctlmenu, .controls, .jcard, .sec-files .fx-preview) :is(.glass, .tile) { -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: var(--glass-in); }
/* a glass box that scrolls sideways can't host an absolute rim (it would scroll away): its rim is an inset line */
.cal-wrap.glass::after { content: none; }
.cal-wrap.glass { box-shadow: inset 1px 1px 0 rgb(255 255 255 / .14), inset -1px -1px 0 rgb(255 255 255 / .04), var(--glass-in), var(--glass-out-card); }

/* ---------- tiers ---------- */
/* thin: bars and columns. High blur, thin tint, a single lit edge instead of a ring */
.rail, .sechead, .mainhead, .sec-agents .ag-head, .side, .members, .sec-agents .ag-side {
  background: var(--spec), var(--grain) 0 0 / 160px 160px, var(--glass-thin-tint);
  -webkit-backdrop-filter: var(--glass-thin-filter); backdrop-filter: var(--glass-thin-filter);
  border-color: transparent;
}
.sechead, .mainhead, .sec-agents .ag-head { background: var(--grain) 0 0 / 160px 160px, var(--glass-thin-tint); box-shadow: 0 10px 30px -18px rgb(0 0 0 / .8); }
.rail::after, .sechead::after, .mainhead::after, .side::after, .members::after {
  content: ""; position: absolute; pointer-events: none; z-index: 1; }
/* lit hairlines: the header's bottom edge, the rail's right edge, the tab bar's top edge (brightest at the left) */
.sechead::after, .mainhead::after { left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, rgb(255 255 255 / .16), rgb(255 255 255 / .07) 40%, rgb(255 255 255 / .03)); }
.rail::after, .side::after { top: 0; bottom: 0; right: -1px; width: 1px;
  background: linear-gradient(180deg, rgb(255 255 255 / .2), rgb(255 255 255 / .07) 30%, rgb(255 255 255 / .03)); }
.members::after { top: 0; bottom: 0; left: -1px; width: 1px; background: linear-gradient(180deg, rgb(255 255 255 / .12), rgb(255 255 255 / .03)); }
.rail { box-shadow: 18px 0 48px -30px rgb(0 0 0 / .9); }
.callbar { background: var(--spec), var(--grain) 0 0 / 160px 160px, var(--glass-thin-tint); border: 1px solid transparent;
  -webkit-backdrop-filter: var(--glass-thin-filter); backdrop-filter: var(--glass-thin-filter);
  box-shadow: var(--glass-in), var(--glass-out-card); }
.callbar::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px; background: var(--rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }

/* card: everything else in the page (the shared fill above is the card tier) */
.controls { --tint: var(--glass-card-tint); }
.tiles .tile { --tint: var(--glass-card-tint);
  background: radial-gradient(120% 80% at 50% 0%, rgb(10 132 255 / .08), transparent 62%),
    radial-gradient(320px circle at var(--mx) var(--my), rgb(var(--sheen-rgb) / calc(var(--sheen) * .055)), transparent 70%),
    var(--spec), var(--grain) 0 0 / 160px 160px, var(--tint); }
.tiles .tile::before { z-index: 2; }

/* thick: sheets, menus and dialogs. Heavy blur, a deep tint (text stays AA whatever is behind), a light rim */
.sheetwrap .sheet, .sheetwrap .sheet.mediasheet, .moresheet .sheet, .moresheet .sheet.moresheetbody, .ctlmenu, .popover, .sec-agents .ag-menu,
.sec-files .fx-preview, .sec-files .fx-dlg, .sec-files .fx-menu {
  --tint: var(--glass-thick-tint);
  -webkit-backdrop-filter: var(--glass-thick-filter); backdrop-filter: var(--glass-thick-filter);
  box-shadow: var(--glass-in), var(--glass-out-thick);
}
.sheetfoot { background: linear-gradient(180deg, rgb(20 20 24 / 0), rgb(20 20 24 / .6) 40%); }
/* the scrim dims without blurring: a blurred scrim would be the sheet's backdrop root and the sheet would have
   nothing to see through. The sheet does the blurring. */
.sheetwrap, .moresheet { background: rgb(0 0 0 / .52); -webkit-backdrop-filter: none; backdrop-filter: none; }
/* the More scrim fades in with an opacity animation; held at its end with fill-mode "both" it would stay an opacity
   group, which walls the sheet off from the page (the sheet would blur only the scrim). Let it end cleanly. */
.moresheet { animation-fill-mode: none; }
@media (min-width: 761px) { #mediaSheet.sheetwrap { background: rgb(0 0 0 / .32); } }
.toast, .netbar { --tint: var(--glass-thick-tint); }

/* ---------- primary buttons: amber gel (opaque on purpose: the one CTA stays solid amber and AA) ---------- */
.primary, .pillbtn.go, .sendbtn {
  background: linear-gradient(180deg, rgb(255 255 255 / .38), rgb(255 255 255 / 0) 52%), linear-gradient(0deg, rgb(0 40 110 / .22), rgb(0 40 110 / 0) 45%), var(--go);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .55), inset 0 -1px 0 rgb(0 30 90 / .35), 0 1px 2px rgb(0 0 0 / .35), 0 6px 16px -8px rgb(10 90 200 / .55);
}

/* ---------- 3. touch: press compresses, desktop hover gets a pointer sheen ---------- */
.glass:is(a, button, [role="button"]):active, .tiles .tile:active, .railbtn:active, .morerow:active, .ctl:active, .primary:active, .pillbtn:active, .sendbtn:active {
  transform: scale(.97); transition-duration: 140ms; }
.tiles .tile:active { transform: scale(.99); }
.railbtn, .morerow, .ctl { transition: transform 160ms var(--ease), background-color 200ms var(--ease), color 200ms var(--ease); }
html.sheen .lit { --sheen: 1; }
html.sheen :is(.glass, .tiles .tile, .jcard, .controls, .sheet):not(.lit) { --sheen: 0; }
@media (prefers-reduced-motion: reduce) {
  .glass, .tiles .tile, .controls, .sheet { transition: none; }
}

/* ---------- liquid refraction (Chromium, progressive): an SVG displacement lens on the tab bar and call controls ---------- */
html.liquid .controls { -webkit-backdrop-filter: url(#den-liquid) blur(12px) saturate(170%) brightness(1.05); backdrop-filter: url(#den-liquid) blur(12px) saturate(170%) brightness(1.05); }
@media (max-width: 760px) {
  html.liquid .rail { backdrop-filter: url(#den-liquid) blur(14px) saturate(175%) brightness(1.04); }
  html.liquid .callbar { backdrop-filter: url(#den-liquid) blur(14px) saturate(175%) brightness(1.04); }
}
.fxdefs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

/* ---------- 4. phone: the tab bar is glass with the page scrolling underneath it ---------- */
@media (max-width: 760px) {
  .rail { background: var(--grain) 0 0 / 160px 160px, rgb(12 12 16 / .58); border-top-color: transparent; box-shadow: 0 -12px 32px -20px rgb(0 0 0 / .9); }
  .rail::after { top: -1px; left: 0; right: 0; bottom: auto; width: auto; height: 1px;
    background: linear-gradient(90deg, rgb(255 255 255 / .05), rgb(255 255 255 / .2) 30%, rgb(255 255 255 / .08) 75%, rgb(255 255 255 / .04)); }
  /* scrolling sections run under the tab bar (their own bottom padding keeps the last card clear of it); chat and
     agents keep their composer above it */
  :root .sections { padding-bottom: 0; }
  #app, #sec-agents { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .sections > .section:not(#app):not(#sec-agents) { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + var(--s5)); }
  /* layer budget (<= 6 blurs on screen): on a phone the in-page cards are tinted glass without their own blur. What
     sits behind them is only the soft light fields (blurring those changes nothing you can see); the real blur is
     where content actually passes behind glass: the header, the tab bar, the call bar, the controls and the sheets. */
  .glass, .jcard, .composer, .txpanel, .autofocus, .tiles .tile { -webkit-backdrop-filter: none; backdrop-filter: none; --tint: rgb(26 26 30 / .56); }
  /* the phone More sheet: same thick glass, straight off the tab bar */
  .moresheet .sheet { background: var(--spec), var(--grain) 0 0 / 160px 160px, var(--glass-thick-tint); }
}

/* ---------- 5. no backdrop-filter, or the viewer asked for less transparency: solid warm panels ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-thin-tint: #0e0e11; --glass-card-tint: #151518; --glass-thick-tint: #1c1c20; --panel: #151518; --glass: #151518; --glass-2: #1c1c20; }
  .rail, .sechead, .mainhead, .sec-agents .ag-head, .side, .members, .callbar { background-color: #0e0e11; }
  .glass, .jcard, .composer, .controls, .tiles .tile, .txpanel, .autofocus { background-color: #151518; }
  .sheetwrap .sheet, .moresheet .sheet, .ctlmenu, .popover, .toast, .netbar, .sec-files .fx-preview, .sec-files .fx-dlg, .sec-files .fx-menu, .sec-files .fx-dock { background-color: #1c1c20; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-thin-tint: #0e0e11; --glass-card-tint: #151518; --glass-thick-tint: #1c1c20; }
  .rail, .sechead, .mainhead, .side, .members, .callbar { background-color: #0e0e11; }
}
