/* Macaron Agent Platform — Main stylesheet */

:root {
  /* ── Backgrounds ── */
  --bg-primary: #0f0a1a;
  --bg-secondary: #1a1225;
  --bg-tertiary: #251d33;

  /* ── Borders ── */
  --border: #352d45;

  /* ── Text ── */
  --text-primary: #e6edf3;
  --text-secondary: #9e95b0;
  --text-on-accent: #ffffff;

  /* ── Brand colors ── */
  --accent: #f78166;
  --accent-hover: #ffa28b;
  --purple: #bc8cff;
  --purple-light: #c084fc;
  --purple-deep: #7c3aed;
  --blue: #7c8aff;
  --blue-bright: #3b82f6;
  --blue-light: #60a5fa;
  --green: #3fb950;
  --green-light: #34d399;
  --green-deep: #16a34a;
  --red: #f85149;
  --red-light: #f87171;
  --red-deep: #dc2626;
  --yellow: #d29922;
  --yellow-light: #fbbf24;
  --yellow-deep: #f59e0b;
  --pink: #f472b6;
  --cyan: #06b6d4;
  --gray: #6b7280;
  --gray-light: #9ca3af;
  --gray-muted: #8b949e;

  /* ── Contextual bubbles ── */
  --user-bubble: #1d4a2a;
  --user-bubble-border: #2a6b3c;

  /* ── Typography scale ── */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
  --text-2xs: 0.55rem; /* 8.8px — micro labels */
  --text-xs: 0.62rem; /* 9.9px — tiny badges */
  --text-sm: 0.68rem; /* 10.9px — pills, tags */
  --text-base: 0.75rem; /* 12px — captions, meta */
  --text-md: 0.82rem; /* 13.1px — body small */
  --text-lg: 0.88rem; /* 14.1px — body */
  --text-xl: 1rem; /* 16px — headings */
  --text-2xl: 1.25rem; /* 20px — titles */
  --text-3xl: 1.8rem; /* 28.8px — hero metrics */

  /* ── Spacing scale ── */
  --space-0: 0;
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem; /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem; /* 24px */
  --space-8: 2rem; /* 32px */
  --space-10: 2.5rem; /* 40px */

  /* ── Border radius ── */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius: 10px;
  --radius-xl: 12px;
  --radius-2xl: 14px;
  --radius-full: 50%;

  /* ── Sidebar ── */
  --sidebar-width: 56px;
}

/* ── Light theme overrides ── */
[data-theme="light"] {
  --bg-primary: #f8f6fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0ecf5;
  --border: #d8d0e5;
  --text-primary: #1a1225;
  --text-secondary: #5c5470;
  --text-on-accent: #ffffff;
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --purple-deep: #5b21b6;
  --blue: #4f46e5;
  --blue-bright: #2563eb;
  --blue-light: #3b82f6;
  --green: #16a34a;
  --green-light: #22c55e;
  --green-deep: #15803d;
  --red: #dc2626;
  --red-light: #ef4444;
  --red-deep: #b91c1c;
  --yellow: #ca8a04;
  --yellow-light: #eab308;
  --yellow-deep: #a16207;
  --pink: #ec4899;
  --cyan: #0891b2;
  --gray: #6b7280;
  --gray-light: #9ca3af;
  --gray-muted: #6b7280;
  --accent: #ea580c;
  --accent-hover: #f97316;
  --user-bubble: #dcfce7;
  --user-bubble-border: #86efac;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar — compact icon-only */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  width: var(--sidebar-width);
}

.sidebar-header {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: center;
}

.logo {
  font-size: 0;
  display: flex;
  justify-content: center;
}
.logo .icon {
  width: 28px;
  height: 28px;
}
.version {
  display: none;
}

.sidebar-section {
  width: 100%;
  padding: 8px 0;
}
.sidebar-section-title {
  display: none;
}

.nav-links {
  list-style: none;
  padding: 4px 0;
  flex: 1;
}

.nav-links li {
  position: relative;
}

.nav-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  color: var(--gray-light);
  text-decoration: none;
  font-size: 0;
  transition: all 0.15s;
}

.nav-links a .icon {
  width: 20px;
  height: 20px;
}

.nav-links a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.nav-links a.active {
  color: #fff;
  background: var(--purple-deep);
  border-left: 3px solid var(--purple-light);
}

/* Tooltip on hover */
.nav-links a::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-width) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
  border: 1px solid var(--border);
}
.nav-links a:hover::after {
  opacity: 1;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: center;
  font-size: 0;
}
.sidebar-footer .status-dot {
  margin: 0;
}

