/* ============================================================
   COMPONENTS — The Ai Toolz
   Buttons, form controls, navigation components, overlays,
   feedback, data display, and all interactive widgets.
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
  transition:
    background var(--trans-fast),
    box-shadow var(--trans-fast),
    translate var(--trans-fast),
    opacity var(--trans-fast),
    color var(--trans-fast),
    border-color var(--trans-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: opacity var(--trans-fast); }
}

/* ── Sizes ── */
.btn--sm  { height: 32px; padding-inline: var(--space-3); font-size: var(--text-xs);  gap: var(--space-1); }
.btn--md  { height: 40px; padding-inline: var(--space-4); font-size: var(--text-sm); }
.btn--lg  { height: 48px; padding-inline: var(--space-6); font-size: 1rem; }
@media (max-width: 767px) {
  .btn--sm { height: 44px; }
  .btn--md { height: 44px; }
}

/* ── Variants ── */
.btn--primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.35);
}
.btn--primary:hover {
  background: var(--gradient-brand-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  translate: 0 -1px;
  color: #fff;
  text-decoration: none;
}
.btn--primary:active { translate: 0 0; box-shadow: 0 1px 3px rgba(79,70,229,0.35); }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-1);
}
.btn--secondary:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
  translate: 0 -1px;
  box-shadow: var(--shadow-2);
  color: var(--color-text);
  text-decoration: none;
}
.btn--secondary:active { translate: 0 0; box-shadow: var(--shadow-1); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
}
.btn--ghost:hover {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  text-decoration: none;
}
.btn--ghost:active { background: var(--color-surface-2); }

.btn--danger {
  background: var(--color-danger);
  color: #fff;
}
.btn--danger:hover {
  background: #b91c1c;
  translate: 0 -1px;
  box-shadow: 0 4px 12px rgba(220,38,38,0.35);
  color: #fff;
  text-decoration: none;
}
.btn--danger:active { translate: 0 0; }

.btn--primary-soft {
  background: var(--color-primary-tint);
  color: var(--color-primary);
  border: 1px solid transparent;
}
.btn--primary-soft:hover {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  text-decoration: none;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
}
.btn--icon.btn--sm { width: 32px; height: 32px; }
.btn--icon.btn--md { width: 40px; height: 40px; }
.btn--icon.btn--lg { width: 48px; height: 48px; }
@media (max-width: 767px) {
  .btn--icon { width: 44px; height: 44px; }
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  translate: 0 0 !important;
  box-shadow: none !important;
}

.btn--loading {
  cursor: wait;
  pointer-events: none;
}
.btn--loading .btn__label { opacity: 0; }
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .btn--loading::after { animation: none; opacity: 0.5; }
}

@keyframes spin { to { rotate: 1turn; } }

