/* ==========================================================================
   Advoke CV — Component library
   Buttons, forms, cards, chips, tabs, modals, toasts, accordions,
   dropdowns, badges, pills, empty states, skeletons, tooltips,
   pagination, breadcrumbs. Every interactive component gets keyboard
   states, disabled states, and reduced-motion handling.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--interactive-primary);
  --btn-bg-hover: var(--interactive-primary-hover);
  --btn-bg-active: var(--interactive-primary-active);
  --btn-fg: var(--c-white);
  --btn-border: transparent;
  --btn-shadow: var(--shadow-xs);
  --btn-shadow-hover: var(--shadow-sm);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 42px;
  padding: var(--sp-2) var(--sp-5);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  letter-spacing: var(--ls-tight);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard),
    transform var(--dur-instant) var(--ease-standard);
}

@media (min-width: 768px) {
  .btn {
    min-height: 44px;
    padding: var(--sp-3) var(--sp-6);
    font-size: var(--fs-sm);
  }
}

.btn:hover {
  background: var(--btn-bg-hover);
  box-shadow: var(--btn-shadow-hover);
  text-decoration: none;
}

.btn:active {
  background: var(--btn-bg-active);
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

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

.btn svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

/* --- Variants ------------------------------------------------------------ */
.btn--primary {
  --btn-bg: var(--interactive-primary);
  --btn-bg-hover: var(--interactive-primary-hover);
  --btn-bg-active: var(--interactive-primary-active);
  --btn-fg: var(--c-white);
}

.btn--accent {
  --btn-bg: var(--interactive-accent);
  --btn-bg-hover: var(--interactive-accent-hover);
  --btn-bg-active: var(--c-blue-800);
  --btn-fg: var(--c-white);
}

.btn--secondary {
  --btn-bg: var(--c-white);
  --btn-bg-hover: var(--c-neutral-100);
  --btn-bg-active: var(--c-neutral-150);
  --btn-fg: var(--text-primary);
  --btn-border: var(--border-default);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-bg-hover: var(--interactive-ghost-hover);
  --btn-bg-active: var(--c-neutral-200);
  --btn-fg: var(--text-primary);
  --btn-border: transparent;
  --btn-shadow: none;
  --btn-shadow-hover: none;
}

.btn--outline {
  --btn-bg: transparent;
  --btn-bg-hover: var(--interactive-accent-soft);
  --btn-bg-active: var(--c-blue-100);
  --btn-fg: var(--text-accent);
  --btn-border: var(--interactive-accent);
  --btn-shadow: none;
  --btn-shadow-hover: none;
}

.btn--danger {
  --btn-bg: var(--interactive-danger);
  --btn-bg-hover: var(--interactive-danger-hover);
  --btn-bg-active: var(--c-red-700);
  --btn-fg: var(--c-white);
}

.btn--danger-outline {
  --btn-bg: transparent;
  --btn-bg-hover: var(--c-red-50);
  --btn-bg-active: var(--c-red-50);
  --btn-fg: var(--text-danger);
  --btn-border: var(--c-red-500);
  --btn-shadow: none;
  --btn-shadow-hover: none;
}

.btn--on-dark {
  --btn-bg: rgba(255, 255, 255, 0.1);
  --btn-bg-hover: rgba(255, 255, 255, 0.18);
  --btn-bg-active: rgba(255, 255, 255, 0.24);
  --btn-fg: var(--c-white);
  --btn-border: rgba(255, 255, 255, 0.2);
}

/* --- Sizes --------------------------------------------------------------- */
.btn--sm {
  min-height: 34px;
  padding: var(--sp-1) var(--sp-4);
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
}

.btn--lg {
  min-height: 52px;
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--fs-md);
  border-radius: var(--radius-lg);
}

@media (min-width: 768px) {
  .btn--lg {
    min-height: 56px;
    padding: var(--sp-4) var(--sp-10);
    font-size: var(--fs-lg);
  }
}

.btn--block {
  width: 100%;
}

