/* ==========================================================================
   ByteProject UI principles layer
   --------------------------------------------------------------------------
   One shared stylesheet for every surface of the product:
   panel (layouts/app + router), auth, admin (AdminLTE), docs, marketing.

   It implements the 40 typography / layout / motion rules without touching
   Tailwind's generated utilities. Everything is progressive enhancement:
   browsers without oklch(), @starting-style, view transitions or
   transition-behavior: allow-discrete simply get the static state.

   Sections
     01  Tokens (OKLCH, tracking, leading, duration, easing)
     02  Typography: kerning, x-height, leading, tracking, widows, measure
     03  Numbers: tabular figures
     04  Layout stability: CLS, scrollbar gutter, reserved space
     05  Safe areas
     06  Optical centring
     07  Touch targets + affordance
     08  Press feedback (scale .97) + switch knob stretch
     09  Entrances / exits (ease-out, 20% shorter exits, no bounce)
     10  Popovers, dropdowns, combobox (origin-aware, scale .95, arcs)
     11  Stagger (30 ms)
     12  Success pulse
     13  View transitions / shared elements (layoutId)
     14  Masks (reveal + colour)
     15  Icon crossfade + blur
     16  Rubber band + overscroll
     17  Progressive disclosure
     18  Combobox component
     19  Optimistic update states
     20  AdminLTE (Bootstrap 3) integration
     21  Docs integration
     22  Marketing / legal integration
     23  Reduced motion + print
   ========================================================================== */

/* --------------------------------------------------------------------------
   01  Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Motion */
  --ui-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ui-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ui-ease-enter: var(--ui-ease-out);
  --ui-ease-move: var(--ui-ease-in-out);
  --ui-dur-enter: 220ms;
  --ui-dur-exit: 176ms; /* exactly 20% shorter than the entrance */
  --ui-dur-popover: 180ms; /* inside the 150-250 ms window */
  --ui-dur-popover-exit: 144ms; /* 20% shorter than the popover entrance */
  --ui-dur-press: 120ms;
  --ui-dur-pulse: 420ms;
  --ui-stagger-step: 30ms;

  /* Type */
  --ui-tracking-tight: -0.011em;
  --ui-tracking-normal: 0.015em;
  --ui-tracking-wide: 0.08em;
  --ui-leading-tight: 1.15;
  --ui-leading-body: 1.55;
  --ui-measure: 68ch;
  --ui-measure-narrow: 58ch;
  --ui-x-height: 0.52; /* IBM Plex Sans x-height ratio */

  /* Layout */
  --ui-touch: 44px;
  --ui-admin-menu-icon: 1.25rem; /* 20px: AdminLTE's 14px menu glyphs read too small */
  --ui-radius-focus: 4px;

  /* OKLCH colour tokens. The theme still owns the RGB palette; these are
     derived in OKLCH so lightness/chroma stay perceptually even across themes. */
  --ui-oklch-ink: oklch(0.24 0.02 255);
  --ui-oklch-surface: oklch(0.31 0.018 255);
  --ui-oklch-line: oklch(0.52 0.02 255 / 0.35);
  --ui-oklch-accent: oklch(0.63 0.19 25);
  --ui-ring: color-mix(in oklch, rgb(var(--color-primary)) 58%, white 8%);
  --ui-ring-soft: color-mix(in oklch, rgb(var(--color-primary)) 26%, transparent);
  --ui-success-soft: color-mix(in oklch, rgb(var(--color-success)) 28%, transparent);
  --ui-danger-soft: color-mix(in oklch, rgb(var(--color-danger)) 28%, transparent);
  --ui-overlay: color-mix(in oklch, rgb(0 0 0) 62%, transparent);
}

@supports not (color: color-mix(in oklch, red 50%, blue)) {
  :root {
    --ui-ring: rgb(var(--color-primary));
    --ui-ring-soft: rgb(var(--color-primary) / 0.26);
    --ui-success-soft: rgb(var(--color-success) / 0.28);
    --ui-danger-soft: rgb(var(--color-danger) / 0.28);
    --ui-overlay: rgb(0 0 0 / 0.62);
  }
}

/* --------------------------------------------------------------------------
   02  Typography
   -------------------------------------------------------------------------- */
