/**
 * AskDegree Operator Design System (AODS) - components
 * Requires tokens.css and foundations.css loaded first.
 * Spec: docs/UI-DESIGN-SYSTEM.md
 */

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

.card {
  background: var(--card);
  color: var(--card-foreground, var(--text));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-lg);
}

.card-head--split {
  align-items: flex-start;
}

/* -------------------------------------------------------------------------- */
/* Buttons (shadcn/ui - AskDegree primary)                                    */
/* -------------------------------------------------------------------------- */

button:not(.list-row):not(.workflow-step):not(.tabs-trigger):not(.queue-tab):not(.template-pick):not(.template-modal-close),
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 2.25rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--input, var(--border));
  border-radius: var(--radius-md);
  background: var(--background, var(--card));
  color: var(--foreground, var(--text));
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button:not(.list-row):not(.workflow-step):not(.tabs-trigger):not(.queue-tab):not(.template-pick):not(.template-modal-close):hover:not(:disabled),
.btn:hover:not(:disabled) {
  background: var(--accent-surface, var(--brand-soft));
  color: var(--accent-foreground, var(--brand));
}

button.primary,
.btn.primary,
.btn-primary {
  background: var(--primary, var(--brand));
  color: var(--primary-foreground, var(--text-inverse));
  border-color: transparent;
}

button.primary:hover:not(:disabled),
.btn.primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  color: var(--primary-foreground, var(--text-inverse));
}

button.secondary,
.btn-secondary {
  background: var(--secondary, var(--muted-surface));
  color: var(--secondary-foreground, var(--text));
  border-color: transparent;
  box-shadow: none;
}

button.secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--secondary, #f1f5f9) 82%, var(--foreground, #0f172a));
}

button.ghost,
.btn.ghost,
.btn-ghost {
  background: transparent;
  color: var(--muted-foreground, var(--muted));
  border-color: transparent;
  box-shadow: none;
}

button.ghost:hover:not(:disabled),
.btn.ghost:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--accent-surface, var(--brand-soft));
  color: var(--accent-foreground, var(--brand));
}

button.outline,
.btn-outline {
  background: var(--background, var(--card));
  border-color: var(--input, var(--border));
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.is-loading .btn-label,
.btn.is-loading .btn-label {
  opacity: 0.7;
}

.primary-compact,
.btn-compact {
  height: 2rem;
  font-size: var(--text-xs);
  padding: 0 var(--space-3);
}

.primary-lg,
.btn-lg {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-md);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
}

.spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: aods-spin 0.7s linear infinite;
}

button.is-loading .spinner,
.btn.is-loading .spinner {
  display: inline-block;
}

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

.button-link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  font-size: var(--text-sm);
}

.button-link:hover {
  background: #d9e3ff;
  text-decoration: none;
}

/* -------------------------------------------------------------------------- */
/* Forms                                                                      */
/* -------------------------------------------------------------------------- */

label,
.form-label {
  display: block;
  margin: var(--space-3) 0 var(--space-1);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-md);
}

label:first-child,
.form-label:first-child {
  margin-top: 0;
}

input,
textarea,
select,
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  border: 1px solid var(--input, var(--border));
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: var(--background, var(--card));
  color: var(--foreground, var(--text));
  font-size: var(--text-sm);
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
.form-input,
.form-select {
  height: 2.25rem;
}

input:focus,
textarea:focus,
select:focus,
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--ring, var(--border-focus));
  box-shadow: var(--shadow-focus);
}

textarea,
.form-textarea {
  resize: vertical;
  min-height: 120px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--brand);
}

.form-hint {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--muted);
}

.form-error {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--error);
}

/* -------------------------------------------------------------------------- */
/* Badges & chips                                                             */
/* -------------------------------------------------------------------------- */

.status-badge,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: break-word;
  flex-shrink: 0;
}

.status-badge--intake_received,
.badge--info {
  background: var(--accent-surface, var(--info-bg));
  color: var(--accent-foreground, var(--brand));
  border-color: var(--info-border);
}

.status-badge--insights_added,
.badge--indigo {
  background: var(--brand-soft);
  color: var(--brand-hover);
}

.status-badge--draft_ready,
.badge--warn {
  background: var(--warn-bg);
  color: color-mix(in srgb, var(--warn) 85%, var(--text));
}

.status-badge--pdf_generated,
.status-badge--signed,
.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge--sent_for_signature,
.badge--brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.status-badge--declined,
.badge--error {
  background: var(--error-bg);
  color: var(--error);
}

