@import "tailwindcss";

@custom-variant dark (&:is(.dark *));

:root {
  --font-geist-sans: var(--font-manrope), "Avenir Next", "Segoe UI", sans-serif;
  --font-geist-mono:
    var(--font-jetbrains-mono), "Cascadia Code", "Fira Code", monospace;
  --background: #fafafa;
  --foreground: #0b1220;
  --card: #ffffff;
  --card-foreground: #0b1220;
  --popover: #ffffff;
  --popover-foreground: #0b1220;
  --primary: #6366f1;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --secondary-foreground: #66758a;
  --muted: #f8fafc;
  --muted-foreground: #7a899d;
  --accent: #f1f5f9;
  --accent-foreground: #0b1220;
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #6366f1;
  --success: #059669;
  --warning: #d97706;
  --info: #2563eb;
  --highlight: #7c3aed;
  --sidebar: #ffffff;
  --grid-header: #f8fafc;
  --grid-stripe: #fafbfc;

  /* Semantic opacity-level tokens (no slash numbers in components) */
  --surface-subtle: color-mix(in srgb, var(--background) 70%, transparent);
  --surface-elevated: color-mix(in srgb, var(--background) 98%, transparent);
  --surface-overlay: color-mix(in srgb, var(--background) 60%, transparent);
  --muted-panel: color-mix(in srgb, var(--muted) 30%, var(--background));
  --muted-card: color-mix(in srgb, var(--muted) 60%, var(--background));
  --muted-subtle: color-mix(in srgb, var(--muted) 20%, var(--background));
  --muted-faint: color-mix(in srgb, var(--muted) 10%, var(--background));
  --destructive-subtle: color-mix(
    in srgb,
    var(--destructive) 5%,
    var(--background)
  );
  --destructive-muted: color-mix(
    in srgb,
    var(--destructive) 10%,
    var(--background)
  );
  --destructive-border: color-mix(
    in srgb,
    var(--destructive) 30%,
    var(--border)
  );
  --primary-subtle: color-mix(in srgb, var(--primary) 5%, var(--background));
  --primary-muted: color-mix(in srgb, var(--primary) 10%, var(--background));
  --primary-panel: color-mix(in srgb, var(--primary) 15%, var(--background));
  --primary-border: color-mix(in srgb, var(--primary) 25%, var(--border));
  --success-subtle: color-mix(in srgb, var(--success) 8%, var(--background));
  --success-muted: color-mix(in srgb, var(--success) 10%, var(--background));
  --success-border: color-mix(in srgb, var(--success) 20%, var(--border));
  --warning-subtle: color-mix(in srgb, var(--warning) 8%, var(--background));
  --warning-muted: color-mix(in srgb, var(--warning) 10%, var(--background));
  --warning-border: color-mix(in srgb, var(--warning) 40%, var(--border));
  --info-subtle: color-mix(in srgb, var(--info) 12%, var(--background));
  --info-muted: color-mix(in srgb, var(--info) 10%, var(--background));
  --info-border: color-mix(in srgb, var(--info) 30%, var(--border));
  --highlight-subtle: color-mix(
    in srgb,
    var(--highlight) 12%,
    var(--background)
  );
  --highlight-muted: color-mix(
    in srgb,
    var(--highlight) 10%,
    var(--background)
  );
  --highlight-border: color-mix(in srgb, var(--highlight) 40%, var(--border));
  --accent-subtle: color-mix(in srgb, var(--accent) 20%, var(--background));
  --accent-muted: color-mix(in srgb, var(--accent) 30%, var(--background));
  --border-subtle: color-mix(in srgb, var(--border) 70%, transparent);
  --border-faint: color-mix(in srgb, var(--border) 50%, transparent);
  --border-muted: color-mix(in srgb, var(--border) 40%, transparent);
  --muted-foreground-subtle: color-mix(
    in srgb,
    var(--muted-foreground) 60%,
    transparent
  );
  --muted-foreground-faint: color-mix(
    in srgb,
    var(--muted-foreground) 50%,
    transparent
  );
  --muted-foreground-dim: color-mix(
    in srgb,
    var(--muted-foreground) 40%,
    transparent
  );
  --foreground-subtle: color-mix(in srgb, var(--foreground) 90%, transparent);
  --foreground-muted: color-mix(in srgb, var(--foreground) 70%, transparent);
  --card-subtle: color-mix(in srgb, var(--card) 20%, transparent);
  --ring-subtle: color-mix(in srgb, var(--ring) 30%, transparent);
  --ring-destructive-subtle: color-mix(
    in srgb,
    var(--destructive) 30%,
    transparent
  );
  --overlay: color-mix(in srgb, black 60%, transparent);
  --foreground-border: color-mix(in srgb, var(--foreground) 30%, var(--border));
  --accent-panel: color-mix(in srgb, var(--accent) 50%, var(--background));
}