/* Main content */
.content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.topbar h2 {
  font-size: var(--text-xl);
  font-weight: 600;
}
.app-version {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
  letter-spacing: 0.02em;
  cursor: default;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topbar-bell {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.topbar-bell:hover {
  background: var(--border);
  color: var(--text-primary);
}
.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-on-accent);
  cursor: pointer;
}

.main-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: var(--text-lg);
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--text-secondary);
}
.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-danger {
  background: var(--red);
  color: var(--text-on-accent);
  border-color: var(--red);
}
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-base);
}
.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-xl);
}

/* Panels */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}
.panel-body {
  padding: var(--space-4);
}

/* Workspace layout */
.workspace {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: var(--space-4);
  height: calc(100vh - 120px);
}

.sessions-panel,
.agents-sidebar {
  overflow-y: auto;
}
.conversation-panel {
  display: flex;
  flex-direction: column;
}
.conversation-panel .panel-body {
  flex: 1;
  overflow-y: auto;
}

/* Forms */
.form-group {
  margin-bottom: var(--space-4);
}
.form-group label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-lg);
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--text-lg);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Badges / Tags */
.badge {
  display: inline-block;
  padding: var(--radius-xs) var(--space-2);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  font-weight: 500;
}

.badge-red {
  background: rgba(248, 81, 73, 0.2);
  color: var(--red);
}
.badge-blue {
  background: rgba(124, 138, 255, 0.2);
  color: var(--blue);
}
.badge-green {
  background: rgba(63, 185, 80, 0.2);
  color: var(--green);
}
.badge-yellow {
  background: rgba(210, 153, 34, 0.2);
  color: var(--yellow);
}
.badge-purple {
  background: rgba(188, 140, 255, 0.2);
  color: var(--purple);
}

.tag {
  display: inline-block;
  padding: var(--radius-xs) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Status dots */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--text-secondary);
}

.status-dot.active,
.status-dot.idle {
  background: var(--green);
}
.status-dot.thinking {
  background: var(--yellow);
  animation: pulse 1s infinite;
}
.status-dot.waiting {
  background: var(--blue);
}
.status-dot.blocked {
  background: var(--red);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--space-6);
  font-size: var(--text-lg);
}

/* Welcome */
.welcome-message {
  text-align: center;
  padding: 60px var(--space-6);
}

.welcome-message h2 {
  margin-bottom: var(--space-3);
}
.welcome-message p {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}
.quick-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* SVG Icons */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}

.icon-xs {
  width: 14px;
  height: 14px;
}
.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-lg {
  width: 24px;
  height: 24px;
}
.icon-xl {
  width: 32px;
  height: 32px;
}

.icon-logo {
  color: var(--accent);
}

.nav-links .icon {
  width: 20px;
  height: 20px;
}
.nav-links a.active .icon {
  color: #fff;
}

.agent-avatar .icon {
  color: var(--accent);
}
.badge .icon {
  vertical-align: -2px;
}
.btn .icon {
  vertical-align: -2px;
}

.welcome-message h2 .icon {
  color: var(--accent);
  vertical-align: -4px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* Project Meta Row */
.project-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.vision-panel .vision-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.values-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag-value {
  background: var(--purple) 15;
  color: var(--purple);
  border: 1px solid var(--purple) 40;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xl);
  font-size: 0.75rem;
  font-weight: 500;
}
.label-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.lead-agent-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-panel .input-group {
  display: flex;
  gap: 0.5rem;
}
.chat-panel .input {
  flex: 1;
}
.typing-indicator {
  display: inline-flex;
  gap: 4px;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--purple);
  opacity: 0.4;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typing {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block;
}

