/* ===== 3Drawers component library — namespaced .ds-* classes =====
 * The .ds-* classes keep their names (DesignSystemHelper, views and tests
 * all use them) but are drawn in the 3Drawers Neo design system
 * (claude.ai artifact "3Drawers Neo", components/bundle.css, where the same
 * components are .neo-*). Every value comes from tokens/. App-specific
 * extensions live in components/overrides.css, NOT here. */

:where(.ds-btn, .ds-btn-icon, .ds-tab, .ds-input, .ds-select, .ds-textarea):focus-visible {
  outline: var(--border-width-thick) solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Button ---------- */
.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: var(--space-2) var(--space-6);
  border: 1px solid var(--lime-edge); border-radius: var(--radius-button);
  font: 700 14.9px/24px var(--font-sans); white-space: nowrap; text-decoration: none; cursor: pointer;
  color: var(--on-lime);
  background: linear-gradient(180deg, var(--lime) 21.818%, var(--lime-light) 77.497%);
  transition: box-shadow var(--duration-fast) ease, background var(--duration-fast) ease;
}
.ds-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--lime-hover) 21.85%, var(--lime-hover-light) 77.497%);
  box-shadow: var(--shadow-lime);
}
.ds-btn:disabled { background: var(--disabled-fill); color: var(--disabled-ink); border-color: var(--lime-edge); cursor: not-allowed; box-shadow: none; }
.ds-btn.ds-btn-secondary { color: var(--ink); background: var(--surface); border: 1.5px solid var(--ink); }
.ds-btn.ds-btn-secondary:hover:not(:disabled) { background: var(--surface-field-hover); box-shadow: none; }
.ds-btn.ds-btn-danger { color: var(--danger-ink); background: var(--surface); border: 1.5px solid var(--danger); }
.ds-btn.ds-btn-danger:hover:not(:disabled) { background: var(--danger-fill); box-shadow: none; }
.ds-btn.ds-btn-ghost { color: var(--ink); background: none; border: 1.5px solid transparent; padding-inline: var(--space-3); }
.ds-btn.ds-btn-ghost:hover:not(:disabled) { background: var(--line); box-shadow: none; }
.ds-btn.ds-btn-secondary:disabled,
.ds-btn.ds-btn-danger:disabled,
.ds-btn.ds-btn-ghost:disabled { background: none; border-color: var(--line); }
.ds-btn.ds-btn-sm { min-height: 32px; padding: 4px var(--space-4); font-size: 13px; line-height: 20px; }
.ds-btn.ds-btn-lg { min-height: 48px; padding: var(--space-3) var(--space-8); font-size: 16px; }

/* Standalone icon-only button (theme toggle, etc.) — its own round shape,
   not meant to compose with .ds-btn's variants. */
.ds-btn-icon {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; padding: 0;
  border-radius: 50%; border: 1.5px solid transparent; background: none; color: var(--ink); cursor: pointer;
  transition: background var(--duration-fast) ease;
}
.ds-btn-icon:hover:not(:disabled) { background: var(--line); }
.ds-btn-icon:disabled { color: var(--disabled-ink); cursor: not-allowed; }

/* ---------- Fields ---------- */
.ds-field { display: flex; flex-direction: column; gap: var(--space-1); font-family: var(--font-sans); min-width: 0; }
.ds-label { font: 600 14px/20px var(--font-label); color: var(--ink-strong); }
.ds-hint { font-size: 12px; line-height: 16px; color: var(--ink-hint); }
.ds-hint.ds-hint-error { color: var(--danger-ink); }
.ds-input, .ds-textarea, .ds-select {
  font: 400 16px/24px var(--font-sans); color: var(--ink-strong);
  background: var(--surface); border: 1px solid var(--line-field); border-radius: var(--radius-pill);
  padding: 11px var(--space-4); min-height: 48px; box-sizing: border-box;
  transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
}
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--ink-placeholder); }
.ds-input:hover:not(:disabled), .ds-textarea:hover:not(:disabled), .ds-select:hover:not(:disabled) {
  border-color: var(--line-field-hover); background: var(--surface-field-hover);
}
.ds-input:focus, .ds-textarea:focus, .ds-select:focus {
  outline: none; border: 2px solid var(--focus); padding: 10px calc(var(--space-4) - 1px); background: var(--surface);
}
.ds-input.ds-input-error, .ds-textarea.ds-input-error { border: 2px solid var(--danger); background: var(--danger-fill); padding: 10px calc(var(--space-4) - 1px); }
.ds-input:disabled, .ds-textarea:disabled, .ds-select:disabled { color: var(--disabled-ink); background: var(--disabled-fill); border-color: var(--line); cursor: not-allowed; }
.ds-textarea { resize: vertical; min-height: 96px; border-radius: var(--radius-md); }
.ds-select {
  appearance: none; padding-right: 44px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) center, calc(100% - 16px) center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}

