/* Упомни small primitives · approved DGN-008 · depends on tokens.css */

:where([data-up-theme="light"], [data-up-theme="dark"]) {
  font-family: var(--font-body);
  color: var(--text);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

.up-icon {
  width: var(--up-icon);
  height: var(--up-icon);
  flex: 0 0 var(--up-icon);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.up-button,
.up-icon-button,
.up-select-trigger {
  appearance: none;
  border: var(--up-border) solid transparent;
  border-radius: var(--radius);
  min-height: var(--up-control-h);
  font: var(--up-type-control);
  letter-spacing: 0;
  transition: background-color var(--up-motion-fast) var(--up-ease), border-color var(--up-motion-fast) var(--up-ease), color var(--up-motion-fast) var(--up-ease), transform var(--up-motion-fast) var(--up-ease);
  cursor: pointer;
}

.up-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--up-space-2);
  padding: calc((var(--up-control-h) - 18px) / 2 - 1px) var(--up-control-px);
  white-space: nowrap;
}

.up-button--primary {
  color: var(--on-color);
  background: var(--accent);
}

.up-button--primary:hover,
.up-button--primary.is-hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--text));
}

.up-button--primary:active,
.up-button--primary.is-pressed {
  background: color-mix(in srgb, var(--accent) 76%, var(--text));
  transform: translateY(1px);
}

.up-button--secondary,
.up-select-trigger,
.up-icon-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.up-button--secondary:hover,
.up-button--secondary.is-hover,
.up-select-trigger:hover,
.up-select-trigger.is-hover,
.up-icon-button:hover,
.up-icon-button.is-hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--line) 62%, var(--text));
}

.up-button--secondary:active,
.up-button--secondary.is-pressed,
.up-select-trigger:active,
.up-select-trigger.is-pressed,
.up-icon-button:active,
.up-icon-button.is-pressed {
  background: color-mix(in srgb, var(--surface-2) 86%, var(--line));
  transform: translateY(1px);
}

.up-button--quiet {
  color: var(--text);
  background: transparent;
}

.up-button--quiet:hover,
.up-button--quiet.is-hover,
.up-button--quiet:active,
.up-button--quiet.is-pressed {
  background: var(--surface-2);
}

.up-button--danger {
  color: var(--err);
  background: var(--surface);
  border-color: color-mix(in srgb, var(--err) 44%, var(--line));
}

.up-button--danger:hover,
.up-button--danger.is-hover,
.up-button--danger:active,
.up-button--danger.is-pressed {
  background: var(--err-soft);
  border-color: var(--err);
}

.up-button:focus-visible,
.up-icon-button:focus-visible,
.up-select-trigger:focus-visible,
.up-field__control:focus-visible,
.up-choice__input:focus-visible + .up-choice__mark,
.up-switch__input:focus-visible + .up-switch__track,
.ak-link:focus-visible,
.ak-chip:focus-visible,
.ak-term:focus-visible {
  outline: var(--up-focus) solid var(--info);
  outline-offset: var(--up-focus-offset);
}

.up-button.is-focus,
.up-icon-button.is-focus,
.up-select-trigger.is-focus,
.up-field__control.is-focus,
.up-choice.is-focus .up-choice__mark,
.up-switch.is-focus .up-switch__track {
  outline: var(--up-focus) solid var(--info);
  outline-offset: var(--up-focus-offset);
}

.up-button:disabled,
.up-icon-button:disabled,
.up-select-trigger:disabled,
.up-field__control:disabled,
.up-choice__input:disabled + .up-choice__mark,
.up-switch__input:disabled + .up-switch__track,
.is-disabled {
  opacity: var(--up-disabled-opacity);
  cursor: not-allowed;
  pointer-events: none;
}

.up-button.is-loading {
  cursor: wait;
}

.up-button.is-loading .up-button__label {
  opacity: 0.66;
}

.up-icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--up-hit);
  min-width: var(--up-hit);
  padding: 0;
}

.up-spinner {
  width: var(--up-icon);
  height: var(--up-icon);
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: up-spin 700ms linear infinite;
}

.ak-link,
.ak-term {
  color: var(--info);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-radius: 1px;
}

.ak-link:has(.up-icon) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ak-link:has(.up-icon) .up-icon { width: 15px; height: 15px; }

.ak-link:hover,
.ak-link.is-hover,
.ak-term:hover,
.ak-term.is-hover {
  text-decoration-thickness: 2px;
}

.ak-link--danger { color: var(--err); }

.ak-term {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--muted);
}

.up-field {
  display: grid;
  gap: var(--up-space-2);
  min-width: 0;
}

.up-field__label {
  font: var(--up-type-control);
  color: var(--text);
}

.up-field__required { color: var(--err); }

.up-field__frame {
  position: relative;
  display: flex;
  align-items: center;
}

.up-field__frame > .up-icon {
  position: absolute;
  left: var(--up-space-3);
  color: var(--muted);
  pointer-events: none;
}

