/* Electrodvor Web DS v1.0 responsive contract.
 * Target core scope: primitives, semantic aliases and reusable component foundations.
 * Existing public aliases are retained.
 * Accepted responsive roles are documented in design-system-v1.0.md; page recipes stay in page styles.
 * BigApp is an upstream reference, not a dependency.
 */
@font-face {
  font-family: "Onest";
  src: url("./assets/Onest-VariableFont_wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Onest";
  src: url("./assets/Onest-VariableFont_wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Primitives. Page components consume semantic aliases, never these values. */
  --ds-neutral-0: #fff;
  --ds-neutral-25: #fbfcfc;
  --ds-neutral-50: #f6f7f8;
  --ds-neutral-100: #f0f2f4;
  --ds-neutral-150: #e9edef;
  --ds-neutral-200: #dde2e7;
  --ds-neutral-300: #c7ced5;
  --ds-neutral-400: #9aa3ac;
  --ds-neutral-500: #66707a;
  --ds-neutral-700: #394048;
  --ds-neutral-800: #272c32;
  --ds-neutral-900: #20242a;
  --ds-brand-50: #fff0eb;
  --ds-brand-100: #ffe2d8;
  --ds-brand-500: #d83b20;
  --ds-brand-600: #b92f17;
  --ds-brand-700: #8e2514;

  /* Stable semantic color contract. Components consume these public aliases. */
  --color-bg: var(--ds-neutral-50);
  --color-surface: var(--ds-neutral-0);
  --color-surface-raised: var(--ds-neutral-0);
  --color-surface-muted: var(--ds-neutral-100);
  --color-surface-hover: #e8ebee;
  --color-surface-subtle: var(--ds-neutral-25);
  --color-surface-inverse: var(--ds-neutral-800);
  --color-surface-inverse-muted: var(--ds-neutral-700);
  --color-text: var(--ds-neutral-900);
  --color-text-secondary: var(--ds-neutral-500);
  --color-text-tertiary: var(--ds-neutral-400);
  --color-text-inverse: var(--ds-neutral-0);
  --color-border: var(--ds-neutral-200);
  --color-border-strong: var(--ds-neutral-300);
  --color-accent: var(--ds-brand-500);
  --color-accent-hover: var(--ds-brand-600);
  --color-accent-active: var(--ds-brand-700);
  --color-accent-soft: var(--ds-brand-50);
  --color-accent-soft-hover: var(--ds-brand-100);
  --color-accent-bright: #f25532;
  --color-focus: #146ef5;
  --color-field-focus: var(--ds-neutral-900);
  --color-success: #147a4b;
  --color-success-soft: #edf8f2;
  --color-warning: #9a5b00;
  --color-warning-soft: #fff8e7;
  --color-danger: #b42318;
  --color-danger-soft: #fff0ef;
  --color-info: #1d5c96;
  --color-info-soft: #edf6ff;
  --color-disabled-bg: var(--ds-neutral-150);
  --color-disabled-text: var(--ds-neutral-500);
  --color-overlay: rgb(32 36 42 / 42%);
  --color-overlay-control: rgb(255 255 255 / 94%);
  --color-control-hover-on-accent: rgb(0 0 0 / 12%);
  --category-safety: #d85a2b;
  --category-fasteners: #178a52;
  --category-electric: #0b96c4;
  --category-light: #e4b800;

  /* Stable typography contract: one family, nine sizes and two weights. */
  --font-family-sans: "Onest", Arial, sans-serif;
  --font-size-12: 12px;
  --font-size-13: 13px;
  --font-size-14: 14px;
  --font-size-16: 16px;
  --font-size-20: 20px;
  --font-size-24: 24px;
  --font-size-32: 32px;
  --font-size-40: 40px;
  --font-size-64: 64px;
  --type-caption-size: var(--font-size-12);
  --type-meta-size: var(--font-size-13);
  --type-label-size: var(--font-size-14);
  --type-body-size: var(--font-size-16);
  --type-subtitle-size: var(--font-size-20);
  --type-section-title-size: var(--font-size-24);
  --type-title-size: var(--font-size-32);
  --type-title-line: 1.2;
  --type-subtitle-line: 1.35;
  --type-page-title-size: var(--font-size-40);
  --type-display-size: var(--font-size-64);
  --type-display-line: 1;
  --type-body-line: 1.5;
  --weight-regular: 400;
  --weight-bold: 700;
  /* Compatibility aliases. They do not introduce extra font instances. */
  --weight-medium: var(--weight-regular);
  --weight-semibold: var(--weight-bold);

  /* Stable 4px spacing system and normalized reusable component geometry. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-18: 72px;
  --space-20: 80px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;
  --badge-min-height: 24px;
  --badge-padding-block: 4px;
  --badge-padding-inline: 8px;
  --badge-radius: var(--radius-sm);
  --badge-font-size: var(--font-size-12);
  --border-width: 1px;
  --control-sm: 36px;
  --control-md: 44px;
  --control-lg: 48px;
  --control-xl: 52px;
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --icon-source: none;

  /* Legacy breakpoint aliases retained for compatibility.
   * They are not the v1.0 viewport matrix or shared behavior boundaries and must not gain new consumers.
   * No responsive layout is activated in core.
   */
  --breakpoint-mobile: 480px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1180px;
  --breakpoint-wide: 1440px;

  --shadow-control: 0 4px 14px rgb(30 35 40 / 12%);
  --shadow-secondary: 0 2px 8px rgb(30 35 40 / 10%);
  --shadow-floating: 0 8px 22px rgb(25 31 38 / 14%);
  --shadow-overlay: 0 16px 36px rgb(25 31 38 / 16%);
  --shadow-card-hover: 0 14px 28px rgb(32 36 42 / 9%);
  --shadow-transaction: 0 -8px 24px rgb(32 36 42 / 8%);
  --ease-standard: cubic-bezier(.2, .8, .2, 1);
  --ease: var(--ease-standard);
  --duration-fast: 150ms;
}

:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
:where(button, a, input, select, textarea):focus:not(:focus-visible) { outline: none; }
:where(button, input, select, textarea):disabled,
[aria-disabled="true"] { cursor: not-allowed; }

/* Stable icon foundation. BigApp SVG files are masks so monochrome icons inherit currentColor. */
.ds-icon {
  width: var(--icon-md);
  height: var(--icon-md);
  display: inline-block;
  flex: 0 0 auto;
  color: inherit;
  background-color: currentColor;
  -webkit-mask: var(--icon-source) center / contain no-repeat;
  mask: var(--icon-source) center / contain no-repeat;
}
.ds-icon-16 { width: var(--icon-sm); height: var(--icon-sm); }
.ds-icon-20 { width: var(--icon-md); height: var(--icon-md); }
.ds-icon-24 { width: var(--icon-lg); height: var(--icon-lg); }

/* Shared control foundations. Component maturity is tracked individually in the DS contract. */
.ds-button,
.button,
.product-button {
  min-height: var(--control-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding-inline: var(--space-5);
  border: var(--border-width) solid var(--color-accent);
  border-radius: var(--radius-lg);
  color: var(--color-text-inverse);
  background: var(--color-accent);
  font-size: var(--type-label-size);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
:where(.ds-button, .button, .product-button):hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
:where(.ds-button, .button, .product-button):active { background: var(--color-accent-active); border-color: var(--color-accent-active); transform: translateY(1px); }
.ds-button.ds-button-secondary,
.button.secondary,
.product-button.secondary {
  color: var(--color-text);
  background: var(--color-surface-muted);
  border-color: transparent;
  box-shadow: none;
}
.ds-button.ds-button-secondary:hover,
.button.secondary:hover,
.product-button.secondary:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
  border-color: transparent;
}
.ds-button.ds-button-secondary:active,
.button.secondary:active,
.product-button.secondary:active {
  color: var(--color-text);
  background: var(--color-border);
  border-color: transparent;
}
:where(.ds-button-inverse, .button.light) { color: var(--color-accent); background: var(--color-surface); border-color: var(--color-surface); }
:where(.ds-button-inverse, .button.light):hover { color: var(--color-accent-hover); background: var(--color-accent-soft); border-color: var(--color-accent-soft); }
:where(.ds-button, .button, .product-button):disabled,
:where(.ds-button, .button, .product-button)[aria-disabled="true"] { color: var(--color-disabled-text); background: var(--color-disabled-bg); border-color: var(--color-disabled-bg); transform: none; }

.ds-icon-button {
  width: var(--control-md);
  height: var(--control-md);
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.ds-icon-button:hover { color: var(--color-accent); background: var(--color-accent-soft); border-color: var(--color-accent); }
.ds-icon-button:active { transform: translateY(1px); }
.ds-icon-button[aria-pressed="true"] { color: var(--color-accent); background: var(--color-accent-soft); border-color: var(--color-accent); }
.ds-icon-button:disabled { color: var(--color-disabled-text); background: var(--color-disabled-bg); border-color: var(--color-disabled-bg); }

/* Invisible pointer target for accepted compact visuals. The painted control keeps its geometry. */
:where(.ds-hit-area, .ds-icon-button:not(.ds-modal-close), .ds-chip, .ds-tab, .ds-dropdown-trigger, .ds-stepper > button) {
  position: relative;
}

:where(.ds-hit-area, .ds-icon-button:not(.ds-modal-close), .ds-chip, .ds-tab, .ds-dropdown-trigger, .ds-stepper > button)::before {
  width: max(100%, 44px);
  height: max(100%, 44px);
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ds-hit-area-proxy {
  width: max(100%, 44px);
  height: max(100%, 44px);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ds-badge,
.ds-tag,
.media-tag {
  min-height: var(--badge-min-height);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--badge-padding-block) var(--badge-padding-inline);
  border-radius: var(--badge-radius);
  font-size: var(--badge-font-size);
  line-height: 1;
  font-weight: var(--weight-bold);
}

.ds-chip {
  min-height: var(--control-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  background: var(--color-surface);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.ds-chip:hover { border-color: var(--color-border-strong); background: var(--color-surface-muted); }
.ds-chip[aria-pressed="true"], .ds-chip[aria-selected="true"] { color: var(--color-accent); border-color: var(--color-accent); background: var(--color-accent-soft); }

/* Working shared tabs. Visual state is shared; each surface owns its panel content and URL state. */
.ds-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.ds-tab {
  min-height: var(--control-xl);
  padding-inline: var(--space-5);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-surface);
  font: inherit;
  font-size: var(--type-label-size);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.ds-tab:hover {
  border-color: var(--color-text-tertiary);
  background: var(--color-surface-muted);
}

.ds-tab[aria-selected="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 var(--border-width) var(--color-accent);
}

/* Native disclosure/accordion. Product content and default-open state belong to the consumer. */
.ds-disclosure-group {
  overflow: clip;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.ds-disclosure {
  color: var(--color-text);
  background: var(--color-surface);
}

.ds-disclosure:not(.ds-disclosure-group > .ds-disclosure) {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
}

.ds-disclosure-group > .ds-disclosure + .ds-disclosure {
  border-top: var(--border-width) solid var(--color-border);
}

.ds-disclosure-summary {
  min-height: var(--control-xl);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  list-style: none;
  cursor: pointer;
  font-size: var(--font-size-16);
  font-weight: var(--weight-semibold);
}

.ds-disclosure-summary::-webkit-details-marker { display: none; }
.ds-disclosure-summary::marker { content: ""; }

.ds-disclosure-summary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -3px;
}

.ds-disclosure-marker {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: 0 0 auto;
  color: var(--color-text-secondary);
  background: currentColor;
  -webkit-mask: url("./assets/icons/ui/chevron-down.svg") center / contain no-repeat;
  mask: url("./assets/icons/ui/chevron-down.svg") center / contain no-repeat;
  transition: transform var(--duration-fast) var(--ease);
}

.ds-disclosure[open] > .ds-disclosure-summary .ds-disclosure-marker {
  transform: rotate(180deg);
}

.ds-disclosure-body {
  padding: 0 var(--space-4) var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--font-size-14);
  line-height: 1.5;
}

.ds-disclosure-body > :first-child { margin-top: 0; }
.ds-disclosure-body > :last-child { margin-bottom: 0; }

.ds-disclosure.is-disabled > .ds-disclosure-summary {
  color: var(--color-disabled-text);
  cursor: not-allowed;
  pointer-events: none;
}

.ds-disclosure.is-disabled > .ds-disclosure-summary .ds-disclosure-marker {
  color: var(--color-disabled-text);
}

@media (max-width: 1024px) {
  .ds-tabs[role="tablist"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: var(--space-1);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-padding-inline: var(--space-1);
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
    -webkit-overflow-scrolling: touch;
  }

  .ds-tabs[role="tablist"]::-webkit-scrollbar { height: 4px; }
  .ds-tabs[role="tablist"]::-webkit-scrollbar-track { background: transparent; }
  .ds-tabs[role="tablist"]::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill);
    background: var(--color-border-strong);
  }

  .ds-tabs[role="tablist"] > .ds-tab[role="tab"] {
    flex: 0 0 auto;
  }
}

.ds-field { display: grid; gap: var(--space-2); }
.ds-field-label { color: var(--color-text); font-size: var(--type-label-size); font-weight: var(--weight-semibold); }
.ds-field-control {
  width: 100%;
  min-height: var(--control-lg);
  padding-inline: var(--space-4);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
textarea.ds-field-control {
  padding-block: var(--space-3);
  font-size: var(--font-size-16);
  line-height: 1.5;
}
.ds-field-control::placeholder { color: var(--color-text-secondary); }
@media (hover: hover) {
  .ds-field-control:hover { border-color: var(--color-text-tertiary); }
}
.ds-field-control:focus { border-color: var(--color-field-focus); box-shadow: 0 0 0 1px var(--color-field-focus); outline: 0; }
/* После выбора в списке фокус возвращается на кнопку списка. Рамка фокуса нужна
   только клавиатуре: после касания она выглядела как ошибка. */
.ds-dropdown:not([open]) > .ds-dropdown-trigger:not([aria-invalid="true"]):focus:not(:focus-visible) { border-color: var(--color-border-strong); box-shadow: none; }
@media (hover: none) and (pointer: coarse) {
  .ds-dropdown:not([open]) > .ds-dropdown-trigger:not([aria-invalid="true"]):focus { border-color: var(--color-border-strong); box-shadow: none; outline: none; }

  /* iOS увеличивает страницу при фокусе в поле со шрифтом мельче 16px и не
     возвращает масштаб. На телефонах токены шрифта уменьшаются, поэтому размер
     полей задан явно и сильнее правил компонентов. */
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="button"], [type="submit"], [type="reset"], [type="file"], [type="hidden"]),
  select,
  textarea { font-size: 16px !important; }
}
.ds-field-control[aria-invalid="true"] { border-color: var(--color-danger); }
.ds-field-control[aria-invalid="true"]:focus { box-shadow: 0 0 0 1px var(--color-danger); }
.ds-field-control:disabled { color: var(--color-disabled-text); background: var(--color-disabled-bg); border-color: var(--color-border); }
.ds-field-hint,
.ds-field-message {
  display: block;
  color: var(--color-text-secondary);
  font-size: var(--font-size-12);
  line-height: 1.35;
}
.ds-field-message:empty { display: none; }
.ds-field-error { color: var(--color-danger); }
.ds-field:has(.ds-field-control[aria-invalid="true"]) .ds-field-label { color: var(--color-danger); }
.ds-form-grid {
  display: grid;
  grid-template-columns: repeat(var(--ds-form-columns, 2), minmax(0, 1fr));
  gap: var(--ds-form-row-gap, var(--space-4)) var(--ds-form-column-gap, var(--space-4));
}
.ds-form-grid-3 { --ds-form-columns: 3; }
.ds-field-wide { grid-column: 1 / -1; }
.ds-search { position: relative; border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-lg); background: var(--color-surface); }
.ds-search:focus-within { border-color: var(--color-field-focus); box-shadow: 0 0 0 1px var(--color-field-focus); }

/* Native form controls. The input remains the only state owner; labels provide the hit area. */
:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control, .ds-switch-control) {
  min-height: var(--control-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  font-size: var(--type-label-size);
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}
:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control, .ds-switch-control):has(> input:disabled) {
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control) > input {
  width: 18px;
  height: 18px;
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  border: var(--border-width) solid var(--color-border-strong);
  color: var(--color-text-inverse);
  background: var(--color-surface);
  cursor: inherit;
  transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control):hover > input:not(:disabled) {
  border-color: var(--color-accent-hover);
}
:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control) > input:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
:where(.ds-checkbox-control, .ds-check-control, .ds-radio-control) > input:disabled {
  border-color: var(--color-border);
  background: var(--color-disabled-bg);
}

