:root {
  --bg-app: #0f1117;
  --bg-card: #181c27;
  --bg-card-hover: #1f2433;
  --bg-input: #12151e;
  
  --border-subtle: #272d3f;
  --border-focus: #e1306c;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --insta-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  --insta-pink: #e1306c;
  --insta-blue: #0095f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-phone: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: rgba(24, 28, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--insta-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 15px rgba(225, 48, 108, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #f09433;
  letter-spacing: 0.05em;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-input);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: #fff;
}

.nav-btn.active {
  background: var(--bg-card);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.badge-pill {
  background: rgba(225, 48, 108, 0.2);
  color: var(--insta-pink);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
}

/* Account Status Pill */
.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.95rem;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
  white-space: nowrap;
}

.account-pill.connected {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--accent-green);
  color: #fff;
}

.account-pill.disconnected {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.account-pill:hover {
  transform: translateY(-1px);
  border-color: var(--insta-pink);
}

/* Header Actions & Logout Button */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-logout svg {
  color: #94a3b8;
  transition: color 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  transform: translateY(-1px);
}

.btn-logout:hover svg {
  color: #fca5a5;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
}

.account-pill.connected .status-indicator {
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

/* Main Container */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Composer Grid */
.composer-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2.5rem;
  align-items: start;
}

.composer-form-card, .section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  margin-bottom: 1.75rem;
}

.card-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.sub-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.5rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.tip-link {
  font-size: 0.8rem;
  color: var(--insta-pink);
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}

.tip-link:hover {
  text-decoration: underline;
}

.text-input, .select-input, .caption-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-input:focus, .select-input:focus, .caption-textarea:focus {
  border-color: var(--insta-pink);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.15);
}

.input-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Format Buttons */
.format-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.format-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all 0.2s;
}

.format-btn:hover {
  border-color: var(--insta-pink);
  color: #fff;
}

.format-btn.active {
  background: rgba(225, 48, 108, 0.12);
  border-color: var(--insta-pink);
  color: #fff;
}

/* AI Sparkle Button */
.btn-ai-sparkle {
  background: linear-gradient(135deg, rgba(240, 148, 51, 0.2), rgba(225, 48, 108, 0.2));
  border: 1px solid rgba(225, 48, 108, 0.4);
  color: #ffb3d9;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-ai-sparkle:hover {
  background: var(--insta-gradient);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}

.caption-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
}

/* Schedule Toggle Box */
.schedule-box {
  background: var(--bg-input);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background: #334155;
  border-radius: 20px;
  position: relative;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.3s;
}

.toggle-control input:checked + .toggle-slider {
  background: var(--insta-pink);
}

.toggle-control input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.schedule-input-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.schedule-input-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Action Buttons */
.action-buttons-row {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.btn-primary {
  flex: 1;
  background: var(--insta-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-shadow: 0 4px 20px rgba(225, 48, 108, 0.4);
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(225, 48, 108, 0.6);
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--insta-pink);
}

.btn-secondary-sm {
  background: var(--bg-input);
  border: 1px dashed var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-secondary-sm:hover {
  border-color: var(--insta-pink);
  color: #fff;
}

/* Smartphone Live Mockup */
.preview-wrapper {
  position: sticky;
  top: 6.5rem;
  display: flex;
  justify-content: center;
}

.phone-frame {
  width: 380px;
  background: #000;
  border: 10px solid #232733;
  border-radius: 44px;
  box-shadow: var(--shadow-phone);
  overflow: hidden;
  position: relative;
}

.phone-notch {
  width: 140px;
  height: 20px;
  background: #232733;
  margin: 0 auto;
  border-radius: 0 0 16px 16px;
  position: relative;
  z-index: 10;
}

.insta-mockup {
  background: #000;
  min-height: 580px;
  color: #fff;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
}

.insta-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  gap: 0.75rem;
}

.insta-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #222;
  border: 2px solid var(--insta-pink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  overflow: hidden;
}

.insta-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.insta-user-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.insta-username {
  font-weight: 700;
  font-size: 0.85rem;
}

.insta-location {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.insta-options {
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.insta-media-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #12151e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.insta-media-box img, .insta-media-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-media-placeholder {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-media-placeholder span {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.empty-media-placeholder p {
  font-size: 0.8rem;
  line-height: 1.4;
}

.insta-actions {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.4rem;
}

.left-actions {
  display: flex;
  gap: 1rem;
}

.action-icon {
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.15s;
}

.action-icon:hover {
  transform: scale(1.15);
}

.insta-caption-box {
  padding: 0.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.insta-likes {
  font-size: 0.82rem;
}

.insta-caption-text {
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow-y: auto;
}

.insta-caption-text strong {
  margin-right: 0.35rem;
}

.insta-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 0.2rem;
}

/* Queue List */
.queue-list {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.queue-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.queue-thumb {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-sm);
  background: #000;
  object-fit: cover;
  flex-shrink: 0;
}

.queue-info {
  flex: 1;
}

.queue-status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.35rem;
}

.status-published { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.status-scheduled { background: rgba(0, 149, 246, 0.2); color: var(--insta-blue); }
.status-failed { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.queue-caption {
  font-size: 0.85rem;
  color: #cbd5e1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-actions {
  display: flex;
  gap: 0.5rem;
}

/* Settings Grid & Tutorial */
.settings-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
}

.guide-card {
  background: linear-gradient(145deg, #181c27, #131720);
}

.step-guide {
  padding-left: 1.25rem;
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.step-guide li strong {
  color: #fff;
}

.step-guide li p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.step-guide a {
  color: var(--insta-pink);
  text-decoration: none;
  font-weight: 600;
}

.step-guide code {
  background: var(--bg-input);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #f09433;
  font-family: 'JetBrains Mono', monospace;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.form-group-row {
  display: flex;
  gap: 1rem;
}

.flex-1 { flex: 1; }

.ai-result-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
}

.ai-result-box h4 {
  font-size: 0.85rem;
  color: var(--insta-pink);
  margin-bottom: 0.5rem;
}

.ai-result-box pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.85rem;
  color: #cbd5e1;
  max-height: 180px;
  overflow-y: auto;
}

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.preset-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.preset-card:hover {
  transform: translateY(-2px);
  border-color: var(--insta-pink);
}

.preset-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
}

.preset-card-body {
  padding: 0.75rem;
}

.preset-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.preset-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

@media (max-width: 1024px) {
  .composer-grid, .settings-grid {
    grid-template-columns: 1fr;
  }
  .preview-wrapper {
    position: static;
  }
}

/* ================= AUTH GATE SCREEN ================= */
.auth-gate-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1b2030 0%, #0d0f17 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1.5rem;
}

.auth-card {
  background: rgba(22, 26, 38, 0.95);
  border: 1px solid rgba(225, 48, 108, 0.35);
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 2.75rem 2.25rem;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 40px rgba(225, 48, 108, 0.15);
  backdrop-filter: blur(20px);
  animation: authFadeIn 0.3s ease-out;
}

@keyframes authFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-icon-badge {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, rgba(240, 148, 51, 0.2), rgba(225, 48, 108, 0.25));
  border: 1px solid rgba(225, 48, 108, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
  box-shadow: 0 0 25px rgba(225, 48, 108, 0.3);
}

.auth-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.6rem;
  letter-spacing: -0.02em;
}

.auth-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 2rem;
}

.auth-input {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #0f1118;
}

.auth-input:focus {
  border-color: var(--insta-pink);
  box-shadow: 0 0 15px rgba(225, 48, 108, 0.3);
}

.auth-error {
  margin-top: 1.25rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.85rem;
  font-weight: 600;
}
