.hubit-avatar-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color-light, var(--bs-border-color, rgba(0, 0, 0, 0.1)));
}

.hubit-avatar-editor__preview-wrap {
  flex: 0 0 auto;
}

.hubit-avatar-editor__preview-trigger {
  position: relative;
  display: block;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.hubit-avatar-editor__preview-trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--bs-primary, #0d6efd) 40%, transparent);
  outline-offset: 3px;
}

.hubit-avatar-editor__preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.75rem;
  color: #fff;
  background: linear-gradient(135deg, #5d9779, #3d6b55);
  border: 2px solid var(--border-color, var(--bs-border-color, rgba(0, 0, 0, 0.12)));
}

.hubit-avatar-editor__preview-trigger .hubit-avatar-editor__preview {
  transition: filter 140ms ease, transform 140ms ease;
}

.hubit-avatar-editor__preview-trigger:hover .hubit-avatar-editor__preview,
.hubit-avatar-editor__preview-trigger:focus-visible .hubit-avatar-editor__preview {
  filter: brightness(0.86);
  transform: scale(1.015);
}

.hubit-avatar-editor__preview-badge {
  position: absolute;
  right: -0.1rem;
  bottom: -0.1rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd)));
  border: 3px solid var(--bg-surface, var(--bs-body-bg, #fff));
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease, background-color 140ms ease;
}

.hubit-avatar-editor__preview-trigger:hover .hubit-avatar-editor__preview-badge,
.hubit-avatar-editor__preview-trigger:focus-visible .hubit-avatar-editor__preview-badge {
  background: color-mix(in srgb, var(--bs-primary, #0d6efd) 82%, #000);
  transform: scale(1.08);
}

.hubit-avatar-editor__preview-badge svg,
.hubit-avatar-editor__dropzone-icon svg {
  width: 1rem;
  height: 1rem;
  max-width: none;
  max-height: none;
  flex: 0 0 auto;
  fill: currentColor;
}

.hubit-avatar-editor__preview.is-initials {
  user-select: none;
}

.hubit-avatar-editor__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hubit-avatar-editor__actions {
  min-width: 0;
}

.hubit-avatar-editor__label {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, inherit);
}

.hubit-avatar-editor__hint {
  font-size: 0.875rem;
  color: var(--text-secondary, var(--bs-secondary-color, #6c757d));
  margin: 0.2rem 0 0.65rem;
}

.hubit-avatar-editor__file-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.hubit-avatar-editor__dropzone {
  width: 100%;
  min-height: 3.75rem;
  margin: 0;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.7rem;
  color: var(--text-primary, var(--bs-body-color, #212529));
  font: inherit;
  text-align: left;
  background: var(--bg-hover, var(--bs-tertiary-bg, #f8f9fa));
  border: 1px dashed var(--border-color, var(--bs-border-color, rgba(0, 0, 0, 0.22)));
  border-radius: var(--radius, var(--bs-border-radius, 0.5rem));
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.hubit-avatar-editor__dropzone-icon {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  color: var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd)));
  background: color-mix(in srgb, var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd))) 12%, var(--bg-surface, var(--bs-body-bg, #fff)));
  border-radius: 0.55rem;
}

.hubit-avatar-editor__dropzone-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.hubit-avatar-editor__dropzone:hover,
.hubit-avatar-editor__dropzone.is-dragover {
  color: var(--text-link, var(--color-primary, var(--bs-primary, #0d6efd)));
  background: color-mix(in srgb, var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd))) 10%, var(--bg-hover, var(--bs-body-bg, #fff)));
  border-color: var(--text-link, var(--color-primary, var(--bs-primary, #0d6efd)));
}

.hubit-avatar-editor__dropzone.is-dragover {
  border-style: solid;
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd))) 18%, transparent);
}

.hubit-avatar-editor__dropzone:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary, var(--text-link, var(--bs-primary, #0d6efd))) 35%, transparent);
  outline-offset: 2px;
}

.hubit-avatar-editor__dropzone-title {
  font-weight: 600;
  line-height: 1.25;
}

.hubit-avatar-editor__dropzone-hint {
  color: var(--text-secondary, var(--bs-secondary-color, #6c757d));
  font-size: 0.8125rem;
  line-height: 1.25;
}

.hubit-avatar-editor__toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.hubit-avatar-editor__status {
  font-size: 0.875rem;
  min-height: 1.25rem;
  margin-top: 0.5rem;
  color: var(--text-secondary, var(--bs-secondary-color, #6c757d));
}

.hubit-avatar-editor__status.is-error {
  color: var(--bs-danger, #dc3545);
}

.hubit-avatar-editor__status.is-success {
  color: var(--bs-success, #198754);
}

.hubit-avatar-editor__modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  overflow-y: auto;
}

.hubit-avatar-editor__modal.is-open {
  display: flex;
}

.hubit-avatar-editor__dialog {
  background: var(--bg-surface, var(--bs-body-bg, #fff));
  color: var(--text-primary, inherit);
  border-radius: 12px;
  max-width: 420px;
  max-height: calc(100dvh - 2rem);
  width: 100%;
  padding: 1.25rem;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

.hubit-avatar-editor__dialog h2 {
  font-size: 1.125rem;
  margin: 0 0 0.75rem;
  color: var(--text-primary, inherit);
}

.hubit-avatar-editor__canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.hubit-avatar-editor__canvas {
  width: 280px;
  max-width: 100%;
  height: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  background: #111;
}

.hubit-avatar-editor__canvas:active {
  cursor: grabbing;
}

.hubit-avatar-editor__zoom {
  margin-bottom: 1rem;
}

.hubit-avatar-editor__zoom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

.hubit-avatar-editor__zoom-head label {
  margin: 0;
}

.hubit-avatar-editor__zoom-head output {
  color: var(--text-secondary, var(--bs-secondary-color, #6c757d));
  font-variant-numeric: tabular-nums;
}

.hubit-avatar-editor__zoom .form-range {
  width: 100%;
}

.hubit-avatar-editor__zoom-hint {
  margin: 0.35rem 0 0;
  color: var(--text-secondary, var(--bs-secondary-color, #6c757d));
  font-size: 0.8125rem;
}

.hubit-avatar-editor__footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

@media (max-width: 479.98px) {
  .hubit-avatar-editor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
  }

  .hubit-avatar-editor__preview-wrap {
    justify-self: center;
  }

  .hubit-avatar-editor__dropzone {
    align-items: flex-start;
  }

  .hubit-avatar-editor__toolbar {
    justify-content: stretch;
  }

  .hubit-avatar-editor__toolbar .btn {
    width: 100%;
  }

  .hubit-avatar-editor__canvas {
    width: min(280px, calc(100vw - 4.5rem));
    height: auto;
  }

  .hubit-avatar-editor__footer {
    flex-direction: column-reverse;
  }

  .hubit-avatar-editor__footer .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hubit-avatar-editor__dropzone,
  .hubit-avatar-editor__preview,
  .hubit-avatar-editor__preview-badge {
    transition: none;
  }
}

[data-theme="dark"] .hubit-avatar-editor__dropzone {
  background: var(--bg-hover, #1e2a42);
  border-color: var(--border-color, #2a3a52);
}

[data-theme="dark"] .hubit-avatar-editor__dropzone-icon {
  background: color-mix(in srgb, var(--text-link, #7cb8ff) 14%, var(--bg-surface, #131a2b));
}

[data-theme="dark"] .hubit-avatar-editor__dropzone:hover,
[data-theme="dark"] .hubit-avatar-editor__dropzone.is-dragover {
  background: color-mix(in srgb, var(--text-link, #7cb8ff) 12%, var(--bg-hover, #1e2a42));
  border-color: var(--text-link, #7cb8ff);
}

[data-theme="dark"] .hubit-avatar-editor__preview-badge {
  border-color: var(--bg-surface, #131a2b);
}

[data-theme="dark"] .hubit-avatar-editor__dialog {
  border: 1px solid var(--border-color, #2a3a52);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