:where(.ds-checkbox-control, .ds-check-control) > input { border-radius: var(--radius-xs); }
:where(.ds-checkbox-control, .ds-check-control) > input::after {
  content: "";
  position: absolute;
  display: none;
}
:where(.ds-checkbox-control, .ds-check-control) > input:checked,
:where(.ds-checkbox-control, .ds-check-control) > input:indeterminate {
  border-color: var(--color-accent);
  background: var(--color-accent);
}
:where(.ds-checkbox-control, .ds-check-control):hover > input:is(:checked, :indeterminate):not(:disabled) {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
}
:where(.ds-checkbox-control, .ds-check-control):active > input:is(:checked, :indeterminate):not(:disabled) {
  border-color: var(--color-accent-active);
  background: var(--color-accent-active);
}
:where(.ds-checkbox-control, .ds-check-control) > input:checked::after {
  width: 5px;
  height: 9px;
  top: 2px;
  left: 6px;
  display: block;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
:where(.ds-checkbox-control, .ds-check-control) > input:indeterminate::after {
  width: 8px;
  height: 2px;
  top: 7px;
  left: 4px;
  display: block;
  border-radius: var(--radius-pill);
  background: currentColor;
}
:where(.ds-checkbox-control, .ds-check-control) > input:is(:checked, :indeterminate):disabled,
.ds-radio-control > input:checked:disabled {
  border-color: var(--color-disabled-text);
  background: var(--color-disabled-text);
}

.ds-radio-control > input { border-radius: 50%; }
.ds-radio-control > input::after {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  top: 4px;
  left: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease);
}
.ds-radio-control > input:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
}
.ds-radio-control:hover > input:checked:not(:disabled) {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
}
.ds-radio-control:active > input:checked:not(:disabled) {
  border-color: var(--color-accent-active);
  background: var(--color-accent-active);
}
.ds-radio-control > input:checked::after { transform: scale(1); }

