/* ==========================================================================
   Components: Button, Card, Section, Field, Badge, Chip, Alert, Dialog,
   Skeleton, Toast, Spinner
   ========================================================================== */

/* ---------- Icon ---------- */
.icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Button ---------- */
.btn {
  --btn-h: 48px;
  --btn-px: var(--space-6);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--btn-h);
  min-width: 44px;
  padding: 0 var(--btn-px);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background-color var(--dur-base) ease,
    border-color var(--dur-base) ease,
    color var(--dur-base) ease,
    opacity var(--dur-base) ease;
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.btn .icon {
  transition: transform var(--dur-base) var(--ease-out);
}

.btn:hover:not(:disabled) .icon--nudge {
  transform: translateX(3px);
}

/* Primary: gold gradient. Dark label keeps WCAG AA contrast on the light gold. */
.btn--primary {
  background-image: linear-gradient(120deg, hsl(var(--gold)) 0%, hsl(var(--gold-light)) 50%, hsl(var(--gold)) 100%);
  background-size: 200% 100%;
  background-position: 0% 0;
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-gold), inset 0 1px 0 hsl(0 0% 100% / 0.35);
}

.btn--primary:hover:not(:disabled):not([aria-disabled="true"]) {
  color: hsl(var(--foreground));
  background-position: 100% 0;
  transform: translateY(-2px);
  box-shadow: 0 16px 36px -12px rgba(185, 140, 69, 0.65), inset 0 1px 0 hsl(0 0% 100% / 0.35);
}

.btn--primary:focus-visible {
  outline-color: hsl(var(--brown));
}

.btn--secondary {
  background: hsl(var(--secondary));
  border-color: hsl(var(--border));
  color: hsl(var(--secondary-foreground));
}

.btn--secondary:hover:not(:disabled) {
  color: hsl(var(--secondary-foreground));
  background: hsl(var(--cream-dark));
  border-color: hsl(var(--gold-light));
  transform: translateY(-1px);
}

.btn--outline {
  background: transparent;
  border-color: hsl(var(--foreground) / 0.25);
  color: hsl(var(--foreground));
}

.btn--outline:hover:not(:disabled) {
  color: hsl(var(--foreground));
  border-color: hsl(var(--gold));
  background: hsl(var(--gold-light) / 0.15);
}

.btn--ghost {
  background: transparent;
  color: hsl(var(--foreground));
  --btn-px: var(--space-4);
}

.btn--ghost:hover:not(:disabled) {
  color: hsl(var(--foreground));
  background: hsl(var(--secondary));
}

/* Strong secondary action (e.g. repeated card CTAs) so the gold stays unique per screen */
.btn--dark {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
}

.btn--dark:hover:not(:disabled) {
  color: hsl(var(--foreground));
  background: linear-gradient(120deg, hsl(var(--gold)), hsl(var(--gold-light)));
  transform: translateY(-1px);
  box-shadow: var(--shadow-gold);
}

.btn--dark[aria-busy="true"]::after {
  border-color: hsl(var(--background) / 0.3);
  border-top-color: hsl(var(--background));
}

.btn--danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn--danger:hover:not(:disabled) {
  color: hsl(var(--destructive-foreground));
  background: hsl(var(--destructive) / 0.9);
}

/* Dark surfaces */
.btn--on-dark {
  background: var(--dark-cta);
  color: #1b1612;
  box-shadow: 0 10px 30px -12px var(--glow-strong);
}

.btn--on-dark:hover:not(:disabled) {
  color: #1b1612;
  transform: translateY(-2px);
}

