/*
  Kit Design System — component shim for prototypes
  ==================================================

  Vanilla CSS classes that mirror the Tier 1 components from
  packages/design/src in Kit/convertkit. Pair with kit-tokens.css
  (which provides the colour, typography, radius, shadow, and
  animation tokens referenced below).

  Usage:
    <link rel="stylesheet" href="../_shared/kit-tokens.css">
    <link rel="stylesheet" href="../_shared/kit-components.css">

  Notes:
    - All classes are namespaced with `.kit-` to avoid collisions with
      prototype-local CSS.
    - Behaviour-rich components (Drawer, Modal, Menu, Tooltip, etc.)
      ship as visual styles only. The prototype is responsible for
      open/close state via JS.
    - Lucide icons (loaded via unpkg) are the expected icon source.
    - Tradeoffs and unresolved questions are listed at the bottom of
      this file.
*/

/* ----------------------------------------------------------------- */
/* Reset / base                                                      */
/* ----------------------------------------------------------------- */

.kit-app {
  font-family: var(--font-ui);
  color: var(--gray-900);
  background: white;
  font-size: 14px;
  line-height: 20px;
}

.kit-app *,
.kit-app *::before,
.kit-app *::after {
  box-sizing: border-box;
}

/* ----------------------------------------------------------------- */
/* Layout shell — sidebar Navigation + Top bar                        */
/* ----------------------------------------------------------------- */

.kit-nav {
  width: var(--kit-sidebar-width);
  min-width: var(--kit-sidebar-width);
  height: 100%;
  background: var(--warm-white-100);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px 8px;
  overflow-y: auto;
  font-family: var(--font-ui);
}

.kit-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--kit-topbar-height);
  padding: 0 8px;
  flex-shrink: 0;
}

.kit-nav__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.kit-nav__group-title {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kit-nav__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.kit-nav__item:hover {
  background: rgba(var(--gray-900-rgb), 0.06);
}

.kit-nav__item:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: 1px;
}

.kit-nav__item--active,
.kit-nav__item[aria-current="page"] {
  background: rgba(var(--gray-900-rgb), 0.06);
  color: var(--gray-900);
}

.kit-nav__item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: currentColor;
}

.kit-nav__item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kit-nav__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-200);
}

/* Top bar pattern (no DS component — codified shell) */

.kit-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--kit-topbar-height);
  padding: 0 16px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  font-family: var(--font-ui);
}

.kit-topbar__logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.kit-topbar__divider {
  width: 1px;
  height: 20px;
  background: var(--gray-200);
}

.kit-topbar__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ----------------------------------------------------------------- */
/* Layout primitives — Stack & Grid                                   */
/* ----------------------------------------------------------------- */

.kit-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kit-stack--horizontal {
  flex-direction: row;
  align-items: center;
}

.kit-stack--vertical {
  flex-direction: column;
}

.kit-stack--gap-sm { gap: 8px; }
.kit-stack--gap-md { gap: 16px; }
.kit-stack--gap-lg { gap: 24px; }

.kit-grid {
  display: grid;
  gap: 16px;
}

.kit-grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kit-grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kit-grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 768px) {
  .kit-grid--cols-3,
  .kit-grid--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .kit-grid--cols-2,
  .kit-grid--cols-3,
  .kit-grid--cols-4 { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------- */
/* Card                                                               */
/* ----------------------------------------------------------------- */

.kit-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-lg);
  box-shadow: var(--kit-shadow-sm);
  overflow: hidden;
}

.kit-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kit-card__body {
  padding: 16px 20px;
}

.kit-card__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ----------------------------------------------------------------- */
/* Buttons                                                            */
/* ----------------------------------------------------------------- */

.kit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--kit-radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  white-space: nowrap;
  user-select: none;
}

.kit-button:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: 1px;
}

