/* Andy Web Service: client passkeys. Scoped to .apk-* so it can't leak into the theme. */
.apk-card, .apk-modal, .apk-toast, .apk-btn {
  --apk-accent: #1062fe;
  --apk-accent-strong: #0b4fd6;
  --apk-accent-subtle: rgb(16 98 254 / 0.1);
  --apk-border: oklch(92.4% 0.007 262);
  --apk-border-strong: oklch(84% 0.012 262);
  --apk-border-subtle: oklch(95.6% 0.005 262);
  --apk-fg: oklch(21% 0.025 262);
  --apk-fg-2: oklch(45% 0.02 262);
  --apk-fg-3: oklch(50% 0.015 262);
  --apk-surface: #fff;
  --apk-surface-muted: oklch(96.6% 0.006 262);
  --apk-success: oklch(55% 0.12 155);
  --apk-success-subtle: oklch(95% 0.04 155);
  --apk-danger: oklch(52% 0.19 25);
  --apk-danger-strong: oklch(46% 0.18 25);
  --apk-danger-subtle: oklch(95.5% 0.03 25);
  --apk-shadow-resting: 0 1px 2px oklch(0% 0 0 / 0.035);
  --apk-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.apk-card *, .apk-modal *, .apk-toast * { box-sizing: border-box; }
.apk-card [hidden], .apk-modal [hidden], .apk-btn[hidden] { display: none !important; }

/* ---------------------------------------------------------------- buttons */
.apk-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-sizing: border-box; height: 44px; min-height: 44px; margin: 0; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px; background: none; box-shadow: none;
  color: var(--apk-fg); font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  letter-spacing: normal; text-transform: none; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .12s ease;
}
.apk-btn svg { width: 18px; height: 18px; flex: none; }
.apk-btn:focus { outline: none; }
.apk-btn:focus-visible { outline: 2px solid var(--apk-accent); outline-offset: 2px; }
.apk-btn:active:not(:disabled) { transform: scale(.98); }
.apk-btn:disabled { opacity: .55; cursor: not-allowed; }
.apk-btn.is-loading:disabled { opacity: 1; cursor: progress; }
.apk-btn--block { display: flex; width: 100%; }
.apk-btn--primary { background: var(--apk-accent); border-color: var(--apk-accent); color: #fff; }
.apk-btn--primary:hover:not(:disabled), .apk-btn--primary:focus-visible { background: var(--apk-accent-strong); border-color: var(--apk-accent-strong); color: #fff; }
.apk-btn--secondary { background: var(--apk-surface); border-color: var(--apk-border-strong); color: var(--apk-fg); }
.apk-btn--secondary:hover:not(:disabled) { background: var(--apk-surface-muted); color: var(--apk-fg); }
.apk-btn--ghost { padding: 0 14px; color: var(--apk-fg-2); }
.apk-btn--ghost:hover:not(:disabled) { background: var(--apk-surface-muted); color: var(--apk-fg); }
.apk-btn--ghost.apk-btn--danger { color: var(--apk-danger); }
.apk-btn--ghost.apk-btn--danger:hover:not(:disabled) { background: var(--apk-danger-subtle); color: var(--apk-danger-strong); }
.apk-btn--primary.apk-btn--danger { background: var(--apk-danger); border-color: var(--apk-danger); }
.apk-btn--primary.apk-btn--danger:hover:not(:disabled) { background: var(--apk-danger-strong); border-color: var(--apk-danger-strong); }

.apk-spin {
  display: inline-block; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .85;
  animation: apk-spin .75s linear infinite;
}
@keyframes apk-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- card */
.apk-card {
  margin: 0 0 24px; padding: 24px;
  background: var(--apk-surface); border: 1px solid var(--apk-border); border-radius: 22px; box-shadow: var(--apk-shadow-resting);
  color: var(--apk-fg); font-family: inherit; font-size: 14px; line-height: 1.45; text-align: left;
}
.apk-card__head { display: flex; align-items: flex-start; gap: 16px; }
.apk-card__icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--apk-accent-subtle); color: var(--apk-accent);
}
.apk-card__icon svg { width: 20px; height: 20px; }
.apk-card__intro { flex: 1 1 auto; min-width: 0; }
.apk-card .apk-card__title { margin: 0 0 4px; padding: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--apk-fg); }
.apk-card .apk-card__text { margin: 0; max-width: 62ch; color: var(--apk-fg-2); font-size: 14px; line-height: 1.5; }
.apk-card__add { flex: none; }
.apk-card .apk-card__note { margin: 16px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--apk-surface-muted); color: var(--apk-fg-2); font-size: 13.5px; }

