/* Lee design system primitives.
   Source of intent: DESIGN.md. Keep this file small, explicit, and easy to reuse. */

:root {
  --lee-ds-primary: #3f654e;
  --lee-ds-primary-active: #2f4d3b;
  --lee-ds-primary-disabled: #dfe7de;
  --lee-ds-ink: #141413;
  --lee-ds-body: #3d3d3a;
  --lee-ds-body-strong: #252523;
  --lee-ds-muted: #6c6a64;
  --lee-ds-muted-soft: #8e8b82;
  --lee-ds-hairline: #dfe7de;
  --lee-ds-hairline-soft: #ebe6df;
  --lee-ds-canvas: #faf9f5;
  --lee-ds-surface-soft: #f5f0e8;
  --lee-ds-surface-card: #efe9de;
  --lee-ds-surface-cream-strong: #e8e0d2;
  --lee-ds-surface-dark: #181d17;
  --lee-ds-surface-dark-elevated: #252b23;
  --lee-ds-surface-dark-soft: #20251e;
  --lee-ds-on-primary: #ffffff;
  --lee-ds-on-dark: #faf9f5;
  --lee-ds-on-dark-soft: #a09d96;
  --lee-ds-accent-teal: #5db8a6;
  --lee-ds-accent-amber: #e8a55a;
  --lee-ds-success: #4f9464;
  --lee-ds-warning: #d4a017;
  --lee-ds-error: #c64545;

  --lee-ds-radius-xs: 4px;
  --lee-ds-radius-sm: 6px;
  --lee-ds-radius-md: 8px;
  --lee-ds-radius-lg: 12px;
  --lee-ds-radius-xl: 16px;
  --lee-ds-radius-pill: 9999px;

  --lee-ds-space-xxs: 4px;
  --lee-ds-space-xs: 8px;
  --lee-ds-space-sm: 12px;
  --lee-ds-space-md: 16px;
  --lee-ds-space-lg: 24px;
  --lee-ds-space-xl: 32px;
  --lee-ds-space-xxl: 48px;

  --lee-ds-font-display: "Anthropic Serif", Georgia, "Times New Roman", serif;
  --lee-ds-font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --lee-ds-font-code: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --lee-ds-shadow-soft: 0 1px 3px rgba(20, 20, 19, 0.08);
  --lee-ds-focus-ring: 0 0 0 3px rgba(63, 101, 78, 0.14);
}

/* Compatibility bridge for the current app shell tokens. */
:root {
  --bg: var(--lee-ds-canvas);
  --surface: var(--lee-ds-canvas);
  --rail: var(--lee-ds-surface-soft);
  --panel: #ffffff;
  --surface-alt: var(--lee-ds-surface-card);
  --surface-wash: var(--lee-ds-canvas);
  --border: var(--lee-ds-hairline-soft);
  --border-strong: #d0cec8;
  --chrome-rgb: 250, 249, 245;
  --rail-rgb: 245, 240, 232;
  --ink: var(--lee-ds-body-strong);
  --ink-soft: var(--lee-ds-muted);
  --ink-faint: var(--lee-ds-muted-soft);
  --accent: var(--lee-ds-primary);
  --accent-soft: #e9efe8;
  --accent-line: #b9c9ba;
  --danger: #7a3a3a;
  --danger-soft: #f3e8e8;
  --warn: #8a6a2a;
  --radius: var(--lee-ds-radius-md);
  --radius-sm: var(--lee-ds-radius-xs);
  --radius-btn: var(--lee-ds-radius-sm);
}

.lee-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--lee-ds-space-xs);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--lee-ds-radius-md);
  font-family: var(--lee-ds-font-ui);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.lee-button:focus-visible,
.lee-input:focus,
.lee-select:focus,
.lee-textarea:focus {
  outline: none;
  border-color: rgba(63, 101, 78, 0.42);
  box-shadow: var(--lee-ds-focus-ring);
}

.lee-button:disabled,
.lee-input:disabled,
.lee-select:disabled,
.lee-textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

body.lee-desktop button,
body.lee-mobile button,
body.lee-desktop input,
body.lee-mobile input,
body.lee-desktop textarea,
body.lee-mobile textarea,
body.lee-desktop select,
body.lee-mobile select {
  font: inherit;
  color: inherit;
}