.kit-button:disabled,
.kit-button[aria-disabled="true"] {
  cursor: default;
  background: var(--gray-100);
  color: var(--gray-600);
  border-color: var(--gray-100);
}

/* Sizes */
.kit-button--sm { height: 32px; padding: 4px 12px; font-size: 14px; border-radius: var(--kit-radius-sm); }
.kit-button--md { height: 40px; padding: 8px 16px; font-size: 14px; border-radius: var(--kit-radius-md); }
.kit-button--lg { height: 48px; padding: 12px 20px; font-size: 14px; border-radius: var(--kit-radius-lg); }

/* Variants — mirror packages/design/src/button/index.tsx TOKENS map.
   Source of truth: TOKENS.primary = "text-white bg-black hover:bg-gray-800",
   TOKENS.secondary = "bg-gray-900/[0.06] hover:bg-gray-900/[0.12]",
   TOKENS.tertiary  = "bg-transparent hover:bg-gray-900/[0.06]". */
.kit-button--primary {
  background: var(--black);
  color: white;
  border-color: var(--black);
}

.kit-button--primary:hover:not(:disabled) {
  background: var(--gray-800);
  border-color: var(--gray-800);
}

.kit-button--primary:active:not(:disabled) {
  background: var(--gray-900);
  border-color: var(--gray-900);
}

.kit-button--secondary {
  background: rgba(var(--gray-900-rgb), 0.06);
  color: var(--gray-900);
  border-color: transparent;
}

.kit-button--secondary:hover:not(:disabled) {
  background: rgba(var(--gray-900-rgb), 0.12);
}

.kit-button--secondary:active:not(:disabled) {
  background: rgba(var(--gray-900-rgb), 0.16);
}

.kit-button--tertiary {
  background: transparent;
  color: var(--gray-900);
  border-color: transparent;
}

.kit-button--tertiary:hover:not(:disabled) {
  background: rgba(var(--gray-900-rgb), 0.06);
}

.kit-button--tertiary:active:not(:disabled) {
  background: rgba(var(--gray-900-rgb), 0.12);
}

/* Destructive: not a first-class DS variant. The DS Button's color="red"
   actually falls back to primary (black). For prototype clarity (Delete /
   Remove actions) we mirror the DS color="light-red" fallback:
   "bg-red-200 hover:bg-red-300 text-gray-900". */
.kit-button--destructive {
  background: var(--red-200);
  color: var(--gray-900);
  border-color: transparent;
}

.kit-button--destructive:hover:not(:disabled) {
  background: var(--red-300);
}

.kit-button--destructive:active:not(:disabled) {
  background: var(--red-400);
}

/* Icon-only button (square aspect) */
.kit-button--icon { padding: 0; aspect-ratio: 1 / 1; }
.kit-button--icon.kit-button--sm { width: 32px; }
.kit-button--icon.kit-button--md { width: 40px; }
.kit-button--icon.kit-button--lg { width: 48px; }

/* ----------------------------------------------------------------- */
/* SaveButton — three states: idle, saving, saved                     */
/* ----------------------------------------------------------------- */

.kit-save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--black);
  border-radius: var(--kit-radius-md);
  background: var(--black);
  color: white;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
  white-space: nowrap;
}

.kit-save-button:hover:not(:disabled) {
  background: var(--gray-800);
  border-color: var(--gray-800);
}

.kit-save-button--saving {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-100);
  cursor: progress;
}

.kit-save-button--saving::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: kit-save-spin 0.8s linear infinite;
}

.kit-save-button--saved {
  background: var(--green-500);
  border-color: var(--green-500);
  color: white;
}

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

/* ----------------------------------------------------------------- */
/* SubmitButton — semantic alias for primary                           */
/* ----------------------------------------------------------------- */

.kit-submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--black);
  border-radius: var(--kit-radius-md);
  background: var(--black);
  color: white;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.kit-submit-button:hover:not(:disabled) {
  background: var(--gray-800);
  border-color: var(--gray-800);
}