/* Project card values */
.project-card-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.project-card-values .tag-value {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}
.project-card-agents {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

/* Pattern execution bar */
.conv-pattern-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}
.conv-pattern-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
}
.badge-purple {
  background: rgba(124, 58, 237, 0.12);
  color: var(--purple-deep);
  border: 1px solid rgba(124, 58, 237, 0.25);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Enhanced message bubbles */
.msg-sender-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}
.msg-to-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.msg-to-name {
  font-size: 0.75rem;
  font-weight: 500;
}
.msg-role-tag {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  margin-left: auto;
}
.msg-model-tag,
.msg-tokens-tag {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 6px;
  padding: 0 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.msg-badge-instruction {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue-light);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: var(--text-xs);
  padding: 1px 6px;
  border-radius: var(--radius-md);
  font-weight: 600;
}
.from-system .msg-bubble-wrap {
  background: transparent;
  text-align: center;
  padding: 4px 0;
}
.from-system .msg-system-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.typing-dots span {
  animation: typingDot 1.4s infinite;
  opacity: 0;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingDot {
  0%,
  60%,
  100% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
}

/* Agent status dot animation */
.agent-status-dot.thinking {
  background: var(--yellow-deep);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Pattern preview box */
.pattern-preview-box {
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}
.pp-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.pp-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 6px;
}
.pp-agent-chip {
  background: rgba(124, 58, 237, 0.1);
  color: var(--purple-deep);
  border: 1px solid rgba(124, 58, 237, 0.2);
  padding: var(--radius-xs) var(--space-2);
  border-radius: var(--radius-xl);
  font-size: var(--text-base);
  font-weight: 500;
}
.pp-type {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.form-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Workflows */
.workflows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  padding: 20px;
}
.workflow-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 20px;
  transition: border-color 0.2s;
}
.workflow-card:hover {
  border-color: var(--purple);
}
.wf-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.wf-card-title {
  margin: 0;
  font-size: 1.1rem;
}
.wf-card-desc {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.wf-phases {
  padding: 8px 0;
}
.wf-phase {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.wf-phase-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.12);
  color: var(--purple);
  font-size: var(--text-base);
  font-weight: 700;
  flex-shrink: 0;
}
.wf-phase-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wf-phase-info strong {
  font-size: 0.85rem;
}
.wf-phase-pattern {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.wf-phase-gate {
  font-size: var(--text-xs);
  color: var(--yellow-deep);
  background: rgba(245, 158, 11, 0.08);
  padding: 1px 6px;
  border-radius: var(--radius-lg);
}
.wf-phase-arrow {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2px 0 2px 8px;
}
.wf-card-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* Tool calls in message bubbles */
.msg-tools {
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}
.msg-tool-call {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 2px 0;
}
.msg-tool-icon {
  font-size: 0.7rem;
}
.msg-tool-name {
  font-weight: 600;
  color: var(--purple);
  white-space: nowrap;
}
.msg-tool-result {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
  opacity: 0.7;
}

/* Workflow editor */
.btn-danger {
  background: var(--red-deep);
  color: var(--text-on-accent);
}
.btn-danger:hover {
  background: var(--red);
}

/* Loading indicator for agent thinking */
.msg-loading-indicator {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 20px;
  font-size: 0.85rem;
  color: var(--purple);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10;
}
.msg-loading-indicator.htmx-indicator {
  display: none;
}
.htmx-request .msg-loading-indicator.htmx-indicator,
.htmx-request.msg-loading-indicator.htmx-indicator {
  display: block;
}
.loading-dots span {
  animation: dotBlink 1.4s infinite;
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes dotBlink {
  0%,
  80%,
  100% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════════
   VIEW SWITCHER — Apple-style toggle bar
   ═══════════════════════════════════════════════════════════════ */

.view-switcher {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 3px;
  margin-right: 8px;
}
.vs-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.vs-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.vs-btn.active {
  background: rgba(167, 139, 250, 0.2);
  color: var(--purple);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   UNIFIED ITEM GRID — Shared card system for all list pages
   ═══════════════════════════════════════════════════════════════ */

/* ---- Base card structure ---- */
.item-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto;
  grid-template-areas: "icon main meta" "icon detail actions";
  gap: 0 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.item-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  background: rgba(167, 139, 250, 0.04);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.item-card:hover {
  border-color: var(--purple);
  transform: translateY(-1px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(167, 139, 250, 0.1);
}
.item-card:hover::before {
  opacity: 1;
}

.item-icon {
  grid-area: icon;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}
.item-main {
  grid-area: main;
  min-width: 0;
}
.item-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}
.item-detail {
  grid-area: detail;
}
.item-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.item-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
  text-transform: capitalize;
}
.item-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.item-tag {
  font-size: 0.65rem;
  background: rgba(167, 139, 250, 0.1);
  color: var(--purple);
  padding: 2px 8px;
  border-radius: var(--radius-lg);
  white-space: nowrap;
}
.item-badge {
  font-size: 0.65rem;
  background: rgba(63, 185, 80, 0.12);
  color: var(--green);
  padding: 2px 8px;
  border-radius: var(--radius-lg);
  white-space: nowrap;
}
.item-badge.muted {
  background: rgba(158, 149, 176, 0.1);
  color: var(--text-secondary);
}
.item-badge.accent {
  background: rgba(167, 139, 250, 0.12);
  color: var(--purple);
}

/* Agent dot (colored circle with icon) */
.agent-dot {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Agent avatar circles */
.agent-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.agent-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  flex-shrink: 0;
}

/* Project type dot */
.project-type-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  background: var(--text-secondary);
  margin-top: 5px;
}
.project-type-dot.sf {
  background: var(--blue);
}
.project-type-dot.mf {
  background: var(--purple);
}
.project-type-dot.manual {
  background: var(--yellow);
}

/* Workflow mini phases */
.wf-mini-phases {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.wf-mini-dot {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: rgba(167, 139, 250, 0.15);
  color: var(--purple);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-mini-arrow {
  font-size: 0.6rem;
  color: var(--text-secondary);
}

/* Status dots */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--text-secondary);
  display: inline-block;
  margin-top: 5px;
}
.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.status-dot.done {
  background: var(--blue);
}
.status-dot.idle {
  background: var(--text-secondary);
}

/* Empty state */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.empty-state .btn {
  margin-top: 12px;
}

/* ── Tab inline toolbar (view switcher + actions inside tab content) ── */
.tab-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0 4px;
}
.tab-toolbar .view-switcher {
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   VIEW MODES — Applied via data-view attribute on .item-grid
   ═══════════════════════════════════════════════════════════════ */

/* — CARD (full detail, grid) — */
.item-grid[data-view="card"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 4px;
}
.item-grid[data-view="card"] .item-card {
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "icon main meta"
    "icon detail detail"
    ". actions actions";
}

/* — CARD-SIMPLE (Apple-style minimal) — */
.item-grid[data-view="card-simple"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 4px;
}
.item-grid[data-view="card-simple"] .item-card {
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon main";
  padding: 14px 16px;
  border-radius: var(--radius-xl);
  gap: 0 12px;
}
.item-grid[data-view="card-simple"] .item-detail,
.item-grid[data-view="card-simple"] .item-meta,
.item-grid[data-view="card-simple"] .item-actions,
.item-grid[data-view="card-simple"] .item-desc,
.item-grid[data-view="card-simple"] .item-tags,
.item-grid[data-view="card-simple"] .wf-mini-phases {
  display: none;
}
.item-grid[data-view="card-simple"] .item-title {
  font-size: 0.88rem;
  -webkit-line-clamp: 1;
}

/* — LIST (horizontal rows) — */
.item-grid[data-view="list"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px;
}
.item-grid[data-view="list"] .item-card {
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "icon main meta actions";
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  align-items: center;
}
.item-grid[data-view="list"] .item-detail {
  display: none;
}
.item-grid[data-view="list"] .item-desc {
  display: none;
}
.item-grid[data-view="list"] .item-tags {
  display: none;
}
.item-grid[data-view="list"] .wf-mini-phases {
  display: none;
}
.item-grid[data-view="list"] .item-subtitle {
  display: inline;
  margin: 0 0 0 8px;
  font-size: 0.72rem;
}
.item-grid[data-view="list"] .item-main {
  display: flex;
  align-items: baseline;
  gap: 0;
  flex-wrap: nowrap;
}
.item-grid[data-view="list"] .item-title {
  font-size: 0.85rem;
  flex-shrink: 0;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* — LIST-COMPACT (dense, tight rows) — */
.item-grid[data-view="list-compact"] {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.item-grid[data-view="list-compact"] .item-card {
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "icon main meta";
  padding: 7px 14px;
  border-radius: 0;
  border: none;
  background: var(--bg-secondary);
  gap: 0 10px;
}
.item-grid[data-view="list-compact"] .item-card:hover {
  transform: none;
  box-shadow: none;
  background: var(--bg-tertiary);
}
.item-grid[data-view="list-compact"] .item-card::before {
  display: none;
}
.item-grid[data-view="list-compact"] .item-detail,
.item-grid[data-view="list-compact"] .item-actions,
.item-grid[data-view="list-compact"] .item-desc,
.item-grid[data-view="list-compact"] .item-tags,
.item-grid[data-view="list-compact"] .wf-mini-phases {
  display: none;
}
.item-grid[data-view="list-compact"] .item-icon {
  align-items: center;
}
.item-grid[data-view="list-compact"] .item-icon .agent-dot {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-md);
}
.item-grid[data-view="list-compact"] .item-icon .agent-dot .icon {
  width: 12px;
  height: 12px;
}
.item-grid[data-view="list-compact"] .item-icon .agent-avatar-circle {
  width: 24px;
  height: 24px;
}
.item-grid[data-view="list-compact"] .agent-avatar-circle .icon {
  width: 12px;
  height: 12px;
}
.item-grid[data-view="list-compact"] .item-icon .icon-md {
  width: 16px;
  height: 16px;
}
.item-grid[data-view="list-compact"] .item-main {
  display: flex;
  align-items: baseline;
  gap: 0;
  min-width: 0;
}
.item-grid[data-view="list-compact"] .item-title {
  font-size: 0.8rem;
  font-weight: 500;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-grid[data-view="list-compact"] .item-subtitle {
  display: inline;
  margin: 0 0 0 8px;
  font-size: 0.68rem;
}
.item-grid[data-view="list-compact"] .item-badge {
  font-size: 0.6rem;
  padding: 1px 6px;
}

/* ═══════════════════════════════════════════════════════════════
   SMALL APPLE REFINEMENTS
   ═══════════════════════════════════════════════════════════════ */

/* Ghost button */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-ghost:hover {
  border-color: var(--purple);
  color: var(--text-primary);
  background: rgba(167, 139, 250, 0.06);
}

/* Skill preview panel stays below grid */
.skill-preview-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-secondary);
  min-height: 40px;
  overflow: hidden;
  transition: min-height 0.2s;
}
.skill-preview-panel.collapsed #skill-preview-body { display: none; }
.skill-preview-toggle {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 10px 16px;
  background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; text-align: left; letter-spacing: 0.3px;
  transition: color 0.15s, background 0.15s;
}
.skill-preview-toggle:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.skill-preview-panel.collapsed .skill-preview-toggle { border-bottom: none; }
#skill-preview-chevron { transition: transform 0.2s; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   GITHUB SOURCES PANEL
   ═══════════════════════════════════════════════════════════════ */

.gh-sources-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.gh-sources-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.gh-sources-header h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}
.gh-sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.gh-source-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
}
.gh-source-repo {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.gh-source-repo:hover {
  color: var(--purple);
}
.gh-source-path {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}
.gh-source-meta {
  color: var(--text-secondary);
  font-size: 0.65rem;
}
.gh-source-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0 2px;
  line-height: 1;
}
.gh-source-remove:hover {
  color: var(--red);
}

