/* ==========================================================================
   COMPONENTS — Buttons, forms, cards, modals, toasts, etc.
   ========================================================================== */

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
  position: relative;
  border-radius: var(--radius-btn);
  /* Size defaults (md) */
  height: var(--btn-height-md);
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  min-width: 44px; /* touch target */
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* ── Sizes ────────────────────────────────────────────────────────────────── */
.btn--sm {
  height: var(--btn-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: 10px;
  gap: var(--space-1);
}

.btn--lg {
  height: var(--btn-height-lg);
  padding: 0 var(--space-8);
  font-size: 1rem;
}

/* ── Variants ─────────────────────────────────────────────────────────────── */

/* Primary — gradient */
.btn--primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgb(79 70 229 / .4);
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgb(79 70 229 / .45);
  filter: brightness(1.08);
}

[data-theme="dark"] .btn--primary {
  color: #fff;
}

/* Secondary — outlined */
.btn--secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn--secondary:hover:not(:disabled) {
  background: rgb(79 70 229 / .08);
}

[data-theme="dark"] .btn--secondary:hover:not(:disabled) {
  background: rgb(129 140 248 / .1);
}

/* Ghost */
.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* Danger */
.btn--danger {
  background: var(--color-danger);
  color: #fff;
}

.btn--danger:hover:not(:disabled) {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgb(220 38 38 / .35);
}

[data-theme="dark"] .btn--danger:hover:not(:disabled) {
  background: #ef4444;
}

/* Icon-only */
.btn--icon {
  width: var(--btn-height-md);
  padding: 0;
  border-radius: var(--radius-input);
}

.btn--icon.btn--sm {
  width: var(--btn-height-sm);
}

.btn--icon.btn--lg {
  width: var(--btn-height-lg);
}

/* ── States ───────────────────────────────────────────────────────────────── */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--loading {
  pointer-events: none;
}

.btn--loading .btn__text { opacity: 0; }

.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .btn--loading::after { animation: none; opacity: 0.5; }
}

/* ══════════════════════════════════════════════════════════════════════════
   FORM CONTROLS
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Form group ───────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Input / Textarea / Select ────────────────────────────────────────────── */
.input,
.textarea,
.select {
  width: 100%;
  height: var(--input-height-md);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  outline: none;
  appearance: none;
}

.textarea {
  height: auto;
  min-height: 120px;
  padding: var(--space-3);
  resize: vertical;
  line-height: var(--line-body);
}

.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='%23475569' 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 12px center;
  padding-right: var(--space-8);
  cursor: pointer;
}

.input:hover, .textarea:hover, .select:hover {
  border-color: var(--color-text-muted);
}

.input:focus, .textarea:focus, .select:focus,
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.input--error, .textarea--error, .select--error {
  border-color: var(--color-danger);
}

.input--error:focus, .textarea--error:focus, .select--error:focus {
  box-shadow: var(--shadow-focus-danger);
}

.input:disabled, .textarea:disabled, .select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-surface-2);
}

.input--sm { height: var(--input-height-sm); font-size: var(--text-xs); }
.input--lg { height: var(--input-height-lg); font-size: 1rem; }

/* ── Checkbox & Radio ─────────────────────────────────────────────────────── */
.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  user-select: none;
}

.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  position: relative;
}

.checkbox-label input[type="checkbox"] {
  border-radius: 5px;
}

.radio-label input[type="radio"] {
  border-radius: 50%;
}

.checkbox-label input[type="checkbox"]:checked,
.radio-label input[type="radio"]:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.radio-label input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
}

.checkbox-label input:focus-visible,
.radio-label input:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

.checkbox-label input:disabled,
.radio-label input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Switch / Toggle ──────────────────────────────────────────────────────── */
.switch-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch__track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  transition: background var(--duration-fast) var(--ease-out);
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-1);
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.switch input:checked ~ .switch__track {
  background: var(--color-primary);
}

