:root {
  --oc-progress-hud-safe-bottom: max(14px, env(safe-area-inset-bottom));
  --oc-progress-hud-safe-right: max(14px, env(safe-area-inset-right));
}

#openclaw-progress-capsule-root {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 2147482500;
  width: fit-content;
  height: fit-content;
  pointer-events: none;
  transform: translate3d(calc(100vw - 366px), 12px, 0);
  will-change: transform;
  contain: layout style paint;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.oc-progress-hud {
  --oc-hud-rgb: 63, 159, 106;
  --oc-hud-accent: rgb(var(--oc-hud-rgb));
  --oc-hud-glow: rgba(var(--oc-hud-rgb), 0.22);
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(216px, 1fr) 34px;
  align-items: stretch;
  gap: 8px;
  width: min(350px, calc(100vw - 14px));
  min-height: 74px;
  box-sizing: border-box;
  color: #213528;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,255,250,0.78)),
    radial-gradient(circle at 8% 10%, rgba(var(--oc-hud-rgb), 0.13), transparent 42%);
  border: 1px solid rgba(63, 159, 106, 0.20);
  border-radius: 24px;
  box-shadow:
    0 18px 48px rgba(53, 107, 72, 0.14),
    0 2px 8px rgba(26, 52, 36, 0.08),
    inset 0 1px 0 rgba(255,255,255,0.92);
  backdrop-filter: blur(18px) saturate(1.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  opacity: 0.92;
  transition:
    opacity 160ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    width 180ms ease,
    min-height 180ms ease;
}

.oc-progress-hud::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--oc-hud-rgb), 0.14), transparent 36%, rgba(255,255,255,0.42) 72%, transparent),
    linear-gradient(180deg, rgba(255,255,255,0.42), transparent 58%);
  opacity: 0.62;
}

.oc-progress-hud.is-idle {
  opacity: 0.62;
  filter: saturate(0.92);
}

.oc-progress-hud.is-active {
  opacity: 0.98;
  border-color: rgba(var(--oc-hud-rgb), 0.34);
  box-shadow:
    0 18px 52px rgba(53, 107, 72, 0.18),
    0 0 0 1px rgba(var(--oc-hud-rgb), 0.10),
    0 0 34px var(--oc-hud-glow),
    inset 0 1px 0 rgba(255,255,255,0.96);
}

.oc-progress-hud.is-dragging {
  opacity: 1;
  box-shadow:
    0 24px 64px rgba(53, 107, 72, 0.22),
    0 10px 26px rgba(26, 52, 36, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.95);
  transition: opacity 80ms ease, box-shadow 80ms ease;
}

.oc-progress-hud.is-expanded {
  width: min(390px, calc(100vw - 14px));
  min-height: 214px;
  grid-template-rows: auto auto;
}

.oc-progress-hud.sentinel-low { --oc-hud-rgb: 63, 159, 106; }
.oc-progress-hud.sentinel-normal { --oc-hud-rgb: 63, 159, 106; }
.oc-progress-hud.sentinel-medium { --oc-hud-rgb: 217, 119, 6; }
.oc-progress-hud.sentinel-high { --oc-hud-rgb: 220, 38, 38; }
.oc-progress-hud.is-error { --oc-hud-rgb: 220, 38, 38; }
.oc-progress-hud.is-done { --oc-hud-rgb: 47, 127, 80; }

.oc-progress-hud__grab,
.oc-progress-hud__toggle {
  position: relative;
  z-index: 2;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

.oc-progress-hud__grab {
  display: grid;
  place-content: center;
  gap: 3px;
  padding-left: 2px;
  border-right: 1px solid rgba(63, 159, 106, 0.12);
}

.oc-progress-hud__grab span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(var(--oc-hud-rgb), 0.42);
  box-shadow: 8px 0 0 rgba(var(--oc-hud-rgb), 0.22);
}

.oc-progress-hud.is-dragging .oc-progress-hud__grab { cursor: grabbing; }

.oc-progress-hud__main {
  position: relative;
  z-index: 2;
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px 0 9px;
}

.oc-progress-hud__topline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  line-height: 1.15;
}