.btn--pill {
  border-radius: var(--radius-full);
}

.btn--icon {
  min-width: 42px;
  min-height: 42px;
  padding: 0;
}

.btn--icon.btn--sm {
  min-width: 34px;
  min-height: 34px;
}

.btn--icon.btn--lg {
  min-width: 52px;
  min-height: 52px;
}

/* --- Loading state ------------------------------------------------------- */
.btn.is-loading {
  pointer-events: none;
  position: relative;
  color: transparent !important;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.1em;
  height: 1.1em;
  margin: -0.55em 0 0 -0.55em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: advoke-spin 0.7s linear infinite;
  color: var(--btn-fg);
}

/* --- Button groups ------------------------------------------------------- */
.btn-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.btn-group > .btn {
  border-radius: 0;
  box-shadow: none;
}

.btn-group > .btn + .btn {
  border-left: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-group > .btn:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.btn-group > .btn:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

/* --------------------------------------------------------------------------
   2. FORM CONTROLS
   -------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-secondary);
}

.field__label-optional {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-tertiary);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  line-height: var(--lh-snug);
}

.field__error {
  display: none;
  font-size: var(--fs-xs);
  color: var(--text-danger);
  line-height: var(--lh-snug);
}

.field.has-error .field__error {
  display: block;
}

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

.input,
.textarea,
.select {
  width: 100%;
  min-height: 42px;
  padding: var(--sp-3) var(--sp-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--text-primary);
  background: var(--c-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition:
    border-color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard),
    background var(--dur-fast) var(--ease-standard);
  appearance: none;
  -webkit-appearance: none;
}

@media (min-width: 768px) {
  .input,
  .textarea,
  .select {
    font-size: var(--fs-base);
    min-height: 44px;
  }
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

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

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

.input:disabled,
.textarea:disabled,
.select:disabled {
  background: var(--surface-sunken);
  color: var(--text-tertiary);
}

.textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: var(--lh-relaxed);
}

.textarea--short {
  min-height: 5rem;
}

.textarea--tall {
  min-height: 12rem;
}

/* --- Select ----------------------------------------------------------------- */
.select {
  padding-right: var(--sp-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23545d72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  background-size: 1rem;
  cursor: pointer;
}

.select::-ms-expand {
  display: none;
}

/* --- Input with prefix/suffix ---------------------------------------------- */
.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
}

.input-group .input {
  flex: 1 1 auto;
}

.input-group__addon {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  border-right: none;
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  white-space: nowrap;
}

.input-group__addon--trailing {
  border-right: 1px solid var(--border-default);
  border-left: none;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.input-group .input:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group .input:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* --- Checkbox / Radio ------------------------------------------------------- */
.checkbox,
.radio {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  cursor: pointer;
  user-select: none;
  padding: var(--sp-1) 0;
}

.checkbox input,
.radio input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  background: var(--c-white);
  border: 1.5px solid var(--border-strong);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard);
}

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

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

.checkbox input:checked {
  background: var(--interactive-accent);
  border-color: var(--interactive-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.radio input:checked {
  background: var(--c-white);
  border-color: var(--interactive-accent);
  border-width: 5px;
}

.checkbox input:focus-visible,
.radio input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* --- Switch ----------------------------------------------------------------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 40px;
  height: 24px;
  background: var(--c-neutral-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-standard);
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--c-white);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-emphasized);
}

.switch input:checked {
  background: var(--interactive-accent);
}

.switch input:checked::after {
  transform: translateX(16px);
}

.switch input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.switch__label {
  font-size: var(--fs-sm);
  color: var(--text-primary);
}

/* --- Range ------------------------------------------------------------------ */
.range {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  background: var(--c-neutral-200);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--interactive-accent);
  border: 3px solid var(--c-white);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  cursor: grab;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--interactive-accent);
  border: 3px solid var(--c-white);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  cursor: grab;
  border-width: 3px;
}

.range:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 4px;
}