/* Responsive-stable selectable card: native radio owns state and keyboard behavior. */
.ds-radio-card-group {
  display: grid;
  grid-template-columns: repeat(var(--ds-radio-card-columns, 3), minmax(0, 1fr));
  align-items: stretch;
  gap: var(--space-3);
}
.ds-radio-card {
  min-width: 0;
  min-height: var(--control-xl);
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.ds-radio-card > input {
  width: 1px;
  height: 1px;
  position: absolute;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.ds-radio-card:hover:not(:has(input:disabled)) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.ds-radio-card:has(input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.ds-radio-card:has(input:checked) {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 var(--border-width) var(--color-accent);
}
.ds-radio-card:has(input:disabled) {
  color: var(--color-disabled-text);
  background: var(--color-disabled-bg);
  cursor: not-allowed;
}
.ds-radio-card-copy {
  min-width: 0;
  display: grid;
  gap: var(--space-2);
}
.ds-radio-card-copy strong {
  font-size: var(--font-size-14);
  line-height: 1.3;
}
.ds-radio-card-copy span {
  color: var(--color-text-secondary);
  font-size: var(--font-size-12);
  line-height: 1.45;
}

.ds-switch-control > input {
  width: 42px;
  height: 24px;
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
  cursor: inherit;
  transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}
.ds-switch-control > input::after {
  content: "";
  width: 18px;
  height: 18px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-control);
  transition: transform var(--duration-fast) var(--ease);
}
.ds-switch-control:hover > input:not(:checked):not(:disabled) { border-color: var(--color-accent-hover); }
.ds-switch-control > input:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
}
.ds-switch-control:hover > input:checked:not(:disabled) {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
}
.ds-switch-control:active > input:checked:not(:disabled) {
  border-color: var(--color-accent-active);
  background: var(--color-accent-active);
}
.ds-switch-control > input:checked::after { transform: translateX(18px); }
.ds-switch-control > input:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.ds-switch-control > input:disabled {
  border-color: var(--color-border);
  background: var(--color-disabled-bg);
}
.ds-switch-control > input:checked:disabled {
  border-color: var(--color-disabled-text);
  background: var(--color-disabled-text);
}

.ds-stepper {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ds-stepper button { color: inherit; background: transparent; }
.ds-stepper button:hover { background: var(--color-accent-soft-hover); }

/* Shared product-card purchase control: one renderer and one visual/mechanical contract. */
.card-quantity-control {
  width: 100%;
  min-height: var(--control-md);
  display: grid;
  grid-template-columns: var(--control-md) minmax(0, 1fr) var(--control-md);
  align-items: center;
}
.card-quantity-control button {
  width: var(--control-md);
  height: var(--control-md);
  display: grid;
  place-items: center;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.card-quantity-control button:disabled { color: var(--color-disabled-text); cursor: not-allowed; opacity: 1; }
.card-quantity-control output { justify-self: center; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.card-quantity-control output small { font-size: var(--font-size-12); font-weight: var(--weight-bold); opacity: .85; }
.card-quantity-control-compact {
  width: 46px;
  display: grid;
  grid-template-rows: 34px 32px 34px;
  align-items: center;
}
.card-quantity-control-compact button { width: 100%; height: 34px; display: grid; place-items: center; border: 0; color: inherit; background: transparent; cursor: pointer; }
.card-quantity-control-compact button:disabled { color: var(--color-disabled-text); cursor: not-allowed; opacity: 1; }
.card-quantity-control-compact output { justify-self: center; font-size: var(--font-size-12); font-weight: var(--weight-bold); }

/* Shared single-choice dropdown used across product flows and the DS reference page. */
.ds-dropdown-field { min-width: 0; }
.ds-dropdown { position: relative; min-width: 0; }
.ds-dropdown[open] { z-index: 20; }
.ds-dropdown-trigger {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  cursor: pointer;
  font-size: var(--font-size-16);
  line-height: 1.25;
}
.ds-dropdown-trigger::-webkit-details-marker { display: none; }
.ds-dropdown-trigger > span:first-child {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ds-dropdown-trigger .ds-icon {
  width: var(--icon-sm);
  height: var(--icon-sm);
  flex: 0 0 auto;
  margin-left: var(--space-2);
  transition: transform var(--duration-fast) var(--ease);
}
.ds-dropdown[open] .ds-dropdown-trigger {
  border-color: var(--color-field-focus);
  box-shadow: 0 0 0 1px var(--color-field-focus);
}
.ds-dropdown[open] .ds-dropdown-trigger .ds-icon { transform: rotate(180deg); }
.ds-dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  width: max(100%, 220px);
  max-height: 280px;
  padding: var(--space-2);
  display: grid;
  gap: var(--space-1);
  overflow: auto;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-floating);
  animation: ds-dropdown-enter 160ms var(--ease) both;
}
.ds-dropdown-option {
  width: 100%;
  min-height: var(--control-md);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-16);
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}
.ds-dropdown-option:hover { background: var(--color-surface-muted); }
.ds-dropdown-option:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.ds-dropdown-option[aria-selected="true"] {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  font-weight: var(--weight-semibold);
}
@keyframes ds-dropdown-enter {
  from { opacity: .65; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

:where(.ds-bottom-sheet, .ds-dropdown-sheet) { display: none; }

@media (max-width: 1024px) {
  :where(.ds-bottom-sheet, .ds-dropdown-sheet)[open] {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    margin: auto 0 0;
    padding: 0;
    display: block;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  :where(.ds-bottom-sheet, .ds-dropdown-sheet)::backdrop { background: var(--color-overlay); }

  :where(.ds-bottom-sheet-panel, .ds-dropdown-sheet-panel) {
    max-height: calc(100dvh - max(var(--space-4), env(safe-area-inset-top, 0px)));
    padding: var(--space-5) max(var(--space-4), env(safe-area-inset-right)) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: var(--color-surface-raised);
    box-shadow: 0 -12px 32px rgb(32 36 42 / 16%);
    animation: ds-dropdown-sheet-enter 180ms var(--ease) both;
  }

  :is(.ds-bottom-sheet-heading, .ds-dropdown-sheet-heading) {
    min-height: var(--control-lg);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }

  :is(.ds-bottom-sheet-heading, .ds-dropdown-sheet-heading) h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: -0.025em;
  }

  :where(.ds-bottom-sheet-body, .ds-dropdown-sheet-options) {
    min-height: 0;
    display: grid;
    align-content: start;
    gap: var(--space-1);
    padding-right: var(--space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
  }

  :where(.ds-bottom-sheet-body, .ds-dropdown-sheet-options)::-webkit-scrollbar { width: 6px; }
  :where(.ds-bottom-sheet-body, .ds-dropdown-sheet-options)::-webkit-scrollbar-track { background: transparent; }
  :where(.ds-bottom-sheet-body, .ds-dropdown-sheet-options)::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill);
    background: var(--color-border-strong);
  }

  .ds-bottom-sheet-actions {
    position: sticky;
    z-index: 2;
    bottom: 0;
    margin-top: 0;
    padding-top: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    background: var(--color-surface-raised);
  }

  .ds-bottom-sheet-actions .ds-button { width: 100%; }

  :is(.ds-bottom-sheet-option, .ds-dropdown-sheet-option) {
    width: 100%;
    min-height: var(--control-lg);
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  .ds-dropdown-sheet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    border: 0;
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-16);
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
  }

  .ds-dropdown-sheet-option .ds-icon {
    width: var(--icon-md);
    height: var(--icon-md);
    flex: 0 0 auto;
    visibility: hidden;
  }

  .ds-dropdown-sheet-option[aria-selected="true"] {
    color: var(--color-accent);
    font-weight: var(--weight-semibold);
  }

  .ds-dropdown-sheet-option[aria-selected="true"] .ds-icon { visibility: visible; }
  .ds-dropdown-sheet-option:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
  .ds-dropdown-sheet-open { overflow: hidden; }

  @keyframes ds-dropdown-sheet-enter {
    from { transform: translateY(24px); }
    to { transform: translateY(0); }
  }
}

@media (max-width: 767px) {
  .ds-form-grid { --ds-form-columns: 1; }
  .ds-radio-card-group { --ds-radio-card-columns: 1; }
  .ds-bottom-sheet-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Stable pagination shared by button- and link-based collections. */
.ds-pagination {
  min-height: var(--control-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.ds-pagination :is(a, button) {
  width: var(--control-md);
  height: var(--control-md);
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-pill);
  color: var(--color-text);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-14);
  font-weight: var(--weight-regular);
  text-decoration: none;
  cursor: pointer;
}

.ds-pagination :is(a, button):hover:not(:disabled):not([aria-current="page"]) { background: var(--color-surface-muted); }
.ds-pagination :is(a, button):focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.ds-pagination :is(a, button)[aria-current="page"] {
  color: var(--color-text-inverse);
  background: var(--color-accent);
  font-weight: var(--weight-bold);
}
.ds-pagination button:disabled { color: var(--color-disabled-text); cursor: not-allowed; }
.ds-pagination .ds-icon { width: var(--icon-sm); height: var(--icon-sm); }
.ds-pagination [data-pagination-direction="previous"] .ds-icon { transform: rotate(180deg); }

/* Shared system-state foundation; live semantics, recovery and focus remain surface obligations. */
.ds-state {
  min-height: 184px;
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  text-align: center;
}
.ds-state .ds-icon { width: 32px; height: 32px; color: var(--color-info); }
.ds-state-error .ds-icon { color: var(--color-danger); }
.ds-state-loading .ds-icon { animation: ds-spin 800ms linear infinite; }
@keyframes ds-spin { to { transform: rotate(1turn); } }

/* Responsive-stable transactional action summary shared by cart and checkout. */
.ds-transaction-bar { display: none; }

@media (max-width: 1024px) {
  .ds-transaction-bar {
    position: fixed;
    z-index: 90;
    right: 0;
    bottom: var(--ds-transaction-bar-offset, 0px);
    left: 0;
    padding: var(--space-2) max(var(--space-6), env(safe-area-inset-right)) max(var(--space-2), var(--ds-transaction-bar-safe-bottom, env(safe-area-inset-bottom))) max(var(--space-6), env(safe-area-inset-left));
    display: block;
    border-top: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--color-surface);
    box-shadow: var(--shadow-transaction);
  }

  .ds-transaction-bar-inner {
    width: min(var(--ds-transaction-bar-max-width, 1280px), 100%);
    min-height: var(--control-xl);
    margin-inline: auto;
    display: grid;
    grid-template-columns: minmax(140px, 200px) minmax(220px, 320px);
    align-items: center;
    justify-content: end;
    gap: var(--space-4);
  }

  .ds-transaction-summary {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .ds-transaction-summary > span {
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: var(--font-size-12);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ds-transaction-summary > strong {
    font-size: var(--font-size-20);
    line-height: 1.15;
    letter-spacing: -0.025em;
    white-space: nowrap;
  }

  .ds-transaction-action {
    width: 100%;
    min-height: var(--control-lg);
    white-space: nowrap;
  }

  .ds-viewport-keyboard-open .ds-transaction-bar { display: none; }
}

@media (max-width: 767px) {
  .ds-transaction-bar {
    padding-right: max(var(--space-4), env(safe-area-inset-right));
    padding-left: max(var(--space-4), env(safe-area-inset-left));
  }

  .ds-transaction-bar-inner {
    min-height: var(--control-lg);
    grid-template-columns: minmax(0, 1fr) minmax(152px, 54%);
    gap: var(--space-3);
  }

  .ds-transaction-summary > strong { font-size: var(--font-size-16); }
}

@media (max-width: 359px) {
  .ds-transaction-bar-inner { grid-template-columns: minmax(0, 1fr) 136px; }
  .ds-transaction-action { padding-inline: var(--space-2); }
}

/* Responsive-stable modal contract: every native modal becomes a dedicated task screen. */
@media (max-width: 1024px) {
  body:has(dialog[open]) {
    overflow: hidden;
  }

  dialog[open] .ds-modal-close {
    width: var(--control-sm) !important;
    height: var(--control-sm) !important;
    position: relative;
  }

  dialog[open] .ds-modal-close::before {
    content: "";
    position: absolute;
    width: 44px;
    height: 44px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  dialog[open] .ds-modal-close .ds-icon {
    width: var(--icon-sm);
    height: var(--icon-sm);
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet):has(.ds-modal-actions) > :first-child {
    box-sizing: border-box;
    min-height: 100dvh;
    display: flex !important;
    flex-direction: column;
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) .ds-modal-actions {
    width: 100%;
    position: sticky;
    z-index: 3;
    bottom: 0;
    margin-top: auto;
    padding: var(--space-4) 0 max(var(--space-4), env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    background: var(--color-surface);
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) .ds-modal-actions .ds-button {
    width: 100%;
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) .ds-modal-actions > :not(.ds-button) {
    grid-column: 1 / -1;
  }

  .ds-viewport-keyboard-open dialog[open] .ds-modal-actions {
    position: static;
    padding-bottom: var(--space-4);
  }

  .ds-viewport-keyboard-open dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) {
    height: var(--ds-visual-viewport-height, 100dvh) !important;
    min-height: var(--ds-visual-viewport-height, 100dvh) !important;
    max-height: var(--ds-visual-viewport-height, 100dvh) !important;
  }

  .ds-viewport-keyboard-open dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet):has(.ds-modal-actions) > :first-child {
    min-height: var(--ds-visual-viewport-height, 100dvh);
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) {
    box-sizing: border-box !important;
    width: 100dvw !important;
    min-width: 100dvw !important;
    max-width: 100dvw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    position: fixed !important;
    inset: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: auto !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--color-surface) !important;
    box-shadow: none !important;
    display: grid !important;
    align-items: safe center !important;
    justify-items: center !important;
  }

  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet)::backdrop { background: transparent !important; }
  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) .ds-modal-close {
    position: fixed !important;
    z-index: 4;
    top: max(var(--space-4), env(safe-area-inset-top, 0px)) !important;
    right: max(var(--space-4), env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
    left: auto !important;
    margin: 0 !important;
  }
  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) > :first-child {
    width: 100%;
    min-height: 0;
    max-height: var(--ds-visual-viewport-height, 100dvh);
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding-block: var(--space-16) calc(var(--space-16) + var(--ds-keyboard-offset, 0px));
  }
}

@media (max-width: 767px) {
  dialog[open]:not(.ds-dropdown-sheet):not(.ds-bottom-sheet) .ds-modal-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
