/*
  Caelion workspace · v4 (Fable 5.2) · the three native systems

  The same markup, re-read the way each platform would build it.

    Material 3   tinted window, content in a rounded pane, pills, tonal fills, state layers,
                 an extended FAB for the agent, connected button groups, ripples (ripple.js)
    Fluent 2     Mica window, content on a layer with one rounded corner, 4px controls with a
                 firmer bottom edge, a 3px selection pill, Acrylic flyouts
    Liquid Glass plain content, and above it a navigation layer made of glass that bends what
                 passes underneath (glass.js), capsules and continuous corners
*/

/* ========================================================================================
   Material 3
   ======================================================================================== */

:root[data-layout="v5"][data-ds="material"] {
  --r-field: 4px;

  .work-area {
    margin: 0 var(--frame) 0 0;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /* the content pane */
  .workspace-content {
    max-width: none;
    min-height: calc(100dvh - var(--top-h) - var(--frame));
    margin-bottom: var(--frame);
    padding-inline: max(var(--pad), calc((100% - 1380px) / 2));
    border-radius: var(--r-pane);
    background: var(--s-base);
  }

  .v4-top {
    top: 0;
    margin: 0;
    padding: 0 4px 0 0;
    border: 0;
    border-radius: 0;
    background: var(--s-frame);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* the pane keeps its rounded shoulders while the page scrolls under the bar */
  .v4-top::before,
  .v4-top::after {
    top: 100%;
  }

  .v4-top::before {
    left: 0;
    background: radial-gradient(circle at 100% 100%, transparent calc(var(--r-pane) - .5px), var(--s-frame) var(--r-pane));
  }

  .v4-top::after {
    right: 0;
    background: radial-gradient(circle at 0 100%, transparent calc(var(--r-pane) - .5px), var(--s-frame) var(--r-pane));
  }

  /* Sidebar: a navigation drawer */
  .v4-rail {
    padding: 14px 12px 12px;
  }

  .v4-rail-head {
    padding: 0 4px 0 12px;
    margin-bottom: 10px;
  }

  .v4-wordmark {
    font-stretch: 112%;
    letter-spacing: .08em;
  }

  .v4-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }

  .v4-fold {
    width: 40px;
    height: 40px;
    color: var(--t-2);
  }

  .v4-fab {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: max-content;
    max-width: 100%;
    height: 56px;
    margin: 2px 0 14px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 16px;
    background: var(--m-pri-c);
    color: var(--m-on-pri-c);
    box-shadow: var(--sh-3);
    font: 600 .9rem/1 var(--font-ui);
    letter-spacing: .006em;
    transition: box-shadow var(--d-2) var(--e-inout), border-radius var(--d-2) var(--e-inout), transform var(--d-2) var(--e-inout);
  }

  .v4-fab .trigger-mark {
    width: 24px;
    height: 24px;
  }

  .v4-fab:active {
    border-radius: 12px;
    box-shadow: var(--sh-2);
  }

  .v4-ask {
    display: none;
  }

  .v4-company > summary,
  .v4-account > summary,
  .v4-dock {
    min-height: 56px;
    padding: 8px 12px;
    border-radius: 28px;
  }

  .v4-company .company-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--a-fill);
    box-shadow: none;
  }

  .v4-account .avatar {
    width: 36px;
    height: 36px;
    background: var(--m-ter-c);
    color: var(--m-on-ter-c);
  }

  .v4-nav-label,
  .v4-group > summary {
    min-height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    font-size: .84rem;
    font-weight: 560;
    letter-spacing: .006em;
    color: var(--t-2);
  }

  .v4-group + .v4-group,
  .v4-pins + .v4-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--b-0);
  }

  .v4-list {
    gap: 0;
  }

  .v4-list a {
    gap: 12px;
    padding: 0 20px 0 16px;
    font-size: .875rem;
    font-weight: 520;
    letter-spacing: .006em;
    color: var(--t-2);
  }

  .v4-list a .icon {
    width: 22px;
    height: 22px;
    color: var(--t-2);
  }

  .v4-list a[aria-current="page"] {
    color: var(--m-on-sec);
    font-weight: 650;
  }

  .v4-list a[aria-current="page"]::before {
    background: var(--m-sec);
    box-shadow: none;
  }

  .v4-list a[aria-current="page"] .icon {
    color: var(--m-on-sec);
  }

  .v4-pin {
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }

  .v4-rail-foot {
    border-top-color: var(--b-0);
  }

  .v4-count,
  .attention-row .count {
    background: var(--m-ter-c);
    color: var(--m-on-ter-c);
  }

  /* Top bar: the search bar */
  .v4-crumb {
    flex: 0 0 auto;
    order: 2;
    display: none;
  }

  .v4-command {
    flex: 1 1 auto;
    max-width: 720px;
    height: calc(var(--h-ctl) + 8px);
    padding: 0 10px 0 18px;
    gap: 14px;
    border: 0;
    border-radius: 999px;
    background: var(--s-2);
    box-shadow: none;
    color: var(--t-2);
    font-size: .95rem;
  }

  .v4-command .icon {
    width: 20px;
    height: 20px;
    color: var(--t-1);
  }

  .v4-command kbd {
    border: 0;
    border-radius: 8px;
    background: var(--s-well);
    padding: 4px 8px;
    color: var(--t-2);
  }

  .v4-top-actions {
    flex: 1 0 auto;
    gap: 4px;
  }

  /* Buttons: filled, tonal, outlined */
  .btn,
  .small-btn {
    padding: 0 24px;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 600;
    letter-spacing: .006em;
    box-shadow: none;
    transition: background-color var(--d-2) var(--e-inout), border-radius var(--d-2) var(--e-inout), box-shadow var(--d-2) var(--e-inout), filter var(--d-2) ease;
  }

  .btn:has(> .icon:first-child) {
    padding-left: 16px;
  }

  .btn:has(> .icon:last-child) {
    padding-right: 16px;
  }

  .btn .icon {
    width: 18px;
    height: 18px;
  }

  /* M3 Expressive: pressed buttons square their corners instead of shrinking */
  .btn:active,
  .small-btn:active {
    transform: none;
    border-radius: 12px;
  }

  .btn.gold {
    border: 0;
    background: var(--a-fill);
    color: var(--a-on);
    box-shadow: none;
  }

  .btn.gold:active {
    transform: none;
    box-shadow: none;
  }

  .btn.primary {
    background: var(--m-sec);
    color: var(--m-on-sec);
    box-shadow: none;
  }

  .btn.secondary,
  .small-btn {
    border: 1px solid var(--m-outline);
    background: transparent;
    color: var(--a-ink);
    box-shadow: none;
  }

  .btn.secondary .icon {
    color: currentColor;
  }

  .small-btn,
  .btn.compact {
    padding: 0 16px;
  }

  .icon-btn {
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: var(--t-2);
  }

  /* Fields: outlined */
  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), select, textarea) {
    min-height: calc(var(--h-ctl) + 6px);
    border: 1px solid var(--m-outline);
    border-radius: var(--r-field);
    background-color: transparent;
    box-shadow: none;
  }

  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus-visible {
    border-color: var(--a-fill);
    box-shadow: inset 0 0 0 1px var(--a-fill);
  }

  /* Cards: filled */
  .panel {
    border: 0;
    background: var(--s-1);
    box-shadow: none;
  }

  .tile-icon {
    border-radius: 12px;
    background: var(--m-sec);
    color: var(--m-on-sec);
    box-shadow: none;
  }

  .badge {
    height: 24px;
    border-radius: 8px;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--b-1);
  }

  .message {
    border-radius: 12px;
  }

  th {
    font-weight: 600;
    color: var(--t-2);
  }

  /* Menus and sheets */
  .picker-options,
  .v4-quick {
    border: 0;
    background: var(--s-3);
    box-shadow: var(--sh-2);
  }

  .picker-options :is(a, button) {
    min-height: 44px;
    padding-inline: 12px;
    border-radius: 12px;
  }

  .v4-quick {
    padding: 16px;
    border-radius: 28px;
  }

  .palette {
    border: 0;
    border-radius: 28px;
    background: var(--s-2);
    box-shadow: var(--sh-3);
  }

  /* Connected button group: neighbours stay square, the chosen one rounds off */
  .v4-seg {
    gap: 2px;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .v4-seg::before {
    display: none;
  }

  .v4-seg > :is(button, a) {
    height: 40px;
    border-radius: 8px;
    background: var(--s-well);
    color: var(--t-2);
    font-weight: 600;
    transition: border-radius var(--d-3) var(--e-spring), background-color var(--d-2) ease, color var(--d-2) ease, flex-grow var(--d-3) var(--e-spring);
  }

  .v4-seg > :is(button, a):first-child {
    border-radius: 20px 8px 8px 20px;
  }

  .v4-seg > :is(button, a):last-child {
    border-radius: 8px 20px 20px 8px;
  }

  .v4-seg > :is([aria-pressed="true"], [aria-checked="true"], [aria-current="true"]),
  .v4-seg:not([data-ready]) > :is([aria-pressed="true"], [aria-checked="true"], [aria-current="true"]) {
    flex-grow: 1.25;
    border-radius: 20px;
    background: var(--m-sec);
    color: var(--m-on-sec);
    box-shadow: none;
  }

  .v4-seg > :is(button, a):active {
    border-radius: 14px;
  }

  .v4-systems > button {
    border: 0;
    border-radius: 16px;
    background: var(--s-well);
  }

  .v4-systems > button[aria-checked="true"] {
    background: var(--m-sec);
    color: var(--m-on-sec);
    box-shadow: none;
  }

  .v4-quick-more {
    border-top: 0;
    border-radius: 999px;
    margin: 12px 0 0;
    padding-inline: 14px;
  }

  /* Ripple (ripple.js) */
  .v4-ripple-host {
    position: relative;
    overflow: hidden;
  }

  .v4-ripple {
    position: absolute;
    z-index: 0;
    border-radius: 50%;
    background: currentColor;
    opacity: .12;
    pointer-events: none;
    transform: scale(0);
    animation: v4-ripple 420ms var(--e-inout) forwards;
  }

  .v4-ripple.is-out {
    transition: opacity 260ms linear;
    opacity: 0;
  }
}