.dark {
  --background: #09090b;
  --foreground: #e2e8f0;
  --card: #0c0c0e;
  --card-foreground: #e2e8f0;
  --popover: #0c0c0e;
  --popover-foreground: #e2e8f0;
  --primary: #818cf8;
  --primary-foreground: #000000;
  --secondary: #16161a;
  --secondary-foreground: #94a3b8;
  --muted: #111114;
  --muted-foreground: #71717a;
  --accent: #16161a;
  --accent-foreground: #e2e8f0;
  --destructive: #f87171;
  --destructive-foreground: #000000;
  --border: #27272a;
  --input: #27272a;
  --ring: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --info: #3b82f6;
  --highlight: #8b5cf6;
  --sidebar: #0c0c0e;
  --grid-header: #0e0e11;
  --grid-stripe: #0b0b0e;

  /* Semantic opacity-level tokens (dark mode same names, color-mix uses current vars) */
  --surface-subtle: color-mix(in srgb, var(--background) 70%, transparent);
  --surface-elevated: color-mix(in srgb, var(--background) 98%, transparent);
  --surface-overlay: color-mix(in srgb, var(--background) 60%, transparent);
  --muted-panel: color-mix(in srgb, var(--muted) 30%, var(--background));
  --muted-card: color-mix(in srgb, var(--muted) 60%, var(--background));
  --muted-subtle: color-mix(in srgb, var(--muted) 20%, var(--background));
  --muted-faint: color-mix(in srgb, var(--muted) 10%, var(--background));
  --destructive-subtle: color-mix(
    in srgb,
    var(--destructive) 5%,
    var(--background)
  );
  --destructive-muted: color-mix(
    in srgb,
    var(--destructive) 10%,
    var(--background)
  );
  --destructive-border: color-mix(
    in srgb,
    var(--destructive) 30%,
    var(--border)
  );
  --primary-subtle: color-mix(in srgb, var(--primary) 5%, var(--background));
  --primary-muted: color-mix(in srgb, var(--primary) 10%, var(--background));
  --primary-panel: color-mix(in srgb, var(--primary) 15%, var(--background));
  --primary-border: color-mix(in srgb, var(--primary) 25%, var(--border));
  --success-subtle: color-mix(in srgb, var(--success) 8%, var(--background));
  --success-muted: color-mix(in srgb, var(--success) 10%, var(--background));
  --success-border: color-mix(in srgb, var(--success) 20%, var(--border));
  --warning-subtle: color-mix(in srgb, var(--warning) 8%, var(--background));
  --warning-muted: color-mix(in srgb, var(--warning) 10%, var(--background));
  --warning-border: color-mix(in srgb, var(--warning) 40%, var(--border));
  --info-subtle: color-mix(in srgb, var(--info) 12%, var(--background));
  --info-muted: color-mix(in srgb, var(--info) 10%, var(--background));
  --info-border: color-mix(in srgb, var(--info) 30%, var(--border));
  --highlight-subtle: color-mix(
    in srgb,
    var(--highlight) 12%,
    var(--background)
  );
  --highlight-muted: color-mix(
    in srgb,
    var(--highlight) 10%,
    var(--background)
  );
  --highlight-border: color-mix(in srgb, var(--highlight) 40%, var(--border));
  --accent-subtle: color-mix(in srgb, var(--accent) 20%, var(--background));
  --accent-muted: color-mix(in srgb, var(--accent) 30%, var(--background));
  --border-subtle: color-mix(in srgb, var(--border) 70%, transparent);
  --border-faint: color-mix(in srgb, var(--border) 50%, transparent);
  --border-muted: color-mix(in srgb, var(--border) 40%, transparent);
  --muted-foreground-subtle: color-mix(
    in srgb,
    var(--muted-foreground) 60%,
    transparent
  );
  --muted-foreground-faint: color-mix(
    in srgb,
    var(--muted-foreground) 50%,
    transparent
  );
  --muted-foreground-dim: color-mix(
    in srgb,
    var(--muted-foreground) 40%,
    transparent
  );
  --foreground-subtle: color-mix(in srgb, var(--foreground) 90%, transparent);
  --foreground-muted: color-mix(in srgb, var(--foreground) 70%, transparent);
  --card-subtle: color-mix(in srgb, var(--card) 20%, transparent);
  --ring-subtle: color-mix(in srgb, var(--ring) 30%, transparent);
  --ring-destructive-subtle: color-mix(
    in srgb,
    var(--destructive) 30%,
    transparent
  );
  --overlay: color-mix(in srgb, black 60%, transparent);
  --foreground-border: color-mix(in srgb, var(--foreground) 30%, var(--border));
  --accent-panel: color-mix(in srgb, var(--accent) 50%, var(--background));
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-success: var(--success);
  --color-warning: var(--warning);
  --color-info: var(--info);
  --color-highlight: var(--highlight);
  --color-sidebar: var(--sidebar);
  --color-grid-header: var(--grid-header);
  --color-grid-stripe: var(--grid-stripe);
  --color-surface-subtle: var(--surface-subtle);
  --color-surface-elevated: var(--surface-elevated);
  --color-surface-overlay: var(--surface-overlay);
  --color-muted-panel: var(--muted-panel);
  --color-muted-card: var(--muted-card);
  --color-muted-subtle: var(--muted-subtle);
  --color-muted-faint: var(--muted-faint);
  --color-destructive-subtle: var(--destructive-subtle);
  --color-destructive-muted: var(--destructive-muted);
  --color-destructive-border: var(--destructive-border);
  --color-primary-subtle: var(--primary-subtle);
  --color-primary-muted: var(--primary-muted);
  --color-primary-panel: var(--primary-panel);
  --color-primary-border: var(--primary-border);
  --color-success-subtle: var(--success-subtle);
  --color-success-muted: var(--success-muted);
  --color-success-border: var(--success-border);
  --color-warning-subtle: var(--warning-subtle);
  --color-warning-muted: var(--warning-muted);
  --color-warning-border: var(--warning-border);
  --color-info-subtle: var(--info-subtle);
  --color-info-muted: var(--info-muted);
  --color-info-border: var(--info-border);
  --color-highlight-subtle: var(--highlight-subtle);
  --color-highlight-muted: var(--highlight-muted);
  --color-highlight-border: var(--highlight-border);
  --color-accent-subtle: var(--accent-subtle);
  --color-accent-muted: var(--accent-muted);
  --color-border-subtle: var(--border-subtle);
  --color-border-faint: var(--border-faint);
  --color-border-muted: var(--border-muted);
  --color-muted-foreground-subtle: var(--muted-foreground-subtle);
  --color-muted-foreground-faint: var(--muted-foreground-faint);
  --color-muted-foreground-dim: var(--muted-foreground-dim);
  --color-foreground-subtle: var(--foreground-subtle);
  --color-foreground-muted: var(--foreground-muted);
  --color-card-subtle: var(--card-subtle);
  --color-ring-subtle: var(--ring-subtle);
  --color-ring-destructive-subtle: var(--ring-destructive-subtle);
  --color-overlay: var(--overlay);
  --color-foreground-border: var(--foreground-border);
  --color-accent-panel: var(--accent-panel);

  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);

  /* Typography scale (design tokens for text sizing) */
  --text-2xs: 8px;
  --text-tiny: 9px;
  --text-caption: 10px;
  --text-body-sm: 11px;
  --text-prose-sm: 12px;

  --radius-sm: 0.125rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.375rem;
  --radius-xl: 0.5rem;
}

