/* Existing UI classes are the project's primitives; these rules centralize their states. */
:where(button, input, select, textarea, a[href]) {
  -webkit-tap-highlight-color: transparent;
}

:where(button, input, select, textarea, a[href]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ds-accent) 72%, transparent);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
}

.btn, .iconbtn, .item, .row, .chip, .dchip, .prop-item, .opt-toggle {
  touch-action: manipulation;
  transition: background-color var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    color var(--motion-fast) var(--motion-ease),
    opacity var(--motion-fast) var(--motion-ease),
    transform var(--motion-instant) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease);
}

.btn {
  min-height: 52px;
  background: var(--ds-inverse);
  color: var(--ds-on-inverse);
  border-radius: var(--radius-lg);
  font-size: var(--type-button-size);
  font-weight: var(--type-button-weight);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: scale(.985); filter: brightness(.92); }
.btn:focus-visible, .iconbtn:focus-visible, .chip:focus-visible { outline-offset: 3px; }
.btn:disabled { background: var(--ds-disabled); color: var(--ds-disabled-text); cursor: not-allowed; }

.iconbtn { width: 48px; height: 48px; border-radius: var(--radius-md); }
.item { min-height: 72px; border-radius: var(--radius-lg); }
.dchip { min-height: 44px; }
.item:hover { border-color: var(--ds-accent); }
.item:active, .prop-item:active, .chip:active, .dchip:active { transform: scale(.985); }

.card { border-color: var(--ds-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.field, .search {
  min-height: 52px;
  border-color: var(--ds-border);
  border-radius: var(--radius-md);
  color: var(--ds-text);
  background: var(--ds-surface);
  transition: border-color var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease);
}
.field:focus, .search:focus { outline: 0; border-color: var(--ds-accent); box-shadow: var(--shadow-focus); }
.field::placeholder, .search::placeholder { color: var(--ds-text-tertiary); opacity: 1; }

.sheet-wrap { z-index: var(--z-sheet); }
.sheet { border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; overscroll-behavior: contain; touch-action: pan-y; }
.sheet-h { touch-action: none; }
.sheet-t button { min-width: 44px; min-height: 44px; border-radius: var(--radius-full); }
.toast { z-index: var(--z-toast); }
.cta { z-index: var(--z-cta); }
.hd { z-index: var(--z-header); }
.veil { z-index: var(--z-transition); }

.lender.wait .st { min-width: 7em; justify-content: flex-end; }
.lender.wait .tdots { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.banner.warn { color: var(--ds-warning); }
.banner.ok { color: var(--ds-positive); }
.banner.error { color: var(--ds-negative); }

.ui-divider { height: 1px; border: 0; background: var(--ds-border-subtle); margin-block: var(--space-4); }
.ui-badge { display: inline-flex; align-items: center; min-height: 24px; padding-inline: var(--space-2); border-radius: var(--radius-full); font-size: var(--type-caption-size); font-weight: 700; }
.ui-badge.positive { color: var(--ds-positive); background: var(--ds-accent-soft); }
.ui-badge.warning { color: var(--ds-warning); background: color-mix(in srgb, var(--ds-warning) 12%, var(--ds-surface)); }
.ui-select { width: 100%; min-height: 52px; padding: var(--space-3) var(--space-4); border: 1px solid var(--ds-border); border-radius: var(--radius-md); color: var(--ds-text); background: var(--ds-surface); font: inherit; }
.ui-tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--ds-border); }
.ui-tab { min-height: 44px; padding-inline: var(--space-4); border: 0; border-bottom: 2px solid transparent; color: var(--ds-text-secondary); background: transparent; font: inherit; }
.ui-tab[aria-selected="true"] { color: var(--ds-text); border-color: var(--ds-accent); font-weight: 700; }
.ui-segmented { display: flex; gap: var(--space-1); padding: var(--space-1); border-radius: var(--radius-md); background: var(--ds-border-subtle); }
.ui-segmented > button { flex: 1; min-height: 44px; border: 0; border-radius: var(--radius-sm); color: var(--ds-text-secondary); background: transparent; font: inherit; }
.ui-segmented > button[aria-pressed="true"] { color: var(--ds-text); background: var(--ds-surface); box-shadow: var(--shadow-card); }
.ui-state { max-width: 34rem; margin-inline: auto; padding-block: var(--space-10); }
.ui-state h1, .ui-state h2 { margin: 0 0 var(--space-2); color: var(--ds-text); }
.ui-state p { margin: 0; color: var(--ds-text-secondary); }
.ui-error { border-inline-start: 3px solid var(--ds-negative); padding-inline-start: var(--space-4); }
.ui-empty { text-align: center; }
.ui-spinner { width: 24px; aspect-ratio: 1; border: 3px solid var(--ds-border); border-top-color: var(--ds-accent); border-radius: var(--radius-full); animation: ui-spin 800ms linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
.ui-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.has-sheet, .has-sheet body { overflow: hidden; overscroll-behavior: none; }
.sheet.dragging { transition: none !important; }
.mascot { width: 48px; height: 48px; margin: var(--space-5) auto 0; border: 4px solid var(--ds-border); border-top-color: var(--ds-accent); border-right-color: var(--ds-accent); background: transparent; box-shadow: none; animation: ui-spin 850ms linear infinite; }





@media (max-width: 359px) {
  .main { padding-inline: var(--space-3); }
  .hd-in { padding-inline: var(--space-3); }
  .cta { padding-inline: var(--space-3); }
  .item { gap: var(--space-2); }
  .optrow { gap: var(--space-2); padding-inline: var(--space-3); }
  .optrow .nm { min-width: 0; overflow-wrap: anywhere; }
  .sheet { max-height: min(88dvh, 720px); }
}
