/* api.css — styles ONLY for what api.js creates (sheets, toasts, spinner). Tokens from style.css. */
html:not(.api-ready) [data-auth] { visibility: hidden; }
[data-auth][hidden] { display: none !important; }
html.api-lock, html.api-lock body { overflow: hidden; }

/* ---------- spinner ---------- */
.api-spin {
  display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -.15em;
  border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%;
  animation: api-rot .7s linear infinite; opacity: .85;
}
.api-spin--lg { width: 28px; height: 28px; border-width: 3px; color: var(--primary); }
.api-busy { cursor: progress !important; }
.api-busy > .api-spin { margin-inline-end: .5em; }
@keyframes api-rot { to { transform: rotate(360deg); } }

/* ---------- toasts ---------- */
.api-toasts {
  position: fixed; z-index: 1100; inset-inline: 0; bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none;
}
.api-toast {
  pointer-events: auto; cursor: pointer; max-width: min(440px, 100%);
  font: 500 14px/1.6 var(--font);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(10px); transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.api-toast.is-in { opacity: 1; transform: none; }
.api-toast::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-ink) 25%, transparent); }
.api-toast--ok::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 35%, transparent); }
.api-toast--err::before { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---------- sheet ---------- */
.api-sheet {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center;
  font-family: var(--font); color: var(--text);
}
.api-sheet__bg { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; transition: opacity .25s var(--ease); }
.api-sheet__panel {
  position: relative; width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 6px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .28s var(--ease);
}
.api-sheet.is-open .api-sheet__bg { opacity: 1; }
.api-sheet.is-open .api-sheet__panel { transform: none; }
.api-sheet__grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 6px; }
.api-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 10px; }
.api-sheet__title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.5; }
.api-sheet__x {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font: 400 22px/1 system-ui, sans-serif; transition: color .2s var(--ease), background .2s var(--ease);
}
.api-sheet__x:hover { color: var(--text); background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }
@media (min-width: 640px) {
  .api-sheet { align-items: center; padding: 24px; }
  .api-sheet__panel { border-radius: var(--radius-lg); max-width: 420px; padding-top: 14px; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .25s var(--ease), opacity .25s var(--ease); }
  .api-sheet.is-open .api-sheet__panel { opacity: 1; }
  .api-sheet__grip { display: none; }
}
@media (prefers-reduced-motion: reduce) { .api-sheet__panel, .api-sheet__bg, .api-toast { transition: none; } }

/* ---------- form bits inside sheets ---------- */
.api-form { display: flex; flex-direction: column; gap: 14px; padding-bottom: 4px; }
.api-lead { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.api-lead b { color: var(--text); }
.api-fine { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.api-dev { color: var(--warn); }
.api-field { display: flex; flex-direction: column; gap: 6px; }
.api-field__label { font-size: 13.5px; font-weight: 600; }
.api-input {
  width: 100%; box-sizing: border-box; min-height: 50px; padding: 10px 14px;
  font: 500 17px/1.4 var(--font); color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 14px;
  outline: none; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); font-variant-numeric: tabular-nums;
}
.api-input::placeholder { color: var(--muted); opacity: .55; }
.api-input:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--line-strong)); }
.api-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.api-ltr { direction: ltr; text-align: left; }
.api-ltr::placeholder { text-align: left; }
.api-ltr-inline { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.api-code { direction: ltr; text-align: center; font-size: 28px; font-weight: 700; letter-spacing: .5em; padding-inline-start: .5em; min-height: 60px; }
.api-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 52px; padding: 10px 18px;
  font: 700 16px/1.4 var(--font);
  background: var(--primary); color: var(--primary-ink);
  border: 0; border-radius: 999px; cursor: pointer; box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 24%, transparent);
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.api-btn:hover { background: color-mix(in srgb, var(--primary) 88%, var(--bg)); transform: translateY(-1px); }
.api-btn:active { transform: translateY(0) scale(.98); transition-duration: .08s; }
.api-btn:disabled { opacity: .7; cursor: default; transform: none; box-shadow: none; }
.api-btn:focus-visible, .api-link:focus-visible, .api-chip:focus-visible, .api-sheet__x:focus-visible, .api-file:focus-within {
  outline: 2px solid var(--primary); outline-offset: 3px; /* teal by day, lime by night */
}
.api-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.api-row--center { justify-content: center; }
.api-link {
  border: 0; background: none; padding: 6px 2px; cursor: pointer; color: var(--primary);
  font: 600 14px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
.api-link:disabled { color: var(--muted); cursor: default; font-weight: 500; }
.api-err {
  margin: 0; padding: 9px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.7;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent);
}
.api-err[hidden] { display: none; }
.api-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 0; color: var(--muted); }

/* ---------- pay ---------- */
.api-pay__prod { display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-size: 16px; }
.api-pay__prod small { font-weight: 400; font-size: 13px; color: var(--muted); }
.api-pay__amount {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 18px 16px; border-radius: 18px; background: var(--surface-2);
}
.api-pay__label { font-size: 13px; color: var(--muted); }
.api-pay__big { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.api-pay__big b { font-size: 34px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.api-pay__warn { margin: 4px 0 0; font-weight: 700; font-size: 14px; color: var(--warn); }
.api-chip {
  margin-top: 6px; padding: 6px 14px; min-height: 36px; cursor: pointer; border-radius: 999px;
  font: 600 13px/1.4 var(--font);
  background: var(--surface); color: var(--primary); border: 1px solid var(--line-strong); transition: border-color .2s var(--ease), background .2s var(--ease);
}
.api-chip:hover { border-color: var(--primary); }
.api-chip--solid { background: var(--primary); color: var(--primary-ink); border-color: transparent; align-self: flex-start; }
.api-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 18px;
  border: 1.5px dashed var(--line-strong);
}
.api-card__num { font-size: 22px; font-weight: 700; letter-spacing: .06em; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.api-card__meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.api-step { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; margin-top: 4px; }
.api-step__n {
  width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px;
  background: var(--accent); color: var(--accent-ink);
}
.api-file {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px; cursor: pointer;
  border: 1.5px dashed var(--primary); border-radius: 16px; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent); font-weight: 600; font-size: 14.5px;
}
.api-file.has-file { border-style: solid; }
.api-file__input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.api-file__icon { font-size: 20px; line-height: 1; }
.api-file.has-file .api-file__icon { display: none; }
.api-file__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-file__thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; flex: none; }
.api-file__thumb[hidden] { display: none; }

/* ---------- done ---------- */
.api-done { align-items: center; text-align: center; padding: 8px 0 4px; }
.api-done__icon {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 700;
  background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok);
}
.api-done__icon--wait { background: color-mix(in srgb, var(--warn) 14%, transparent); font-size: 26px; }
.api-done__title { margin: 0; font-weight: 700; font-size: 17px; line-height: 1.7; }

/* ---------- instant activation (pay) ---------- */
/* lime highlight = the one key word; ink is always --accent-ink on lime */
.api-pay__tail { color: var(--accent-ink); padding: 0 .22em; border-radius: 8px; background: var(--accent); }
.api-done__icon svg { display: block; }
.api-done__icon--wait { color: var(--warn); }
.api-done__icon--pop { animation: api-pop .38s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes api-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.api-done__until {
  margin: -4px 0 0; padding: 4px 14px; border-radius: 999px; font-weight: 700; font-size: 14.5px;
  font-variant-numeric: tabular-nums; color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
@media (prefers-reduced-motion: reduce) { .api-done__icon--pop { animation: none; } }