html.ui-html {
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body.ui {
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
  font-optical-sizing: auto;
  letter-spacing: var(--ui-tracking-normal);
  line-height: var(--ui-leading-body);
}

@supports (font-size-adjust: 0.5) {
  /* Normalise perceived x-height across the theme font and its fallbacks. */
  body.ui {
    font-size-adjust: var(--ui-x-height);
  }
}

:where(body.ui) :where(h1, h2, h3, h4, h5, h6) {
  letter-spacing: var(--ui-tracking-tight);
  line-height: var(--ui-leading-tight);
  text-wrap: balance;
  font-kerning: normal;
}

:where(body.ui) :where(p, li, dd, blockquote) {
  text-wrap: pretty; /* no widows / orphans */
}

body.ui .ui-measure,
body.ui .measure,
body.ui [data-measure] {
  max-width: var(--ui-measure);
}

body.ui .ui-measure-narrow,
body.ui [data-measure="narrow"] {
  max-width: var(--ui-measure-narrow);
}

body.ui .ui-tracking-wide {
  letter-spacing: var(--ui-tracking-wide);
}

body.ui .ui-tracking-tight {
  letter-spacing: var(--ui-tracking-tight);
}

body.ui .ui-leading-tight {
  line-height: var(--ui-leading-tight);
}

/* Long prose blocks keep a readable measure even inside wide cards. */
body.ui .prose p,
body.ui .prose li,
body.ui [data-prose] p,
body.ui [data-prose] li {
  max-width: var(--ui-measure);
  text-wrap: pretty;
}

/* --------------------------------------------------------------------------
   03  Numbers
   -------------------------------------------------------------------------- */
body.ui table,
body.ui .font-mono,
body.ui code,
body.ui kbd,
body.ui samp,
body.ui pre,
body.ui .tabular,
body.ui .tabular-nums,
body.ui [data-tabular],
body.ui [data-stat],
body.ui input[type="number"],
body.ui input[type="date"],
body.ui input[type="time"],
body.ui input[type="datetime-local"],
body.ui .stat-value,
body.ui .badge,
body.ui .label {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Stats must not reflow when a digit changes. */
body.ui [data-stat],
body.ui .stat-value {
  display: inline-block;
  min-width: 5ch;
  text-align: start;
}

/* --------------------------------------------------------------------------
   04  Layout stability
   -------------------------------------------------------------------------- */

/* Sidebar geometry. The aside is a fixed overlay, so it takes no part in the
   flex row and would otherwise shrink to its content — giving every page a
   different width. The shell reserves this token instead, so both sides always
   agree and the content can never slide under the sidebar. */
body.ui {
  --sidebar-width: 235px;
  --sidebar-gap: 15px;
}

body.ui #sidebar {
  width: var(--sidebar-width);
}

@media (min-width: 1024px) {
  body.ui #app-shell {
    padding-left: calc(var(--sidebar-width) + var(--sidebar-gap));
  }
}

body.ui #router-view {
  min-height: calc(100dvh - 4rem);
  overflow-anchor: auto;
}

body.ui img,
body.ui video,
body.ui canvas,
body.ui svg {
  max-width: 100%;
}

body.ui img[width][height] {
  height: auto;
}

/* Media without explicit dimensions still reserves a box until loaded. */
body.ui [data-media] {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background-color: rgb(var(--color-700) / 0.4);
}

body.ui .ui-reserve {
  min-height: 1.5em;
}

body.ui [aria-busy="true"] {
  cursor: progress;
}

/* --------------------------------------------------------------------------
   05  Safe areas
   -------------------------------------------------------------------------- */
