:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #13151f;
  --bg-card: rgba(23, 26, 38, 0.7);
  --bg-card-hover: rgba(30, 34, 50, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(225, 48, 108, 0.3);
  
  /* Instagram Signature Gradient & Accents */
  --insta-pink: #e1306c;
  --insta-purple: #833ab4;
  --insta-orange: #fd1d1d;
  --insta-yellow: #fcaf45;
  --accent-blue: #38bdf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  line-height: 1.5;
}

/* Ambient glow orbs */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}
.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--insta-pink), transparent);
  top: -100px;
  left: -100px;
}
.orb-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, var(--insta-purple), transparent);
  bottom: -50px;
  right: -50px;
}
.orb-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--insta-orange), transparent);
  top: 40%;
  left: 45%;
}

.app-container {
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--insta-purple), var(--insta-pink), var(--insta-orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 20px rgba(225, 48, 108, 0.4);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.gradient-text {
  background: linear-gradient(90deg, #fd1d1d, #e1306c, #833ab4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  min-height: 44px; /* Mobile touch target */
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--insta-pink), var(--insta-purple));
  color: white;
  box-shadow: 0 4px 15px rgba(225, 48, 108, 0.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(225, 48, 108, 0.5);
}

.btn-glow {
  background: linear-gradient(135deg, #e1306c, #fd1d1d);
  color: white;
  width: 100%;
  justify-content: center;
  padding: 0.85rem;
  font-size: 1rem;
  box-shadow: 0 6px 20px rgba(225, 48, 108, 0.4);
}
.btn-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(225, 48, 108, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-color);
  backdrop-filter: blur(10px);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}
.btn-outline:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
  width: 100%;
  justify-content: center;
  padding: 0.85rem;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  min-height: 36px;
  font-size: 0.82rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.icon-total { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); }
.icon-completed { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.icon-active { background: rgba(225, 48, 108, 0.15); color: var(--insta-pink); }
.icon-skipped { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
  line-height: 1.2;
}
.text-success { color: var(--accent-green); }
.text-active { color: var(--insta-pink); }
.text-accent { color: var(--accent-blue); }

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.tab-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  gap: 0.3rem;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-weight: 600;
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.2s;
  touch-action: manipulation;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

.textarea-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.textarea-header label {
  margin-bottom: 0 !important;
}
.textarea-wrapper label,
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  height: 160px;
  background: rgba(10, 11, 16, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus {
  border-color: var(--insta-pink);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.2);
}

.file-drop-area {
  margin-top: 0.75rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.file-drop-area:hover {
  border-color: var(--insta-pink);
  background: rgba(225, 48, 108, 0.05);
}
.file-drop-area input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.speed-selector-row {
  margin: 0.9rem 0 0.5rem 0;
}
.speed-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.speed-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.speed-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
  min-height: 40px;
}
.speed-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.speed-pill.active {
  background: linear-gradient(135deg, rgba(225, 48, 108, 0.3), rgba(131, 58, 180, 0.3));
  border-color: var(--insta-pink);
  color: #fff;
  box-shadow: 0 2px 10px rgba(225, 48, 108, 0.25);
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.1rem 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-pill input {
  accent-color: var(--insta-pink);
  width: 18px;
  height: 18px;
}

.engine-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.25rem 0.55rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.form-group {
  margin-bottom: 1.15rem;
}
.form-group input {
  width: 100%;
  min-height: 44px;
  background: rgba(10, 11, 16, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
}
.form-group input:focus {
  border-color: var(--insta-pink);
}

.input-with-icon {
  position: relative;
}
.input-with-icon i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-with-icon input {
  padding-left: 2.6rem;
}

/* Queue Panel */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}
.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.throttle-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(225, 48, 108, 0.2));
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.queue-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 0.2rem;
}
.queue-container::-webkit-scrollbar {
  width: 5px;
}
.queue-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Item Card - Responsive Layout */
.reel-card {
  background: rgba(15, 17, 26, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.reel-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.reel-card.status-completed {
  border-left: 4px solid var(--accent-green);
}
.reel-card.status-downloading {
  border-left: 4px solid var(--insta-pink);
}
.reel-card.status-failed {
  border-left: 4px solid var(--accent-red);
}

.reel-thumb {
  width: 64px;
  height: 84px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.5);
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 1.3rem;
  overflow: hidden;
}

.reel-info {
  flex: 1;
  min-width: 0;
}
.reel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.3rem;
  gap: 0.5rem;
}
.reel-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.reel-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--insta-purple), var(--insta-pink));
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.success {
  background: var(--accent-green);
}
.progress-fill.failed {
  background: var(--accent-red);
}

.reel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-completed { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.badge-downloading { background: rgba(225, 48, 108, 0.2); color: var(--insta-pink); }
.badge-pending { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }
.badge-failed { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2.5rem;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
}
.empty-state h3 {
  color: var(--text-main);
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}
.empty-state p {
  font-size: 0.88rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open {
  display: flex;
}
.modal-card {
  background: #151824;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #151824;
  z-index: 2;
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text-main);
}
.modal-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.setting-item h4 {
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}
.browser-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.browser-selector label {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 0.65rem 0.75rem;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.cookie-upload-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.cookie-upload-row input[type="file"] {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
}
.range-inputs {
  display: flex;
  gap: 0.75rem;
}
.range-inputs div {
  flex: 1;
}
.range-inputs input {
  width: 100%;
  min-height: 42px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  margin-top: 0.3rem;
  font-family: var(--font-mono);
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: #151824;
}

/* ==========================================================================
   📱 COMPREHENSIVE MOBILE & TABLET RESPONSIVENESS (Media Queries)
   ========================================================================== */

/* Tablets & Small Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .app-container {
    padding: 1.5rem 1rem;
  }
  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Phones (<= 768px) */
@media (max-width: 768px) {
  .app-container {
    padding: 1rem 0.75rem;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .brand {
    justify-content: flex-start;
  }
  .brand-icon {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
  }
  .brand h1 {
    font-size: 1.45rem;
  }
  .subtitle {
    font-size: 0.78rem;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    width: 100%;
  }
  .header-actions .btn {
    width: 100%;
    padding: 0.6rem 0.5rem;
    font-size: 0.82rem;
  }

  /* Stats grid: 2 columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 0.75rem 0.85rem;
    gap: 0.75rem;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 8px;
  }
  .stat-label {
    font-size: 0.68rem;
  }
  .stat-value {
    font-size: 1.15rem;
  }

  .panel {
    padding: 1.1rem;
    border-radius: var(--radius-md);
  }

  .tab-btn {
    font-size: 0.82rem;
    padding: 0.5rem;
  }

  textarea {
    height: 130px;
    font-size: 0.8rem;
  }

  /* Reel Card on Mobile */
  .reel-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .reel-thumb {
    width: 54px;
    height: 72px;
  }

  .reel-info {
    flex: 1;
    min-width: calc(100% - 68px);
  }

  .reel-title {
    font-size: 0.85rem;
    max-width: 170px;
  }

  .reel-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.25rem;
  }
  .reel-actions .btn {
    width: 100%;
  }

  /* Browser Selector inside Modal */
  .browser-selector {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modal-backdrop {
    padding: 0.5rem;
  }
  .modal-card {
    max-height: 95vh;
  }
  .modal-header, .modal-body, .modal-footer {
    padding: 1rem;
  }
}

/* Extra Small Phones (<= 420px) */
@media (max-width: 420px) {
  .header-actions {
    grid-template-columns: 1fr;
  }
  .browser-selector {
    grid-template-columns: 1fr;
  }
  .control-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
}