/* ═══════════════════════════════════════════════════════════
   FORM CONTROLS
   ═══════════════════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.field__label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  line-height: 1.4;
}
.field__hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.field__error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.field--error .input,
.field--error .select { border-color: var(--color-danger); }
.field--error .input:focus,
.field--error .select:focus {
  outline-color: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}

.input {
  display: block;
  width: 100%;
  height: 40px;
  padding-inline: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--trans-fast),
    box-shadow var(--trans-fast),
    background var(--trans-fast);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--color-text-muted); }
.input:hover  { border-color: var(--color-border-strong); }
.input:focus  {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}
.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-surface);
}
.input--sm  { height: 32px; font-size: var(--text-xs); padding-inline: var(--space-2); }
.input--lg  { height: 48px; font-size: 1rem; padding-inline: var(--space-4); }

.input-wrap {
  position: relative;
}
.input-wrap .input { padding-left: 38px; }
.input-wrap--icon-right .input { padding-right: 38px; padding-left: var(--space-3); }
.input-wrap__icon {
  position: absolute;
  top: 50%;
  left: 10px;
  translate: 0 -50%;
  color: var(--color-text-muted);
  pointer-events: none;
}
.input-wrap--icon-right .input-wrap__icon { left: auto; right: 10px; }

.textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  resize: vertical;
  line-height: var(--line-height-body);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
  -webkit-appearance: none;
  appearance: none;
}
.textarea::placeholder { color: var(--color-text-muted); }
.textarea:hover { border-color: var(--color-border-strong); }
.textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}
.textarea:disabled { opacity: 0.5; cursor: not-allowed; background: var(--color-surface); }
.textarea--mono { font-family: var(--font-mono); font-size: var(--text-sm); }

.select {
  display: block;
  width: 100%;
  height: 40px;
  padding-inline: var(--space-3) 36px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  background:
    var(--color-bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA6C4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.select:hover { border-color: var(--color-border-strong); }
.select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-tint); }
.select:disabled { opacity: 0.5; cursor: not-allowed; }

.checkbox-wrap,
.radio-wrap {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.checkbox-wrap input,
.radio-wrap input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.checkbox-wrap .control,
.radio-wrap .control {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  background: var(--color-bg);
  border: 2px solid var(--color-border-strong);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans-fast), border-color var(--trans-fast), box-shadow var(--trans-fast);
}
.radio-wrap .control { border-radius: 50%; }

.checkbox-wrap:hover .control,
.radio-wrap:hover .control { border-color: var(--color-primary); }

.checkbox-wrap input:checked ~ .control,
.radio-wrap input:checked ~ .control {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.checkbox-wrap input:checked ~ .control::after {
  content: '';
  display: block;
  width: 4px; height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  rotate: 45deg;
  margin-top: -2px;
}
.radio-wrap input:checked ~ .control::after {
  content: '';
  display: block;
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
}
.checkbox-wrap input:focus-visible ~ .control,
.radio-wrap input:focus-visible ~ .control {
  box-shadow: 0 0 0 3px var(--color-primary-tint);
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.checkbox-wrap input:disabled ~ .control,
.radio-wrap input:disabled ~ .control {
  opacity: 0.5;
  cursor: not-allowed;
}

.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}
.switch-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  transition: background var(--trans-fast);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: translate var(--trans-fast), background var(--trans-fast);
  box-shadow: var(--shadow-1);
}
.switch-wrap input:checked ~ .switch {
  background: var(--color-primary);
}
.switch-wrap input:checked ~ .switch::after { translate: 18px 0; }
.switch-wrap input:focus-visible ~ .switch {
  box-shadow: 0 0 0 3px var(--color-primary-tint);
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.switch-wrap input:disabled ~ .switch { opacity: 0.5; cursor: not-allowed; }
.switch-label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  accent-color: var(--color-primary);
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--color-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--color-bg), 0 0 0 5px var(--color-primary);
  transition: box-shadow var(--trans-fast);
}
.range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--color-bg), 0 0 0 5px var(--color-primary), 0 0 0 8px var(--color-primary-tint);
}
.range-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.stepper-input {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  height: 40px;
}
.stepper-input__btn {
  width: 36px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--trans-fast), color var(--trans-fast);
  font-size: 1.2em;
  line-height: 1;
  font-weight: var(--font-weight-bold);
}
.stepper-input__btn:hover { background: var(--color-surface-2); color: var(--color-text); }
.stepper-input__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper-input__val {
  flex: 1;
  text-align: center;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  background: transparent;
  outline: none;
  padding: 0 var(--space-2);
  min-width: 48px;
  height: 100%;
}
.stepper-input__val:focus { background: var(--color-primary-tint); }

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: calc(var(--radius-md) - 2px); }
.color-swatch:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   TABS & SEGMENTED CONTROL
   ═══════════════════════════════════════════════════════════ */
.tabs {}
.tabs__list {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs__list::-webkit-scrollbar { display: none; }
.tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  margin-bottom: -2px;
  transition: color var(--trans-fast), border-color var(--trans-fast);
}
.tabs__tab:hover { color: var(--color-text); }
.tabs__tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tabs__tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
.tabs__panel { display: none; padding-top: var(--space-6); }
.tabs__panel[data-active="true"] { display: block; }

.seg-control {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: 3px;
  gap: 2px;
}
.seg-control__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-btn) - 3px);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--trans-fast);
}
.seg-control__btn:hover { color: var(--color-text); }
.seg-control__btn[aria-pressed="true"],
.seg-control__btn[data-active="true"] {
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-1);
}

/* ═══════════════════════════════════════════════════════════
   ACCORDION / FAQ
   ═══════════════════════════════════════════════════════════ */