@keyframes v4-ripple {
  to { transform: scale(1) }
}

@media (hover: hover) and (pointer: fine) {
  :root[data-layout="v5"][data-ds="material"] {
    .v4-fab:hover {
      box-shadow: var(--sh-4);
    }

    .btn.gold:hover {
      filter: none;
      background: color-mix(in oklch, var(--a-fill) 92%, var(--a-on));
      box-shadow: var(--sh-1);
    }

    .btn.primary:hover {
      background: color-mix(in oklch, var(--m-sec) 92%, var(--m-on-sec));
      box-shadow: var(--sh-1);
    }

    .btn.secondary:hover,
    .small-btn:hover {
      border-color: var(--m-outline);
      background: color-mix(in oklch, var(--a-ink) 8%, transparent);
      color: var(--a-ink);
    }

    .icon-btn:hover {
      background: var(--f-hover);
      border-color: transparent;
    }

    .v4-command:hover {
      background: color-mix(in oklch, var(--s-2) 92%, var(--t-1));
    }

    .v4-seg > :is(button, a):not([aria-pressed="true"], [aria-checked="true"]):hover {
      background: color-mix(in oklch, var(--s-well) 92%, var(--t-1));
    }
  }
}

@media (max-width: 859px) {
  :root[data-layout="v5"][data-ds="material"] {
    .work-area {
      margin: 0;
    }

    .workspace-content {
      border-radius: var(--r-pane) var(--r-pane) 0 0;
      margin-bottom: 0;
    }

    .v4-top {
      padding: 0 8px;
    }

    .v4-top::before,
    .v4-top::after {
      display: block;
    }

    .v4-command {
      flex: 1 1 auto;
      width: auto;
      justify-content: flex-start;
      padding: 0 16px;
    }

    .v4-command > span:not(.icon) {
      display: inline;
    }

    .v4-crumb {
      display: none;
    }

    .v4-fab {
      display: none;
    }
  }
}