.up-field__control {
  width: 100%;
  height: var(--up-control-h);
  min-height: var(--up-control-h);
  box-sizing: border-box;
  padding: calc((var(--up-control-h) - 18px) / 2 - 1px) var(--up-space-3);
  border: var(--up-border) solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font: var(--up-type-control);
  caret-color: var(--accent);
  transition: border-color var(--up-motion-fast) var(--up-ease), background-color var(--up-motion-fast) var(--up-ease);
}

.up-field__frame > .up-icon + .up-field__control { padding-left: 40px; }

.up-field__control:hover { border-color: color-mix(in srgb, var(--line) 60%, var(--text)); }
.up-field__control:focus { border-color: var(--info); }
.up-field__control::placeholder { color: var(--muted); opacity: 1; }
.up-field__control[readonly] { background: var(--surface-2); }

textarea.up-field__control {
  min-height: 80px;
  resize: vertical;
}

.up-field__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--up-space-3);
  color: var(--muted);
  font: var(--up-type-meta);
}

.up-field--error .up-field__control,
.up-field__control[aria-invalid="true"] { border-color: var(--err); }
.up-field--error .up-field__meta { color: var(--err); }

.up-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--up-space-4);
  min-width: 208px;
  padding: 0 var(--up-space-3);
}

.up-choice,
.up-switch {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--up-space-3);
  color: var(--text);
  font: var(--up-type-control);
  cursor: pointer;
}

.up-choice__input,
.up-switch__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.up-choice__mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  flex: 0 0 18px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--on-color);
  transition: background-color var(--up-motion-fast) var(--up-ease), border-color var(--up-motion-fast) var(--up-ease);
}

.up-choice--radio .up-choice__mark { border-radius: 50%; }
.up-choice__input:checked + .up-choice__mark,
.up-choice__input:indeterminate + .up-choice__mark {
  background: var(--accent);
  border-color: var(--accent);
}

.up-choice__mark .up-icon { width: 14px; height: 14px; opacity: 0; }
.up-choice__input:checked + .up-choice__mark .up-icon { opacity: 1; }
.up-choice--indeterminate .up-choice__mark .up-icon { display: none; }
.up-choice--indeterminate .up-choice__input:indeterminate + .up-choice__mark::after {
  content: "";
  width: 8px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--on-color);
}
.up-choice--radio .up-choice__input:checked + .up-choice__mark::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--on-color);
}

.up-choice__label { display: grid; gap: 2px; }
.up-choice__hint { color: var(--muted); font-size: 12px; line-height: 16px; }

.up-switch { align-items: center; }
.up-switch__track {
  position: relative;
  width: 36px;
  height: 20px;
  flex: 0 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  transition: background-color var(--up-motion-fast) var(--up-ease), border-color var(--up-motion-fast) var(--up-ease);
}

.up-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--up-motion-normal) var(--up-ease), background-color var(--up-motion-fast) var(--up-ease);
}

.up-switch__input:checked + .up-switch__track {
  background: var(--accent);
  border-color: var(--accent);
}
.up-switch__input:checked + .up-switch__track::after {
  transform: translateX(16px);
  background: var(--on-color);
}

.ak-badge,
.ak-status,
.ak-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font: 500 12px/16px var(--font-body);
}

.ak-badge,
.ak-status { padding: 3px 7px; }
.ak-chip { min-height: 28px; padding: 4px 8px; font-size: 13px; line-height: 18px; }
.ak-chip[tabindex] { cursor: pointer; }

.ak-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.ak-badge--info,
.ak-status--info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, var(--line)); }
.ak-badge--ok,
.ak-status--ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, var(--line)); }
.ak-badge--warn,
.ak-status--warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, var(--line)); }
.ak-badge--err,
.ak-status--err { color: var(--err); background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 28%, var(--line)); }
.ak-status--info::before { background: var(--info); }
.ak-status--ok::before { background: var(--ok); }
.ak-status--warn::before { background: var(--warn); }
.ak-status--err::before { background: var(--err); }

.ak-chip__remove {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: -1px -3px -1px 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.ak-chip__remove .up-icon { width: 14px; height: 14px; }

.ak-progress {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-2);
}
.ak-progress__bar { height: 100%; background: var(--accent); }
.ak-progress--ok .ak-progress__bar { background: var(--ok); }

.ak-skeleton {
  display: block;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--surface-2) 22%, color-mix(in srgb, var(--surface-2) 78%, var(--line)) 38%, var(--surface-2) 54%);
  background-size: 220% 100%;
  animation: up-skeleton 1.5s ease-in-out infinite;
}

.up-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

.up-kbd {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--text);
  background: var(--surface);
  font: 500 12px/16px var(--font-mono);
}

.up-evidence {
  padding: 1px 3px;
  border-radius: 2px;
  color: var(--text);
  background: var(--accent-soft);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.up-tooltip {
  display: inline-block;
  max-width: 240px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font: 400 12px/16px var(--font-body);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--text) 12%, transparent);
}

@keyframes up-spin { to { transform: rotate(360deg); } }
@keyframes up-skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  .up-spinner { animation-duration: 1.8s; }
  .ak-skeleton { animation: none; }
}