.kit-submit-button:disabled {
  background: var(--gray-100);
  color: var(--gray-600);
  border-color: var(--gray-100);
  cursor: default;
}

/* ----------------------------------------------------------------- */
/* Input                                                              */
/* ----------------------------------------------------------------- */

.kit-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-md);
  background: white;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 24px;
  color: var(--gray-900);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.kit-input::placeholder {
  color: var(--gray-600);
}

.kit-input:hover:not(:disabled):not(:focus) {
  border-color: var(--gray-300);
}

.kit-input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(var(--blue-500-rgb), 0.16);
}

.kit-input:disabled {
  background: var(--gray-50);
  color: var(--gray-600);
  cursor: not-allowed;
}

.kit-input--error {
  border-color: var(--red-600);
}

.kit-input--error:focus {
  box-shadow: 0 0 0 3px rgba(var(--red-500-rgb), 0.16);
}

.kit-input--success {
  border-color: var(--green-600);
}

/* ----------------------------------------------------------------- */
/* Textarea                                                           */
/* ----------------------------------------------------------------- */

.kit-textarea {
  display: block;
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-md);
  background: white;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 22px;
  color: var(--gray-900);
  resize: vertical;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.kit-textarea::placeholder { color: var(--gray-600); }

.kit-textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(var(--blue-500-rgb), 0.16);
}

.kit-textarea:disabled {
  background: var(--gray-50);
  color: var(--gray-600);
}

/* ----------------------------------------------------------------- */
/* Checkbox                                                           */
/* ----------------------------------------------------------------- */

.kit-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid var(--gray-300);
  border-radius: var(--kit-radius-sm);
  background: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease, border-color 120ms ease;
  vertical-align: middle;
}

.kit-checkbox:hover:not(:disabled):not(:checked) {
  border-color: var(--gray-500);
}

.kit-checkbox:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: 1px;
}

.kit-checkbox:checked {
  background: var(--green-500);
  border-color: var(--green-500);
}

.kit-checkbox:checked::after {
  content: "";
  width: 10px;
  height: 10px;
  background: white;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.kit-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ----------------------------------------------------------------- */
/* Radio                                                              */
/* ----------------------------------------------------------------- */

.kit-radio {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid var(--gray-300);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease, border-color 120ms ease;
  vertical-align: middle;
}

.kit-radio:hover:not(:disabled):not(:checked) {
  border-color: var(--gray-500);
}

.kit-radio:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: 1px;
}

.kit-radio:checked {
  border-color: var(--gray-900);
  border-width: 5px;
}

.kit-radio:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ----------------------------------------------------------------- */
/* Toggle (switch)                                                    */
/* ----------------------------------------------------------------- */

.kit-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
  padding: 2px;
  border: none;
  border-radius: var(--kit-radius-full);
  background: var(--gray-500);
  cursor: pointer;
  transition: background-color 200ms ease;
  flex-shrink: 0;
}

.kit-toggle__track {
  /* The button itself acts as the track; this class is for semantic
     completeness when wrapping with a span. */
  display: contents;
}

.kit-toggle__thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--kit-shadow-sm);
  transition: transform 200ms ease;
  pointer-events: none;
}

.kit-toggle[aria-checked="true"],
.kit-toggle[data-enabled="true"] {
  background: var(--gray-900);
}

.kit-toggle[aria-checked="true"] .kit-toggle__thumb,
.kit-toggle[data-enabled="true"] .kit-toggle__thumb {
  transform: translateX(20px);
}

.kit-toggle:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: 2px;
}

.kit-toggle:disabled {
  cursor: not-allowed;
  filter: grayscale(100%);
  opacity: 0.75;
}

/* ----------------------------------------------------------------- */
/* Select                                                             */
/* ----------------------------------------------------------------- */

.kit-select {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 40px;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-md);
  background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 10px center / 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 24px;
  color: var(--gray-900);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.kit-select:hover:not(:disabled):not(:focus) { border-color: var(--gray-300); }