.apk-list { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--apk-border-subtle); }
.apk-item {
  display: flex; align-items: center; gap: 14px; margin: 0; padding: 14px 0;
  border-bottom: 1px solid var(--apk-border-subtle); overflow: hidden;
}
.apk-item:last-child { border-bottom-color: transparent; padding-bottom: 0; }
.apk-item__icon {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--apk-surface-muted); color: var(--apk-fg-2);
}
.apk-item__icon svg { width: 18px; height: 18px; }
.apk-item__main { flex: 1 1 auto; min-width: 0; }
.apk-item__name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; font-size: 14.5px; color: var(--apk-fg); }
.apk-item__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apk-item__meta { margin-top: 2px; color: var(--apk-fg-3); font-size: 13px; overflow-wrap: anywhere; }
.apk-item__actions { flex: none; display: flex; gap: 4px; }
.apk-chip {
  flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 9999px;
  background: var(--apk-success-subtle); color: oklch(40% 0.1 155); font-size: 12px; font-weight: 500; line-height: 1;
}
.apk-card .apk-empty {
  margin: 20px 0 0; padding: 18px 16px; border: 1px dashed var(--apk-border-strong); border-radius: 14px;
  color: var(--apk-fg-2); font-size: 13.5px; text-align: center;
  animation: apk-in .3s var(--apk-ease-out) both;
}
.apk-item--new { animation: apk-in .36s var(--apk-ease-out) both; }
.apk-item.is-leaving {
  opacity: 0; padding-top: 0; padding-bottom: 0; border-bottom-color: transparent;
  transition: height .26s ease, padding .26s ease, opacity .16s ease, border-color .26s ease;
}
@keyframes apk-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 600px) {
  .apk-card { padding: 20px; }
  .apk-card__head { flex-wrap: wrap; }
  .apk-card__intro { flex-basis: calc(100% - 56px); }
  .apk-card__add { width: 100%; }
  .apk-item { flex-wrap: wrap; row-gap: 8px; }
  .apk-item__main { flex-basis: calc(100% - 50px); }
  .apk-item__actions { width: 100%; padding-left: 46px; }
  .apk-item__actions .apk-btn { flex: 1 1 0; }
}

/* ---------------------------------------------------------------- modal */
.apk-modal {
  position: fixed; inset: 0; z-index: 100001;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  font-family: inherit; font-size: 14px; line-height: 1.45; color: var(--apk-fg);
}
.apk-modal__backdrop {
  position: absolute; inset: 0; background: oklch(21% 0.025 262 / 0.45);
  opacity: 0; transition: opacity .22s ease;
}
.apk-modal__dialog {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto;
  padding: 24px; background: var(--apk-surface); border: 1px solid var(--apk-border); border-radius: 22px;
  box-shadow: 0 24px 60px oklch(0% 0 0 / 0.18), 0 2px 6px oklch(0% 0 0 / 0.06);
  opacity: 0; transform: translateY(12px) scale(.97);
  transition: opacity .2s ease, transform .28s var(--apk-ease-out);
}
.apk-modal.is-open .apk-modal__backdrop { opacity: 1; }
.apk-modal.is-open .apk-modal__dialog { opacity: 1; transform: none; }
.apk-modal.is-closing .apk-modal__backdrop { transition-duration: .16s; }
.apk-modal.is-closing .apk-modal__dialog { transform: translateY(8px) scale(.98); transition-duration: .16s, .18s; transition-timing-function: ease, ease-in; }
.apk-modal .apk-modal__title { margin: 0 0 8px; padding: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--apk-fg); }
.apk-modal .apk-modal__desc { margin: 0 0 18px; color: var(--apk-fg-2); font-size: 14px; line-height: 1.5; }
.apk-modal .apk-field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; padding: 0; font-weight: 400; }
.apk-field__label { font-size: 13px; font-weight: 500; color: var(--apk-fg); }
.apk-modal .apk-input {
  display: block; width: 100%; height: 44px; margin: 0; padding: 0 14px;
  border: 1px solid var(--apk-border-strong); border-radius: 12px; background: var(--apk-surface); box-shadow: none;
  color: var(--apk-fg); font-family: inherit; font-size: 15px; line-height: normal;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.apk-modal .apk-input:focus { outline: none; border-color: var(--apk-accent); box-shadow: 0 0 0 3px var(--apk-accent-subtle); }
.apk-modal .apk-input[readonly] { background: var(--apk-surface-muted); }
.apk-modal .apk-modal__status { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--apk-fg-2); font-size: 13.5px; }
.apk-modal .apk-modal__status .apk-spin { color: var(--apk-accent); }
.apk-modal .apk-modal__error {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--apk-danger-subtle); color: var(--apk-danger-strong); font-size: 13.5px; line-height: 1.45;
  animation: apk-in .24s var(--apk-ease-out) both;
}
.apk-modal__actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 10px; }
@media (max-width: 480px) {
  .apk-modal { align-items: flex-end; }
  .apk-modal__dialog { padding: 20px; }
  .apk-modal .apk-input { font-size: 16px; }
  .apk-modal__actions .apk-btn { flex: 1 1 0; }
}