.accordion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.accordion-item {
  border-bottom: 1px solid var(--color-border);
}
.accordion-item:last-child { border-bottom: none; }
.accordion-item__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  text-align: left;
  gap: var(--space-4);
  transition: background var(--trans-fast);
}
.accordion-item__btn:hover { background: var(--color-surface-2); }
.accordion-item__btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.accordion-item__icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: rotate var(--trans-fast);
}
.accordion-item__btn[aria-expanded="true"] .accordion-item__icon { rotate: 180deg; }

.accordion-item__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--trans-normal);
  background: var(--color-bg);
}
.accordion-item__body[data-open="true"] { grid-template-rows: 1fr; }
.accordion-item__inner {
  overflow: hidden;
}
.accordion-item__content {
  padding: var(--space-5) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--line-height-relaxed);
}

.faq { max-width: 720px; margin-inline: auto; }
.faq .accordion-item__btn { font-size: 1rem; padding: var(--space-6); }
.faq .accordion-item__content { font-size: var(--text-sm); padding: 0 var(--space-6) var(--space-6); }

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--trans-slow), visibility var(--trans-slow);
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal-backdrop[data-open="true"] {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  max-width: 560px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  translate: 0 32px;
  transition: translate var(--trans-slow);
  border: 1px solid var(--color-border);
}
.modal-backdrop[data-open="true"] .modal { translate: 0 0; }
@media (prefers-reduced-motion: reduce) {
  .modal { translate: 0 0 !important; }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) 0;
  gap: var(--space-4);
}
.modal__title { font-size: var(--text-h4); font-weight: var(--font-weight-bold); }
.modal__close {
  flex-shrink: 0;
  margin-top: -4px;
  margin-right: -4px;
}
.modal__body { padding: var(--space-5) var(--space-6); }
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 0 var(--space-6) var(--space-6);
}

@media (max-width: 639px) {
  .modal {
    border-radius: var(--radius-hero) var(--radius-hero) 0 0;
    max-height: 85dvh;
    margin: 0;
  }
}

/* ═══════════════════════════════════════════════════════════
   TOAST STACK
   ═══════════════════════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
  width: calc(100vw - var(--space-8));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-4);
  pointer-events: auto;
  animation: toast-in var(--trans-slow) var(--ease-bounce) both;
  font-size: var(--text-sm);
  line-height: 1.5;
}
@keyframes toast-in {
  from { opacity: 0; translate: 0 8px; }
  to   { opacity: 1; translate: 0 0;   }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
.toast--success { border-left: 4px solid var(--color-success); }
.toast--warning { border-left: 4px solid var(--color-warning); }
.toast--danger  { border-left: 4px solid var(--color-danger);  }
.toast--info    { border-left: 4px solid var(--color-info);    }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: var(--font-weight-semibold); margin-bottom: 2px; }
.toast__close { flex-shrink: 0; color: var(--color-text-muted); margin-left: auto; }

/* ═══════════════════════════════════════════════════════════
   TOOLTIP
   ═══════════════════════════════════════════════════════════ */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  translate: -50% 0;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--trans-fast), visibility var(--trans-fast);
  z-index: var(--z-tooltip);
}
.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 5px solid transparent;
  border-top-color: var(--color-text);
}
.tooltip-wrap:hover .tooltip,
.tooltip-wrap [aria-describedby]:focus ~ .tooltip {
  opacity: 1;
  visibility: visible;
}
.tooltip--bottom {
  bottom: auto;
  top: calc(100% + 6px);
}
.tooltip--bottom::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.progress-bar__fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width var(--trans-normal);
}
.progress-bar--indeterminate .progress-bar__fill {
  width: 40% !important;
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate {
  0%   { translate: -100% 0; }
  100% { translate: 260% 0;  }
}
@media (prefers-reduced-motion: reduce) {
  .progress-bar--indeterminate .progress-bar__fill { animation: none; width: 100% !important; }
}
.progress-bar--sm { height: 3px; }
.progress-bar--lg { height: 10px; }

.progress-labeled {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.progress-labeled__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════════════════
   SPINNER
   ═══════════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 40px; height: 40px; border-width: 3px; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-color: var(--color-primary); border-top-color: transparent; }
}

