.o-checkbox, .o-checkbox-indicator {
  --checkbox-side: 26px;
  --checkbox-accent: var(--ink);
  --checkbox-gradient: var(--cta-ink-gradient);
  --checkbox-shadow: var(--shadow-control-small);
  --checkbox-rim: var(--cta-ink-rim);
}
.o-checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
  color: var(--ink);
}

.o-checkbox[hidden] { display: none; }

.o-checkbox input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.o-checkbox-surface {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--checkbox-side);
  height: var(--checkbox-side);
  border-radius: 35%;
  overflow: hidden;
  background: var(--cta-glass-gradient);
  box-shadow: var(--shadow-control-small);
  transition: box-shadow 250ms ease-out 100ms, transform 0.16s var(--ease-quint);
}
@supports (transition-timing-function: linear(0, 1)) {
  .o-checkbox-surface { transition: box-shadow 250ms ease-out 100ms, transform var(--motion-release) var(--ease-bounce); }
}
.o-checkbox:active:not(:has(input:disabled)) .o-checkbox-surface {
  transform: scale(0.9);
  transition-duration: 250ms, var(--motion-press);
  transition-timing-function: ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .o-checkbox:hover:not(:has(input:disabled)) input:not(:checked) + .o-checkbox-surface { box-shadow: var(--shadow-control); }
}
.o-checkbox-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: var(--checkbox-accent);
  background-image: var(--checkbox-gradient);
  clip-path: circle(0% at 50% 50%);
  opacity: 0;
  transition: clip-path 200ms ease-in, opacity 200ms ease-in;
}
.o-checkbox-surface::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: var(--cta-glass-rim); transition: box-shadow 250ms ease-out 100ms; }
.o-checkbox-surface svg {
  position: relative;
  width: 46%;
  height: 46%;
  fill: none;
  stroke: var(--on-ink);
  stroke-width: 3.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: rotate(-25deg);
  transition: transform 250ms ease-out 100ms, opacity 250ms ease-out 100ms, stroke-dashoffset 320ms var(--ease-out) 120ms;
}
.o-checkbox input + .o-checkbox-surface svg { stroke-dasharray: 30; stroke-dashoffset: 30; }
.o-checkbox input:checked + .o-checkbox-surface,
.o-checkbox-indicator[data-checked="true"] { box-shadow: var(--checkbox-shadow); }
.o-checkbox input:checked + .o-checkbox-surface::before,
.o-checkbox-indicator[data-checked="true"]::before { clip-path: circle(72% at 50% 50%); opacity: 1; }
.o-checkbox input:checked + .o-checkbox-surface::after,
.o-checkbox-indicator[data-checked="true"]::after { box-shadow: var(--checkbox-rim); }
.o-checkbox input:checked + .o-checkbox-surface svg,
.o-checkbox-indicator[data-checked="true"] svg { opacity: 1; transform: rotate(0); stroke-dashoffset: 0; }
.o-checkbox input:focus-visible + .o-checkbox-surface { outline: 2px solid var(--tint); outline-offset: 4px; }
.o-checkbox:has(input:disabled) { cursor: default; }
.o-checkbox input:disabled + .o-checkbox-surface { opacity: .4; filter: grayscale(.4); }
.o-checkbox-row { display: flex; justify-content: space-between; width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .o-checkbox-surface, .o-checkbox-surface::before, .o-checkbox-surface::after, .o-checkbox-surface svg { transition: none; }
}

.o-checkbox-danger {
  --checkbox-accent: var(--danger);
  --checkbox-gradient: var(--cta-danger-gradient);
  --checkbox-shadow: var(--shadow-control-small);
  --checkbox-rim: var(--cta-danger-rim);
}

.o-checkbox-round .o-checkbox-surface, .o-checkbox-surface.o-checkbox-round { border-radius: 50%; }

.o-checkbox-switch .o-checkbox-surface {
  justify-items: start;
  width: var(--switch-width);
  height: var(--switch-height);
  border-radius: 999px;
  background: var(--switch-track);
  box-shadow: var(--switch-track-shadow);
}
.o-checkbox-switch .o-checkbox-surface::before {
  clip-path: circle(0% at calc(var(--switch-height) / 2) 50%);
  transition: clip-path 320ms var(--ease-out), opacity 160ms ease-out;
}
.o-checkbox-switch .o-checkbox-surface::after { box-shadow: none; }
.o-checkbox-switch .o-checkbox-surface svg {
  box-sizing: border-box;
  width: var(--switch-thumb);
  height: var(--switch-thumb);
  margin-left: calc((var(--switch-height) - var(--switch-thumb)) / 2);
  padding: 6px;
  border-radius: 50%;
  background: var(--switch-thumb-surface);
  box-shadow: var(--switch-thumb-shadow);
  stroke: var(--ink);
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  opacity: 1;
  transform: none;
  transition: transform 0.24s var(--ease-quint), stroke-dashoffset 260ms var(--ease-out) 140ms;
}
@supports (transition-timing-function: linear(0, 1)) {
  .o-checkbox-switch .o-checkbox-surface svg { transition: transform var(--motion-release) var(--ease-spring), stroke-dashoffset 260ms var(--ease-out) 140ms; }
}
.o-checkbox-switch input:checked + .o-checkbox-surface { box-shadow: var(--switch-track-shadow); }
.o-checkbox-switch input:checked + .o-checkbox-surface::before { clip-path: circle(150% at calc(var(--switch-height) / 2) 50%); opacity: 1; }
.o-checkbox-switch input:checked + .o-checkbox-surface::after { box-shadow: var(--checkbox-rim); }
.o-checkbox-switch input:checked + .o-checkbox-surface svg {
  transform: translateX(calc(var(--switch-width) - var(--switch-height)));
  stroke-dashoffset: 0;
}
.o-checkbox-switch:active:not(:has(input:disabled)) .o-checkbox-surface { transform: none; }
.o-checkbox-switch:active:not(:has(input:disabled)) .o-checkbox-surface svg { width: calc(var(--switch-thumb) + 4px); }
.o-checkbox-switch:active:not(:has(input:disabled)) input:checked + .o-checkbox-surface svg { transform: translateX(calc(var(--switch-width) - var(--switch-height) - 4px)); }
@media (hover: hover) and (pointer: fine) {
  .o-checkbox-switch:hover:not(:has(input:disabled)) input:not(:checked) + .o-checkbox-surface { box-shadow: var(--switch-track-shadow); background: linear-gradient(180deg, rgba(22, 26, 44, 0.2), rgba(22, 26, 44, 0.12)); }
}
@media (prefers-reduced-motion: reduce) {
  .o-checkbox-switch .o-checkbox-surface svg { transition: none; }
  .o-checkbox:active .o-checkbox-surface { transform: none; }
}
@media (prefers-contrast: more) {
  .o-checkbox-surface { outline: 1px solid var(--ink); }
}
@media (forced-colors: active) {
  .o-checkbox-surface { border: 1px solid ButtonText; }
  .o-checkbox input:checked + .o-checkbox-surface { background: Highlight; }
  .o-checkbox-surface svg { stroke: HighlightText; }
}