.gh-add-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.gh-add-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 5px 10px;
  font-size: 0.75rem;
  color: var(--text-primary);
  outline: none;
}
.gh-add-input:focus {
  border-color: var(--purple);
}
.gh-add-input::placeholder {
  color: var(--text-secondary);
}
.gh-add-input {
  width: 180px;
}
.gh-add-path {
  width: 120px;
}
.gh-add-branch {
  width: 70px;
}

.gh-sync-result {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-lg);
  display: inline-block;
}
.gh-sync-result.success {
  color: var(--green);
}
.gh-sync-result.error {
  color: var(--red);
}

/* Skills toolbar — search, filters, pagination */
.skills-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.skills-search {
  flex: 1;
  min-width: 200px;
}
.search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: var(--purple);
}
.search-input::placeholder {
  color: var(--text-secondary);
}
.skills-filters {
  display: flex;
  gap: 6px;
  align-items: center;
}
.filter-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 10px;
  font-size: 0.75rem;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: auto;
}
.filter-select:focus {
  border-color: var(--purple);
}
.skills-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
}
.pagination-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--purple);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.pagination-btn:hover {
  background: var(--bg-tertiary);
}
.pagination-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   PROJECT CHAT LAYOUT (ChatGPT-style)
   ═══════════════════════════════════════════════════════════════ */

