/* Dark glass materials. Layout belongs to the surrounding control room.
   Native text stays unfiltered; only the background receives refraction.
   A visible dark scene behind a surface gives the glass something to bend. */
#hub .glass-surface.glass-surface,
#hub .glass-action,
#hub .glass-icon {
  --glass-radius: 20px;
  --glass-blur: 8px;
  --glass-fill: #161616;
  --glass-edge: #ffffff24;
  --glass-highlight: #ffffff52;
  position: relative;
  isolation: isolate;
  border: 1px solid var(--glass-edge);
  border-top-color: var(--glass-highlight);
  border-left-color: #ffffff35;
  border-radius: var(--glass-radius);
  background-color: var(--glass-fill);
  background-image: none;
  color: #eeeeee;
  box-shadow:
    inset 0 1px 0 #ffffff1c,
    inset 1px 0 0 #ffffff0c,
    inset 0 -1px 0 #000000bf,
    0 2px 3px #00000033,
    0 9px 22px #00000024;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Partial rims reflect the upper edge; the lower rim catches a quieter light. */
#hub .glass-surface::before,
#hub .glass-surface::after,
#hub .glass-action::before,
#hub .glass-action::after {
  content: '';
  position: absolute;
  pointer-events: none;
  user-select: none;
  z-index: -1;
  box-sizing: border-box;
}
#hub .glass-surface.glass-surface::before {
  inset: 1px;
  border: 1px solid transparent;
  border-top-color: #ffffff21;
  border-right-color: #ffffff0a;
  border-radius: calc(var(--glass-radius) - 2px);
}
#hub .glass-surface.glass-surface::after {
  left: 16px;
  right: 16px;
  bottom: 1px;
  height: 8px;
  border-bottom: 1px solid #ffffff0f;
  border-radius: 0 0 50% 50%;
}

#hub .glass-surface.glass-chrome { --glass-blur: 16px; }
#hub .machine-card.glass-surface:hover {
  background-color: var(--glass-fill);
  background-image: none;
  border-color: #ffffff40;
  border-top-color: #ffffff65;
  box-shadow: inset 0 1px 0 #ffffff20, inset 0 -1px 0 #000000bf,
    0 9px 22px #00000024;
}

/* Intrinsic pill geometry accommodates labels, translated copy and touch input. */
#hub .glass-action {
  --glass-radius: 999px;
  --glass-fill: #242424;
  --glass-highlight: #ffffff66;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 44px;
  min-height: 44px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 16px;
  vertical-align: middle;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.1px;
  text-decoration: none;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
  box-shadow:
    inset 0 1px 1px #ffffff21,
    inset 1px 0 1px #ffffff12,
    inset -1px 0 1px #ffffff08,
    inset 0 -2px 2px #0000008c,
    0 1px 2px #0000007a,
    0 5px 13px #00000038;
  transition: background-color 160ms ease, border-color 160ms ease,
    box-shadow 160ms ease, transform 160ms ease;
}
#hub .glass-action::before {
  inset: 2px;
  border: 1px solid transparent;
  border-top-color: #ffffff21;
  border-left-color: #ffffff0a;
  border-radius: inherit;
}
#hub .glass-action::after {
  right: 13%;
  left: 13%;
  bottom: 2px;
  height: 45%;
  border: 1px solid transparent;
  border-bottom-color: #ffffff17;
  border-radius: 0 0 50% 50%;
}
#hub .glass-action > .text {
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: pretty;
  color: inherit;
  line-height: 1.3;
}
#hub .glass-action > .btn-icon,
#hub .glass-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  border: 1px solid #ffffff14;
  border-top-color: #ffffff29;
  border-radius: 50%;
  background-color: #00000030;
  box-shadow: inset 0 1px 1px #00000055, 0 1px 0 #ffffff0c;
  color: inherit;
}
#hub .glass-action > .btn-icon > .ui-icon,
#hub .glass-icon > .ui-icon {
  width: 15px;
  height: 15px;
  display: block;
  margin: 0;
  opacity: .9;
}
#hub .glass-action > .btn-icon > img,
#hub .glass-icon > img {
  width: 17px;
  height: 17px;
  object-fit: contain;
}
#hub .glass-action > .btn-icon {
  position: relative;
  pointer-events: none;
}
#hub .glass-action.glass-action-icon {
  padding: 7px;
  width: 44px;
  flex: 0 0 44px;
  gap: 0;
}

/* Optional decorative reflection: a narrow ellipse, never an input target. */
#hub .glass-action .circle-overlay {
  position: absolute;
  inset: 3px 7px;
  pointer-events: none;
  user-select: none;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-top-color: #ffffff14;
  border-right-color: #ffffff09;
  border-radius: inherit;
  background: none;
}
#hub .glass-action .circle-overlay * { pointer-events: none; }