.oc-progress-hud__state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--oc-hud-accent);
  box-shadow: 0 0 0 3px rgba(var(--oc-hud-rgb), 0.11), 0 0 15px rgba(var(--oc-hud-rgb), 0.38);
  flex: 0 0 auto;
}

.oc-progress-hud.is-active .oc-progress-hud__state-dot {
  animation: oc-progress-hud-pulse 1.35s ease-in-out infinite;
}

.oc-progress-hud__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: -0.01em;
  color: #203427;
}

.oc-progress-hud__percent {
  margin-left: auto;
  font-size: 12px;
  font-weight: 850;
  color: rgb(var(--oc-hud-rgb));
  font-variant-numeric: tabular-nums;
}

.oc-progress-hud__bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(63, 159, 106, 0.10);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(63, 159, 106, 0.08);
}

.oc-progress-hud__bar span {
  display: block;
  width: calc(var(--oc-progress, 0.03) * 100%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(var(--oc-hud-rgb)), rgba(111, 189, 141, 0.88), rgba(255,255,255,0.9));
  box-shadow: 0 0 16px rgba(var(--oc-hud-rgb), 0.24);
  transition: width 240ms ease-out;
}

.oc-progress-hud__detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.25;
  color: rgba(43, 71, 53, 0.84);
}

.oc-progress-hud__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.oc-progress-hud__meta span {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 92px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(63, 159, 106, 0.08);
  color: rgba(43, 71, 53, 0.72);
  font-size: 9.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.oc-progress-hud__toggle {
  display: grid;
  place-items: center;
  min-width: 34px;
  color: rgba(47, 127, 80, 0.88);
  border-left: 1px solid rgba(63, 159, 106, 0.12);
  font-size: 20px;
  line-height: 1;
}

.oc-progress-hud__toggle:active,
.oc-progress-hud__grab:active {
  transform: scale(0.98);
}

.oc-progress-hud__panel {
  position: relative;
  z-index: 2;
  grid-column: 1 / -1;
  display: none;
  padding: 0 12px 12px;
}

.oc-progress-hud.is-expanded .oc-progress-hud__panel {
  display: block;
}

.oc-progress-hud__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(63, 159, 106, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
}

.oc-progress-hud__grid div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.oc-progress-hud__grid b {
  color: rgba(43, 71, 53, 0.58);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.oc-progress-hud__grid span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #213528;
  font-size: 10.5px;
  font-weight: 720;
}

.oc-progress-hud__events {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  max-height: 86px;
  overflow: hidden;
}

.oc-progress-hud__event,
.oc-progress-hud__empty {
  display: grid;
  grid-template-columns: 54px 74px 1fr;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(248, 255, 250, 0.54);
  color: rgba(43, 71, 53, 0.76);
  font-size: 10px;
}

.oc-progress-hud__event span,
.oc-progress-hud__event b,
.oc-progress-hud__event em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.oc-progress-hud__event b {
  color: rgb(var(--oc-hud-rgb));
  font-weight: 800;
}

.oc-progress-hud__empty {
  grid-template-columns: 1fr;
  text-align: center;
}

@keyframes oc-progress-hud-pulse {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.22); opacity: 1; }
}

@media (max-width: 680px) {
  #openclaw-progress-capsule-root {
    transform: translate3d(8px, 10px, 0);
  }
  .oc-progress-hud {
    width: min(338px, calc(100vw - 12px));
    grid-template-columns: 28px minmax(190px, 1fr) 32px;
    border-radius: 22px;
  }
  .oc-progress-hud.is-expanded {
    width: min(374px, calc(100vw - 12px));
  }
  .oc-progress-hud__event {
    grid-template-columns: 48px 64px 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .oc-progress-hud,
  .oc-progress-hud__bar span,
  .oc-progress-hud__state-dot {
    animation: none !important;
    transition: none !important;
  }
}