.project-chat-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  height: calc(100vh - 64px);
  margin: -20px;
}

.project-chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 48px;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  max-width: 760px;
}
.chat-msg-user {
  flex-direction: row-reverse;
  margin-left: auto;
}
.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--purple);
  font-size: 0.75rem;
}
.chat-msg-avatar.user {
  background: var(--purple);
  color: white;
  font-weight: 600;
}
.chat-msg-body {
  flex: 1;
  min-width: 0;
}
.chat-msg-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 2px;
}
.chat-msg-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-user .chat-msg-text {
  background: rgba(167, 139, 250, 0.12);
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.chat-tool-pill {
  font-size: 0.65rem;
  background: rgba(167, 139, 250, 0.08);
  color: var(--purple);
  padding: 2px 8px;
  border-radius: var(--radius-lg);
}

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 48px;
}
.chat-welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: rgba(167, 139, 250, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.chat-welcome h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.chat-welcome p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  max-width: 400px;
  margin-bottom: 20px;
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chat-suggestion {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.chat-suggestion:hover {
  border-color: var(--purple);
  color: var(--text-primary);
}

/* Loading */
.chat-loading {
  display: none;
}
.htmx-request ~ .chat-loading,
.chat-loading.htmx-request {
  display: block;
}
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--purple);
  border-radius: var(--radius-full);
  animation: dotBlink 1.4s infinite;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Input bar */
.chat-input-bar {
  padding: 12px 48px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 12px;
  transition: border-color 0.2s;
}
.chat-input-row:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.15);
}
.chat-input-row textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 120px;
}
.chat-input-row textarea::placeholder {
  color: var(--text-secondary);
}
.chat-send-btn {
  background: var(--purple);
  border: none;
  border-radius: var(--radius-lg);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chat-send-btn:hover {
  background: var(--purple);
  transform: scale(1.05);
}

/* Project sidebar */
.project-sidebar {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  height: 100%;
}
.ps-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.ps-section:last-child {
  border-bottom: none;
}
.ps-section h4 {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.ps-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.ps-empty {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}
.ps-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ps-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.ps-pipe-step {
  font-size: 0.68rem;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.ps-pipe-arrow {
  font-size: 0.6rem;
  color: var(--text-secondary);
}
.ps-workflow-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-primary);
}
.ps-workflow-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.ps-workflow-desc {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}
.ps-workflow-actions {
  display: flex;
  gap: 6px;
}
.ps-workflow-actions .btn {
  font-size: 0.7rem;
  padding: 3px 10px;
}

/* Responsive: collapse sidebar on small screens */
@media (max-width: 900px) {
  .project-chat-layout {
    grid-template-columns: 1fr;
  }
  .project-sidebar {
    display: none;
  }
  .project-sidebar.open {
    display: block;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    z-index: 100;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  }
}

/* ── Tablet (768px - 900px) ── */
@media (max-width: 900px) {
  .dora-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dora-card[style*="span 2"] {
    grid-column: span 2;
  }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100% !important;
    height: 56px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    z-index: 200;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .sidebar-header,
  .sidebar-footer,
  .sidebar-section-title {
    display: none;
  }
  .sidebar-section {
    padding: 0;
    display: flex;
  }
  .nav-links {
    display: flex;
    flex-direction: row;
    gap: 0;
    width: 100%;
    justify-content: space-around;
  }
  .nav-links li {
    width: auto;
  }
  .nav-links a {
    padding: 8px 12px;
    justify-content: center;
    border-left: none !important;
  }
  .nav-links a::after {
    display: none;
  }
  .nav-links a.active {
    border-left: none;
    border-bottom: 3px solid var(--purple-light);
  }

  .main-content {
    padding-bottom: 64px;
  }
  .topbar {
    padding: 0.75rem 1rem;
  }
  .topbar h2 {
    font-size: 1.1rem;
  }
  .dora-grid {
    grid-template-columns: 1fr;
  }
  .dora-card[style*="span 2"] {
    grid-column: span 1;
  }
  .dora-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Small phone (< 480px) ── */
@media (max-width: 480px) {
  .nav-links a {
    padding: 8px 6px;
  }
  .nav-links a .icon {
    width: 18px;
    height: 18px;
  }
  .topbar h2 {
    font-size: 1rem;
  }
  .card {
    padding: 0.75rem;
  }
}

/* ── PWA safe-area insets (iPhone notch / home bar) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  @media (max-width: 768px) {
    .main-content {
      padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }
  }
}

/* ── PWA standalone mode adjustments ── */
@media (display-mode: standalone) {
  .topbar {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
}

/* ── Light theme refinements ── */
[data-theme="light"] .sidebar {
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .topbar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .card,
[data-theme="light"] .ds-token,
[data-theme="light"] .ds-showcase {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .sidebar .nav-links a.active {
  background: var(--purple);
  color: #fff;
}
[data-theme="light"] .sidebar .nav-links a:hover {
  background: var(--bg-tertiary);
}

/* ── PWA / Mobile sidebar collapse (max-width: 768px) ── */
@media (max-width: 768px) {
  .sidebar .nav-links a span { display: none; }
}