body.ui {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

body.ui #navbar,
body.ui header.sticky,
body.ui .main-header,
body.ui .docs-header,
body.ui .legal-footer {
  padding-top: env(safe-area-inset-top, 0px);
}

body.ui #sidebar,
body.ui .main-sidebar {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.ui .ui-safe-bottom {
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

body.ui .ui-safe-top {
  padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
}

body.ui #rc-modal,
body.ui #eula-modal,
body.ui .modal {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   06  Optical centring
   -------------------------------------------------------------------------- */
body.ui .ui-optical,
body.ui [data-optical] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Icons sit on the optical centre of the text baseline, not the line box. */
body.ui button > svg,
body.ui .btn > svg,
body.ui .ui-optical > svg,
body.ui .side-nav-link > svg {
  translate: 0 0.02em;
  flex: none;
}

/* All-caps labels read high; nudge them down by a fraction of the cap height. */
body.ui .ui-optical-caps,
body.ui .badge {
  transform: translateY(0.03em);
}

body.ui .ui-optical-num {
  font-variant-numeric: tabular-nums;
  transform: translateY(0.02em);
}

/* --------------------------------------------------------------------------
   07  Touch targets + affordance
   -------------------------------------------------------------------------- */
body.ui button,
body.ui [role="button"],
body.ui .btn,
body.ui a.side-nav-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {
  body.ui button,
  body.ui [role="button"],
  body.ui .btn,
  body.ui .side-nav-link,
  body.ui .dropdown-menu > li > a,
  body.ui .nav-tabs > li > a,
  body.ui .pagination > li > a,
  body.ui .pagination > li > span,
  body.ui summary,
  body.ui .ui-touch {
    min-height: var(--ui-touch);
  }

  /* Native checkboxes get a touch-sized box. Custom-drawn ones (appearance-none,
     e.g. the file-manager list and its select-all box) are sized by their own
     w-4 h-4 classes, and forcing the touch size makes them overflow the row. */
  body.ui input[type="checkbox"]:not(.appearance-none):not([class*="appearance-none"]),
  body.ui input[type="radio"]:not(.appearance-none):not([class*="appearance-none"]) {
    min-width: var(--ui-touch);
    min-height: var(--ui-touch);
  }
}

body.ui button:not(:disabled),
body.ui [role="button"]:not([aria-disabled="true"]),
body.ui .btn:not(.disabled),
body.ui .pressable,
body.ui a.side-nav-link,
body.ui .box,
body.ui .clickable {
  cursor: pointer;
}

body.ui button:disabled,
body.ui [aria-disabled="true"],
body.ui .disabled,
body.ui .cursor-not-allowed {
  cursor: not-allowed;
}

/* Keyboard focus is always visible, mouse focus is not. */
body.ui :focus-visible {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
  border-radius: var(--ui-radius-focus);
}

body.ui a:focus-visible,
body.ui button:focus-visible,
body.ui [role="button"]:focus-visible,
body.ui summary:focus-visible {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

/* Hover affordance for cards that behave like links. */
body.ui .pressable:hover,
body.ui .clickable:hover {
  filter: brightness(1.06);
}

body.ui .pressable:active,
body.ui .clickable:active {
  filter: brightness(0.98);
}

/* --------------------------------------------------------------------------
   08  Press feedback + switch knob stretch
   -------------------------------------------------------------------------- */
body.ui button,
body.ui [role="button"],
body.ui .btn,
body.ui .pressable,
body.ui .side-nav-link,
body.ui .box {
  transition:
    scale var(--ui-dur-press) var(--ui-ease-out),
    translate 160ms var(--ui-ease-out),
    transform 160ms var(--ui-ease-out),
    background-color 160ms var(--ui-ease-out),
    border-color 160ms var(--ui-ease-out),
    color 160ms var(--ui-ease-out),
    box-shadow 160ms var(--ui-ease-out),
    filter 160ms var(--ui-ease-out);
}

body.ui button:active:not(:disabled),
body.ui [role="button"]:active:not([aria-disabled="true"]),
body.ui .btn:active:not(.disabled),
body.ui .pressable:active,
body.ui .side-nav-link:active,
body.ui .clickable:active {
  scale: 0.97;
}

/* Never tween while the pointer is held down: the press must feel direct. */
body.ui .is-held,
body.ui .is-held * {
  transition-property: none !important;
}

/* Toggle knobs stretch by 12% while pressed/dragged. */
body.ui .ui-switch > span,
body.ui .ui-switch::after,
body.ui .ui-switch:active > div::after,
body.ui .ui-switch.is-held > div::after,
body.ui .ui-switch > .slider::before {
  transition:
    transform 160ms var(--ui-ease-out),
    scale 160ms var(--ui-ease-out),
    background-color 160ms var(--ui-ease-out),
    left 160ms var(--ui-ease-out);
}

body.ui .ui-switch:active > div::after,
body.ui .ui-switch.is-held > div::after,
body.ui .ui-switch:active > .slider::before,
body.ui .ui-switch.is-held > .slider::before {
  scale: 1.12 1;
}

/* --------------------------------------------------------------------------
   09  Entrances / exits
   -------------------------------------------------------------------------- */
@keyframes ui-rise {
  from {
    opacity: 0;
    translate: 0 8px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes ui-rise-soft {
  from {
    opacity: 0;
    translate: 0 4px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes ui-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-pop {
  from {
    opacity: 0;
    scale: 0.95;
    translate: 0 -4px;
    rotate: -0.5deg;
  }
  to {
    opacity: 1;
    scale: 1;
    translate: 0 0;
    rotate: 0deg;
  }
}

/* Arc: the element travels on a shallow curve, never a straight line. */
@keyframes ui-arc {
  0% {
    opacity: 0;
    translate: -6px 8px;
    rotate: -1.5deg;
    scale: 0.95;
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    translate: 0 0;
    rotate: 0deg;
    scale: 1;
  }
}

@keyframes ui-leave {
  from {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
  to {
    opacity: 0;
    translate: 0 -4px;
    scale: 0.99;
  }
}

@keyframes ui-leave-soft {
  from { opacity: 1; }
  to { opacity: 0; }
}

body.ui .ui-enter {
  animation: ui-rise var(--ui-dur-enter) var(--ui-ease-enter) backwards;
}

body.ui .ui-enter-soft {
  animation: ui-rise-soft var(--ui-dur-enter) var(--ui-ease-enter) backwards;
}

body.ui .ui-enter-arc {
  animation: ui-arc var(--ui-dur-enter) var(--ui-ease-enter) both;
}

body.ui .ui-leaving {
  animation: ui-leave var(--ui-dur-exit) var(--ui-ease-in-out) both;
  pointer-events: none;
}

body.ui .ui-leaving-soft {
  animation: ui-leave-soft var(--ui-dur-exit) var(--ui-ease-in-out) both;
  pointer-events: none;
}

/* HTMX view swaps: old state leaves, new state settles with ease-out. */
body.ui #router-view.htmx-swapping > * {
  animation: ui-leave-soft var(--ui-dur-exit) var(--ui-ease-in-out) both;
}

body.ui #router-view.htmx-settling > * {
  animation: ui-rise-soft var(--ui-dur-enter) var(--ui-ease-enter) backwards;
}

/* Everyday UI never bounces; the only spring-like motion is the explicit
   rubber-band gesture in section 16. */

/* --------------------------------------------------------------------------
   10  Popovers / dropdowns / origin-aware animation
   -------------------------------------------------------------------------- */
body.ui .ui-popover,
body.ui [data-lang-menu] > div,
body.ui .ui-combobox-list,
body.ui .select2-dropdown,
body.ui .dropdown-menu {
  transform-origin: var(--ui-origin, top center);
  will-change: opacity, scale, translate;
}

@supports (transition-behavior: allow-discrete) {
  body.ui .ui-popover,
  body.ui [data-lang-menu] > div,
  body.ui .ui-combobox-list {
    opacity: 1;
    scale: 1;
    translate: 0 0;
    rotate: 0deg;
    transition:
      opacity var(--ui-dur-popover) var(--ui-ease-out),
      scale var(--ui-dur-popover) var(--ui-ease-out),
      translate var(--ui-dur-popover) var(--ui-ease-out),
      rotate var(--ui-dur-popover) var(--ui-ease-out),
      display var(--ui-dur-popover) allow-discrete;
  }

  body.ui .ui-popover.hidden,
  body.ui [data-lang-menu] > div.hidden,
  body.ui .ui-combobox-list.hidden {
    opacity: 0;
    scale: 0.95;
    translate: 0 -4px;
    rotate: -0.5deg;
    transition-duration: var(--ui-dur-popover-exit);
    pointer-events: none;
  }

  @starting-style {
    body.ui .ui-popover:not(.hidden),
    body.ui [data-lang-menu] > div:not(.hidden),
    body.ui .ui-combobox-list:not(.hidden) {
      opacity: 0;
      scale: 0.95;
      translate: 0 -4px;
      rotate: -0.5deg;
    }
  }
}

/* Bootstrap-style menus cannot animate display; animate the open state. */
body.ui .open > .dropdown-menu,
body.ui .dropdown-menu.ui-open {
  animation: ui-pop var(--ui-dur-popover) var(--ui-ease-out) both;
  transform-origin: var(--ui-origin, top left);
}

/* Select2 is injected by admin JS; match the same motion. */
body.ui .select2-container--open .select2-dropdown {
  animation: ui-pop var(--ui-dur-popover) var(--ui-ease-out) both;
}

/* Modals: scale .97 on press is for buttons; dialogs settle from .97 -> 1. */
body.ui #rc-modal:not(.hidden) > .relative,
body.ui #eula-modal:not(.hidden) > .relative,
body.ui .modal.in .modal-dialog {
  animation: ui-pop var(--ui-dur-enter) var(--ui-ease-out) both;
}

body.ui .modal.fade .modal-dialog {
  transition: transform var(--ui-dur-enter) var(--ui-ease-out), opacity var(--ui-dur-enter) var(--ui-ease-out);
  transform: translateY(8px) scale(0.97);
}

body.ui .modal.in .modal-dialog {
  transform: none;
}

/* --------------------------------------------------------------------------
   11  Stagger
   -------------------------------------------------------------------------- */
body.ui [data-stagger] > * {
  animation: ui-rise var(--ui-dur-enter) var(--ui-ease-out) backwards;
  animation-delay: calc(var(--ui-i, 0) * var(--ui-stagger-step));
}

body.ui [data-stagger="soft"] > * {
  animation-name: ui-rise-soft;
}

/* Tables stagger automatically; no per-page markup required. */
body.ui table > tbody > tr {
  animation: ui-rise-soft var(--ui-dur-enter) var(--ui-ease-out) backwards;
  animation-delay: calc(var(--ui-i, 0) * var(--ui-stagger-step));
}

body.ui table > tbody > tr:nth-child(1) { --ui-i: 0; }
body.ui table > tbody > tr:nth-child(2) { --ui-i: 1; }
body.ui table > tbody > tr:nth-child(3) { --ui-i: 2; }
body.ui table > tbody > tr:nth-child(4) { --ui-i: 3; }
body.ui table > tbody > tr:nth-child(5) { --ui-i: 4; }
body.ui table > tbody > tr:nth-child(6) { --ui-i: 5; }
body.ui table > tbody > tr:nth-child(7) { --ui-i: 6; }
body.ui table > tbody > tr:nth-child(8) { --ui-i: 7; }
body.ui table > tbody > tr:nth-child(9) { --ui-i: 8; }
body.ui table > tbody > tr:nth-child(10) { --ui-i: 9; }
body.ui table > tbody > tr:nth-child(11) { --ui-i: 10; }
body.ui table > tbody > tr:nth-child(12) { --ui-i: 11; }
body.ui table > tbody > tr:nth-child(13) { --ui-i: 12; }
body.ui table > tbody > tr:nth-child(14) { --ui-i: 13; }
body.ui table > tbody > tr:nth-child(15) { --ui-i: 14; }
body.ui table > tbody > tr:nth-child(16) { --ui-i: 15; }
body.ui table > tbody > tr:nth-child(17) { --ui-i: 16; }
body.ui table > tbody > tr:nth-child(18) { --ui-i: 17; }
body.ui table > tbody > tr:nth-child(19) { --ui-i: 18; }
body.ui table > tbody > tr:nth-child(20) { --ui-i: 19; }
body.ui table > tbody > tr:nth-child(n + 21) { --ui-i: 20; }

/* Disclosure content settles in with its own short stagger. */
body.ui details.ui-disclosure[open] > *:not(summary):not(.ui-disclosure-panel),
body.ui details.ui-disclosure[open] .ui-disclosure-panel > * {
  animation: ui-rise-soft var(--ui-dur-enter) var(--ui-ease-out) backwards;
  animation-delay: calc(var(--ui-i, 0) * var(--ui-stagger-step));
}

/* --------------------------------------------------------------------------
   12  Success pulse
   -------------------------------------------------------------------------- */
@keyframes ui-pulse {
  0% { scale: 1; }
  35% { scale: 1.04; }
  100% { scale: 1; }
}

@keyframes ui-pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--ui-success-soft); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

body.ui .pulse-success,
body.ui .is-confirmed {
  animation:
    ui-pulse var(--ui-dur-pulse) var(--ui-ease-out),
    ui-pulse-ring var(--ui-dur-pulse) var(--ui-ease-out);
}

/* --------------------------------------------------------------------------
   13  View transitions / shared elements
   -------------------------------------------------------------------------- */
@view-transition {
  navigation: auto;
}

@keyframes ui-vt-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes ui-vt-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

::view-transition-old(root) {
  animation: ui-vt-out var(--ui-dur-exit) var(--ui-ease-in-out) both;
}

::view-transition-new(root) {
  animation: ui-vt-in var(--ui-dur-enter) var(--ui-ease-out) both;
}

::view-transition-group(*) {
  animation-duration: 240ms;
  animation-timing-function: var(--ui-ease-out);
}

/* Shared elements keep the same view-transition-name across routes. */
body.ui .ui-shared {
  view-transition-name: var(--ui-shared-name);
}

body.ui .ui-shared-active {
  contain: layout;
}

/* --------------------------------------------------------------------------
   14  Masks (reveal + colour)
   -------------------------------------------------------------------------- */
body.ui .ui-mask-reveal {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
}

body.ui .ui-mask-reveal-x {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
}

body.ui [data-mask-scroll] {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 var(--ui-mask-l, 0px),
    #000 calc(100% - var(--ui-mask-r, 0px)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 var(--ui-mask-l, 0px),
    #000 calc(100% - var(--ui-mask-r, 0px)),
    transparent 100%
  );
}

/* Colour mask: the accent fades out instead of hard-clipping. */
body.ui .ui-mask-color {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 72%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 72%, transparent 100%);
  color: rgb(var(--color-primary));
}

body.ui .ui-reveal-on-hover {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 0, transparent 0);
  mask-image: linear-gradient(to right, #000 0, #000 0, transparent 0);
  transition: -webkit-mask-image 320ms var(--ui-ease-out), mask-image 320ms var(--ui-ease-out);
}

body.ui .ui-reveal-on-hover:hover,
body.ui .ui-reveal-on-hover:focus-visible {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 100%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 100%, transparent 100%);
}

/* --------------------------------------------------------------------------
   15  Icon crossfade + blur
   -------------------------------------------------------------------------- */
body.ui [data-copy-target] {
  position: relative;
}

body.ui [data-copy-icon],
body.ui [data-copy-icon-check] {
  transition:
    opacity 160ms var(--ui-ease-out),
    filter 160ms var(--ui-ease-out),
    scale 160ms var(--ui-ease-out);
}

body.ui [data-copy-icon].hidden,
body.ui [data-copy-icon-check].hidden {
  display: inline-flex !important;
  opacity: 0;
  filter: blur(3px);
  scale: 0.9;
  position: absolute;
  pointer-events: none;
}

body.ui .ui-icon-swap {
  position: relative;
  display: inline-flex;
}

body.ui .ui-icon-swap > * {
  transition:
    opacity 160ms var(--ui-ease-out),
    filter 160ms var(--ui-ease-out),
    scale 160ms var(--ui-ease-out);
}

body.ui .ui-icon-swap > .hidden {
  display: inline-flex !important;
  opacity: 0;
  filter: blur(3px);
  scale: 0.9;
  position: absolute;
}

/* --------------------------------------------------------------------------
   16  Rubber band + overscroll
   -------------------------------------------------------------------------- */
body.ui [data-rubber-band] {
  overscroll-behavior-x: contain;
  touch-action: pan-y;
}

body.ui [data-rubber-band].is-rubbering {
  transition: none !important;
  cursor: grabbing;
}

body.ui [data-rubber-band].is-rubber-release {
  transition: transform 320ms var(--ui-ease-out);
}

body.ui .modal,
body.ui #rc-modal > .relative,
body.ui #eula-modal > .relative,
body.ui .ui-overscroll-contain {
  overscroll-behavior: contain;
}

/* --------------------------------------------------------------------------
   17  Progressive disclosure
   -------------------------------------------------------------------------- */
body.ui details.ui-disclosure {
  border-radius: var(--ui-radius-focus);
}

body.ui details.ui-disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 40px;
  list-style: none;
  user-select: none;
}

body.ui details.ui-disclosure > summary::-webkit-details-marker {
  display: none;
}

body.ui details.ui-disclosure > summary::marker {
  content: "";
}

body.ui details.ui-disclosure .ui-disclosure-icon {
  transition: rotate var(--ui-dur-popover) var(--ui-ease-out);
  flex: none;
}

body.ui details.ui-disclosure[open] .ui-disclosure-icon {
  rotate: 90deg;
}

body.ui details.ui-disclosure[open] > summary {
  margin-bottom: 0.25rem;
}

body.ui .ui-disclosure-panel {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   18  Combobox
   -------------------------------------------------------------------------- */
body.ui .ui-combobox {
  position: relative;
  width: 100%;
}

body.ui .ui-combobox-input {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid rgb(var(--color-600));
  border-radius: var(--radius, 4px);
  background: rgb(var(--color-700));
  color: rgb(var(--color-100));
  font: inherit;
  transition: border-color 160ms var(--ui-ease-out), box-shadow 160ms var(--ui-ease-out);
}

body.ui .ui-combobox-input:focus {
  outline: none;
  border-color: var(--ui-ring);
  box-shadow: 0 0 0 3px var(--ui-ring-soft);
}

body.ui .ui-combobox-toggle {
  position: absolute;
  inset-inline-end: 0;
  inset-block: 0;
  width: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--color-300));
  background: transparent;
  border: 0;
}

body.ui .ui-combobox-list {
  position: absolute;
  z-index: 80;
  inset-inline: 0;
  margin-top: 0.35rem;
  max-height: 18rem;
  overflow: auto;
  padding: 0.25rem;
  border: 1px solid rgb(var(--color-600));
  border-radius: var(--radius, 4px);
  background: rgb(var(--color-700));
  box-shadow: 0 18px 40px -18px var(--ui-oklch-ink);
}

body.ui .ui-combobox-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  min-height: 40px;
  color: rgb(var(--color-100));
}

body.ui .ui-combobox-option[aria-selected="true"] {
  background: var(--ui-ring-soft);
}

body.ui .ui-combobox-option[data-active="true"] {
  background: rgb(var(--color-600));
}

body.ui .ui-combobox-empty {
  padding: 0.6rem;
  color: rgb(var(--color-400));
  font-size: 0.875rem;
}

body.ui select[data-ui-combobox="1"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --------------------------------------------------------------------------
   19  Optimistic update states
   -------------------------------------------------------------------------- */
@keyframes ui-spin {
  to { rotate: 360deg; }
}

body.ui .is-pending {
  position: relative;
  cursor: progress;
}

body.ui .is-pending::after {
  content: "";
  width: 0.9em;
  height: 0.9em;
  margin-inline-start: 0.5em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  display: inline-block;
  vertical-align: -0.1em;
  animation: ui-spin 700ms linear infinite;
}

body.ui .is-pending[data-ui-spinner="off"]::after {
  display: none;
}

body.ui [data-optimistic].is-optimistic {
  opacity: 0.72;
}

body.ui .is-optimistic-removed {
  animation: ui-leave var(--ui-dur-exit) var(--ui-ease-in-out) both;
  pointer-events: none;
}

body.ui .is-reverted {
  animation: ui-shake 320ms var(--ui-ease-out);
}

@keyframes ui-shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -3px 0; }
  50% { translate: 3px 0; }
  75% { translate: -2px 0; }
}