.btn--glass {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  color: var(--dark-text);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.btn--glass:hover:not(:disabled) {
  color: var(--dark-text);
  background: rgba(255, 255, 255, 0.16);
}

.btn--sm { --btn-h: 44px; --btn-px: var(--space-4); font-size: var(--fs-sm); }
.btn--lg { --btn-h: 60px; --btn-px: var(--space-8); font-size: var(--fs-lg); }
.btn--block { display: flex; width: 100%; }
.btn--icon { --btn-px: 0; width: var(--btn-h); }

/* Loading state: set aria-busy="true" (see setButtonLoading in core/utils.js) */
.btn[aria-busy="true"] {
  color: transparent !important;
  pointer-events: none;
}

.btn[aria-busy="true"] > * {
  visibility: hidden;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2px solid hsl(var(--foreground) / 0.25);
  border-top-color: hsl(var(--foreground));
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.btn--on-dark[aria-busy="true"]::after,
.btn--danger[aria-busy="true"]::after {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Text-style link button */
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: hsl(var(--gold-text));
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  text-decoration-thickness: 1px;
}

.link-btn:hover { color: hsl(var(--brown)); }

/* ---------- Section ---------- */
.section {
  position: relative;
  padding-block: var(--section-y);
}

.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.section--cream { background: hsl(var(--cream-dark)); }
.section--blush { background: hsl(var(--blush)); }

.section--dark {
  background: var(--dark-bg);
  color: var(--dark-text);
}

.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 { color: var(--dark-text); }
.section--dark .lead,
.section--dark .text-muted { color: var(--dark-muted); }
.section--dark .eyebrow { color: var(--dark-gold); }

.section-header {
  display: grid;
  gap: var(--space-4);
  max-width: 720px;
  margin-bottom: clamp(2rem, 1.5rem + 2vw, 3.5rem);
}

.section-header--center {
  justify-items: center;
  margin-inline: auto;
  text-align: center;
}

.section-header--center .lead { margin-inline: auto; }

/* ---------- Card ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__body {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-6);
}

.card--padded { padding: var(--space-6); }
.card--elevated { box-shadow: var(--shadow-md); }
.card--white { background: hsl(0 0% 100% / 0.75); }

.card--interactive {
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) ease;
}

@media (hover: hover) {
  .card--interactive:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: hsl(var(--gold-light));
  }
}

.card--glass {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  color: var(--dark-text);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ---------- Form fields ---------- */
.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: hsl(var(--foreground));
}

.field__label .req {
  color: hsl(var(--destructive));
  margin-inline-start: 2px;
}

.field__hint {
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
}

.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  min-height: 0;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.5;
  color: hsl(var(--destructive));
}

.field__error:empty { display: none; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-lg);
  background: hsl(0 0% 100% / 0.85);
  color: hsl(var(--foreground));
  font-size: max(16px, var(--fs-base)); /* prevents iOS zoom */
  line-height: 1.4;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background-color var(--dur-fast) ease;
  appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: hsl(var(--gold-light));
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.25);
  background: #fff;
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: hsl(var(--destructive));
  box-shadow: 0 0 0 3px hsl(var(--destructive) / 0.12);
}

.input:disabled,
.select:disabled,
.textarea:disabled,
.input[readonly] {
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
}

.input[readonly] { cursor: default; }

.textarea {
  min-height: 112px;
  resize: vertical;
}

.select {
  padding-inline-end: var(--space-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23574a3f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
}

.input-group__prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-4);
  border: 1px solid hsl(var(--input));
  border-right: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  font-weight: 600;
  font-size: var(--fs-sm);
}

.input-group__prefix + .input {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Native radio / checkbox accent */
input[type="checkbox"],
input[type="radio"] {
  accent-color: hsl(var(--gold-text));
}

/* Shake for invalid submit (class toggled by JS) */
.shake {
  animation: shake 420ms var(--ease-in-out);
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.3em 0.75em;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge--gold {
  background: linear-gradient(120deg, hsl(var(--gold)), hsl(var(--gold-light)));
  color: hsl(var(--foreground));
}

.badge--dark { background: var(--dark-bg); color: var(--dark-text); }
.badge--success { background: hsl(var(--success-soft)); color: hsl(var(--success)); }
.badge--warning { background: hsl(var(--warning-soft)); color: hsl(var(--warning)); }
.badge--info { background: hsl(var(--info-soft)); color: hsl(var(--info)); }
.badge--danger { background: hsl(var(--destructive) / 0.1); color: hsl(var(--destructive)); }
.badge--muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* ---------- Chip (filters, slots) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-pill);
  background: hsl(0 0% 100% / 0.6);
  color: hsl(var(--foreground));
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.chip:hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: hsl(var(--gold));
}

.chip:active:not(:disabled) { transform: scale(0.97); }

.chip[aria-pressed="true"],
.chip[aria-checked="true"],
.chip.is-selected {
  background: hsl(var(--foreground));
  border-color: hsl(var(--foreground));
  color: hsl(var(--background));
}

.chip:disabled,
.chip[aria-disabled="true"] {
  background: hsl(var(--muted) / 0.6);
  color: hsl(var(--muted-foreground));
  border-style: dashed;
  text-decoration: line-through;
  cursor: not-allowed;
}

.chip--static { cursor: default; }
.chip--gold { border-color: hsl(var(--gold-light)); background: hsl(var(--gold-light) / 0.25); }