/* ---------- Checkbox / radio ---------- */
.ds-checkbox, .ds-radio {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-3);
  font: 400 16px/24px var(--font-sans); cursor: pointer; color: var(--ink);
}
.ds-checkbox input, .ds-radio input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.ds-checkbox .ds-box, .ds-radio .ds-dot {
  width: 22px; height: 22px; flex-shrink: 0; box-sizing: border-box; border: 1.5px solid var(--ink); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
}
.ds-checkbox .ds-box { border-radius: 7px; }
.ds-radio .ds-dot { border-radius: 50%; }
.ds-checkbox input:checked + .ds-box,
.ds-radio input:checked + .ds-dot { background: linear-gradient(180deg, var(--lime) 21.818%, var(--lime-light) 77.497%); border-color: var(--lime-edge); }
.ds-checkbox input:checked + .ds-box::after { content: ""; width: 10px; height: 5px; border-left: 2.5px solid var(--on-lime); border-bottom: 2.5px solid var(--on-lime); transform: translateY(-2px) rotate(-45deg); }
.ds-radio input:checked + .ds-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-lime); }
.ds-checkbox input:focus-visible + .ds-box,
.ds-radio input:focus-visible + .ds-dot { outline: var(--border-width-thick) solid var(--focus); outline-offset: 2px; }
.ds-checkbox input:disabled + .ds-box,
.ds-radio input:disabled + .ds-dot { background: var(--disabled-fill); border-color: var(--line); }

/* ---------- Switch ---------- */
.ds-switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font: 400 16px/24px var(--font-sans); color: var(--ink); }
.ds-switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.ds-switch .ds-track {
  position: relative; flex: none; box-sizing: border-box; width: 44px; height: 26px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink); background: var(--surface); transition: background var(--duration-fast) ease;
}
.ds-switch .ds-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--ink);
  transition: transform var(--duration-fast) ease;
}
.ds-switch input:checked + .ds-track { background: linear-gradient(180deg, var(--lime) 21.818%, var(--lime-light) 77.497%); border-color: var(--lime-edge); }
.ds-switch input:checked + .ds-track::after { background: var(--on-lime); transform: translateX(18px); }
.ds-switch input:focus-visible + .ds-track { outline: var(--border-width-thick) solid var(--focus); outline-offset: 2px; }

/* ---------- Badge / tag ---------- */
/* Status badges are Neo's pill badge: uppercase Solway bold, 1.5px outline.
   The default (no tone) is the quiet neutral badge; success/error/warning/info
   are the status tones, always carrying a word. */
.ds-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px var(--space-3);
  border-radius: var(--radius-pill); border: 1.5px solid var(--line-field-hover); background: transparent;
  font: 700 12px/16px var(--font-display); letter-spacing: -0.24px; text-transform: uppercase; color: var(--ink-muted);
}
.ds-badge.ds-badge-success { border-color: var(--success); color: var(--ink-strong); background: var(--success-fill); }
.ds-badge.ds-badge-error { border-color: var(--danger); color: var(--ink-strong); background: var(--danger-fill); }
.ds-badge.ds-badge-warning { border-color: var(--warning); color: var(--ink-strong); background: var(--warning-fill); }
.ds-badge.ds-badge-info { border-color: var(--teal-deep); color: var(--ink); background: var(--surface); }

.ds-tag {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 3px var(--space-3); border-radius: var(--radius-pill);
  background: var(--surface-well); border: 1px solid var(--line-field-quiet);
  font: 400 12px/18px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-muted); white-space: nowrap;
}

/* ---------- Card ---------- */
.ds-card {
  background: var(--surface); border: 1px solid var(--line-card); border-radius: var(--radius-lg);
  padding: var(--space-6); box-shadow: var(--shadow-card); color: var(--ink-strong);
}
.ds-card.ds-card-flat { box-shadow: none; }
.ds-card .ds-card-title { font: 400 22px/28px var(--font-display); letter-spacing: -0.22px; margin: 0 0 var(--space-2); }
.ds-card .ds-card-body { font: 400 16px/24px var(--font-sans); color: var(--ink-muted); margin: 0; }

/* ---------- Tabs (segmented) ---------- */
.ds-tabs {
  display: flex; gap: 2px; padding: 3px; width: fit-content;
  border-radius: var(--radius-pill); border: 1px solid var(--line-field); background: var(--surface-field);
}
.ds-tab {
  border: 0; background: transparent; padding: 6px var(--space-4); border-radius: var(--radius-pill); cursor: pointer;
  font: 700 13px/20px var(--font-sans); color: var(--ink-muted);
  transition: color var(--duration-fast) ease;
}
.ds-tab:hover:not(:disabled):not(.ds-tab-active) { color: var(--ink); }
.ds-tab.ds-tab-active { color: var(--on-lime); background: linear-gradient(180deg, var(--lime) 21.818%, var(--lime-light) 77.497%); box-shadow: inset 0 0 0 1px var(--lime-edge); }
.ds-tab:disabled { color: var(--disabled-ink); cursor: not-allowed; }