.kit-select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(var(--blue-500-rgb), 0.16);
}

.kit-select:disabled {
  background-color: var(--gray-50);
  color: var(--gray-600);
  cursor: not-allowed;
}

/* ----------------------------------------------------------------- */
/* Avatar                                                             */
/* ----------------------------------------------------------------- */

.kit-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--gray-900);
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}

.kit-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kit-avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.kit-avatar--md { width: 32px; height: 32px; font-size: 12px; }
.kit-avatar--lg { width: 40px; height: 40px; font-size: 14px; }

/* Optional colour treatments — keyed off data attribute or extra class */
.kit-avatar--blue   { background: var(--blue-700); color: white; }
.kit-avatar--green  { background: var(--green-700); color: white; }
.kit-avatar--orange { background: var(--orange-700); color: white; }
.kit-avatar--purple { background: var(--purple-700); color: white; }

/* ----------------------------------------------------------------- */
/* Avatar group — overlapping avatars                                 */
/* ----------------------------------------------------------------- */

.kit-avatar-group {
  display: inline-flex;
  align-items: center;
}

.kit-avatar-group .kit-avatar {
  border: 2px solid white;
  box-sizing: content-box;
}

.kit-avatar-group .kit-avatar + .kit-avatar {
  margin-left: -10px;
}

.kit-avatar-group__overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -10px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-800);
  font-weight: 600;
  font-size: 10px;
  width: 24px;
  height: 24px;
  box-sizing: content-box;
}

/* ----------------------------------------------------------------- */
/* Badge                                                              */
/* ----------------------------------------------------------------- */

.kit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border: 1px solid transparent;
  border-radius: var(--kit-radius-full);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

/* Light variants — the default visual most prototypes need */
.kit-badge--gray   { background: var(--gray-100);   border-color: var(--gray-100);   color: var(--gray-900); }
.kit-badge--red    { background: var(--red-50);     border-color: var(--red-50);     color: var(--red-600); }
.kit-badge--blue   { background: var(--blue-50);    border-color: var(--blue-50);    color: var(--blue-600); }
.kit-badge--green  { background: var(--green-100);  border-color: var(--green-100);  color: var(--green-800); }
.kit-badge--orange { background: var(--orange-100); border-color: var(--orange-100); color: var(--orange-800); }
.kit-badge--purple { background: var(--purple-100); border-color: var(--purple-100); color: var(--purple-800); }

/* ----------------------------------------------------------------- */
/* Heading & Text                                                     */
/* ----------------------------------------------------------------- */

.kit-heading {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--gray-900);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.kit-heading--h1 { font-size: 32px; line-height: 40px; }
.kit-heading--h2 { font-size: 24px; line-height: 32px; }
.kit-heading--h3 { font-size: 18px; line-height: 28px; }
.kit-heading--h4 { font-size: 16px; line-height: 20px; }

.kit-text {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--gray-900);
}

.kit-text--sm { font-size: 12px; line-height: 16px; }
.kit-text--md { font-size: 14px; line-height: 20px; }
.kit-text--lg { font-size: 16px; line-height: 24px; }

.kit-text--muted { color: var(--gray-700); }
.kit-text--subtle { color: var(--gray-600); }

/* ----------------------------------------------------------------- */
/* Label                                                              */
/* ----------------------------------------------------------------- */

.kit-label {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--gray-800);
}

/* ----------------------------------------------------------------- */
/* Icon (sizing wrapper for inline SVG / Lucide)                      */
/* ----------------------------------------------------------------- */

.kit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex-shrink: 0;
  vertical-align: middle;
}

.kit-icon svg,
.kit-icon [data-lucide] { display: block; }

.kit-icon--sm,
.kit-icon--sm svg { width: 16px; height: 16px; }
.kit-icon--md,
.kit-icon--md svg { width: 20px; height: 20px; }
.kit-icon--lg,
.kit-icon--lg svg { width: 24px; height: 24px; }