/* ---------- Alert / info box ---------- */
.alert {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-4) var(--space-5);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  background: hsl(var(--card));
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.alert > .icon { margin-top: 2px; }
.alert--info { background: hsl(var(--info-soft)); border-color: hsl(var(--info) / 0.2); color: hsl(var(--info)); }
.alert--success { background: hsl(var(--success-soft)); border-color: hsl(var(--success) / 0.2); color: hsl(var(--success)); }
.alert--warning { background: hsl(var(--warning-soft)); border-color: hsl(var(--warning) / 0.2); color: hsl(var(--warning)); }
.alert--danger { background: hsl(var(--destructive) / 0.07); border-color: hsl(var(--destructive) / 0.25); color: hsl(var(--destructive)); }
.alert--gold { background: hsl(var(--gold-light) / 0.2); border-color: hsl(var(--gold-light)); color: hsl(var(--foreground)); }

/* ---------- Key-value list (summaries, bank info) ---------- */
.kv {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

.kv__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  font-size: var(--fs-sm);
}

.kv__row dt { color: hsl(var(--muted-foreground)); }
.kv__row dd { margin: 0; text-align: end; font-weight: 600; }
.kv__row--total { padding-top: var(--space-3); border-top: 1px dashed hsl(var(--border)); font-size: var(--fs-base); }

/* ---------- Dialog (native <dialog>; bottom sheet up to 640px) ---------- */
.dialog {
  --dialog-w: 560px;
  width: min(var(--dialog-w), calc(100vw - 2rem));
  max-width: none;
  max-height: 90vh;
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-2xl);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: 0 40px 80px -30px hsl(25 40% 15% / 0.5);
  overflow: hidden;
}

.dialog--lg { --dialog-w: 760px; }
.dialog--sm { --dialog-w: 440px; }

.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in 360ms var(--ease-out) both;
}

.dialog::backdrop {
  background: rgba(27, 22, 18, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: backdrop-in 300ms ease both;
}

.dialog.is-closing {
  animation: dialog-out 220ms var(--ease-in-out) both;
}

.dialog.is-closing::backdrop {
  animation: backdrop-out 220ms ease both;
}

.dialog__handle {
  display: none;
}

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid hsl(var(--border) / 0.7);
}

.dialog__title {
  font-size: var(--fs-h4);
  font-weight: 600;
  line-height: 1.2;
}

.dialog__subtitle {
  margin-top: var(--space-1);
  font-size: var(--fs-sm);
  color: hsl(var(--muted-foreground));
}

.dialog__close {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: hsl(var(--muted-foreground));
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.dialog__close:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6);
}

.dialog__footer {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6) var(--space-6);
  border-top: 1px solid hsl(var(--border) / 0.7);
  background: hsl(var(--popover));
}

.dialog--alert .dialog__header { border-bottom: 0; padding-bottom: 0; }
.dialog--alert .dialog__footer { border-top: 0; }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes dialog-out {
  to { opacity: 0; transform: translateY(12px) scale(0.98); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes backdrop-out {
  to { opacity: 0; }
}

@media (max-width: 640px) {
  .dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-bottom: 0;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  .dialog[open] {
    animation: sheet-in 420ms var(--ease-out) both;
  }

  .dialog.is-closing {
    animation: sheet-out 260ms var(--ease-in-out) both;
  }

  .dialog.is-dragging {
    animation: none;
    transition: none;
  }

  .dialog__handle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 44px; /* full tap target; the bar itself stays small */
    flex-shrink: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
  }

  .dialog__handle::before {
    content: "";
    width: 44px;
    height: 5px;
    border-radius: var(--radius-pill);
    background: hsl(var(--muted-foreground) / 0.35);
  }

  .dialog__header { padding-top: 0; }

  .dialog__footer {
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  }

  .dialog__footer .btn { flex: 1 1 100%; }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@keyframes sheet-out {
  to { transform: translateY(100%); }
}

/* Keep page from scrolling behind an open modal */
html:has(dialog[open]:modal) {
  overflow: hidden;
}

/* ---------- Skeleton ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: hsl(var(--muted) / 0.7);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, hsl(0 0% 100% / 0.55), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton--text { height: 0.9em; margin-block: 0.25em; }
.skeleton--title { height: 1.6em; width: 70%; }
.skeleton--media { aspect-ratio: 4 / 3; border-radius: var(--radius-xl); }
.skeleton--pill { height: 44px; border-radius: var(--radius-pill); }

@keyframes shimmer {
  to { transform: translateX(100%); }
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  display: grid;
  gap: var(--space-2);
  width: min(440px, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

@media (min-width: 768px) {
  .toast-region {
    left: auto;
    right: var(--space-6);
    bottom: var(--space-6);
    transform: none;
  }
}

.toast-list {
  display: grid;
  gap: var(--space-2);
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: rgba(27, 22, 18, 0.96);
  color: var(--dark-text);
  font-size: var(--fs-sm);
  line-height: 1.45;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 360ms var(--ease-spring) both;
}

.toast.is-leaving {
  animation: toast-out 220ms ease both;
}

.toast__icon { color: var(--dark-gold); }
.toast--success .toast__icon { color: #8fd1a3; }
.toast--error .toast__icon { color: #f2a19a; }
.toast--warning .toast__icon { color: #f0c27a; }

.toast__close {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--dark-muted);
}

.toast__close:hover { background: rgba(255, 255, 255, 0.1); color: var(--dark-text); }
.toast__close:focus-visible { outline-color: var(--dark-gold); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* ---------- Spinner (standalone) ---------- */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2px solid hsl(var(--gold) / 0.3);
  border-top-color: hsl(var(--gold-text));
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* ---------- Copy row (bank account etc.) ---------- */
.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px dashed hsl(var(--gold-light));
  border-radius: var(--radius-lg);
  background: hsl(0 0% 100% / 0.6);
}

.copy-row__value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}