/* ---------- Tooltip ---------- */
.ds-tooltip { position: relative; display: inline-flex; }
.ds-tooltip .ds-tooltip-bubble {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--ground); font: 400 13px/20px var(--font-sans); padding: 6px var(--space-3);
  border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--duration-fast) ease;
}
.ds-tooltip .ds-tooltip-bubble::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--ink); }
.ds-tooltip:hover .ds-tooltip-bubble { opacity: 1; }

/* ---------- Toast ---------- */
.ds-toast {
  display: flex; align-items: flex-start; gap: var(--space-3); max-width: 360px; box-sizing: border-box;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  border: 1.5px solid var(--line-card); background: var(--surface); color: var(--ink-strong);
  box-shadow: var(--shadow-lg); font: 400 15px/22px var(--font-sans);
}
.ds-toast.ds-toast-success { border-color: var(--success); }
.ds-toast.ds-toast-error { border-color: var(--danger); background: var(--danger-fill); }
.ds-toast .ds-toast-title { font-weight: 700; margin: 0 0 2px; }
.ds-toast .ds-toast-body { margin: 0; font-size: 14px; color: var(--ink-muted); }

/* ---------- Dialog ---------- */
.ds-dialog-overlay { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 100; }
.ds-dialog {
  position: relative; box-sizing: border-box; width: 90%; max-width: 440px; padding: var(--space-8);
  border: 1px solid var(--line-card); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink-strong);
  box-shadow: var(--shadow-overlay);
}
.ds-dialog .ds-dialog-title { font: 400 26px/32px var(--font-display); letter-spacing: -0.26px; margin: 0 0 var(--space-3); text-wrap: balance; }
.ds-dialog .ds-dialog-body { font: 400 16px/24px var(--font-sans); color: var(--ink-muted); margin: 0 0 var(--space-6); }
.ds-dialog .ds-dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: flex-end; }
.ds-dialog .ds-dialog-close {
  position: absolute; top: var(--space-4); right: var(--space-4); display: grid; place-items: center; width: 32px; height: 32px;
  border: 1.5px solid transparent; border-radius: 50%; background: none; color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1;
}
.ds-dialog .ds-dialog-close:hover { background: var(--line); }

/* ---------- Accordion ---------- */
.ds-accordion-item { border: 1px solid var(--line-card); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.ds-accordion-item + .ds-accordion-item { margin-top: var(--space-3); }
.ds-accordion-q { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-5); cursor: pointer; font: 400 18px/26px var(--font-display); user-select: none; }
.ds-accordion-q .ds-toggle {
  width: 26px; height: 26px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--ink); border-radius: 50%; background: var(--surface);
  transition: transform var(--duration-base) var(--ease-out);
}
.ds-accordion-item.ds-open .ds-toggle { transform: rotate(45deg); background: linear-gradient(180deg, var(--lime) 21.818%, var(--lime-light) 77.497%); border-color: var(--lime-edge); color: var(--on-lime); }
.ds-accordion-a { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.ds-accordion-item.ds-open .ds-accordion-a { max-height: 400px; }
.ds-accordion-a-inner { padding: 2px var(--space-5) var(--space-4); border-top: 1px dashed var(--line-field-hover); font: 400 15px/22px var(--font-sans); color: var(--ink-muted); }

/* ---------- Number stepper ---------- */
.ds-stepper {
  display: inline-flex; align-items: center; padding: 0; box-sizing: border-box; height: 48px; overflow: hidden;
  border: 1px solid var(--line-field); border-radius: var(--radius-pill); background: var(--surface);
}
.ds-stepper:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
/* −/+ sit flush against the field's ends: the container's overflow clip rounds
   their outer corners, and a divider line gives the inner edge a sharp corner. */
.ds-stepper button {
  flex: none; display: grid; place-items: center; align-self: stretch; width: 44px; padding: 0; border-radius: 0;
  border: 0; background: var(--surface-field-hover); color: var(--ink);
  font: 400 20px/1 var(--font-sans); cursor: pointer;
}
.ds-stepper button:first-child { border-inline-end: 1px solid var(--line-field); }
.ds-stepper button:last-child { border-inline-start: 1px solid var(--line-field); }
.ds-stepper button:hover:not(:disabled) { background: var(--line-field); }
.ds-stepper button:active:not(:disabled) { background: var(--line-field-hover); }
.ds-stepper button:focus-visible { outline: var(--border-width-thick) solid var(--focus); outline-offset: -3px; }
.ds-stepper button:disabled { color: var(--disabled-ink); cursor: not-allowed; }
.ds-stepper input {
  width: 64px; height: 100%; padding: 0; text-align: center; border: 0; outline: 0; background: transparent;
  font: 400 16px/24px var(--font-sans); font-variant-numeric: tabular-nums; color: var(--ink-strong);
}
.ds-stepper .ds-stepper-unit { padding: 0 var(--space-2); font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }

/* ---------- Swatches ---------- */
.ds-swatches { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.ds-swatch {
  position: relative; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1.5px var(--line-field-hover);
  transition: transform var(--duration-fast) ease;
}
.ds-swatch:hover { transform: scale(1.08); }