/* ---------------------------------------------------------------- toast */
.apk-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100002;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(480px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 14px; background: oklch(21% 0.025 262); color: #fff;
  font-family: inherit; font-size: 14px; line-height: 1.4; box-shadow: 0 12px 30px oklch(0% 0 0 / 0.22);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .28s var(--apk-ease-out), visibility 0s linear .28s;
}
.apk-toast.is-on { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); transition: opacity .2s ease, transform .28s var(--apk-ease-out), visibility 0s; }
.apk-toast__icon { flex: none; display: inline-flex; width: 18px; height: 18px; }
.apk-toast__icon svg { width: 18px; height: 18px; }
.apk-toast[data-kind="success"] .apk-toast__icon { color: oklch(78% 0.14 155); }
.apk-toast[data-kind="error"] .apk-toast__icon { color: oklch(72% 0.17 25); }
.apk-toast[data-kind="info"] .apk-toast__icon { color: oklch(78% 0.09 262); }

/* ---------------------------------------------------------------- human check (Turnstile) under the sign-in button */
.apk-ts { display: grid; grid-template-rows: 0fr; margin-top: calc(0px - var(--apk-ts-gap, 0px)); transition: grid-template-rows .26s var(--apk-ease-out, cubic-bezier(.16,1,.3,1)), margin-top .26s ease; }
.apk-ts.is-open { grid-template-rows: 1fr; margin-top: calc(10px - var(--apk-ts-gap, 0px)); }
.apk-ts__inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.apk-ts .apk-ts__hint {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; min-height: 20px;
  color: oklch(45% 0.02 262); font-size: 13px; line-height: 1.4; text-align: center;
  opacity: 0; transition: opacity .2s ease;
}
.apk-ts.is-open .apk-ts__hint { opacity: 1; }
.apk-ts.is-error .apk-ts__hint { color: oklch(46% 0.18 25); }
.apk-ts .apk-ts__hint .apk-spin { width: 14px; height: 14px; color: #1062fe; }
.apk-ts__widget { display: flex; justify-content: center; }
.apk-ts__widget:empty { display: none; }
/* the redesign's passkey button while the human check is still running */
.aw-passkey:disabled, [data-andy-passkey-login]:disabled { opacity: .55; cursor: not-allowed; transition: opacity .2s ease; }
.aw-passkey.is-loading:disabled, [data-andy-passkey-login].is-loading:disabled { opacity: 1; cursor: progress; }

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .apk-btn, .apk-modal__backdrop, .apk-modal__dialog, .apk-modal .apk-input, .apk-toast, .apk-item, .apk-item.is-leaving { transition: none !important; }
  .apk-item--new, .apk-card .apk-empty, .apk-modal .apk-modal__error { animation: none !important; }
  .apk-ts, .apk-ts .apk-ts__hint, .aw-passkey:disabled { transition: none !important; }
  .apk-modal__dialog, .apk-modal.is-closing .apk-modal__dialog { transform: none; }
  .apk-btn:active:not(:disabled) { transform: none; }
}