.switch input:checked ~ .switch__thumb {
  transform: translateX(20px);
}

.switch input:focus-visible ~ .switch__track {
  box-shadow: var(--shadow-focus);
}

/* ── Range Slider ─────────────────────────────────────────────────────────── */
.range-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.range-slider__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
}

.range-slider__value {
  font-weight: 600;
  color: var(--color-primary);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  outline: none;
  cursor: pointer;
  border: none;
  box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid #fff;
  box-shadow: var(--shadow-2);
  transition: transform var(--duration-fast) var(--ease-out);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
  box-shadow: var(--shadow-2);
  cursor: pointer;
}

input[type="range"]:focus-visible {
  outline: none;
  box-shadow: none;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--shadow-focus);
}

/* ── Number stepper ───────────────────────────────────────────────────────── */
.number-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  overflow: hidden;
  width: fit-content;
}

.number-stepper__btn {
  width: 36px;
  height: var(--input-height-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.number-stepper__btn:hover { background: var(--color-surface); color: var(--color-text); }
.number-stepper__btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.number-stepper__input {
  width: 64px;
  height: var(--input-height-md);
  border: none;
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
  border-radius: 0;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  outline: none;
  background: var(--color-bg);
}

.number-stepper__input:focus-visible {
  border-color: var(--color-primary);
  box-shadow: inset 0 0 0 1px var(--color-primary);
}

/* ── Color Input ──────────────────────────────────────────────────────────── */
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 4px var(--space-3) 4px 4px;
  width: fit-content;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

/* ══════════════════════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.tabs__list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs__list::-webkit-scrollbar { display: none; }

.tabs__tab {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  border-radius: 4px 4px 0 0;
}

.tabs__tab:hover { color: var(--color-text); }

.tabs__tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tabs__tab:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.tabs__panel { display: none; }
.tabs__panel[aria-hidden="false"] { display: block; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  padding: 3px;
  gap: 2px;
}

.segmented__btn {
  padding: 5px var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.segmented__btn:hover { color: var(--color-text); }

.segmented__btn[aria-pressed="true"],
.segmented__btn[aria-selected="true"] {
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-1);
}

.segmented__btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ══════════════════════════════════════════════════════════════════════════
   ACCORDION / FAQ
   ══════════════════════════════════════════════════════════════════════════ */

.accordion {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.accordion__item + .accordion__item {
  border-top: 1px solid var(--color-border);
}

.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: left;
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--duration-fast) var(--ease-out);
  min-height: 52px;
}

.accordion__trigger:hover {
  background: var(--color-surface-2);
}

.accordion__trigger:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.accordion__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
}

.accordion__trigger[aria-expanded="true"] .accordion__icon {
  transform: rotate(180deg);
}

.accordion__content {
  display: none;
  padding: 0 var(--space-6) var(--space-4);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--line-body);
}

.accordion__content[aria-hidden="false"] {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* ══════════════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgb(0 0 0 / .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.modal-backdrop[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--duration-slow) var(--ease-out);
}

.modal-backdrop[aria-hidden="false"] .modal {
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .modal { transition: none; }
  .modal-backdrop { transition: none; }
}

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

.modal__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
}

.modal__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.modal__close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.modal__close:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.modal__body {
  padding: var(--space-6);
}

.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ══════════════════════════════════════════════════════════════════════════
   TOAST STACK
   ══════════════════════════════════════════════════════════════════════════ */

.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 360px;
  width: calc(100vw - var(--space-8));
}

@media (max-width: 479px) {
  .toast-stack {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

.toast {
  display: flex;
  align-items: flex-start;
  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);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toastIn var(--duration-slow) var(--ease-out);
}

.toast--dismissing {
  animation: toastOut var(--duration-normal) var(--ease-out) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast--dismissing { animation: none; opacity: 0; }
}

.toast__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast--success .toast__icon { color: var(--color-success); }
.toast--error   .toast__icon { color: var(--color-danger); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--info    .toast__icon { color: var(--color-info); }

.toast__body { flex: 1; min-width: 0; }

.toast__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.toast__message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--line-snug);
}

