:root {
  --ace-bg: #f5f5f2;
  --ace-fg: #111111;
  --ace-muted: #52524d;
  --ace-line: #1f1f1c;
  --ace-line-soft: #c8c8c2;
  --ace-surface: #ffffff;
  --ace-soft: #eaeae4;
  --ace-danger: #b42318;
  --ace-danger-bg: #fff2f0;
  --ace-success: #176b3a;
  --ace-success-bg: #eef8f1;
  --ace-focus-ring: 0 0 0 2px var(--ace-bg), 0 0 0 4px var(--ace-fg);
  --ace-radius: 0;
  --ace-border: 2px solid var(--ace-line);
  --ace-border-subtle: 2px solid var(--ace-line-soft);
  --ace-shadow-pixel: 4px 4px 0 var(--ace-fg);
  --ace-shadow-pixel-sm: 2px 2px 0 var(--ace-fg);
  --ace-shadow-soft: 4px 4px 0 rgba(17, 17, 17, 0.16);
  --ace-shadow-modal: 6px 6px 0 var(--ace-fg);
  --ace-content-max: 980px;
  --ace-motion-fast: .12s steps(3, end);
  --ace-motion-standard: .16s steps(4, end);
  --ace-step: 8px;
  --ace-step-sm: 4px;
}

:root[data-theme="dark"] {
  --ace-bg: #121210;
  --ace-fg: #f3f3ee;
  --ace-muted: #b0b0a8;
  --ace-line: #e4e4dc;
  --ace-line-soft: #4a4a44;
  --ace-surface: #1b1b18;
  --ace-soft: #252521;
  --ace-danger: #ff6b5e;
  --ace-danger-bg: #2c1715;
  --ace-success: #4fd180;
  --ace-success-bg: #14281c;
  --ace-focus-ring: 0 0 0 2px var(--ace-bg), 0 0 0 4px var(--ace-fg);
  --ace-shadow-pixel: 4px 4px 0 #000000;
  --ace-shadow-pixel-sm: 2px 2px 0 #000000;
  --ace-shadow-soft: 4px 4px 0 #000000;
  --ace-shadow-modal: 6px 6px 0 #000000;
}

.ace-status {
  min-height: 18px;
  color: var(--ace-muted);
  font-size: 12px;
  line-height: 1.45;
}

.ace-status.error { color: var(--ace-danger); }
.ace-status.success { color: var(--ace-success); }

.ace-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ace-loading::before {
  content: "";
  width: 30px;
  height: 30px;
  flex: 0 0 28px;
  border: 3px solid var(--ace-fg);
  border-radius: 0;
  clip-path: polygon(
    0 var(--ace-step),
    var(--ace-step) 0,
    calc(100% - var(--ace-step)) 0,
    100% var(--ace-step),
    100% calc(100% - var(--ace-step)),
    calc(100% - var(--ace-step)) 100%,
    var(--ace-step) 100%,
    0 calc(100% - var(--ace-step))
  );
  animation: ace-loader-step .8s steps(8,end) infinite;
}

.ace-loading.ace-loading-centered {
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.ace-loading.ace-loading-centered::before {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-width: 4px;
}

@keyframes ace-loader-step {
  0% { transform: rotate(0deg); }
  12.5% { transform: rotate(45deg); }
  25% { transform: rotate(90deg); }
  37.5% { transform: rotate(135deg); }
  50% { transform: rotate(180deg); }
  62.5% { transform: rotate(225deg); }
  75% { transform: rotate(270deg); }
  87.5% { transform: rotate(315deg); }
  100% { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