/* ---------- Referral form (hero + compact variants) ---------- */
.referral-form {
  display: grid;
  gap: var(--space-2);
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
}

.referral-form__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--gold-text));
  text-align: center;
}

.referral-form__field {
  display: grid;
  gap: var(--space-3);
}

.referral-form__input {
  width: 100%;
  min-height: 64px;
  padding: 0 var(--space-6);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-pill);
  background: hsl(0 0% 100% / 0.92);
  color: hsl(var(--foreground));
  font-family: var(--font-body);
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: var(--shadow-md);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-base) ease;
}

.referral-form__input::placeholder {
  color: hsl(var(--muted-foreground));
  font-size: var(--fs-base);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
}

.referral-form__input:hover { border-color: hsl(var(--gold-light)); }

.referral-form__input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: var(--shadow-md), 0 0 0 4px hsl(var(--ring) / 0.22);
}

.referral-form__input[aria-invalid="true"] {
  border-color: hsl(var(--destructive));
  box-shadow: var(--shadow-md), 0 0 0 4px hsl(var(--destructive) / 0.12);
}

.referral-form__submit { width: 100%; }

.referral-form__message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 1.6rem; /* reserved: no layout jump when a message appears */
  font-size: var(--fs-sm);
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.referral-form__message[data-state="error"] { color: hsl(var(--destructive)); }
.referral-form__message[data-state="success"] { color: hsl(var(--success)); }

/* Desktop: button attached to the right side inside the input */
@media (min-width: 640px) {
  .referral-form__field {
    position: relative;
    display: block;
  }

  .referral-form__input {
    padding-inline: var(--space-6) 232px;
  }

  .referral-form__submit {
    position: absolute;
    top: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    min-height: 0;
  }
}

.referral-form--compact .referral-form__input {
  min-height: 58px;
  font-size: 1.125rem;
}

@media (min-width: 640px) {
  .referral-form--compact .referral-form__input { padding-inline: var(--space-5) 210px; }
  .referral-form--compact .referral-form__submit { top: 6px; right: 6px; bottom: 6px; }
}

/* ---------- Lightbox (native dialog) ---------- */
.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dark-text);
  overflow: hidden;
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: backdrop-in 260ms ease both;
}

.lightbox.is-closing { animation: backdrop-out 200ms ease both; }

.lightbox::backdrop {
  background: rgba(27, 22, 18, 0.94);
  animation: backdrop-in 260ms ease both;
}

.lightbox.is-closing::backdrop { animation: backdrop-out 200ms ease both; }

.lightbox__figure {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 72px var(--space-4) 104px;
  align-content: center;
}

.lightbox__frame {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
}

.lightbox__img {
  object-fit: contain;
  max-width: min(1100px, 100%);
  max-height: calc(100dvh - 220px);
  width: auto;
  height: auto;
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  transition: opacity 140ms ease, transform 240ms var(--ease-out);
  touch-action: pan-y;
  user-select: none;
}