/* ----------------------------------------------------------------- */
/* Tabs                                                               */
/* ----------------------------------------------------------------- */

.kit-tabs {
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
}

.kit-tabs__list {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 4px;
}

.kit-tabs__tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
  white-space: nowrap;
}

.kit-tabs__tab:hover:not(.kit-tabs__tab--active) {
  color: var(--gray-800);
}

.kit-tabs__tab:focus-visible {
  outline: 1px solid var(--blue-500);
  outline-offset: -2px;
  border-radius: var(--kit-radius-sm);
}

.kit-tabs__tab--active,
.kit-tabs__tab[aria-selected="true"] {
  color: var(--blue-800);
  border-bottom-color: var(--blue-800);
}

.kit-tabs__panel {
  padding: 16px 0;
}

.kit-tabs__panel[hidden] { display: none; }

/* ----------------------------------------------------------------- */
/* Menu (dropdown)                                                    */
/* ----------------------------------------------------------------- */

.kit-menu {
  position: relative;
  display: inline-block;
}

.kit-menu__trigger {
  /* When applied to a button, no extra rules needed beyond .kit-button. */
  cursor: pointer;
}

.kit-menu__content {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 200px;
  padding: 4px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-xl);
  box-shadow: 0 4px 8px rgba(var(--gray-900-rgb), 0.12);
  font-family: var(--font-ui);
  animation: kit-fade-in-up 150ms ease both;
}

.kit-menu__content[hidden],
.kit-menu__content[data-state="closed"] { display: none; }

.kit-menu__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.kit-menu__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-900);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 100ms ease;
}

.kit-menu__item:hover,
.kit-menu__item[data-highlighted="true"],
.kit-menu__item:focus-visible {
  background: var(--gray-100);
  outline: none;
}

.kit-menu__item[disabled],
.kit-menu__item[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

.kit-menu__item-icon {
  width: 16px;
  height: 16px;
  color: var(--gray-700);
  flex-shrink: 0;
}

.kit-menu__item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kit-menu__divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 0;
  border: none;
}

.kit-menu__item--destructive {
  color: var(--red-600);
}

.kit-menu__item--destructive:hover,
.kit-menu__item--destructive[data-highlighted="true"] {
  background: var(--red-50);
}

.kit-menu__item--destructive .kit-menu__item-icon {
  color: var(--red-600);
}

/* ----------------------------------------------------------------- */
/* Breadcrumbs                                                        */
/* ----------------------------------------------------------------- */

.kit-breadcrumbs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-ui);
}

.kit-breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--kit-radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.kit-breadcrumbs__item:hover {
  background: var(--gray-100);
}

.kit-breadcrumbs__separator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--gray-700);
  flex-shrink: 0;
}

.kit-breadcrumbs__current {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ----------------------------------------------------------------- */
/* Empty state                                                        */
/* ----------------------------------------------------------------- */

.kit-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 48px 24px;
}

.kit-empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-700);
}

.kit-empty-state__icon svg { width: 28px; height: 28px; }

.kit-empty-state__title {
  font-family: var(--font-heading);
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  color: var(--gray-900);
}

.kit-empty-state__description {
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-700);
  max-width: 420px;
}

.kit-empty-state__action {
  margin-top: 8px;
  display: inline-flex;
  gap: 8px;
}

/* ----------------------------------------------------------------- */
/* Note (banner)                                                      */
/* ----------------------------------------------------------------- */

.kit-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--kit-radius-lg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 22px;
  color: var(--black);
  min-height: 48px;
}

.kit-note__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.kit-note__title {
  font-weight: 600;
  margin-bottom: 4px;
}

.kit-note__body {
  flex: 1;
  min-width: 0;
}