.toast__close {
  flex-shrink: 0;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.toast__close:hover { color: var(--color-text); }
.toast__close:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

/* ══════════════════════════════════════════════════════════════════════════
   TOOLTIP
   ══════════════════════════════════════════════════════════════════════════ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  padding: 5px var(--space-2);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  z-index: var(--z-tooltip);
  transition: opacity var(--duration-fast) var(--ease-out);
}

[data-tooltip]::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-text);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════════════
   PROGRESS
   ══════════════════════════════════════════════════════════════════════════ */

.progress {
  width: 100%;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s var(--ease-out);
}

/* Indeterminate */
.progress--indeterminate .progress__bar {
  width: 40% !important;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(350%); }
}

@media (prefers-reduced-motion: reduce) {
  .progress--indeterminate .progress__bar {
    animation: none;
    width: 100% !important;
    opacity: 0.4;
  }
}

/* ── Progress label ───────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.progress-wrap__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════
   SPINNER
   ══════════════════════════════════════════════════════════════════════════ */

.spinner {
  display: inline-block;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spin 0.7s linear infinite;
}

.spinner--sm { width: 16px; height: 16px; }
.spinner--md { width: 24px; height: 24px; }
.spinner--lg { width: 40px; height: 40px; border-width: 3px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--color-primary); opacity: 0.6; }
}

/* ══════════════════════════════════════════════════════════════════════════
   SKELETON
   ══════════════════════════════════════════════════════════════════════════ */

.skeleton {
  background: var(--color-surface-2);
  border-radius: var(--radius-input);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgb(255 255 255 / .6) 50%,
    transparent 100%);
  transform: translateX(-100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg,
    transparent 0%,
    rgb(255 255 255 / .06) 50%,
    transparent 100%);
}

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

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}

.skeleton--text   { height: 1em; width: 80%; margin-bottom: 0.5em; }
.skeleton--title  { height: 2em; width: 60%; }
.skeleton--avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton--card   { height: 160px; border-radius: var(--radius-card); }

/* ══════════════════════════════════════════════════════════════════════════
   BADGE / PILL
   ══════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  line-height: 1.5;
  white-space: nowrap;
}

.badge--default  { background: var(--color-surface-2);       color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge--primary  { background: rgb(79 70 229 / .12);          color: var(--color-primary); }
.badge--success  { background: rgb(22 163 74 / .12);          color: var(--color-success); }
.badge--warning  { background: rgb(217 119 6 / .12);          color: var(--color-warning); }
.badge--danger   { background: rgb(220 38 38 / .12);          color: var(--color-danger); }
.badge--info     { background: rgb(2 132 199 / .12);          color: var(--color-info); }

/* ══════════════════════════════════════════════════════════════════════════
   BREADCRUMB
   ══════════════════════════════════════════════════════════════════════════ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  list-style: none;
  padding: 0;
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.breadcrumb__item:not(:last-child)::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  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='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
}

.breadcrumb__link {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumb__link:hover { color: var(--color-primary); }

.breadcrumb__current {
  color: var(--color-text);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════════════════ */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination__btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-input);
  background: none;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.pagination__btn:hover:not(:disabled):not([aria-current]) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.pagination__btn[aria-current="page"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.pagination__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination__btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.pagination__ellipsis {
  padding: 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ══════════════════════════════════════════════════════════════════════════
   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;
  color: var(--color-text-muted);
  opacity: 0.4;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 36ch;
  margin: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   ALERT / CALLOUT
   ══════════════════════════════════════════════════════════════════════════ */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-card);
  font-size: var(--text-sm);
  border: 1px solid;
}

.alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.alert__body { flex: 1; }
.alert__title { font-weight: 600; margin-bottom: 4px; }
.alert__desc  { color: inherit; opacity: 0.85; margin: 0; }

.alert--info    { background: rgb(2 132 199 / .08);  border-color: rgb(2 132 199 / .3);  color: var(--color-info); }
.alert--success { background: rgb(22 163 74 / .08);  border-color: rgb(22 163 74 / .3);  color: var(--color-success); }
.alert--warning { background: rgb(217 119 6 / .08);  border-color: rgb(217 119 6 / .3);  color: var(--color-warning); }
.alert--danger  { background: rgb(220 38 38 / .08);  border-color: rgb(220 38 38 / .3);  color: var(--color-danger); }

/* ══════════════════════════════════════════════════════════════════════════
   CARD
   ══════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.card--hoverable:hover {
  box-shadow: var(--shadow-3);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.card--hoverable:focus-within {
  box-shadow: var(--shadow-focus);
  border-color: var(--color-primary);
}

/* ── Tool Card ────────────────────────────────────────────────────────────── */
.tool-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: box-shadow var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.tool-card:hover {
  box-shadow: var(--shadow-3);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.tool-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--color-primary);
}

.tool-card__icon-tile {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-card__icon-tile svg {
  width: 22px;
  height: 22px;
}

.tool-card__name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: var(--line-tight);
}

.tool-card__desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--line-snug);
  flex: 1;
  margin: 0;
}

.tool-card__arrow {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-end;
}

.tool-card:hover .tool-card__arrow,
.tool-card:focus-visible .tool-card__arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Skeleton variant */
.tool-card--skeleton { pointer-events: none; }
.tool-card--skeleton .tool-card__icon-tile { background: var(--color-surface-2); }
.tool-card--skeleton .tool-card__name,
.tool-card--skeleton .tool-card__desc { background: var(--color-surface-2); color: transparent; border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════════
   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-2) 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: 600;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.code-block__copy {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.code-block__copy:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.code-block__copy:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.code-block__copy--copied { color: var(--color-success); }

.code-block__body {
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--color-text);
  margin: 0;
}

/* ── kbd hint ─────────────────────────────────────────────────────────────── */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  box-shadow: 0 1px 0 var(--color-border);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════
   SEARCH / COMMAND PALETTE
   ══════════════════════════════════════════════════════════════════════════ */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--space-4) var(--space-4);
  background: rgb(0 0 0 / .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.command-palette[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.command-palette__dialog {
  width: 100%;
  max-width: 600px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform var(--duration-slow) var(--ease-out);
}

.command-palette[aria-hidden="false"] .command-palette__dialog {
  transform: translateY(0);
}

.command-palette__input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.command-palette__search-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
}

.command-palette__input {
  flex: 1;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
  height: auto;
  padding: 0;
}

.command-palette__results {
  max-height: 380px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.command-palette__empty {
  padding: var(--space-8);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.command-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--duration-fast) var(--ease-out);
}

.command-result:hover,
.command-result[aria-selected="true"] {
  background: var(--color-surface-2);
}

.command-result__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.command-result__name {
  font-size: var(--text-sm);
  font-weight: 500;
}

.command-result__cat {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}

.command-palette__footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-4);
  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);
}

/* ══════════════════════════════════════════════════════════════════════════
   THEME TOGGLE
   ══════════════════════════════════════════════════════════════════════════ */

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-input);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  min-width: 44px;
  min-height: 44px;
}

.theme-toggle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }

[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   COOKIE CONSENT BANNER
   ══════════════════════════════════════════════════════════════════════════ */

.cookie-banner {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-hero);
  box-shadow: var(--shadow-4);
  padding: var(--space-4) var(--space-6);
  width: calc(100% - var(--space-8));
  max-width: 680px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}

.cookie-banner__text {
  flex: 1;
  min-width: 200px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.cookie-banner__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   GENERAL ANIMATIONS
   ══════════════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