/* ═══════════════════════════════════════════════════════════
   SKELETON
   ═══════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 25%,
    var(--color-border) 50%,
    var(--color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-md);
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--color-surface-2); }
}
.skeleton--text  { height: 1em; width: 100%; }
.skeleton--title { height: 1.4em; width: 60%; }
.skeleton--circle { border-radius: 50%; }

/* ═══════════════════════════════════════════════════════════
   BADGE / PILL
   ═══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}
.badge--primary  { background: var(--color-primary-tint);  color: var(--color-primary);  }
.badge--success  { background: var(--color-success-bg);    color: var(--color-success);   }
.badge--warning  { background: var(--color-warning-bg);    color: var(--color-warning);   }
.badge--danger   { background: var(--color-danger-bg);     color: var(--color-danger);    }
.badge--info     { background: var(--color-info-bg);       color: var(--color-info);      }
.badge--neutral  { background: var(--color-surface-2);     color: var(--color-text-muted);}
.badge--beta     { background: var(--color-warning-bg);    color: var(--color-warning);   }

/* ═══════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding-inline: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--trans-fast);
}
.page-btn:hover { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); text-decoration: none; }
.page-btn[aria-current="page"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  pointer-events: none;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-4);
}
.empty-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-card);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}
.empty-state__title { font-size: var(--text-h4); font-weight: var(--font-weight-bold); }
.empty-state__desc { font-size: var(--text-sm); color: var(--color-text-muted); max-width: 36ch; }

/* ═══════════════════════════════════════════════════════════
   ALERT / CALLOUT
   ═══════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-card);
  border: 1px solid;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.alert__icon  { flex-shrink: 0; margin-top: 1px; }
.alert__body  { flex: 1; min-width: 0; }
.alert__title { font-weight: var(--font-weight-semibold); margin-bottom: 2px; }
.alert--success { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success); }
.alert--success .alert__body { color: var(--color-text); }
.alert--warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-warning); }
.alert--warning .alert__body { color: var(--color-text); }
.alert--danger  { background: var(--color-danger-bg);  border-color: var(--color-danger-border);  color: var(--color-danger);  }
.alert--danger .alert__body  { color: var(--color-text); }
.alert--info    { background: var(--color-info-bg);    border-color: var(--color-info-border);    color: var(--color-info);    }
.alert--info .alert__body    { color: var(--color-text); }
.alert--neutral { background: var(--color-surface);   border-color: var(--color-border);         color: var(--color-text);    }

/* ═══════════════════════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.card--elevated { box-shadow: var(--shadow-2); }
.card__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card__title { font-size: var(--text-h5); font-weight: var(--font-weight-semibold); }
.card__body  { padding: var(--space-5) var(--space-6); }
.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════
   CODE / OUTPUT BLOCK
   ═══════════════════════════════════════════════════════════ */
.code-block {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.code-block__lang {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}
.code-block__copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--trans-fast);
}
.code-block__copy:hover { color: var(--color-text); background: var(--color-border); }
.code-block__copy.copied { color: var(--color-success); border-color: var(--color-success-border); }
.code-block pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: var(--space-4) var(--space-5);
  max-height: 400px;
  overflow: auto;
}

/* ═══════════════════════════════════════════════════════════
   KBD HINT
   ═══════════════════════════════════════════════════════════ */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   DROPZONE
   ═══════════════════════════════════════════════════════════ */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-hero);
  background: var(--color-surface);
  padding: var(--space-16) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--trans-fast),
    background var(--trans-fast),
    box-shadow var(--trans-fast);
  position: relative;
  min-height: 240px;
}
.dropzone:focus-within,
.dropzone:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.dropzone:hover,
.dropzone[data-state="over"] {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  box-shadow: 0 0 0 4px var(--color-primary-tint);
}
.dropzone[data-state="invalid"] {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}
.dropzone[data-state="loading"] { cursor: wait; pointer-events: none; }
.dropzone[data-state="has-files"] {
  border-style: solid;
  border-color: var(--color-border);
  background: var(--color-bg);
  min-height: auto;
  padding: var(--space-4);
  flex-direction: column;
  align-items: stretch;
}
.dropzone__icon { color: var(--color-text-muted); }
.dropzone[data-state="over"] .dropzone__icon    { color: var(--color-primary); }
.dropzone[data-state="invalid"] .dropzone__icon { color: var(--color-danger); }
.dropzone__title {
  font-size: var(--text-h4);
  font-weight: var(--font-weight-bold);
}
.dropzone__sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.dropzone__or {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}
.dropzone__accept {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.dropzone[data-state="has-files"] input[type="file"] { display: none; }

/* ── File Row ── */
.file-list { display: flex; flex-direction: column; gap: var(--space-2); }
.file-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  transition: border-color var(--trans-fast), background var(--trans-fast);
}
.file-row[data-dragging="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  opacity: 0.6;
}
.file-row__thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--color-text-muted);
}
.file-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-row__info { min-width: 0; }
.file-row__name {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.file-row__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
}
.file-row__status--done    { color: var(--color-success); }
.file-row__status--error   { color: var(--color-danger); }
.file-row__status--pending { color: var(--color-text-muted); }
.file-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.file-row__drag {
  color: var(--color-text-muted);
  cursor: grab;
  touch-action: none;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--trans-fast);
}
.file-row__drag:hover { color: var(--color-text); }
.file-row__drag:active { cursor: grabbing; }

