/* KHub components — 17-DESIGN-SYSTEM.md §6, §10.
   Load order: tokens → base → layout → components.
   Only token variables for colors; literal px values appear only where §6
   specifies them explicitly (paddings, gaps, control sizes). */

/* ============================================================
   Icons (§9)
   ============================================================ */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Spinner (used by .is-loading buttons, async blocks)
   ============================================================ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: var(--r-full);
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
}

.spinner--sm {
  width: 12px;
  height: 12px;
}

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

/* ============================================================
   6.1 Button
   ============================================================ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;                        /* §6.1 icon-text gap */
  height: var(--control-h);        /* 38px */
  padding: 0 14px;                 /* §6.1 */
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);       /* 14px */
  font-weight: var(--fw-medium);   /* 500 */
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

/* --- Variants (§6.1 table) --- */
.btn-primary {
  background: var(--accent-500);
  color: var(--text-invert);       /* white in light, flips in dark */
  border-color: transparent;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

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

.btn-danger {
  background: var(--danger);
  color: var(--text-invert);
  border-color: transparent;
}

/* --- Hover: 8% darker bg for filled/secondary; ghost → surface-2.
       No jump / scale (§6.1 states). --- */
.btn-primary:hover:not(:disabled):not(.is-loading) {
  background: color-mix(in srgb, var(--accent-500) 92%, black);
}

.btn-secondary:hover:not(:disabled):not(.is-loading) {
  background: color-mix(in srgb, var(--surface) 92%, black);
}

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

.btn-danger:hover:not(:disabled):not(.is-loading) {
  background: color-mix(in srgb, var(--danger) 92%, black);
}

/* --- Active: translateY(1px), shadow removed (§6.1) --- */
.btn:active:not(:disabled):not(.is-loading) {
  transform: translateY(1px);
  box-shadow: none;
}

/* --- Focus-visible (§6.1, mandatory) --- */
.btn:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

/* --- Disabled (§6.1): opacity .5, not-allowed cursor, no hover (guarded) --- */
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* --- Loading: text hidden, 14px spinner centered, width stable (§6.1) --- */
.btn.is-loading {
  pointer-events: none;
  cursor: default;
}

.btn.is-loading > :not(.spinner) {
  visibility: hidden;
}

.btn.is-loading > .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* --- Icon-only: square 38×38 (§6.1) --- */
.btn-icon {
  width: var(--control-h);
  padding: 0;
}

.btn-icon.btn-sm {
  width: 30px;
}

/* --- Size sm: 30px / 13px — tables & toolbars only (§6.1) --- */
.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: var(--fs-sm);         /* 13px */
}

.btn-sm .spinner {
  width: 12px;
  height: 12px;
}

/* ============================================================
   6.2 Inputs, selects, checkbox, radio
   ============================================================ */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  height: var(--control-h);        /* 38px */
  padding: 0 12px;                 /* §6.2 */
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.textarea {
  height: auto;
  min-height: calc(var(--control-h) * 2);
  padding: var(--sp-2) 12px;
  resize: vertical;
}

/* Hover: stronger border (§6.2) */
.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) {
  border-color: var(--border-strong);
}

/* Focus: accent border + 3px ring (§6.2) */
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px var(--accent-50);
}

/* Invalid: danger border + danger ring (§6.2) */
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
.textarea[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

/* Disabled (§6.2) */
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--text-subtle);
  border-color: var(--border);
  cursor: not-allowed;
}

/* Placeholder stays visible on focus (§6.2) */
.input::placeholder,
.textarea::placeholder {
  color: var(--text-subtle);
  opacity: 1;
}

/* --- Select with custom SVG arrow (§6.2) --- */
.select-wrap {
  position: relative;
  display: block;
}

.select {
  padding-right: 34px;             /* room for the arrow */
  cursor: pointer;
}

.select-wrap .select__arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.select:disabled + .select__arrow {
  color: var(--text-subtle);
  opacity: .5;
}

/* --- Checkbox & radio: custom 20×20, 120ms fill (§6.2) --- */
.checkbox,
.radio {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.checkbox {
  border-radius: var(--r-sm);
}

.radio {
  border-radius: var(--r-full);
}

.checkbox:hover:not(:disabled),
.radio:hover:not(:disabled) {
  border-color: var(--accent-500);
}

.checkbox:focus-visible,
.radio:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.checkbox:checked,
.radio:checked {
  background: var(--accent-500);
  border-color: var(--accent-500);
}

/* Checkmark tick — pure CSS, currentColor-free (uses --text-invert) */
.checkbox::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid var(--text-invert);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  opacity: 0;
  transition:
    transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

.checkbox:checked::after {
  transform: rotate(45deg) scale(1);
  opacity: 1;
}

/* Radio dot */
.radio::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--text-invert);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition:
    transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

.radio:checked::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.checkbox:disabled,
.radio:disabled {
  background: var(--surface-2);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: .5;
}

.checkbox:disabled:checked,
.radio:disabled:checked {
  background: var(--border-strong);
  border-color: var(--border-strong);
}