/* --- Color picker ------------------------------------------------------------ */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.color-swatch {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--c-white);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--border-default);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch[aria-pressed="true"] {
  box-shadow: var(--shadow-md), 0 0 0 2px var(--interactive-accent);
}

.color-swatch:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. CARDS
   -------------------------------------------------------------------------- */
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition:
    border-color var(--dur-base) var(--ease-standard),
    box-shadow var(--dur-base) var(--ease-standard),
    transform var(--dur-base) var(--ease-standard);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card--interactive:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus), var(--shadow-md);
}

.card__body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  flex: 1 1 auto;
}

@media (min-width: 768px) {
  .card__body {
    padding: var(--sp-6);
  }
}

.card__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
}

.card__desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}

.card__footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

/* --------------------------------------------------------------------------
   4. CHIPS / PILLS / BADGES
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  color: var(--text-secondary);
  background: var(--c-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  transition:
    background var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard);
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--c-navy-900);
  border-color: var(--c-navy-900);
  color: var(--c-white);
}

.chip[aria-pressed="true"]:hover,
.chip.is-active:hover {
  background: var(--c-navy-950);
  border-color: var(--c-navy-950);
}

.chip__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  font-size: 0.625rem;
  font-weight: var(--fw-semibold);
  background: var(--surface-sunken);
  color: var(--text-tertiary);
  border-radius: var(--radius-full);
}

.chip.is-active .chip__count {
  background: rgba(255, 255, 255, 0.18);
  color: var(--c-white);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  font-size: 0.6875rem;
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge--accent   { background: var(--interactive-accent-soft); color: var(--text-accent); }
.badge--neutral  { background: var(--surface-sunken); color: var(--text-secondary); }
.badge--success  { background: var(--c-green-50); color: var(--text-success); }
.badge--warning  { background: var(--c-amber-50); color: var(--text-warning); }
.badge--danger   { background: var(--c-red-50); color: var(--text-danger); }
.badge--navy     { background: var(--c-navy-50); color: var(--c-navy-800); }
.badge--outline  { background: transparent; border: 1px solid var(--border-default); color: var(--text-secondary); }

.badge--pill { border-radius: var(--radius-full); padding: 2px var(--sp-3); }

/* --------------------------------------------------------------------------
   5. TABS
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tabs__tab {
  position: relative;
  flex: none;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-standard);
}

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

.tabs__tab[aria-selected="true"] {
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
}

.tabs__tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  bottom: -1px;
  height: 2px;
  background: var(--interactive-accent);
  border-radius: var(--radius-full);
}

.tabs__tab:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* --- Segmented control ---------------------------------------------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  gap: 2px;
}

.segmented__btn {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard);
}

.segmented__btn[aria-pressed="true"] {
  background: var(--c-white);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.segmented__btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 1px;
}

/* --------------------------------------------------------------------------
   6. ACCORDION
   -------------------------------------------------------------------------- */
.accordion {
  border-top: 1px solid var(--border-subtle);
}

.accordion__item {
  border-bottom: 1px solid var(--border-subtle);
}

.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  width: 100%;
  padding: var(--sp-5) 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-standard);
}

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

.accordion__trigger:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.accordion__icon {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  transition: transform var(--dur-base) var(--ease-standard);
}

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

.accordion__panel {
  overflow: hidden;
  transition: height var(--dur-slow) var(--ease-standard);
}

.accordion__panel-inner {
  padding-bottom: var(--sp-6);
  font-size: var(--fs-base);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
}

.accordion__panel-inner > * + * {
  margin-top: var(--sp-4);
}

.accordion__panel-inner ul,
.accordion__panel-inner ol {
  padding-left: 1.4em;
}