.kit-note--info    { background: var(--blue-100); }
.kit-note--info    .kit-note__icon { color: var(--blue-700); }
.kit-note--success { background: var(--green-100); }
.kit-note--success .kit-note__icon { color: var(--green-700); }
.kit-note--warning { background: var(--orange-100); }
.kit-note--warning .kit-note__icon { color: var(--orange-700); }
.kit-note--error   { background: var(--red-100); }
.kit-note--error   .kit-note__icon { color: var(--red-700); }

/* ----------------------------------------------------------------- */
/* Stats group                                                        */
/* ----------------------------------------------------------------- */

.kit-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--gray-200);
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-lg);
  overflow: hidden;
}

.kit-stats__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 24px;
  background: white;
}

.kit-stats__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  line-height: 24px;
}

.kit-stats__value {
  font-family: var(--font-heading);
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ----------------------------------------------------------------- */
/* Table                                                              */
/* ----------------------------------------------------------------- */

.kit-table {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: var(--kit-radius-lg);
  overflow: hidden;
  font-family: var(--font-ui);
  background: white;
}

.kit-table table {
  width: 100%;
  border-collapse: collapse;
}

.kit-table__head {
  background: var(--gray-50);
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gray-700);
  text-align: left;
}

.kit-table__row {
  border-top: 1px solid var(--gray-300);
}

.kit-table__head .kit-table__row:first-child {
  border-top: none;
}

.kit-table__cell {
  padding: 16px;
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-900);
  vertical-align: middle;
}

.kit-table__header-cell {
  padding: 12px 16px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gray-700);
}

/* ----------------------------------------------------------------- */
/* Inline validation                                                  */
/* ----------------------------------------------------------------- */

.kit-inline-validation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  margin-top: 4px;
}

.kit-inline-validation--error {
  color: var(--red-600);
}

.kit-inline-validation--success {
  color: var(--green-700);
}

.kit-inline-validation svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------- */
/* Dialog                                                             */
/* ----------------------------------------------------------------- */

.kit-dialog__overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--gray-900-rgb), 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  padding-top: 80px;
  z-index: 100;
  animation: kit-fade-in 150ms ease both;
}

.kit-dialog__overlay[hidden] { display: none; }

.kit-dialog {
  /* Convenience class — most prototypes give the dialog a wrapper. */
}

.kit-dialog__content {
  background: white;
  border-radius: var(--kit-radius-lg);
  box-shadow: var(--kit-shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  animation: kit-fade-in-up 200ms ease both;
}

.kit-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.kit-dialog__title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 18px;
  line-height: 28px;
  font-weight: 600;
  color: var(--gray-900);
}

.kit-dialog__body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 22px;
  color: var(--gray-800);
}

.kit-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.kit-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--kit-radius-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.kit-dialog__close:hover { background: var(--gray-100); color: var(--gray-900); }

/* ----------------------------------------------------------------- */
/* Modal (larger / more chrome than Dialog)                           */
/* ----------------------------------------------------------------- */

.kit-modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--gray-900-rgb), 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 100;
  animation: kit-fade-in 150ms ease both;
}

.kit-modal__overlay[hidden] { display: none; }

.kit-modal__content {
  background: white;
  border-radius: var(--kit-radius-lg);
  box-shadow: var(--kit-shadow-xl);
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  animation: kit-fade-in-up 200ms ease both;
}

.kit-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.kit-modal__title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  color: var(--gray-900);
}

.kit-modal__body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.kit-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.kit-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--kit-radius-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.kit-modal__close:hover { background: var(--gray-100); color: var(--gray-900); }

/* ----------------------------------------------------------------- */
/* Drawer                                                             */
/* ----------------------------------------------------------------- */

.kit-drawer__overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--gray-900-rgb), 0.5);
  z-index: 100;
  animation: kit-fade-in 150ms ease both;
}

.kit-drawer__overlay[hidden] { display: none; }