/* ============================================================
   Field: label + control + help / error (§6.2, §11)
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.field__label {
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
}

.field__label .req {
  color: var(--danger);
  margin-left: 2px;
}

/* <small> under the control */
.field-help {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  color: var(--text-muted);
}

/* error under the control, role="alert" in markup */
.field-error {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  color: var(--danger);
}

.field-error::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--sp-1);
  vertical-align: -1px;
  /* tiny alert dot drawn with tokens */
  border-radius: var(--r-full);
  background: var(--danger);
}

/* Checkbox/radio row */
.field-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 24px;
}

.field-check .field__label {
  font-weight: var(--fw-regular);
}

/* ============================================================
   6.3 Card
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);            /* §6.3 */
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

/* Hover only for clickable cards: border + soft shadow, no move/scale (§6.3) */
.card.is-clickable:hover,
a.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.card.is-clickable:focus-visible,
a.card:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.card.is-clickable:active {
  box-shadow: none;
}

.card__title {
  margin-bottom: var(--sp-2);      /* 8px (§6.3) */
  font-size: var(--fs-md);         /* 16px */
  line-height: var(--lh-md);
  font-weight: var(--fw-semibold); /* 600 */
  color: var(--text);
}

.card__desc {
  margin-top: var(--sp-1);
  font-size: var(--fs-base);
  color: var(--text-muted);
  max-width: 68ch;
}

.card__body {
  margin-top: var(--sp-3);
}

.card__footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* Entrance: opacity 0→1 + 4px shift, 30ms stagger, max 6 items (§10).
   Set style="--i:0..5" on the first six cards only. */
.card--enter {
  animation: card-in var(--dur-base) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   6.4 Data table
   ============================================================ */
.table-wrap {
  /* scroll container keeps sticky header reachable */
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: var(--fs-base);
  color: var(--text);
  font-variant-numeric: tabular-nums; /* §5/§6.4 */
}

/* Header: surface-2, 12px, muted, NOT uppercase, sticky (§6.4) */
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-xs);         /* 12px */
  font-weight: var(--fw-medium);
  text-align: left;
  text-transform: none;            /* §6.4/§13: uppercase forbidden */
  white-space: nowrap;
}

.table th.table__num {
  text-align: right;
}

/* Rows: --row-h, bottom border only (§6.4) */
.table td {
  height: var(--row-h);            /* 44px */
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Row hover: surface-hover, 120ms (§6.4) */
.table tbody tr {
  transition: background-color var(--dur-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table tbody tr:focus-within {
  background: var(--surface-hover);
}

/* Numbers right-aligned (§6.4) */
.table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Ids / keys: mono 12px + copy button on hover (§6.4) */
.table__id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

.table__id .copy-btn {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.table tbody tr:hover .table__id .copy-btn,
.table__id .copy-btn:focus-visible {
  opacity: 1;
}

/* Row actions: reveal on hover/focus, always keyboard-reachable (§6.4) */
.table__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-1);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.table tbody tr:hover .table__actions,
.table tbody tr:focus-within .table__actions {
  opacity: 1;
}

/* keep focusable buttons visible when tabbing */
.table__actions:focus-within {
  opacity: 1;
}

/* Inline 16px icons inside tables (§9) */
.table .icon {
  width: 16px;
  height: 16px;
}

/* ============================================================
   6.5 Status badge
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;                /* §6.5 */
  border-radius: var(--r-full);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);         /* 12px */
  font-weight: var(--fw-medium);   /* 500 */
  line-height: var(--lh-xs);
  white-space: nowrap;
  vertical-align: baseline;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* "running" — soft 2s dot pulse, not blinking (§10) */
.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  flex-shrink: 0;
}

.badge-running .badge__dot {
  animation: badge-pulse 2s var(--ease) infinite;
}

@keyframes badge-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: .45;
    transform: scale(.75);
  }
}

/* ============================================================
   Tabs — active underline slides 180ms (§10)
   ============================================================ */
.tabs {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-3);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}

.tab:hover:not(:disabled) {
  color: var(--text);
}

.tab:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: -2px;
  border-radius: var(--r-sm);
}

.tab[aria-selected="true"],
.tab.is-active {
  color: var(--text);
}

.tab:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Sliding ink: JS sets --x (px offset) and --w (scaleX width factor).
   Only transform animates (§8). */
.tabs__ink {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 1px;
  height: 2px;
  background: var(--accent-500);
  border-radius: var(--r-full);
  transform: translateX(var(--x, 0)) scaleX(var(--w, 0));
  transform-origin: left center;
  transition: transform var(--dur-base) var(--ease);
  pointer-events: none;
}

/* Fallback underline when no JS-driven ink is present */
.tabs:not(:has(.tabs__ink)) .tab.is-active::after {
  content: "";
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: -1px;
  height: 2px;
  background: var(--accent-500);
  border-radius: var(--r-full);
}

/* Tab panel */
.tab-panel[hidden] {
  display: none;
}

.tab-panel {
  padding-top: var(--sp-4);
}

/* ============================================================
   6.6 Modal — native <dialog>
   ============================================================ */
