:root {
  --bg-main: #090d16;
  --bg-sidebar: #0f1626;
  --bg-card: #151e32;
  --bg-card-hover: #1b2640;
  --bg-input: #0b111e;
  --border-color: rgba(255, 255, 255, 0.09);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --purple: #8b5cf6;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Layout Desktop + Mobile */
.app-shell {
  display: flex;
  flex: 1;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar (Desktop) & Top Drawer (Mobile) */
.sidebar {
  width: 285px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sites-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  border: 1px solid transparent;
}

.site-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.site-item.active {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.4);
}

.site-item-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.site-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.site-item.active .site-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.site-item-texts {
  min-width: 0;
  flex: 1;
}

.site-item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-item-domain {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge-mini {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.badge-mini.orange {
  background: rgba(245, 158, 11, 0.18);
  color: var(--orange);
}

.badge-mini.green {
  background: rgba(16, 185, 129, 0.18);
  color: var(--green);
}

.btn-trash {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0.7;
}

.btn-trash:hover {
  opacity: 1;
  color: var(--red);
  background: rgba(239, 68, 68, 0.14);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

/* Main Workspace */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.project-title-group {
  min-width: 0;
  flex: 1;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.project-title-row h1 {
  font-size: 18px;
  font-weight: 800;
}

.project-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.project-tagline {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile Project Switcher (Visible on mobile screens) */
.mobile-project-bar {
  display: none;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  gap: 8px;
}

.mobile-project-select {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 700;
}

/* Segmented Tabs */
.tabs-nav {
  display: flex;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Control Banner */
.autopilot-banner {
  padding: 16px 20px;
  background: rgba(21, 30, 50, 0.65);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.autopilot-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  border: 1px solid transparent;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-pill.green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
}
.status-pill.orange {
  background: rgba(245, 158, 11, 0.16);
  color: var(--orange);
}
.status-pill.blue {
  background: rgba(59, 130, 246, 0.16);
  color: var(--accent);
}
.status-pill.selected {
  border-color: currentColor;
  box-shadow: 0 0 0 1px currentColor;
}

/* Category Filter Chips */
.filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.category-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.alert-banner {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fef3c7;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Scrollable Workspace Content */
.workspace-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 90px;
}

.queue-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.queue-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.15s;
}

.queue-card.status-authRequired {
  border-color: rgba(245, 158, 11, 0.5);
}

.queue-card.status-posted {
  border-color: rgba(16, 185, 129, 0.45);
  opacity: 0.85;
}

.queue-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.queue-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  flex: 1;
}

.queue-card-badges {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.channel-name {
  font-size: 14px;
  font-weight: 700;
}

.cat-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.status-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
}

.status-tag.queued {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}
.status-tag.authRequired {
  background: rgba(245, 158, 11, 0.2);
  color: var(--orange);
}
.status-tag.posted {
  background: rgba(16, 185, 129, 0.2);
  color: var(--green);
}

.queue-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.queue-url-link {
  font-family: 'JetBrains Mono', monospace;
  color: #60a5fa;
  text-decoration: none;
}

.queue-url-link:hover {
  text-decoration: underline;
}

.queue-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.queue-preview {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 12px;
}

.queue-preview-title {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.queue-preview-body {
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-card-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-purple {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.btn-danger {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

/* Forms & Inputs */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 860px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input, .textarea, .select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
}

.textarea {
  min-height: 95px;
  resize: vertical;
}

/* Native HTML5 <dialog> Modals */
dialog.modal {
  margin: auto;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 20px;
  width: min(94vw, 620px);
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

dialog.modal::backdrop {
  background: rgba(5, 8, 16, 0.76);
  backdrop-filter: blur(5px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 8px;
}

.toast.visible {
  display: inline-flex;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 22, 38, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  justify-content: space-around;
}

.mobile-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.mobile-nav-btn.active {
  color: var(--accent);
}

/* Responsive Mobile Rules */
@media (max-width: 860px) {
  .sidebar {
    display: none;
  }
  .mobile-project-bar {
    display: flex;
  }
  .top-header .tabs-nav {
    display: none;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .autopilot-banner {
    padding: 12px 14px;
  }
  .workspace-scroll {
    padding: 12px 14px 96px;
  }
  .toast {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    width: 90vw;
    justify-content: center;
  }
}