.status-badge--default,
.badge--neutral {
  background: var(--secondary, #f1f5f9);
  color: var(--secondary-foreground, var(--text));
  border-color: var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.25;
}

.chip-service {
  background: var(--brand-soft);
  color: var(--brand);
}

.chip-folder {
  background: color-mix(in srgb, var(--border) 45%, var(--bg));
  color: var(--muted);
}

.chip-demo {
  background: var(--warn-bg);
  color: color-mix(in srgb, var(--warn) 85%, var(--text));
}

.chip-nurture {
  background: var(--warn-bg);
  color: color-mix(in srgb, var(--warn) 85%, var(--text));
}

.chip-muted {
  background: var(--secondary, #f1f5f9);
  color: var(--secondary-foreground, var(--text));
  border-color: var(--border);
}

.chip-info {
  background: var(--info-bg);
  color: var(--brand);
}

.status-badge--compact {
  padding: 0.12rem 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: var(--font-weight-semibold);
  line-height: 1.25;
}

.status-badge--intake_draft {
  background: color-mix(in srgb, var(--border) 45%, var(--bg));
  color: var(--muted);
}

/* -------------------------------------------------------------------------- */
/* List rows (compact inbox / queue pattern)                                  */
/* -------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
/* Tabs (shadcn/ui TabsList + TabsTrigger)                                    */
/* -------------------------------------------------------------------------- */

.tabs-list {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.25rem;
  gap: 0.25rem;
  border-radius: var(--radius-md);
  background: var(--secondary, #f1f5f9);
  color: var(--muted-foreground, var(--muted));
}

.tabs-trigger {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2rem;
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--muted-foreground, var(--muted));
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tabs-trigger:hover {
  color: var(--foreground, var(--text));
}

.tabs-trigger[data-state="active"],
.tabs-trigger--active,
.tabs-trigger.queue-tab--active {
  background: var(--background, var(--card));
  color: var(--foreground, var(--text));
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------------------- */
/* List rows (shadcn compact data list)                                       */
/* -------------------------------------------------------------------------- */

.list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  overflow: hidden;
  min-width: 0;
}

.list-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: var(--font-weight-normal);
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  min-width: 0;
  transition: background 0.12s ease;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: var(--accent-surface, var(--brand-soft));
}

.list-row:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--ring, var(--brand));
  z-index: 1;
}

.list-row.is-active,
.list-row.active {
  background: var(--sidebar-accent, var(--accent-surface, var(--brand-soft)));
  color: var(--sidebar-accent-foreground, var(--accent-foreground, var(--brand)));
  box-shadow: none;
}

.list-row-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.list-row-leading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem var(--space-1);
  min-width: 0;
  flex: 1;
}

.list-row-title {
  font-family: var(--font-head);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  overflow-wrap: anywhere;
}

.list-row-sep {
  color: var(--border);
  font-size: var(--text-xs);
  user-select: none;
}

.list-row-subtitle {
  font-size: var(--text-xs);
  color: var(--muted-foreground, var(--muted));
  overflow-wrap: anywhere;
}

.list-row-subtitle--empty {
  font-style: italic;
}

.list-row-trailing {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1) var(--space-2);
  flex-shrink: 0;
}

.list-row-date {
  font-size: var(--text-xs);
  color: var(--muted-foreground, var(--muted));
  white-space: nowrap;
}

.list-row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem var(--space-1);
  min-width: 0;
}

.list-row-chips .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .list-row-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .list-row-trailing {
    width: 100%;
    justify-content: space-between;
  }
}

/* -------------------------------------------------------------------------- */
/* Callouts & messages                                                        */
/* -------------------------------------------------------------------------- */

.callout {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  min-width: 0;
  max-width: 100%;
  margin: var(--space-3) 0;
  font-size: var(--text-base);
}

.callout > div {
  flex: 1;
  min-width: 0;
}

.callout p {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.callout-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--warn);
}

.callout-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #92400e;
}

.callout-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: #991b1b;
}

.callout-error .callout-icon {
  color: var(--error);
}

.callout-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: #1e40af;
}

.callout-info .callout-icon {
  color: var(--info);
}

.callout-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #166534;
}

.callout-success .callout-icon {
  color: var(--success);
}

.message {
  min-height: 1.25rem;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
}

.message-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.message-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.message-info {
  background: var(--info-bg);
  color: #1d4ed8;
  border: 1px solid var(--info-border);
}

.message-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

/* -------------------------------------------------------------------------- */
/* Modals                                                                     */
/* -------------------------------------------------------------------------- */

.modal,
.template-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-backdrop,
.template-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-modal-backdrop);
}