/* --------------------------------------------------------------------------
   20  AdminLTE (Bootstrap 3) integration
   -------------------------------------------------------------------------- */
body.ui-admin .box {
  transition: border-color 160ms var(--ui-ease-out), box-shadow 160ms var(--ui-ease-out);
}

/* Sidebar icons: AdminLTE renders them at the 14px text size, which reads too
   small next to the label. Give every menu icon a fixed 18px box so Remix and
   FontAwesome glyphs share one optical size and stay aligned. */
body.ui-admin .sidebar-menu > li > a > i,
body.ui-admin .sidebar-menu > li > a > svg {
  font-size: var(--ui-admin-menu-icon);
  line-height: 1;
  width: calc(var(--ui-admin-menu-icon) * 1.3333);
  min-width: calc(var(--ui-admin-menu-icon) * 1.3333);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  text-align: center;
}

body.ui-admin .box:hover {
  border-color: var(--ui-oklch-line);
  box-shadow: 0 10px 30px -22px var(--ui-oklch-ink);
}

body.ui-admin .table > tbody > tr {
  transition: background-color 120ms var(--ui-ease-out);
}

body.ui-admin .form-control {
  transition: border-color 160ms var(--ui-ease-out), box-shadow 160ms var(--ui-ease-out);
}

body.ui-admin .form-control:focus {
  border-color: var(--ui-ring);
  box-shadow: 0 0 0 3px var(--ui-ring-soft);
}