/* --------------------------------------------------------------------------
   7. DROPDOWN / MENU
   -------------------------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  max-width: 320px;
  padding: var(--sp-2);
  background: var(--c-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity var(--dur-fast) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard),
    visibility var(--dur-fast);
}

.dropdown.is-open .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  text-align: left;
  text-decoration: none;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}

.dropdown__item:hover,
.dropdown__item:focus-visible {
  background: var(--interactive-ghost-hover);
  text-decoration: none;
  outline: none;
}

.dropdown__item[aria-selected="true"] {
  background: var(--interactive-accent-soft);
  color: var(--text-accent);
  font-weight: var(--fw-medium);
}

.dropdown__item--danger {
  color: var(--text-danger);
}

.dropdown__item--danger:hover {
  background: var(--c-red-50);
}

.dropdown__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) 0;
}

.dropdown__item svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   8. MODAL / DIALOG
   -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal.is-open {
  display: flex;
}

.modal__scrim {
  position: absolute;
  inset: 0;
  background: var(--surface-overlay);
  animation: advoke-fade-in var(--dur-base) var(--ease-decelerate);
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - var(--sp-8));
  max-height: calc(100dvh - var(--sp-8));
  background: var(--c-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: advoke-fade-up var(--dur-slow) var(--ease-emphasized);
}

@media (min-width: 768px) {
  .modal__dialog {
    max-width: 600px;
    border-radius: var(--radius-xl);
  }
}

.modal__dialog--sm { max-width: 420px; }
.modal__dialog--lg { max-width: 780px; }
.modal__dialog--xl { max-width: 1040px; }

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

.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.modal__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  flex: none;
  transition: background var(--dur-fast) var(--ease-standard);
}

.modal__close:hover {
  background: var(--interactive-ghost-hover);
  color: var(--text-primary);
}

.modal__close:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.modal__body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1 1 auto;
  line-height: var(--lh-relaxed);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
  flex: none;
  flex-wrap: wrap;
}

.modal__footer--split {
  justify-content: space-between;
}

/* --------------------------------------------------------------------------
   9. TOASTS
   -------------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: calc(100% - var(--sp-8));
  max-width: 420px;
  pointer-events: none;
}

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

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--c-navy-900);
  color: var(--c-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  pointer-events: auto;
  animation: advoke-fade-up var(--dur-slow) var(--ease-emphasized);
}

.toast--success { background: var(--c-green-700); }
.toast--danger  { background: var(--c-red-700); }
.toast--warning { background: var(--c-amber-700); }

.toast__icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast__body { flex: 1 1 auto; }

.toast__close {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  background: none;
  border: none;
  opacity: 0.7;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.toast__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* --------------------------------------------------------------------------
   10. EMPTY / ERROR / LOADING STATES
   -------------------------------------------------------------------------- */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  gap: var(--sp-4);
  min-height: 260px;
}

.state-block__icon {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
}

.state-block__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

.state-block__desc {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  max-width: 30rem;
  line-height: var(--lh-relaxed);
}

.state-block__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: center;
  margin-top: var(--sp-2);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--c-neutral-200);
  border-top-color: var(--interactive-accent);
  border-radius: 50%;
  animation: advoke-spin 0.8s linear infinite;
}

.spinner--sm { width: 18px; height: 18px; border-width: 2px; }
.spinner--lg { width: 48px; height: 48px; border-width: 4px; }

/* --------------------------------------------------------------------------
   11. TOOLTIP
   -------------------------------------------------------------------------- */
.tooltip {
  position: relative;
  display: inline-flex;
}

.tooltip__bubble {
  position: absolute;
  bottom: calc(100% + var(--sp-2));
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  z-index: var(--z-tooltip);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  color: var(--c-white);
  background: var(--c-navy-900);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--dur-fast) var(--ease-standard),
    transform var(--dur-fast) var(--ease-standard),
    visibility var(--dur-fast);
}

.tooltip__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--c-navy-900);
}

.tooltip:hover .tooltip__bubble,
.tooltip:focus-within .tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   12. BREADCRUMBS
   -------------------------------------------------------------------------- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--sp-4);
}

.breadcrumbs__link {
  color: var(--text-tertiary);
  text-decoration: none;
}

.breadcrumbs__link:hover {
  color: var(--text-accent);
  text-decoration: underline;
}

.breadcrumbs__sep {
  color: var(--text-muted);
  user-select: none;
}