.modal-panel,
.template-modal-panel {
  position: relative;
  z-index: calc(var(--z-modal) + 1);
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) var(--space-5);
}

.modal-panel--wide,
.template-modal-panel--wide {
  width: min(920px, 96vw);
}

.modal-header,
.template-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.modal-header h2,
.template-modal-header h2 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
}

.modal-close,
.template-modal-close {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-md);
  line-height: 1;
}

body.modal-open {
  overflow: hidden;
}

/* -------------------------------------------------------------------------- */
/* Toasts                                                                     */
/* -------------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  font-size: var(--text-base);
  animation: aods-toast-in 0.25s ease;
  pointer-events: auto;
}

.toast-icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--brand);
}

.toast-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: #166534;
}

.toast-warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: #92400e;
}

.toast-info {
  border-color: var(--info-border);
  background: var(--info-bg);
  color: #1e40af;
}

.toast-error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: #991b1b;
}

@keyframes aods-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------------------------------------------------------------- */
/* Workflow steps                                                             */
/* -------------------------------------------------------------------------- */

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
  margin: var(--space-4) 0 var(--space-1);
  padding: 0.25rem;
  background: var(--secondary, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 1100px) {
  .workflow-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workflow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  padding: 0.375rem 0.625rem;
  border: 0;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  font-weight: var(--font-weight-medium);
  color: var(--muted-foreground, var(--muted));
  background: transparent;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.workflow-step:hover {
  color: var(--foreground, var(--text));
}

.workflow-step-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: var(--radius-full);
  background: var(--card);
  border: 1px solid var(--border);
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
}

.workflow-step--active {
  background: var(--background, var(--card));
  color: var(--foreground, var(--text));
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow-sm);
}

.workflow-step--active .workflow-step-num {
  background: var(--primary, var(--brand));
  border-color: var(--primary, var(--brand));
  color: var(--primary-foreground, var(--text-inverse));
}

.workflow-step--done {
  color: var(--success);
}

.workflow-step--done .workflow-step-num {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.workflow-progress-wrap {
  margin: var(--space-3) 0 var(--space-2);
}

.workflow-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
  color: var(--muted);
}

.workflow-progress-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--border);
  overflow: hidden;
}

.workflow-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.35s ease;
}

/* -------------------------------------------------------------------------- */
/* Hero & app bar (preview / portal chrome)                                   */
/* -------------------------------------------------------------------------- */

.hero {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.hero-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--accent-surface, var(--brand-soft));
  color: var(--primary, var(--brand));
}

.hero-logo svg {
  width: 100%;
  height: 100%;
}

.hero h1 {
  margin: 0;
}

.hero-subtitle {
  margin: var(--space-1) 0 0;
  max-width: var(--content-narrow);
  color: var(--muted-foreground, var(--muted));
  font-size: var(--text-sm);
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--background, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.app-bar-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-head);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-base);
  min-width: 0;
}

.app-bar-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand);
}

.app-bar-logo svg {
  width: 100%;
  height: 100%;
}

.toolbar,
.actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .app-bar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .toolbar {
    width: 100%;
  }
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                     */
/* -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  background: var(--info-bg);
  color: var(--text-table-header);
  font-family: var(--font-head);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
}

.table td {
  color: var(--text-table-body);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* -------------------------------------------------------------------------- */
/* Preview-only helpers                                                       */
/* -------------------------------------------------------------------------- */

.ds-section {
  margin-bottom: var(--space-8);
}

.ds-section-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xl);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.ds-section-desc {
  margin: 0 0 var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
  max-width: 48rem;
}

.ds-subsection {
  margin-bottom: var(--space-6);
}

.ds-subsection h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
  color: var(--text);
}

.ds-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.ds-swatch {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--card);
}

.ds-swatch-color {
  height: 3.5rem;
}

.ds-swatch-meta {
  padding: var(--space-2) var(--space-3);
}

.ds-swatch-name {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.ds-swatch-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.ds-token-table {
  width: 100%;
  font-size: var(--text-sm);
}

.ds-token-table code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
}

.ds-demo-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.ds-demo-stack {
  display: grid;
  gap: var(--space-3);
  max-width: 28rem;
}

.ds-nav {
  position: sticky;
  top: var(--space-4);
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.ds-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.ds-nav a {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
}

.ds-nav a:hover,
.ds-nav a.is-active {
  background: var(--brand-soft);
  color: var(--brand);
  text-decoration: none;
}

.ds-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 900px) {
  .toast-stack {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }

  .ds-layout {
    grid-template-columns: 1fr;
  }

  .ds-nav {
    position: static;
  }
}