@media (max-width: 640px) {
  :root[data-layout="v5"][data-ds="material"] {
    /* Navigation bar: the active tab sits in a pill */
    .v4-tabbar {
      min-height: 68px;
      padding-top: 8px;
      border-top: 0;
      background: var(--s-frame);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }

    .v4-tabbar :is(a, button) {
      position: relative;
      gap: 6px;
      padding-top: 5px;
      font-size: .7rem;
      font-weight: 560;
      color: var(--t-2);
    }

    .v4-tabbar :is(a, button)::before {
      content: "";
      position: absolute;
      top: 1px;
      left: 50%;
      width: 58px;
      height: 30px;
      border-radius: 15px;
      background: var(--m-sec);
      opacity: 0;
      transform: translateX(-50%) scaleX(.5);
      transition: opacity var(--d-2) ease, transform var(--d-3) var(--e-spring);
    }

    .v4-tabbar a[aria-current="page"]::before {
      opacity: 1;
      transform: translateX(-50%);
    }

    .v4-tabbar :is(a, button) > * {
      position: relative;
    }

    .v4-tabbar a[aria-current="page"] {
      color: var(--t-1);
      font-weight: 700;
    }

    .v4-tabbar a[aria-current="page"] .icon {
      color: var(--m-on-sec);
    }
  }
}

/* ========================================================================================
   Fluent 2
   ======================================================================================== */