.breadcrumbs__current {
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
}

/* --------------------------------------------------------------------------
   13. PAGINATION
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-8);
}

.pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--c-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard);
}

.pagination__btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  text-decoration: none;
}

.pagination__btn[aria-current="page"] {
  background: var(--c-navy-900);
  border-color: var(--c-navy-900);
  color: var(--c-white);
}

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

.pagination__btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   14. DIVIDERS & SEPARATORS
   -------------------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-6) 0;
  border: none;
}

.divider--labelled {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  background: none;
  height: auto;
}

.divider--labelled::before,
.divider--labelled::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border-subtle);
}

/* --------------------------------------------------------------------------
   15. AVATARS & IDENTIFIERS
   -------------------------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--interactive-accent-soft);
  color: var(--text-accent);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  flex: none;
  user-select: none;
}

.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-md); }

/* --------------------------------------------------------------------------
   16. PROGRESS
   -------------------------------------------------------------------------- */
.progress {
  height: 6px;
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--interactive-accent);
  border-radius: var(--radius-full);
  transition: width var(--dur-slow) var(--ease-standard);
}

/* --------------------------------------------------------------------------
   17. KEYBOARD HINT
   -------------------------------------------------------------------------- */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  background: var(--c-white);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   18. CALL-OUTS / NOTES
   -------------------------------------------------------------------------- */
.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--interactive-accent);
  background: var(--interactive-accent-soft);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
}

.callout--success {
  background: var(--c-green-50);
  border-left-color: var(--c-green-500);
  color: var(--text-success);
}

.callout--warning {
  background: var(--c-amber-50);
  border-left-color: var(--c-amber-500);
  color: var(--text-warning);
}

.callout--danger {
  background: var(--c-red-50);
  border-left-color: var(--c-red-500);
  color: var(--text-danger);
}

.callout__icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.callout__body > * + * {
  margin-top: var(--sp-2);
}

/* --------------------------------------------------------------------------
   19. VISUAL CHIP OVERFLOW LIST
   -------------------------------------------------------------------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
}

.tag-list li + li { margin-top: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   20. LINK-LIKE BUTTONS
   -------------------------------------------------------------------------- */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0;
  font-size: inherit;
  font-weight: var(--fw-medium);
  color: var(--text-link);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.link-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* --------------------------------------------------------------------------
   21. SECTION HEADING COMPONENT
   -------------------------------------------------------------------------- */
.block-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.block-heading__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.block-heading__link {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-accent);
  text-decoration: none;
  white-space: nowrap;
}

.block-heading__link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   22. STICKY ACTION BAR (editor / detail pages)
   -------------------------------------------------------------------------- */
.action-bar {
  position: sticky;
  top: var(--header-h-mobile);
  z-index: var(--z-sticky);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--sp-3) var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .action-bar {
    top: var(--header-h-desktop);
  }
}

/* --------------------------------------------------------------------------
   23. FIGURE / RESULT FRAME
   -------------------------------------------------------------------------- */
.frame {
  position: relative;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.frame--ratio-a4 {
  aspect-ratio: 210 / 297;
}

.frame--ratio-letter {
  aspect-ratio: 8.5 / 11;
}

.frame--padded {
  padding: var(--sp-6);
}

/* --------------------------------------------------------------------------
   24. NUMBER / STAT DISPLAY
   -------------------------------------------------------------------------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.stat__value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tighter);
  color: var(--text-primary);
  line-height: 1;
}

.stat__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   25. LIST WITH LEADING ICON
   -------------------------------------------------------------------------- */
.icon-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.icon-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
}

.icon-list li + li { margin-top: 0; }

.icon-list svg {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--interactive-accent);
}

/* --------------------------------------------------------------------------
   26. PROMO / HIGHLIGHT STRIP
   -------------------------------------------------------------------------- */
.highlight-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--interactive-accent-soft);
  border: 1px solid var(--c-blue-200);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--text-accent);
}

.highlight-strip svg {
  flex: none;
  width: 18px;
  height: 18px;
}