.modal {
  padding: 0;
  border: none;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  width: 480px;                    /* sm (§6.6) */
  max-width: calc(100vw - var(--sp-8));
  max-height: calc(100vh - var(--sp-10));
  overflow: hidden;
}

.modal--md {
  width: 640px;                    /* md (§6.6) */
}

.modal::backdrop {
  background: rgba(11, 13, 18, .45); /* §6.6 overlay */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Entry: opacity 0→1 + scale(.98)→1, 180ms (§6.6).
   Only transform/opacity animated (§8). */
.modal[open] {
  animation: modal-in var(--dur-base) var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) 0;
}

.modal__title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);         /* 16px */
  line-height: var(--lh-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
}

.modal__desc {
  margin-top: var(--sp-1);
  font-size: var(--fs-base);
  color: var(--text-muted);
  max-width: 68ch;
}

.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin: calc(var(--sp-1) * -1) calc(var(--sp-1) * -1) 0 0;
  border-radius: var(--r-sm);
  color: var(--text-subtle);
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

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

.modal__close:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.modal__body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto;
}

.modal__footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* dangerous actions: secondary left, danger right (§6.6) */
.modal__footer-start {
  margin-right: auto;
}

.modal__footer-end {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

/* ============================================================
   6.7 Toasts — bottom-right, stack ≤3, 320px (§6.7)
   ============================================================ */
.toast-region {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  width: 320px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: 320px;
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  pointer-events: auto;
  /* slide from below + fade, 180ms (§6.7/§10) */
  animation: toast-in var(--dur-base) var(--ease);
}

.toast.is-leaving {
  animation: toast-out var(--dur-base) var(--ease) forwards;
}

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

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

.toast__icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.toast__text {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

.toast__title {
  font-weight: var(--fw-semibold);
}

.toast__desc {
  margin-top: 2px;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--text-muted);
}

.toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  color: var(--text-subtle);
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

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

.toast__close:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.toast-success .toast__icon {
  color: var(--success);
}

.toast-warning .toast__icon {
  color: var(--warning);
}

.toast-danger .toast__icon {
  color: var(--danger);
}

.toast-info .toast__icon {
  color: var(--info);
}

/* ============================================================
   6.8 Progress — 6px track, mandatory numeric label (§6.8)
   ============================================================ */
.progress {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.progress__track {
  flex: 1;
  min-width: 0;
  height: 6px;                     /* §6.8 */
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

/* fill animates via transform only (§8): set --p = 0…1 inline */
.progress__bar {
  width: 100%;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent-500);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
  transition: transform var(--dur-slow) var(--ease);
}

.progress__label {
  flex-shrink: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* unfinished/indeterminate: soft shimmer, not a full-screen stripe (§6.8) */
.progress--indeterminate .progress__track {
  position: relative;
}

.progress--indeterminate .progress__bar {
  width: 40%;
  transform: none;
  transition: none;
  animation: shimmer 1.4s var(--ease) infinite;
}

/* ============================================================
   6.9 Empty state
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-12) var(--sp-4); /* §6.9 vertical --sp-12 */
  text-align: center;
}

.empty-state__icon {
  width: 40px;                     /* §6.9 */
  height: 40px;
  color: var(--text-subtle);
  margin-bottom: var(--sp-1);
}

.empty-state__title {
  font-size: var(--fs-md);         /* 16px */
  line-height: var(--lh-md);
  font-weight: var(--fw-semibold); /* 600 */
  color: var(--text);
}

.empty-state__desc {
  font-size: var(--fs-base);       /* 14px */
  line-height: var(--lh-base);
  color: var(--text-muted);
  max-width: 46ch;                 /* §6.9 */
}

.empty-state__action {
  margin-top: var(--sp-2);
}

/* ============================================================
   6.10 Skeleton — surface-2 blocks, shimmer 1.4s (§6.10)
   ============================================================ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--surface) 55%, transparent) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: shimmer 1.4s var(--ease) infinite;
}

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

.skeleton--text {
  height: var(--fs-sm);
  border-radius: var(--r-sm);
}

.skeleton--title {
  height: var(--lh-md);
  width: 40%;
}

.skeleton--row {
  height: var(--row-h);
  border-radius: 0;
}

.skeleton--card {
  height: 120px;
  border-radius: var(--r-lg);
}

.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* ============================================================
   Copy button — icon flips to check for 1.2s (§10)
   ============================================================ */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  color: var(--text-subtle);
  vertical-align: middle;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

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

.copy-btn:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

.copy-btn .copy-btn__check {
  display: none;
  color: var(--success);
}

.copy-btn.is-copied .copy-btn__copy {
  display: none;
}

.copy-btn.is-copied .copy-btn__check {
  display: block;
}

/* ============================================================
   Small shared bits
   ============================================================ */

/* inline key/value list used in detail panels */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-base);
}

.kv__key {
  color: var(--text-muted);
}

.kv__val {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* toolbar above tables (uses .btn-sm inside) */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.toolbar__spacer {
  margin-left: auto;
}

/* section spacing helper for page blocks */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