.lightbox__img.is-switching {
  opacity: 0;
  transform: scale(0.985);
}

.lightbox__caption {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-style: italic;
}

.lightbox__count {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-style: normal;
  letter-spacing: 0.14em;
  color: var(--dark-muted);
}

.lightbox__btn {
  position: absolute;
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  color: var(--dark-text);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background-color var(--dur-fast) ease, transform var(--dur-fast) ease;
}

.lightbox__btn:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox__btn:active { transform: scale(0.94); }
.lightbox__btn:focus-visible { outline-color: var(--dark-gold); }
.lightbox__btn--close { top: var(--space-4); right: var(--space-4); }
.lightbox__btn--prev { bottom: var(--space-6); left: calc(50% - 60px); }
.lightbox__btn--next { bottom: var(--space-6); right: calc(50% - 60px); }

@media (min-width: 768px) {
  .lightbox__figure { padding: 72px 96px; }
  .lightbox__img { max-height: calc(100dvh - 200px); }
  .lightbox__btn--prev { bottom: auto; top: 50%; left: var(--space-6); transform: translateY(-50%); }
  .lightbox__btn--next { bottom: auto; top: 50%; right: var(--space-6); transform: translateY(-50%); }
  .lightbox__btn--prev:active,
  .lightbox__btn--next:active { transform: translateY(-50%) scale(0.94); }
}

/* ---------- Countdown (SVG ring) ---------- */
.countdown {
  --countdown-color: hsl(var(--gold-text));
  display: grid;
  place-items: center;
}

.countdown__ring {
  position: relative;
  width: clamp(168px, 40vw, 220px);
  aspect-ratio: 1;
}

.countdown__ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.countdown__track {
  fill: none;
  stroke: hsl(var(--muted));
  stroke-width: 8;
}

.countdown__bar {
  fill: none;
  stroke: var(--countdown-color);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 400ms ease;
}

.countdown__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
}

.countdown__time {
  font-family: var(--font-body);
  font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  color: hsl(var(--foreground));
  transition: color 400ms ease;
}

.countdown__unit {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground));
}

.countdown.is-urgent {
  --countdown-color: hsl(var(--destructive));
}

.countdown.is-urgent .countdown__time { color: hsl(var(--destructive)); }

.countdown.is-urgent .countdown__ring {
  animation: countdown-pulse 1.6s ease-in-out infinite;
}

.countdown.is-expired .countdown__time { color: hsl(var(--muted-foreground)); }

@keyframes countdown-pulse {
  50% { transform: scale(1.02); }
}

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative;
  display: grid;
  gap: var(--space-2);
}

.dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone__area {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  min-height: 180px;
  align-content: center;
  padding: var(--space-8) var(--space-6);
  border: 2px dashed hsl(var(--gold) / 0.7);
  border-radius: var(--radius-xl);
  background: hsl(var(--gold-light) / 0.1);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-base) var(--ease-out);
}

.dropzone__area:hover,
.dropzone.is-dragover .dropzone__area {
  border-color: hsl(var(--gold-text));
  background: hsl(var(--gold-light) / 0.24);
}

.dropzone.is-dragover .dropzone__area { transform: scale(1.01); }

.dropzone:has(.dropzone__input:focus-visible) .dropzone__area {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 3px;
}

.dropzone.has-error .dropzone__area { border-color: hsl(var(--destructive) / 0.7); }

.dropzone__icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--gold-light)), hsl(var(--gold)));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-gold);
}

.dropzone__icon .icon { width: 26px; height: 26px; }

.dropzone__title {
  max-width: 28ch;
  font-weight: 600;
  line-height: 1.4;
}

.dropzone__hint {
  font-size: var(--fs-xs);
  color: hsl(var(--muted-foreground));
}

.dropzone.is-locked .dropzone__area {
  border-color: hsl(var(--border));
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
}

.dropzone.is-locked .dropzone__icon {
  background: hsl(var(--muted));
  box-shadow: none;
  color: hsl(var(--muted-foreground));
}

.dropzone__preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-xl);
  background: #fff;
  animation: page-fade-in 300ms ease both;
}

.dropzone__thumb {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: hsl(var(--cream-dark));
}

.dropzone__thumb img { width: 100%; height: 100%; object-fit: cover; }

.dropzone__thumb--pdf {
  align-content: center;
  gap: 2px;
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
  font-size: var(--fs-xs);
  font-weight: 700;
}

.dropzone__thumb--done {
  background: hsl(var(--success-soft));
  color: hsl(var(--success));
}