body.lee-desktop input,
body.lee-mobile input,
body.lee-desktop textarea,
body.lee-mobile textarea,
body.lee-desktop button,
body.lee-mobile button {
  appearance: none;
  -webkit-appearance: none;
}

body.lee-desktop input[type="checkbox"],
body.lee-mobile input[type="checkbox"] {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-content: center;
  margin: 0;
  border: 1px solid var(--lee-ds-hairline);
  border-radius: var(--lee-ds-radius-xs);
  background: rgba(255, 255, 255, 0.92);
  color: var(--lee-ds-primary);
  vertical-align: middle;
}

body.lee-desktop input[type="checkbox"]::before,
body.lee-mobile input[type="checkbox"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  transform: scale(0);
  transition: transform 0.12s ease;
}

body.lee-desktop input[type="checkbox"]:checked,
body.lee-mobile input[type="checkbox"]:checked {
  border-color: rgba(63, 101, 78, 0.42);
  background: #eef4ed;
}

body.lee-desktop input[type="checkbox"]:checked::before,
body.lee-mobile input[type="checkbox"]:checked::before {
  transform: scale(1);
}

body.lee-desktop input[type="checkbox"]:focus-visible,
body.lee-mobile input[type="checkbox"]:focus-visible,
body.lee-desktop input[type="range"]:focus-visible,
body.lee-mobile input[type="range"]:focus-visible {
  outline: none;
  box-shadow: var(--lee-ds-focus-ring);
}

body.lee-desktop input[type="number"]::-webkit-outer-spin-button,
body.lee-desktop input[type="number"]::-webkit-inner-spin-button,
body.lee-mobile input[type="number"]::-webkit-outer-spin-button,
body.lee-mobile input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

body.lee-desktop input[type="range"],
body.lee-mobile input[type="range"] {
  height: 20px;
  border: 0;
  background: transparent;
}

body.lee-desktop input[type="range"]::-webkit-slider-runnable-track,
body.lee-mobile input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--lee-ds-radius-pill);
  background: var(--lee-ds-hairline);
}

body.lee-desktop input[type="range"]::-webkit-slider-thumb,
body.lee-mobile input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 1px solid rgba(63, 101, 78, 0.28);
  border-radius: 50%;
  background: var(--lee-ds-primary);
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.16);
  -webkit-appearance: none;
}

.lee-native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.lee-select-control {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 0;
  font-family: var(--lee-ds-font-ui);
  color: var(--lee-ds-ink);
}

.lee-select-control-trigger {
  width: 100%;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lee-ds-space-xs);
  padding: 0 10px;
  border: 1px solid var(--lee-ds-hairline);
  border-radius: var(--lee-ds-radius-md);
  background: rgba(255, 255, 255, 0.92);
  color: var(--lee-ds-ink);
  font-family: var(--lee-ds-font-ui);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.lee-select-control-trigger:hover {
  background: var(--lee-ds-canvas);
  border-color: #ccd9cc;
}

.lee-select-control-trigger:focus-visible {
  outline: none;
  border-color: rgba(63, 101, 78, 0.42);
  box-shadow: var(--lee-ds-focus-ring);
}

.lee-select-control.disabled .lee-select-control-trigger {
  cursor: not-allowed;
  opacity: 0.55;
}

.lee-select-control-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lee-select-control-chevrons {
  position: relative;
  width: 10px;
  height: 12px;
  flex: 0 0 10px;
  color: var(--lee-ds-muted);
}

.lee-select-control-chevrons::before,
.lee-select-control-chevrons::after {
  content: "";
  position: absolute;
  left: 2px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}

.lee-select-control-chevrons::before {
  top: 0;
  transform: rotate(225deg);
}

.lee-select-control-chevrons::after {
  bottom: 0;
  transform: rotate(45deg);
}

.lee-select-control-menu {
  position: absolute;
  z-index: 10020;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: min(260px, 48vh);
  display: none;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--lee-ds-hairline);
  border-radius: var(--lee-ds-radius-md);
  background: rgba(250, 249, 245, 0.98);
  box-shadow: 0 12px 32px rgba(20, 20, 19, 0.14);
}

.lee-select-control.open .lee-select-control-menu {
  display: grid;
  gap: 2px;
}