#hub .glass-action:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}
#hub .glass-action[aria-pressed='true'],
#hub .glass-action[aria-current='page'],
#hub .glass-action[aria-selected='true'],
#hub .glass-action.active {
  --glass-fill: #343434;
  border-color: #ffffff57;
  border-top-color: #ffffff8c;
  color: #ffffff;
  box-shadow: inset 0 1px 1px #ffffff26, inset 0 -2px 2px #0000006b,
    0 1px 2px #0000007a, 0 5px 13px #00000038;
}
@media (hover: hover) and (pointer: fine) {
  #hub .glass-action:not(:disabled):not([aria-disabled='true']):hover {
    --glass-fill: #303030;
    border-color: #ffffff47;
    border-top-color: #ffffff85;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 1px #ffffff2e, inset 0 -2px 2px #0000006b,
      0 2px 3px #0000007a, 0 7px 17px #00000047;
  }
}
#hub .glass-action:not(:disabled):not([aria-disabled='true']):active {
  --glass-fill: #1e1e1e;
  transform: translateY(0);
  box-shadow: inset 0 1px 3px #00000066, inset 0 -1px 0 #ffffff0d,
    0 1px 2px #00000055;
}
#hub .glass-action:disabled,
#hub .glass-action[aria-disabled='true'] {
  color: #888888;
  border-color: #ffffff16;
  cursor: not-allowed;
  transform: none;
  box-shadow: inset 0 1px 0 #ffffff08;
}

/* WebKit gets an independent blur fallback. SVG refraction is opt-in. */
@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
  #hub .glass-surface.glass-surface {
    --glass-fill: #161616d9;
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur));
  }
  #hub .glass-surface.glass-chrome { --glass-fill: #161616c4; }
  #hub .glass-action {
    --glass-fill: #242424c2;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  #hub .glass-action[aria-pressed='true'],
  #hub .glass-action[aria-current='page'],
  #hub .glass-action[aria-selected='true'],
  #hub .glass-action.active { --glass-fill: #343434dc; }
}
@supports (backdrop-filter: url('#liquid-glass')) {
  .svg-glass #hub .glass-surface.glass-chrome,
  .svg-glass #hub .machine-card.glass-surface {
    -webkit-backdrop-filter: blur(var(--glass-blur));
    backdrop-filter: blur(var(--glass-blur)) var(--liquid-filter, blur(0px));
  }
  .svg-glass #hub .glass-action {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px) var(--liquid-filter, blur(0px));
  }
}

/* Dragging avoids repeated refraction paint; accessible fallbacks stay dark. */
body.dragging #hub .glass-surface.glass-surface,
body.dragging #hub .glass-action,
body.dragging #hub .glass-icon {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  transition: none !important;
}
body.dragging #hub .glass-surface.glass-surface { background-color: #161616; }
body.dragging #hub .glass-action { background-color: #242424; transform: none; }

@media (prefers-reduced-motion: reduce) {
  #hub .glass-action {
    transition: none;
    transform: none !important;
  }
  .svg-glass #hub .glass-surface.glass-chrome,
  .svg-glass #hub .machine-card.glass-surface { backdrop-filter: blur(var(--glass-blur)); }
  .svg-glass #hub .glass-action { backdrop-filter: blur(10px); }
}
@media (prefers-reduced-transparency: reduce) {
  #hub .glass-surface.glass-surface,
  #hub .glass-action,
  #hub .glass-icon,
  .svg-glass #hub .glass-surface.glass-surface,
  .svg-glass #hub .glass-action {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  #hub .glass-surface.glass-surface { background-color: #161616 !important; }
  #hub .glass-action { background-color: #242424 !important; }
  #hub .glass-action[aria-pressed='true'],
  #hub .glass-action[aria-current='page'],
  #hub .glass-action[aria-selected='true'],
  #hub .glass-action.active { background-color: #343434 !important; }
  #hub .glass-icon,
  #hub .glass-action > .btn-icon { background-color: #171717 !important; }
}
@media (forced-colors: active) {
  #hub .glass-surface.glass-surface,
  #hub .glass-action,
  #hub .glass-icon {
    background-color: Canvas !important;
    color: CanvasText !important;
    border-color: CanvasText !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  #hub .glass-action::before,
  #hub .glass-action::after,
  #hub .glass-surface::before,
  #hub .glass-surface::after,
  #hub .glass-action .circle-overlay { display: none; }
  #hub .glass-action:focus-visible { outline-color: Highlight; }
  #hub .glass-action:disabled,
  #hub .glass-action[aria-disabled='true'] { color: GrayText; border-color: GrayText; }
}