.dropzone__file { display: grid; gap: 2px; min-width: 0; }

.dropzone__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dropzone__size {
  font-size: var(--fs-xs);
  color: hsl(var(--muted-foreground));
}

.dropzone__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
}

.dropzone__actions .link-btn { font-size: var(--fs-sm); }
.dropzone__remove { color: hsl(var(--destructive)); }
.dropzone__remove:hover { color: hsl(var(--destructive) / 0.8); }

/* ---------- Upload progress ---------- */
.upload-progress { display: grid; gap: var(--space-2); }

.upload-progress__bar {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: hsl(var(--muted));
}

.upload-progress__bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, hsl(var(--gold-dark)), hsl(var(--gold)));
  transition: width 200ms ease;
}

.upload-progress__text {
  font-size: var(--fs-sm);
  color: hsl(var(--muted-foreground));
}

/* ---------- Booking details / bank account / CS contact (booking-view.js) ---------- */
.booking-details { gap: var(--space-3); }
.booking-details .kv__row { align-items: flex-start; }
.booking-details dd { max-width: 60%; overflow-wrap: anywhere; }

.booking-details__number {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.booking-details__sub {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: hsl(var(--muted-foreground));
}

.booking-details__heading {
  margin: var(--space-5) 0 var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border) / 0.8);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: hsl(var(--gold-text));
}

.bank-account { display: grid; gap: var(--space-3); }

.bank-account__branch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: hsl(var(--muted-foreground));
}

.bank-account__branch .icon { color: hsl(var(--gold-text)); }

.bank-account__label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: hsl(var(--gold-text));
}

.bank-account__holder { font-size: var(--fs-sm); }
.bank-account__note { font-size: var(--fs-xs); color: hsl(var(--muted-foreground)); }

.cs-contact { display: grid; gap: var(--space-2); }

.cs-contact__meta {
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.status-badge { white-space: normal; text-align: left; }

/* ---------- Timer block + state panels (terima-kasih.html, status.html) ---------- */
.timer-block {
  display: grid;
  gap: var(--space-6);
  justify-items: center;
  text-align: center;
}

.timer-block__info { display: grid; gap: var(--space-3); }

.timer-steps {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  text-align: left;
  font-size: var(--fs-sm);
}

.timer-steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3);
  align-items: start;
}

.timer-steps span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: hsl(var(--gold-light) / 0.45);
  color: hsl(var(--foreground));
  font-size: var(--fs-xs);
  font-weight: 700;
}

@media (min-width: 640px) {
  .timer-block {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    text-align: left;
  }
}

/* ---------- Status panels ---------- */
.state-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.state-panel__icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.state-panel--info .state-panel__icon { background: hsl(var(--info-soft)); color: hsl(var(--info)); }
.state-panel--success .state-panel__icon { background: hsl(var(--success-soft)); color: hsl(var(--success)); }
.state-panel--danger .state-panel__icon { background: hsl(var(--destructive) / 0.08); color: hsl(var(--destructive)); }

.state-panel__body {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  font-size: var(--fs-sm);
  color: hsl(var(--secondary-foreground));
}

.state-panel--danger h2 { color: hsl(var(--destructive)); }

.state-panel__meta { color: hsl(var(--muted-foreground)); }
.state-panel__meta strong { color: hsl(var(--foreground)); }

.state-panel__cs {
  width: 100%;
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid hsl(var(--border));
}

@media (max-width: 479px) {
  .state-panel { grid-template-columns: 1fr; }
}

/* ---------- OTP input (otp.js) ---------- */
.otp__fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.otp__fieldset .field__label { margin-bottom: var(--space-3); padding: 0; }

.otp__boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.375rem, 0.25rem + 0.8vw, 0.75rem);
}

.otp__box {
  width: 100%;
  min-width: 0;
  height: clamp(52px, 12vw, 64px);
  padding: 0;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-lg);
  background: #fff;
  color: hsl(var(--foreground));
  font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  caret-color: hsl(var(--gold-text));
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

.otp__box:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.25);
}

.otp.is-filled .otp__box { border-color: hsl(var(--gold-text)); background: hsl(var(--gold-light) / 0.12); }
.otp.is-invalid .otp__box { border-color: hsl(var(--destructive)); background: hsl(var(--destructive) / 0.04); }
.otp.is-disabled .otp__box { background: hsl(var(--muted) / 0.6); color: hsl(var(--muted-foreground)); cursor: not-allowed; }