* {
  border-color: var(--border);
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-geist-sans), system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 13px;
}

::selection {
  background: rgb(45 212 191 / 0.25);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes slide-up-island {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes soft-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgb(99 102 241 / 0.18);
  }
  50% {
    box-shadow: 0 0 0 8px rgb(99 102 241 / 0);
  }
}
.animate-fade-in {
  animation: fade-in 0.2s ease-out;
}
.animate-slide-up {
  animation: slide-up 0.25s ease-out;
}
.animate-slide-in-right {
  animation: slide-in-right 0.2s ease-out;
}
.animate-slide-up-island {
  animation: slide-up-island 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-pop-in {
  animation: pop-in 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-soft-pulse {
  animation: soft-pulse 2.2s ease-in-out infinite;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.25);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.4);
}
.dark ::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
}
.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

@media (max-width: 768px) {
  .sidebar-mobile-hidden {
    display: none;
  }
  .sidebar-mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
  }

  /* Prevent horizontal overflow on mobile */
  body {
    overflow-x: hidden;
  }

  /* Larger touch targets */
  button,
  [role="button"] {
    min-height: 32px;
    min-width: 32px;
  }
}

/* Resize handle for resizable panels */
[data-separator] {
  width: 1px !important;
  min-width: 1px !important;
  background: var(--border);
  transition: background 0.15s ease;
  cursor: col-resize;
  position: relative;
  flex-shrink: 0;
}
[data-separator]:hover,
[data-separator]:active {
  width: 3px !important;
  min-width: 3px !important;
  background: var(--primary);
}
[data-separator]::after {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

/* Native select dark/light mode */
select,
select option {
  background-color: var(--background);
  color: var(--foreground);
}
.dark select,
.dark select option {
  background-color: var(--background);
  color: var(--foreground);
}

/* Column resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  background: transparent;
  transition: background 0.15s;
}
.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: var(--primary);
}

/* Shiki code blocks */
.shiki {
  background-color: var(--muted) !important;
}
.dark .shiki {
  background-color: var(--muted) !important;
}