/* ═══════════════════════════════════════════════════════════
   BEFORE / AFTER SLIDER
   ═══════════════════════════════════════════════════════════ */
.before-after {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
}
.before-after__after,
.before-after__before {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.before-after__before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 50% 0 0);
}
.before-after__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  translate: -50% 0;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
  pointer-events: none;
}
.before-after__handle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 32px;
  height: 32px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.before-after__label {
  position: absolute;
  bottom: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  pointer-events: none;
}
.before-after__label--before { left: var(--space-3); }
.before-after__label--after  { right: var(--space-3); }

/* ═══════════════════════════════════════════════════════════
   STEP INDICATOR
   ═══════════════════════════════════════════════════════════ */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: var(--space-4);
}
.step-indicator::-webkit-scrollbar { display: none; }
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  position: relative;
  flex: 1;
  min-width: 80px;
}
.step + .step::before {
  content: '';
  position: absolute;
  top: 14px;
  right: calc(50% + 20px);
  left: calc(-50% + 20px);
  height: 2px;
  background: var(--color-border);
  transition: background var(--trans-normal);
}
.step[data-done="true"] + .step::before { background: var(--color-primary); }

.step__circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-bg);
  transition: all var(--trans-normal);
  z-index: 1;
}
.step[data-active="true"] .step__circle {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--color-primary-tint);
}
.step[data-done="true"] .step__circle {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.step__label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
}
.step[data-active="true"] .step__label { color: var(--color-primary); }
.step[data-done="true"] .step__label   { color: var(--color-text); }

/* ═══════════════════════════════════════════════════════════
   COMMAND PALETTE
   ═══════════════════════════════════════════════════════════ */
.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(var(--space-8), 10vh, var(--space-24));
  padding-inline: var(--space-4);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--trans-normal), visibility var(--trans-normal);
}
.command-palette[data-open="true"] { visibility: visible; opacity: 1; }

.command-palette__box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
  translate: 0 -16px;
  transition: translate var(--trans-normal);
}
.command-palette[data-open="true"] .command-palette__box { translate: 0 0; }

.command-palette__input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.command-palette__input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
}
.command-palette__input::placeholder { color: var(--color-text-muted); }

.command-palette__results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-2);
}
.cp-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--trans-fast);
}
.cp-result:hover,
.cp-result[data-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
}
.cp-result__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cp-result__name { font-size: var(--text-sm); font-weight: var(--font-weight-medium); }
.cp-result__cat  { font-size: var(--text-xs); color: var(--color-text-muted); }
.cp-result__kbds { margin-left: auto; display: flex; gap: var(--space-1); align-items: center; }

.command-palette__footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.command-palette__hint {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Cookie Consent Banner ── */
.cookie-banner {
  position: fixed;
  bottom: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  padding: var(--space-5) var(--space-6);
  max-width: 520px;
  translate: 0 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--trans-slow);
}
.cookie-banner[data-visible="true"] {
  translate: 0 0;
  opacity: 1;
  visibility: visible;
}
@media (min-width: 640px) { .cookie-banner { left: var(--space-6); right: auto; } }
.cookie-banner__title { font-weight: var(--font-weight-semibold); margin-bottom: var(--space-2); }
.cookie-banner__desc  { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.cookie-banner__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
