/* Liminality Design System Tokens & Apple Fluid Motion */
:root {
  /* Warm Paper & Ink Palette (Light Default) */
  --paper: #f5f4ef;
  --card: #faf9f5;
  --card-elevated: #ffffff;
  --badge: #eae8e0;
  --ink: #0e0d0a;
  --muted: #595850;
  --tertiary: #66655e;
  --rule: #d7d6cf;
  --rule-subtle: #e6e4dc;
  --grid-line: rgba(14, 13, 10, 0.05);
  --selection: rgba(14, 13, 10, 0.12);

  /* Apple-Grade Motion & Tactility */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fluid: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-press: transform 100ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* System Appearance & Dark Mode Adaptation */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e0d0a;
    --card: #151410;
    --card-elevated: #1a1914;
    --badge: #22211c;
    --ink: #f5f4ef;
    --muted: #a3a195;
    --tertiary: #87857b;
    --rule: #2a2924;
    --rule-subtle: #201f1a;
    --grid-line: rgba(245, 244, 239, 0.05);
    --selection: rgba(245, 244, 239, 0.25);
  }
}

html[data-theme="dark"] {
  --paper: #0e0d0a;
  --card: #151410;
  --card-elevated: #1a1914;
  --badge: #22211c;
  --ink: #f5f4ef;
  --muted: #a3a195;
  --tertiary: #87857b;
  --rule: #2a2924;
  --rule-subtle: #201f1a;
  --grid-line: rgba(245, 244, 239, 0.05);
  --selection: rgba(245, 244, 239, 0.25);
}

* { box-sizing: border-box; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--paper);
  color: var(--ink);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: 
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
}

body.app-shell-lock {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

code, pre, .font-mono {
  font-family: 'Space Mono', monospace;
}

/* Main Timeline Canvas Viewport */
main.timeline-main-viewport {
  flex: 1 1 0%;
  min-width: 0px; /* Allow shrinking gracefully so side panels never get clipped */
}
.studio-sidebar-dock {
  background: var(--card);
  border-right: 1px solid var(--rule);
  width: 260px;
  min-width: 220px;
  max-width: 280px;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.25s var(--ease-spring), min-width 0.25s var(--ease-spring), opacity 0.2s var(--ease-spring);
  position: relative;
  z-index: 20;
}

.studio-sidebar-dock.collapsed {
  width: 0px !important;
  min-width: 0px !important;
  max-width: 0px !important;
  opacity: 0;
  overflow: hidden;
  border-right: none;
}

/* Hairline Grid & Architectural Framing */
.architectural-card {
  background: var(--card);
  border: 1px solid var(--rule);
  position: relative;
  transition: var(--transition-fluid);
}

/* Only clickable interactive cards have hover borders/shadows */
.architectural-card.interactive:hover,
a.architectural-card:hover,
button.architectural-card:hover {
  border-color: var(--ink);
  box-shadow: 0 4px 20px -2px rgba(14, 13, 10, 0.05);
}

/* Corner Marks */
.has-corner-marks::before,
.has-corner-marks::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-color: var(--ink);
  pointer-events: none;
}
.has-corner-marks::before {
  top: -1px;
  left: -1px;
  border-top: 1.5px solid var(--ink);
  border-left: 1.5px solid var(--ink);
}
.has-corner-marks::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
}

/* Tactile Press Interactions */
.press-tactile {
  transition: var(--transition-press);
  cursor: pointer;
}
.press-tactile:active {
  transform: scale(0.97);
}

/* Tactile Pill Buttons */
.liminal-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  transition: var(--transition-fluid);
}
.liminal-pill:hover {
  background: transparent;
  color: var(--ink);
}
.liminal-pill:active { transform: scale(0.96); }

.liminal-pill-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--muted);
  transition: var(--transition-fluid);
}
.liminal-pill-outline:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.liminal-pill-outline:active { transform: scale(0.96); }

/* Floating AI Button */
.floating-ai-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 54px;
  height: 54px;
  border-radius: 9999px;
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 0 10px 25px -4px rgba(14, 13, 10, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  transition: var(--transition-fluid);
}
.floating-ai-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 30px -4px rgba(14, 13, 10, 0.4);
}
.floating-ai-launcher:active { transform: scale(0.96); }
.floating-ai-launcher.hidden { display: none !important; }

/* Collapsible & Resizable AI Panel (Docked in Main Shell) */
.studio-ai-dock {
  background: var(--paper);
  border-left: 1px solid var(--rule);
  width: 420px;
  min-width: 300px;
  max-width: 540px;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 25;
  flex-shrink: 0;
  transition: width 0.25s var(--ease-spring), min-width 0.25s var(--ease-spring), opacity 0.2s var(--ease-spring);
}

.studio-ai-dock.collapsed {
  width: 0px !important;
  min-width: 0px !important;
  max-width: 0px !important;
  opacity: 0;
  overflow: hidden;
  border-left: none;
}

.ai-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
  transition: background 0.15s ease;
  z-index: 60;
}
.ai-resize-handle:hover,
.ai-resize-handle.active {
  background: var(--ink);
}

/* Horizontal Scroll Container for Zoomed Gantt */
.gantt-scroll-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--card);
  padding-bottom: 2px;
}

/* Multi-Lane Parallel Visual Timeline Styles */
.parallel-day-canvas {
  position: relative;
  min-width: 100%;
  background: var(--card);
  transition: width 0.2s var(--ease-spring);
}

/* Hour Ruler */
.time-ruler-grid {
  position: relative;
  height: 30px;
  border-bottom: 1px solid var(--rule);
  background: var(--badge);
  display: flex;
}
.ruler-hour-cell {
  flex: 1;
  border-right: 1px dashed var(--rule);
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  padding: 6px 4px;
  text-align: left;
  white-space: nowrap;
}
.ruler-hour-cell:last-child {
  border-right: none;
}

/* Multi-Track Container */
.parallel-lanes-container {
  position: relative;
  min-height: 120px;
}

/* Project Stream Block */
.parallel-stream-block {
  position: absolute;
  height: 42px;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s var(--ease-spring);
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(14, 13, 10, 0.08);
  z-index: 10;
}

.parallel-stream-block:hover {
  transform: translateY(-2px);
  z-index: 30;
  box-shadow: 0 8px 20px -2px rgba(14, 13, 10, 0.2);
}

/* Overlap Indicator Badge */
.overlap-indicator-badge {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 2px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Markdown AI Chat Feed */
.ai-message h1, .ai-message h2, .ai-message h3 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.ai-message h1 { font-size: 1.15rem; }
.ai-message h2 { font-size: 1.05rem; }
.ai-message h3 { font-size: 0.95rem; }

.ai-message ul {
  list-style-type: none;
  padding-left: 0;
  margin-bottom: 0.75rem;
}
.ai-message li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.35rem;
  line-height: 1.5;
}
.ai-message li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--tertiary);
}
.ai-message strong {
  color: var(--ink);
  font-weight: 600;
}
.ai-message p {
  margin-bottom: 0.65rem;
  line-height: 1.6;
  color: var(--muted);
}