:root[data-layout="v5"][data-ds="fluent"] {
  --r-field: 4px;
  /* Mica: an opaque base that takes a faint tint, as it would from the desktop behind it */
  --mica: radial-gradient(70vw 60vh at 100% 0, color-mix(in oklch, var(--mica-a) 70%, transparent), transparent 72%), radial-gradient(60vw 70vh at 0 100%, color-mix(in oklch, var(--mica-b) 70%, transparent), transparent 72%);
  /* Acrylic grain */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
  background: var(--mica), var(--s-frame);
  background-attachment: fixed;

  body {
    background: transparent;
  }

  .work-area {
    margin: 0;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /* the layer content sits on: one rounded corner, a hairline on the two inner edges */
  .workspace-content {
    max-width: none;
    min-height: calc(100dvh - var(--top-h));
    padding-inline: max(var(--pad), calc((100% - 1380px) / 2));
    border-left: 1px solid var(--b-1);
    border-radius: var(--r-pane) 0 0 0;
    background: color-mix(in oklch, var(--s-base) 62%, transparent);
  }

  .v4-top {
    top: 0;
    margin: 0;
    padding: 0 10px 0 4px;
    border: 0;
    border-radius: 0;
    background: var(--mica), var(--s-frame);
    background-attachment: fixed;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* the layer's top edge and corner stay put under the bar */
  .v4-top::before {
    top: 100%;
    left: 0;
    width: var(--r-pane);
    height: var(--r-pane);
    border-top: 1px solid var(--b-1);
    border-left: 1px solid var(--b-1);
    border-radius: var(--r-pane) 0 0 0;
    background: none;
    box-shadow: -3px -3px 0 3px var(--s-frame);
    clip-path: inset(-1px 0 0 -1px);
  }

  .v4-top::after {
    top: 100%;
    left: var(--r-pane);
    right: 0;
    width: auto;
    height: 1px;
    background: var(--b-1);
  }

  /* Sidebar: NavigationView pane, straight on Mica */
  .v4-rail {
    padding: 4px 4px 6px;
  }

  .v4-rail-head {
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 6px;
    min-height: 44px;
    margin-bottom: 4px;
    padding: 0 4px;
  }

  .v4-brand {
    gap: 9px;
  }

  .v4-brand-mark {
    width: 22px;
    height: 22px;
  }

  .v4-wordmark {
    font-size: .8rem;
    font-weight: 600;
    font-stretch: 110%;
    letter-spacing: .09em;
  }

  .v4-icon-btn {
    width: 40px;
    height: 36px;
    border-radius: 4px;
  }

  .v4-fold {
    width: 40px;
    height: 36px;
    color: var(--t-1);
  }

  .v4-company,
  .v4-nav,
  .v4-rail-foot {
    margin-inline: 0;
    padding-inline: 0;
  }

  .v4-company > summary,
  .v4-account > summary,
  .v4-dock {
    min-height: 44px;
    margin: 0 4px;
    width: calc(100% - 8px);
    padding: 6px 10px;
  }

  .v4-company .company-icon,
  .v4-account .avatar {
    width: 28px;
    height: 28px;
  }

  .v4-company .company-icon {
    border-radius: 4px;
    background: var(--a-fill);
    box-shadow: none;
  }

  .v4-nav-label,
  .v4-group > summary {
    min-height: 36px;
    margin: 0 4px;
    padding: 0 12px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--t-2);
  }

  .v4-list {
    gap: 2px;
  }

  .v4-list a {
    margin: 0 4px;
    gap: 14px;
    padding: 0 12px;
    font-size: .9rem;
    font-weight: 400;
    color: var(--t-1);
  }

  .v4-list a .icon {
    width: 17px;
    height: 17px;
    color: var(--t-1);
  }

  .v4-list a[aria-current="page"] {
    font-weight: 400;
    background: var(--f-selected);
  }

  /* the selection pill */
  .v4-list a[aria-current="page"]::before {
    inset: 50% auto auto 0;
    z-index: 0;
    width: 3px;
    height: 16px;
    margin-top: -8px;
    border-radius: 2px;
    background: var(--a-fill);
    box-shadow: none;
  }

  .v4-list a[aria-current="page"] .icon {
    color: var(--t-1);
  }

  .v4-pin {
    right: 8px;
    border-radius: 4px;
  }

  .v4-rail-foot {
    border-top-color: var(--b-1);
    padding-top: 4px;
  }

  .v4-count {
    border-radius: 999px;
  }

  /* Top bar */
  .v4-crumb {
    padding-left: 12px;
    font-size: .8rem;
  }

  .v4-crumb strong {
    font-weight: 600;
  }

  .v4-crumb-sep {
    font-size: 0;
  }

  .v4-crumb-sep::before {
    content: "›";
    font-size: .95rem;
  }

  .v4-command {
    flex: 0 1 420px;
    padding: 0 8px 0 10px;
    border: 1px solid var(--b-1);
    border-bottom-color: var(--b-2);
    background: color-mix(in oklch, var(--s-well) 70%, transparent);
    box-shadow: none;
    color: var(--t-3);
    font-size: .9rem;
  }

  .v4-command .icon {
    order: 3;
    width: 14px;
    height: 14px;
    color: var(--t-2);
  }

  .v4-command kbd {
    border: 0;
    border-radius: 3px;
    background: var(--f-hover);
    font-weight: 400;
  }

  .v4-ask {
    padding: 0 12px 0 8px;
    font-size: .9rem;
    font-weight: 400;
  }

  /* Controls: 4px corners, a firmer bottom edge */
  .btn,
  .small-btn {
    padding: 0 12px;
    font-size: .9rem;
    font-weight: 400;
    letter-spacing: 0;
    transition: background-color var(--d-1) linear, border-color var(--d-1) linear, color var(--d-1) linear;
  }

  .btn:active,
  .small-btn:active,
  .icon-btn:active,
  .v4-ask:active,
  .v4-icon-btn:active {
    transform: none;
  }

  .btn.secondary,
  .small-btn,
  .icon-btn,
  .v4-ask {
    border: 1px solid var(--b-1);
    border-bottom-color: color-mix(in oklch, var(--t-1) 17%, transparent);
    background: color-mix(in oklch, var(--s-well) 72%, transparent);
    color: var(--t-1);
    box-shadow: none;
  }

  .btn.secondary:active,
  .small-btn:active,
  .icon-btn:active,
  .v4-ask:active {
    border-bottom-color: var(--b-1);
    background: color-mix(in oklch, var(--s-well) 32%, transparent);
    color: var(--t-2);
  }

  .btn.gold,
  .btn.primary {
    border: 1px solid oklch(1 0 0 / .08);
    border-bottom-color: oklch(0 0 0 / .32);
    background: var(--a-fill);
    color: var(--a-on);
    font-weight: 600;
    box-shadow: none;
  }

  .btn.gold:active,
  .btn.primary:active {
    transform: none;
    border-bottom-color: oklch(1 0 0 / .08);
    background: color-mix(in oklch, var(--a-fill) 80%, transparent);
    color: color-mix(in oklch, var(--a-on) 78%, transparent);
    box-shadow: none;
  }

  .icon-btn {
    border-radius: 4px;
    color: var(--t-1);
  }

  .text-link,
  .auth-link a {
    font-weight: 400;
  }

  /* Text box: the bottom edge carries the state */
  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), select, textarea) {
    border: 1px solid var(--b-1);
    border-bottom-color: var(--b-2);
    background-color: color-mix(in oklch, var(--s-well) 70%, transparent);
    box-shadow: none;
  }

  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus-visible {
    border-color: var(--b-1);
    border-bottom-color: var(--a-fill);
    background-color: var(--s-well);
    box-shadow: inset 0 -1px 0 var(--a-fill);
  }

  .field,
  .filterbar > label,
  .inline-form label {
    font-weight: 400;
  }

  /* Cards */
  .panel {
    border: 1px solid var(--b-0);
    background: color-mix(in oklch, var(--s-1) 72%, transparent);
    box-shadow: none;
  }

  .panel h2 {
    font-weight: 600;
    letter-spacing: 0;
  }

  .page-head h1 {
    font-weight: 600;
    letter-spacing: -.012em;
  }

  .tile-icon {
    border-radius: 4px;
    background: var(--f-hover);
    box-shadow: inset 0 0 0 1px var(--b-0);
  }

  .attention-row {
    border-radius: 4px;
  }

  .badge {
    border-radius: 4px;
  }

  .message {
    border-radius: 4px;
  }

  th {
    font-weight: 600;
  }

  /* Acrylic: flyouts, menus, the command palette */
  .picker-options,
  .v4-quick,
  .palette,
  .v4-shell.is-slim .v4-group[data-fly] > .v4-list {
    border: 1px solid var(--b-1);
    background: var(--grain), color-mix(in oklch, var(--s-3) 76%, transparent);
    -webkit-backdrop-filter: blur(30px) saturate(1.25);
    backdrop-filter: blur(30px) saturate(1.25);
    box-shadow: var(--sh-3);
  }

  .palette {
    box-shadow: var(--sh-4);
  }

  .picker-options {
    padding: 3px;
  }

  /* the company's menu opens over the sidebar's own labels, where its Acrylic gets no blur to soften
     them: there it is solid, so that its own lines are the only ones read */
  .w5-company .picker-options {
    background: var(--grain), var(--s-3);
  }

  .picker-options :is(a, button) {
    min-height: 36px;
    margin: 1px;
    width: calc(100% - 2px);
    font-size: .9rem;
  }

  /* Segmented: a raised thumb with the accent pill under the label */
  .v4-seg {
    padding: 3px;
    border-radius: 5px;
    background: var(--f-hover);
    box-shadow: inset 0 0 0 1px var(--b-0);
  }

  .v4-seg::before {
    border-radius: 4px;
    background: color-mix(in oklch, var(--s-well) 82%, transparent);
    box-shadow: 0 0 0 1px var(--b-1), 0 1px 0 color-mix(in oklch, var(--t-1) 12%, transparent);
  }

  .v4-seg > :is(button, a) {
    height: 28px;
    font-size: .86rem;
    font-weight: 400;
    color: var(--t-1);
  }

  .v4-seg > :is([aria-pressed="true"], [aria-checked="true"], [aria-current="true"])::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 1px;
    width: 16px;
    height: 3px;
    margin-left: -8px;
    border-radius: 2px;
    background: var(--a-fill);
  }

  .v4-systems > button {
    border-radius: 4px;
    background: color-mix(in oklch, var(--s-well) 60%, transparent);
  }

  .v4-systems > button[aria-checked="true"] {
    border-color: var(--a-fill);
    box-shadow: 0 0 0 1px var(--a-fill);
  }

  .v4-quick-more {
    border-radius: 4px;
    margin: 12px 0 0;
    border-top: 0;
    font-weight: 400;
    color: var(--a-ink);
  }
}

