@layer components {
  /* Copyable input — absolute-positioned button overlay on the right edge
     of a native-width input. Wrapper is a plain block so it fits into
     any grid cell without overflow; button is positioned absolute and
     vertically centered via the inset + margin-block:auto pattern. */
  .app-input-copy {
    position: relative;
  }

  .app-input-copy > input {
    padding-right: 2.5rem;
    width: 100%;
    display: block;
  }

  /* High specificity (0,2,0) to beat [data-tooltip] (0,1,0) which sets
     position: relative on the copy button (tooltip host). */
  .app-input-copy > .app-input-copy-button {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0.3rem;
    margin-block: auto;
    height: fit-content;
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--app-muted-color);
    cursor: pointer;
    padding: 0.3rem 0.45rem;
    width: auto;
    line-height: var(--leading-none);
    border-radius: calc(var(--app-border-radius) * 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background-color 0.15s ease;
  }

  .app-input-copy > .app-input-copy-button:hover {
    color: var(--app-primary);
    background: color-mix(in srgb, var(--app-primary) 10%, transparent);
  }

  .app-input-copy > .app-input-copy-button:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 1px;
  }

  .app-input-copy > .app-input-copy-button [data-copy-icon-done] {
    display: none;
  }

  .app-input-copy > .app-input-copy-button.is-copied {
    color: var(--app-action-success-border);
    background: color-mix(in srgb, var(--app-action-success-border) 12%, transparent);
  }

  .app-input-copy > .app-input-copy-button.is-copied [data-copy-icon-idle] {
    display: none;
  }

  .app-input-copy > .app-input-copy-button.is-copied [data-copy-icon-done] {
    display: inline-flex;
  }

  /* Input inside the wrapper is now the last child of label (no longer
     a direct <input> child). Add the margin-top that the global
     label > input rule would have applied. */
  label > .app-input-copy {
    margin-top: calc(var(--app-spacing) * 0.25);
  }
}