.lee-select-control-option {
  min-height: 30px;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 9px;
  border: 0;
  border-radius: var(--lee-ds-radius-sm);
  background: transparent;
  color: var(--lee-ds-body);
  font-family: var(--lee-ds-font-ui);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: left;
  cursor: pointer;
}

.lee-select-control-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lee-select-control-option:hover,
.lee-select-control-option.active {
  background: #e9efe8;
  color: var(--lee-ds-ink);
}

.lee-select-control-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.lee-button-primary {
  background: var(--lee-ds-primary);
  color: var(--lee-ds-on-primary);
}

.lee-button-primary:hover {
  background: var(--lee-ds-primary-active);
}

.lee-button-secondary {
  background: var(--lee-ds-canvas);
  border-color: var(--lee-ds-hairline);
  color: var(--lee-ds-ink);
}

.lee-button-secondary:hover {
  background: var(--lee-ds-surface-soft);
  border-color: #ccd9cc;
}

.lee-button-ghost {
  background: transparent;
  color: var(--lee-ds-body);
}

.lee-button-ghost:hover {
  background: rgba(20, 20, 19, 0.05);
  color: var(--lee-ds-ink);
}

.lee-icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--lee-ds-radius-pill);
}

.lee-input,
.lee-select,
.lee-textarea {
  width: 100%;
  border: 1px solid var(--lee-ds-hairline);
  border-radius: var(--lee-ds-radius-md);
  background: rgba(255, 255, 255, 0.9);
  color: var(--lee-ds-ink);
  font-family: var(--lee-ds-font-ui);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

.lee-input,
.lee-select {
  min-height: 40px;
  padding: 0 12px;
}

.lee-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.lee-textarea {
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
}

.lee-card {
  border: 1px solid var(--lee-ds-hairline-soft);
  border-radius: var(--lee-ds-radius-lg);
  background: var(--lee-ds-canvas);
  color: var(--lee-ds-ink);
}

.lee-card-soft {
  background: var(--lee-ds-surface-card);
  border-color: transparent;
}

.lee-card-dark {
  background: var(--lee-ds-surface-dark);
  border-color: rgba(250, 249, 245, 0.08);
  color: var(--lee-ds-on-dark);
}

.lee-status-pill,
.lee-cognitive-mode-pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--lee-ds-radius-pill);
  font-family: var(--lee-ds-font-ui);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.lee-status-pill {
  background: var(--lee-ds-surface-card);
  color: var(--lee-ds-muted);
}

.lee-status-pill[data-tone="success"] {
  background: rgba(79, 148, 100, 0.13);
  border-color: rgba(79, 148, 100, 0.24);
  color: var(--lee-ds-success);
}

.lee-status-pill[data-tone="warning"] {
  background: rgba(212, 160, 23, 0.13);
  border-color: rgba(212, 160, 23, 0.24);
  color: #8a6a2a;
}

.lee-status-pill[data-tone="error"] {
  background: rgba(198, 69, 69, 0.12);
  border-color: rgba(198, 69, 69, 0.24);
  color: var(--lee-ds-error);
}

.lee-cognitive-mode-pill {
  background: var(--lee-ds-surface-card);
  color: var(--lee-ds-ink);
}

.lee-chat-bubble {
  max-width: min(100%, 680px);
  font-family: var(--lee-ds-font-ui);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--lee-ds-ink);
}

.lee-chat-bubble-user {
  padding: 10px 14px;
  border-radius: var(--lee-ds-radius-lg);
  background: var(--lee-ds-surface-soft);
}

.lee-chat-bubble-agent {
  padding: 0;
  border-radius: var(--lee-ds-radius-md);
  background: transparent;
}

.lee-proposed-action-card {
  padding: 12px 14px;
  border: 1px solid var(--lee-ds-hairline);
  border-radius: var(--lee-ds-radius-lg);
  background: rgba(250, 249, 245, 0.94);
  color: var(--lee-ds-ink);
  font-family: var(--lee-ds-font-ui);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

.lee-product-surface {
  border-radius: var(--lee-ds-radius-lg);
  background: var(--lee-ds-surface-dark);
  color: var(--lee-ds-on-dark);
}

.lee-code-surface {
  border-radius: var(--lee-ds-radius-md);
  background: var(--lee-ds-surface-dark-soft);
  color: var(--lee-ds-on-dark);
  font-family: var(--lee-ds-font-code);
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0;
}