:root[data-layout="v5"][data-ds="fluent"][data-mica="alt"] {
  --mica: radial-gradient(90vw 80vh at 100% 0, var(--mica-a), transparent 78%), radial-gradient(80vw 90vh at 0 100%, var(--mica-b), transparent 78%);
}

:root[data-layout="v5"][data-ds="fluent"][data-translucency="reduced"] {
  .picker-options,
  .v4-quick,
  .palette,
  .v4-shell.is-slim .v4-group[data-fly] > .v4-list {
    background: var(--s-3);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (hover: hover) and (pointer: fine) {
  :root[data-layout="v5"][data-ds="fluent"] {
    .btn.secondary:hover,
    .small-btn:hover,
    .icon-btn:hover,
    .v4-ask:hover {
      border-color: var(--b-1);
      border-bottom-color: color-mix(in oklch, var(--t-1) 17%, transparent);
      background: color-mix(in oklch, var(--s-well) 50%, transparent);
    }

    .btn.gold:hover,
    .btn.primary:hover {
      filter: none;
      background: color-mix(in oklch, var(--a-fill) 90%, transparent);
    }

    .v4-command:hover {
      border-color: var(--b-1);
      border-bottom-color: var(--b-2);
      background: color-mix(in oklch, var(--s-well) 50%, transparent);
    }

    .v4-list a[aria-current="page"]:hover {
      background: var(--f-hover);
    }
  }
}

@media (max-width: 859px) {
  :root[data-layout="v5"][data-ds="fluent"] {
    .workspace-content {
      border-left: 0;
      border-radius: 0;
    }

    .v4-top::before {
      display: none;
    }

    .v4-top::after {
      display: block;
      left: 0;
    }

    .v4-rail {
      background: var(--mica), var(--s-frame);
    }
  }
}

@media (max-width: 640px) {
  :root[data-layout="v5"][data-ds="fluent"] {
    .v4-tabbar {
      background: var(--grain), color-mix(in oklch, var(--s-3) 80%, transparent);
      -webkit-backdrop-filter: blur(30px) saturate(1.25);
      backdrop-filter: blur(30px) saturate(1.25);
    }

    .v4-tabbar :is(a, button) {
      border-radius: 4px;
      font-weight: 400;
    }

    .v4-tabbar a[aria-current="page"] .icon {
      color: var(--a-ink);
    }
  }
}

/* ========================================================================================
   Liquid Glass
   ======================================================================================== */

:root[data-layout="v5"][data-ds="glass"] {
  --r-field: 12px;
  --lg-angle: 0deg;
  background: var(--s-base);

  body {
    background: var(--s-base);
  }

  .work-area {
    margin: 0;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /*
    Glass. The backdrop is bent by an SVG displacement filter that glass.js builds for each
    surface's exact size (--lg-filter), then barely blurred and saturated; a thin tint keeps
    type readable on top, and the rim catches the light.
  */
  :is(.v4-command, .v4-ask, .v4-quick-btn) {
    position: relative;
  }

  :is(.v4-rail, .v4-command, .v4-ask, .v4-quick-btn, .v4-quick, .picker-options, .palette, [data-lg]) {
    border: 0;
    background: var(--lg-tint);
    -webkit-backdrop-filter: blur(14px) saturate(var(--lg-sat));
    backdrop-filter: var(--lg-filter,) blur(var(--lg-blur)) saturate(var(--lg-sat)) brightness(var(--lg-bright, 1.03));
    box-shadow: var(--lg-shadow), inset 0 0 0 .5px var(--lg-rim-2), inset 0 -8px 14px -10px var(--lg-shade);
  }

  :is(.v4-rail, .v4-command, .v4-ask, .v4-quick-btn, .v4-quick, .picker-options, .palette, [data-lg])::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    padding: 1px;
    border-radius: inherit;
    corner-shape: inherit;
    background: conic-gradient(from calc(-50deg + var(--lg-angle)), var(--lg-rim) 0deg, var(--lg-rim-2) 62deg, transparent 118deg, var(--lg-rim-2) 172deg, color-mix(in oklch, var(--lg-rim) 62%, transparent) 208deg, var(--lg-rim-2) 262deg, transparent 300deg, var(--lg-rim) 360deg);
    -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);
    pointer-events: none;
  }

  /* no refraction engine: frost carries the material instead */
  &:not([data-lg-engine="refract"]) {
    --lg-blur: 16px;
    --lg-tint: oklch(1 0 0 / .56);
  }

  &[data-theme="dark"]:not([data-lg-engine="refract"]) {
    --lg-tint: oklch(.28 .006 var(--n-h) / .6);
  }

  /* Sidebar: a floating pane of glass */
  .v4-rail {
    top: var(--frame);
    height: calc(100dvh - 2 * var(--frame));
    margin: var(--frame) 0 var(--frame) var(--frame);
    padding: 12px 10px 10px;
    border-radius: 26px;
    corner-shape: squircle;
  }

  .v4-rail > * {
    position: relative;
    z-index: 1;
  }

  .v4-shell {
    --rail-w: calc(272px + var(--frame));
  }

  .v4-shell.is-slim {
    --rail-w: calc(72px + var(--frame));
  }

  .v4-wordmark {
    font-stretch: 116%;
    letter-spacing: .09em;
  }

  .v4-icon-btn {
    border-radius: 50%;
  }

  .v4-company .company-icon {
    border-radius: 9px;
    corner-shape: squircle;
  }

  .v4-nav-label,
  .v4-group > summary {
    font-size: .76rem;
    font-weight: 620;
    color: var(--t-3);
  }

  .v4-list a {
    font-size: .9rem;
    font-weight: 500;
    color: var(--t-1);
  }

  .v4-list a .icon {
    color: var(--t-2);
  }

  .v4-list a[aria-current="page"] {
    font-weight: 620;
  }

  .v4-list a[aria-current="page"]::before {
    background: color-mix(in oklch, var(--t-1) 10%, transparent);
    box-shadow: inset 0 0 0 .5px oklch(1 0 0 / .18);
  }

  .v4-rail-foot {
    border-top-color: var(--b-0);
  }

  /* Toolbar: no bar, only glass controls floating over the page */
  .v4-top {
    top: 0;
    margin: 0;
    padding: 0 var(--pad);
    border: 0;
    border-radius: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* scroll edge: the page softens as it slides under the controls */
  .v4-top::before {
    top: 0;
    left: 0;
    right: 0;
    z-index: -1;
    width: auto;
    height: calc(100% + 18px);
    background: linear-gradient(color-mix(in oklch, var(--s-base) 70%, transparent), color-mix(in oklch, var(--s-base) 22%, transparent) 55%, transparent);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    -webkit-mask: linear-gradient(#000 30%, transparent);
    mask: linear-gradient(#000 30%, transparent);
    opacity: 0;
    transition: opacity var(--d-3) ease;
  }

  .v4-top::after {
    display: none;
  }

  .scrolled .v4-top::before {
    opacity: 1;
  }

  .v4-crumb {
    font-size: .9rem;
  }

  .v4-crumb strong {
    font-size: 1.02rem;
    font-weight: 660;
    letter-spacing: -.014em;
  }

  .v4-command,
  .v4-ask {
    height: calc(var(--h-ctl) + 4px);
    border-radius: 999px;
    color: var(--t-1);
  }

  .v4-command {
    padding: 0 8px 0 14px;
    color: var(--t-2);
  }

  .v4-command kbd {
    border: 0;
    border-radius: 999px;
    background: color-mix(in oklch, var(--t-1) 8%, transparent);
    padding: 3px 8px;
  }

  .v4-command > *,
  .v4-ask > *,
  .v4-quick-btn > *,
  .v4-quick > *,
  .picker-options > * {
    position: relative;
    z-index: 1;
  }

  .v4-ask {
    padding: 0 16px 0 10px;
    font-weight: 600;
  }

  .v4-quick-btn {
    width: calc(var(--h-ctl) + 4px);
    height: calc(var(--h-ctl) + 4px);
    border-radius: 50%;
    color: var(--t-1);
  }

  /* glass answers a press by swelling, then settles */
  :is(.v4-command, .v4-ask, .v4-quick-btn) {
    transition: transform var(--d-4) var(--e-spring), background-color var(--d-2) ease;
  }

  :is(.v4-command, .v4-ask, .v4-quick-btn):active {
    transform: scale(1.045);
    --lg-bright: 1.12;
    transition-duration: var(--d-1);
  }

  /* Content: plain, grouped, no borders */
  .panel {
    border: 0;
    border-radius: var(--r-card);
    corner-shape: squircle;
    background: var(--s-1);
    box-shadow: none;
  }

  .page-head h1 {
    font-weight: 720;
    letter-spacing: -.028em;
  }

  .panel h2 {
    font-weight: 650;
  }

  .tile-icon {
    border-radius: 10px;
    corner-shape: squircle;
    background: var(--s-well);
    box-shadow: none;
  }

  .attention-row {
    border-radius: 14px;
  }

  /* Buttons: capsules */
  .btn,
  .small-btn {
    padding: 0 17px;
    border-radius: 999px;
    font-weight: 600;
    transition: transform var(--d-4) var(--e-spring), background-color var(--d-1) ease, filter var(--d-1) ease;
  }

  .btn:active,
  .small-btn:active {
    transform: scale(.97);
    transition-duration: var(--d-1);
  }

  .btn.gold {
    border: 0;
    background: linear-gradient(180deg, color-mix(in oklch, var(--a-fill) 88%, white), var(--a-fill));
    color: var(--a-on);
    box-shadow: inset 0 1px 0 oklch(1 0 0 / .5), inset 0 0 0 .5px oklch(1 0 0 / .3), 0 6px 16px -8px var(--a-glow);
  }

  .btn.gold:active {
    transform: scale(.97);
    box-shadow: inset 0 1px 0 oklch(1 0 0 / .5), inset 0 0 0 .5px oklch(1 0 0 / .3);
  }

  .btn.primary {
    box-shadow: none;
  }

  .btn.secondary,
  .small-btn,
  .icon-btn {
    border: 0;
    background: var(--s-well);
    color: var(--t-1);
    box-shadow: none;
  }

  .icon-btn {
    border-radius: 50%;
  }

  /* Fields: a soft fill, the ring only on focus */
  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), select, textarea) {
    border: 0;
    border-radius: var(--r-field);
    background-color: var(--s-well);
    box-shadow: none;
  }

  :is(.field, .inline-form, .filterbar, .auth-form) :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus-visible {
    box-shadow: 0 0 0 3.5px color-mix(in oklch, var(--a-ring) 45%, transparent);
  }

  .badge {
    box-shadow: none;
    background: var(--s-well);
  }

  thead th {
    border-bottom-color: var(--b-0);
  }

  .message {
    border-radius: 16px;
    box-shadow: none;
  }

  /* Menus, sheets, palette */
  .picker-options,
  .v4-quick,
  .palette {
    border-radius: var(--r-pop);
    corner-shape: squircle;
    --lg-tint: var(--lg-tint-strong);
    --lg-blur: 12px;
    --lg-shadow: var(--sh-4);
  }

  .picker-options {
    padding: 6px;
  }

  /* the company's menu opens over the sidebar's own labels, and glass inside glass gets no blur to
     soften them: its tint is solid, so that its own lines are the only ones read */
  .w5-company .picker-options {
    --lg-tint: var(--lg-tint-menu);
  }

  .picker-options :is(a, button) {
    min-height: 36px;
    border-radius: 14px;
  }

  .palette::backdrop {
    background: oklch(0 0 0 / .14);
  }

  .palette > * {
    position: relative;
    z-index: 1;
  }

  /* Segmented control: a capsule thumb that lifts into a lens while held */
  .v4-seg {
    padding: 3px;
    border-radius: 999px;
    background: var(--s-well);
    box-shadow: none;
  }

  .v4-seg::before {
    border-radius: 999px;
    background: var(--s-1);
    box-shadow: 0 1px 3px oklch(0 0 0 / .14), 0 0 0 .5px oklch(0 0 0 / .05);
    transition: transform var(--d-4) var(--e-spring), width var(--d-4) var(--e-spring), scale var(--d-3) var(--e-spring), background-color var(--d-2) ease, box-shadow var(--d-2) ease;
  }

  .v4-seg:active::before {
    scale: 1.07 1.2;
    background: color-mix(in oklch, var(--s-1) 34%, transparent);
    -webkit-backdrop-filter: blur(1px) saturate(1.8) brightness(1.08);
    backdrop-filter: blur(1px) saturate(1.8) brightness(1.08);
    box-shadow: 0 4px 14px oklch(0 0 0 / .18), inset 0 0 0 1px var(--lg-rim), inset 0 1px 3px oklch(1 0 0 / .5);
  }

  .v4-seg > :is(button, a) {
    height: 32px;
    border-radius: 999px;
    font-weight: 570;
  }

  .v4-systems > button {
    border: 0;
    border-radius: 16px;
    corner-shape: squircle;
    background: color-mix(in oklch, var(--t-1) 5%, transparent);
  }

  .v4-systems > button[aria-checked="true"] {
    background: var(--s-1);
    box-shadow: 0 0 0 2px var(--a-ring), 0 2px 8px oklch(0 0 0 / .1);
  }

  .v4-quick-more {
    border-top: 0;
    border-radius: 14px;
    margin: 12px 0 0;
    background: color-mix(in oklch, var(--t-1) 5%, transparent);
  }

  .v4-shell.is-slim .v4-group[data-fly] > .v4-list {
    border: 0;
    border-radius: 20px;
    background: var(--lg-tint-strong);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    backdrop-filter: blur(16px) saturate(1.6);
    box-shadow: var(--sh-4), inset 0 0 0 .5px var(--lg-rim);
  }
}

:root[data-layout="v5"][data-ds="glass"][data-theme="dark"] {
  .v4-seg::before {
    background: oklch(1 0 0 / .2);
    box-shadow: 0 1px 3px oklch(0 0 0 / .4), inset 0 0 0 .5px oklch(1 0 0 / .14);
  }

  .v4-list a[aria-current="page"]::before {
    background: oklch(1 0 0 / .14);
  }
}

/* Reduce transparency: glass becomes a solid, edged surface */
:root[data-layout="v5"][data-ds="glass"][data-translucency="reduced"] {
  :is(.v4-rail, .v4-command, .v4-ask, .v4-quick-btn, .v4-quick, .picker-options, .palette, [data-lg]) {
    background: var(--s-3);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: var(--sh-2), inset 0 0 0 1px var(--b-1);
  }

  :is(.v4-rail, .v4-command, .v4-ask, .v4-quick-btn, .v4-quick, .picker-options, .palette, [data-lg])::before {
    display: none;
  }

  .v4-top::before {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: linear-gradient(var(--s-base) 60%, transparent);
  }
}

@media (hover: hover) and (pointer: fine) {
  :root[data-layout="v5"][data-ds="glass"] {
    .btn.secondary:hover,
    .small-btn:hover,
    .icon-btn:hover {
      background: color-mix(in oklch, var(--t-1) 10%, transparent);
    }

    :is(.v4-command, .v4-ask, .v4-quick-btn):hover {
      --lg-bright: 1.08;
    }

    .v4-systems > button:not([aria-checked="true"]):hover {
      background: color-mix(in oklch, var(--t-1) 9%, transparent);
    }
  }
}

@media (max-width: 859px) {
  :root[data-layout="v5"][data-ds="glass"] {
    .v4-rail {
      top: 8px;
      bottom: 8px;
      left: 8px;
      height: auto;
      margin: 0;
      border-right: 0;
      --lg-tint: var(--lg-tint-strong);
      --lg-blur: 14px;
    }

    .v4-top {
      padding: 0 12px;
    }

    .v4-command {
      width: calc(var(--h-ctl) + 4px);
      padding: 0;
    }
  }
}

@media (max-width: 640px) {
  :root[data-layout="v5"][data-ds="glass"] {
    /* Tab bar: a floating capsule */
    .v4-tabbar {
      left: 14px;
      right: 14px;
      bottom: calc(10px + env(safe-area-inset-bottom));
      width: auto;
      min-height: 62px;
      padding: 5px;
      border: 0;
      border-radius: 999px;
      background: var(--lg-tint);
      -webkit-backdrop-filter: blur(14px) saturate(var(--lg-sat));
      backdrop-filter: var(--lg-filter,) blur(var(--lg-blur)) saturate(var(--lg-sat));
      box-shadow: var(--lg-shadow), inset 0 0 0 .5px var(--lg-rim), inset 0 1px 1px var(--lg-rim);
    }

    .v4-tabbar :is(a, button) {
      min-height: 52px;
      border-radius: 999px;
      color: var(--t-1);
      font-weight: 600;
    }

    .v4-tabbar a[aria-current="page"] {
      background: color-mix(in oklch, var(--t-1) 9%, transparent);
      color: var(--a-ink);
    }
  }
}