.kit-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(560px, 80vw);
  background: white;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  box-shadow: var(--kit-shadow-xl);
  z-index: 101;
}

.kit-drawer--right {
  right: 0;
  animation: kit-slide-in-from-right 300ms ease-out both;
}

.kit-drawer--left {
  left: 0;
  animation: kit-slide-in-from-left 300ms ease-out both;
}

.kit-drawer__content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kit-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.kit-drawer__title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--gray-900);
}

.kit-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.kit-drawer__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

.kit-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--kit-radius-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.kit-drawer__close:hover { background: var(--gray-100); color: var(--gray-900); }

/* ----------------------------------------------------------------- */
/* Popover                                                            */
/* ----------------------------------------------------------------- */

.kit-popover {
  position: relative;
  display: inline-block;
}

.kit-popover__trigger {
  cursor: pointer;
}

.kit-popover__content {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 200px;
  padding: 12px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-md);
  box-shadow: var(--kit-shadow-md);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-900);
  animation: kit-fade-in-up 150ms ease both;
}

.kit-popover__content[hidden] { display: none; }

/* ----------------------------------------------------------------- */
/* Tooltip                                                            */
/* ----------------------------------------------------------------- */

.kit-tooltip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--gray-900);
  color: white;
  border-radius: var(--kit-radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--kit-shadow-md);
  pointer-events: none;
  animation: kit-fade-in 150ms ease both;
}

.kit-tooltip[hidden] { display: none; }

/* ----------------------------------------------------------------- */
/* Toast                                                              */
/* ----------------------------------------------------------------- */

.kit-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 360px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--kit-radius-lg);
  box-shadow: var(--kit-shadow-lg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-900);
  position: relative;
  overflow: hidden;
  animation: kit-slide-in-from-right 300ms ease-out both;
}

.kit-toast::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: var(--kit-radius-md);
  background: var(--gray-300);
}

.kit-toast--success::before { background: var(--green-600); }
.kit-toast--error::before   { background: var(--orange-500); }
.kit-toast--info::before    { background: var(--blue-500); }
.kit-toast--warning::before { background: var(--orange-500); }

.kit-toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-left: 10px;
  margin-top: 1px;
}

.kit-toast--success .kit-toast__icon { color: var(--green-700); }
.kit-toast--error   .kit-toast__icon { color: var(--red-600); }
.kit-toast--info    .kit-toast__icon { color: var(--blue-600); }
.kit-toast--warning .kit-toast__icon { color: var(--orange-700); }

.kit-toast__body {
  flex: 1;
  min-width: 0;
}

.kit-toast__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.kit-toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: var(--kit-radius-sm);
  flex-shrink: 0;
}

.kit-toast__close:hover { background: var(--gray-100); }

/* ----------------------------------------------------------------- */
/* Tradeoffs and unresolved questions                                 */
/* ----------------------------------------------------------------- */

/*
  Tradeoff: Compound DS components (Navigation, Menu, Tabs, Modal) are
  deeply context-driven in React. The shim only ships the visual layer —
  prototypes are responsible for managing open/close state and the
  active tab/item via JS or extra utility classes (e.g. `--active`,
  `aria-checked="true"`).

  Note: `.kit-button--destructive` is a shim-only convenience. The DS
  has no destructive variant — `color="red"` falls back to primary
  (black). For prototype clarity on Delete / Remove actions we use the
  DS `light-red` fallback (`bg-red-200 hover:bg-red-300`), which IS a
  real Kit-shipped style — just not a first-class Button token.

  Tradeoff: Toggle thumb position is driven by `aria-checked="true"` or
  `data-enabled="true"` on the button — we can't observe a JS state
  change in pure CSS, so the prototype must update one of those when
  toggling.

  Open question: Tooltip positioning in the DS is handled by Base UI's
  positioner. The shim only styles the bubble — prototypes should wrap
  it in a manually-positioned absolute container or accept that
  tooltips sit beneath the trigger by default.
*/