body.ui-admin .btn {
  transition:
    scale var(--ui-dur-press) var(--ui-ease-out),
    background-color 160ms var(--ui-ease-out),
    border-color 160ms var(--ui-ease-out),
    box-shadow 160ms var(--ui-ease-out);
}

body.ui-admin .btn:active:not(.disabled) {
  scale: 0.97;
}

body.ui-admin .select2-container .select2-selection--single,
body.ui-admin .select2-container--default .select2-selection--multiple {
  transition: border-color 160ms var(--ui-ease-out), box-shadow 160ms var(--ui-ease-out);
}

body.ui-admin .select2-container--focus .select2-selection--single,
body.ui-admin .select2-container--focus .select2-selection--multiple {
  border-color: var(--ui-ring) !important;
  box-shadow: 0 0 0 3px var(--ui-ring-soft);
}

body.ui-admin .small-box,
body.ui-admin .info-box {
  transition: scale var(--ui-dur-press) var(--ui-ease-out), box-shadow 160ms var(--ui-ease-out);
}

body.ui-admin .small-box:active,
body.ui-admin .info-box:active {
  scale: 0.99;
}

body.ui-admin .progress-bar {
  transition: width 420ms var(--ui-ease-out);
}

body.ui-admin .alert,
body.ui-admin .callout {
  animation: ui-rise-soft var(--ui-dur-enter) var(--ui-ease-out) backwards;
}