/* v5 — default compact sphere; tap/click to expand detailed HUD */
.oc-progress-hud:not(.is-expanded) {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  width: 74px;
  min-width: 74px;
  height: 74px;
  min-height: 74px;
  border-radius: 50%;
  padding: 0;
  gap: 0;
  overflow: visible;
  cursor: grab;
  background:
    radial-gradient(circle at 34% 24%, rgba(255,255,255,0.96) 0 12%, rgba(248,255,250,0.88) 23%, rgba(111,189,141,0.58) 52%, rgba(var(--oc-hud-rgb),0.88) 100%),
    linear-gradient(145deg, rgba(255,255,255,0.84), rgba(248,255,250,0.48));
  border-color: rgba(var(--oc-hud-rgb), 0.30);
  box-shadow:
    0 16px 38px rgba(53,107,72,0.18),
    0 0 0 1px rgba(var(--oc-hud-rgb),0.10),
    0 0 26px rgba(var(--oc-hud-rgb),0.18),
    inset 8px 10px 18px rgba(255,255,255,0.42),
    inset -12px -16px 24px rgba(20,83,45,0.20);
}

.oc-progress-hud:not(.is-expanded)::before {
  inset: -7px;
  border-radius: 50%;
  opacity: 0.78;
  background:
    conic-gradient(from -80deg, transparent 0 20%, rgba(var(--oc-hud-rgb),0.46) 26%, transparent 34% 61%, rgba(255,255,255,0.58) 68%, transparent 76% 100%);
  filter: blur(0.2px);
  animation: oc-progress-orb-ring 4.2s linear infinite;
}

.oc-progress-hud:not(.is-expanded)::after {
  content: attr(data-percent) "\A" attr(data-state);
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  white-space: pre;
  text-align: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #15351f;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(circle at 36% 28%, rgba(255,255,255,0.68), transparent 38%),
    rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.48);
}

.oc-progress-hud:not(.is-expanded).is-active {
  animation: oc-progress-orb-breathe 1.8s ease-in-out infinite;
}

.oc-progress-hud:not(.is-expanded).is-dragging {
  cursor: grabbing;
  transform: scale(1.02);
}

.oc-progress-hud:not(.is-expanded) .oc-progress-hud__grab,
.oc-progress-hud:not(.is-expanded) .oc-progress-hud__main,
.oc-progress-hud:not(.is-expanded) .oc-progress-hud__toggle,
.oc-progress-hud:not(.is-expanded) .oc-progress-hud__panel {
  display: none !important;
}

.oc-progress-hud.is-expanded {
  cursor: grab;
}

.oc-progress-hud.is-expanded .oc-progress-hud__main,
.oc-progress-hud.is-expanded .oc-progress-hud__toggle,
.oc-progress-hud.is-expanded .oc-progress-hud__panel {
  display: grid;
}

.oc-progress-hud.is-expanded .oc-progress-hud__grab {
  display: grid;
}

@keyframes oc-progress-orb-ring {
  to { transform: rotate(360deg); }
}

@keyframes oc-progress-orb-breathe {
  0%, 100% { filter: saturate(1) brightness(1); }
  50% { filter: saturate(1.12) brightness(1.04); }
}

@media (max-width: 680px) {
  .oc-progress-hud:not(.is-expanded) {
    width: 68px;
    min-width: 68px;
    height: 68px;
    min-height: 68px;
  }
  .oc-progress-hud:not(.is-expanded)::after {
    width: 54px;
    height: 54px;
    font-size: 9.5px;
  }
}

/* v6 drag hot-path: no blur/filter/heavy shadow while pointer is moving */
html.openclaw-motion-dragging .oc-progress-hud,
html.openclaw-progress-hud-dragging .oc-progress-hud,
.oc-progress-hud.is-dragging {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
  animation: none !important;
  transition: none !important;
  box-shadow: 0 10px 22px rgba(53,107,72,0.16), inset 0 1px 0 rgba(255,255,255,0.58) !important;
  contain: strict;
}

html.openclaw-motion-dragging .oc-progress-hud::before,
html.openclaw-progress-hud-dragging .oc-progress-hud::before,
.oc-progress-hud.is-dragging::before {
  animation: none !important;
  filter: none !important;
  opacity: 0.28 !important;
}

html.openclaw-motion-dragging .oc-progress-hud *,
html.openclaw-progress-hud-dragging .oc-progress-hud * {
  transition: none !important;
  animation: none !important;
}