/* --------------------------------------------------------------------------
   21  Docs integration
   -------------------------------------------------------------------------- */
body.ui .docs-article p,
body.ui .docs-article li,
body.ui .docs-article blockquote {
  max-width: 70ch;
  text-wrap: pretty;
}

body.ui .docs-article h2,
body.ui .docs-article h3 {
  text-wrap: balance;
  letter-spacing: var(--ui-tracking-tight);
}

body.ui .docs-sidebar a {
  min-height: 40px;
  display: flex;
  align-items: center;
  transition: color 160ms var(--ui-ease-out), background-color 160ms var(--ui-ease-out);
}

/* --------------------------------------------------------------------------
   22  Marketing / legal integration
   -------------------------------------------------------------------------- */
body.ui .btn-primary {
  transition:
    scale var(--ui-dur-press) var(--ui-ease-out),
    background-color 180ms var(--ui-ease-out),
    border-color 180ms var(--ui-ease-out),
    box-shadow 180ms var(--ui-ease-out);
}

body.ui .btn-primary:active {
  scale: 0.97;
}

body.ui .nav-link {
  position: relative;
  letter-spacing: 0.005em;
}

body.ui .legal-main p,
body.ui .legal-main li {
  max-width: 72ch;
  text-wrap: pretty;
}

body.ui .legal-main h1,
body.ui .legal-main h2,
body.ui .legal-main h3 {
  text-wrap: balance;
  letter-spacing: var(--ui-tracking-tight);
}

body.ui .legal-main .card {
  box-shadow: 0 24px 60px -40px var(--ui-oklch-ink);
}

/* Marketing cards get a shared-element-friendly contain box. */
body.ui [data-shared-id] {
  contain: layout style;
}

/* --------------------------------------------------------------------------
   23  Reduced motion + print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  body.ui *,
  body.ui *::before,
  body.ui *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  body.ui .is-pending::after {
    animation: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.001ms !important;
  }
}

@media print {
  body.ui .ui-no-print,
  body.ui #navbar,
  body.ui #sidebar,
  body.ui .main-header,
  body.ui .main-sidebar {
    display: none !important;
  }

  body.ui {
    padding: 0 !important;
  }
}
