:root {
  color-scheme: dark;
  --bg: #0c0e14;
  --surface: #12151f;
  --surface-2: #181c29;
  --surface-hover: #1f2436;
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #8492a6;

  /* Intentional brand accent (Indigo-Cobalt) */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-ring: rgba(99, 102, 241, 0.28);

  /* Platform accent (updated via body[data-platform]) */
  --platform-color: #f43f5e;
  --platform-soft: rgba(244, 63, 94, 0.14);
  --platform-border: rgba(244, 63, 94, 0.38);

  /* Semantic colors */
  --green: #10b981;
  --red: #f43f5e;
  --amber: #f59e0b;
  --sky: #38bdf8;

  /* Elevation & shape */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --radius: 10px;
  --radius-sm: 7px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, monospace;
}

body[data-platform='instagram'] {
  --platform-color: #fb7185;
  --platform-soft: rgba(244, 63, 94, 0.14);
  --platform-border: rgba(251, 113, 133, 0.4);
}

body[data-platform='facebook'] {
  --platform-color: #60a5fa;
  --platform-soft: rgba(59, 130, 246, 0.14);
  --platform-border: rgba(96, 165, 250, 0.4);
}

body[data-platform='twitter'] {
  --platform-color: #38bdf8;
  --platform-soft: rgba(56, 189, 248, 0.14);
  --platform-border: rgba(56, 189, 248, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 80% 45% at 50% -10%, rgba(99, 102, 241, 0.11), transparent 65%),
    var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

svg.icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(12, 14, 20, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.brand h1 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 780px) {
  .subtitle {
    display: none;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.export-group {
  display: flex;
  gap: 0.35rem;
}

/* ---------------- App Shell Layout ---------------- */
.workspace {
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Left Sidebar ---------------- */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.control-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

.panel-scroll::-webkit-scrollbar {
  width: 6px;
}

.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
}

.panel-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
}

.panel-footer {
  flex-shrink: 0;
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--border);
  background: rgba(18, 21, 31, 0.96);
  backdrop-filter: blur(8px);
}

.advanced-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.48rem 0.7rem;
  margin-top: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.advanced-toggle-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.advanced-toggle-btn .chevron {
  transition: transform 0.18s ease;
}

.advanced-toggle-btn[aria-expanded='true'] .chevron {
  transform: rotate(180deg);
}

@media (max-width: 960px) {
  .panel {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .panel-scroll {
    overflow-y: visible;
  }
}

.panel-section {
  padding: 1.05rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.panel-section h2 {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.section-header h2 {
  margin: 0;
}

/* Platform-tinted Switcher Dropdown */
.platform-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.25rem 1.65rem 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--platform-border);
  background:
    var(--platform-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 0.5rem center;
  color: var(--platform-color);
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
  outline: none;
  transition: filter 0.15s, box-shadow 0.15s;
}

.platform-select:hover {
  filter: brightness(1.12);
}

.platform-select:focus {
  box-shadow: 0 0 0 3px var(--platform-soft);
}

.platform-select option {
  background: var(--surface-2);
  color: var(--text);
}

.platform-notice {
  font-size: 0.76rem;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.85rem;
}

.field {
  margin-bottom: 0.75rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.field input[type='text'],
.field input[type='number'],
.field input[type='date'],
.field input[type='password'],
.field select {
  width: 100%;
  padding: 0.5rem 0.68rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.83rem;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:hover,
.field select:hover {
  border-color: var(--border-strong);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.field-row .field {
  margin-bottom: 0;
}

/* Segmented Control */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.seg-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.38rem 0.45rem;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.seg-btn:hover {
  color: var(--text-secondary);
}

.seg-btn.active {
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.38);
  color: #c7d2fe;
  font-weight: 600;
}

/* Presets & Checkboxes */
.presets-label {
  display: block;
  font-size: 0.73rem;
  color: var(--muted);
  margin-bottom: 0.38rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.73rem;
  padding: 0.25rem 0.58rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.chip:hover {
  border-color: rgba(99, 102, 241, 0.45);
  background: var(--accent-soft);
  color: #e0e7ff;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.42rem;
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.58rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.79rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.check-pill:has(input:checked) {
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.42);
  color: var(--text);
}

.check-pill input,
.toggle-row input {
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.toggles-stack {
  margin-bottom: 0.9rem;
}

/* Accordion */
.accordion summary {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.accordion summary:hover {
  color: var(--text-secondary);
}

.accordion summary::after {
  content: '+';
  font-size: 0.95rem;
  font-weight: 400;
}

.accordion[open] summary::after {
  content: '−';
}

.accordion-body {
  margin-top: 0.8rem;
}

/* ---------------- Buttons & Pills ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.52rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 0.14s, border-color 0.14s, transform 0.08s, box-shadow 0.14s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  font-weight: 600;
  border-color: rgba(129, 140, 248, 0.4);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-block {
  width: 100%;
  padding: 0.62rem 0.95rem;
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-danger-ghost:hover {
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
  background: rgba(244, 63, 94, 0.1);
}

.btn-sm {
  padding: 0.36rem 0.68rem;
  font-size: 0.76rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s, background-color 0.14s, color 0.14s;
}

.pill:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.badge {
  font-size: 0.71rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.notif-badge,
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 650;
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--muted);
  margin-left: 5px;
}

.notif-badge,
.tab-count.unread {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.22);
}

/* ---------------- Right Content Area ---------------- */
.content-area {
  padding: 1.35rem 1.6rem 2.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* Quick Link Preview Bar */
.quick-bar {
  margin-bottom: 1.05rem;
}

.quick-form {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.4rem 0.4rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.quick-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-sm);
}

.quick-form .icon {
  color: var(--muted);
}

.quick-form input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  padding: 0.4rem 0;
}

.quick-form input::placeholder {
  color: var(--muted);
}

/* Alert */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.alert.error {
  border-color: rgba(244, 63, 94, 0.38);
  background: rgba(244, 63, 94, 0.1);
  color: #fecdd3;
}

.alert.success {
  border-color: rgba(16, 185, 129, 0.38);
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
}

.alert.hidden,
.hidden {
  display: none !important;
}

/* Live Loading & Progress Banner */
.loading-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(18, 21, 31, 0.95));
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: var(--shadow-sm);
}

.loading-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.83rem;
  color: var(--text);
}

.loading-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.loading-elapsed {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-top-color: #818cf8;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #38bdf8);
  width: 0%;
  transition: width 0.25s ease;
}

.progress-fill.indeterminate {
  width: 32%;
  animation: indeterminate 1.3s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(350%); }
}

/* Instant Preview Card */
.instant-preview {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  box-shadow: var(--shadow-md);
}

@media (max-width: 820px) {
  .instant-preview {
    grid-template-columns: 1fr;
  }
}

.preview-media-col {
  position: relative;
  background: #07090e;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 300px;
  border-right: 1px solid var(--border);
}

.preview-media-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  max-height: 440px;
  overflow: hidden;
}

.preview-media-stage img,
.preview-media-stage video {
  width: 100%;
  height: 100%;
  max-height: 440px;
  object-fit: contain;
}

.preview-thumbs {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.preview-info-col {
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.preview-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.preview-caption {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 140px;
  overflow-y: auto;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

/* Compact Inline KPI Strip */
.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.kpi-card {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--muted);
}

.kpi-value {
  font-size: 0.92rem;
  font-weight: 650;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.kpi-value.accent {
  color: #818cf8;
}

.kpi-value.muted {
  color: var(--muted);
}

/* Underlined Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 550;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  transition: color 0.14s;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--text);
}

.tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.tabs-actions {
  display: flex;
  gap: 0.45rem;
  padding-bottom: 0.45rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---------------- Media Grid & Cards ---------------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.post-card:hover {
  border-color: rgba(129, 140, 248, 0.35);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #07090e;
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--border);
}

.card-media img,
.card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.post-card:hover .card-media img {
  transform: scale(1.02);
}

.mock-visual {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem;
  background:
    radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.16), transparent 55%),
    #0e111a;
  color: var(--muted);
}

.mock-visual .mock-code {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Color-coded Media Type Badges */
.media-badge {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  padding: 0.2rem 0.52rem;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 650;
  font-family: var(--font-mono);
  background: rgba(12, 14, 20, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.media-badge.type-carousel {
  border-color: rgba(129, 140, 248, 0.5);
  color: #c7d2fe;
}

.media-badge.type-video,
.media-badge.type-reel {
  border-color: rgba(251, 113, 133, 0.5);
  color: #fecdd3;
}

.media-badge.type-image {
  border-color: rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
}

.card-body {
  padding: 0.85rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
  flex: 1;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.card-user {
  font-weight: 650;
  font-size: 0.85rem;
}

.card-date {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted);
}

.card-caption {
  margin: 0;
  font-size: 0.81rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-top: auto;
  padding-top: 0.25rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag-pill {
  font-size: 0.7rem;
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
}

.card-footer {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

/* Skeleton Cards */
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.skeleton-media {
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, #12151f 25%, #1d2233 50%, #12151f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-line {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #181c29 25%, #252b3f 50%, #181c29 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-line.short { width: 42%; }
.skeleton-line.med { width: 76%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 0.4rem;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
}

.empty-state p {
  margin: 0 auto;
  max-width: 480px;
  font-size: 0.82rem;
}

/* Events Log */
.events-log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.event-row {
  display: grid;
  grid-template-columns: 82px 110px 1fr;
  gap: 0.75rem;
  padding: 0.52rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  font-family: var(--font-mono);
}

.event-row:last-child {
  border-bottom: none;
}

.evt-downloaded { color: var(--green); }
.evt-filtered_out { color: var(--muted); }
.evt-skip_existing { color: var(--amber); }
.evt-early_stop { color: var(--sky); }
.evt-error { color: var(--red); }

/* ---------------- Watchlist & Notifications ---------------- */
.watchlist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.watchlist-add-form {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 240px;
}

.watchlist-add-form input {
  flex: 1;
  padding: 0.48rem 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.83rem;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.watchlist-add-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.watchlist-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 0.85rem;
}

.watch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s;
}

.watch-card:hover {
  border-color: var(--border-strong);
}

.watch-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.watch-handle {
  font-weight: 650;
  font-size: 0.92rem;
}

.watch-meta {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.watch-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.notif-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.notif-item.unread {
  border-color: rgba(99, 102, 241, 0.42);
  background: rgba(99, 102, 241, 0.08);
}

.notif-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.notif-msg {
  font-size: 0.77rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ---------------- Native Dialog Modals ---------------- */
dialog.modal {
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  width: min(840px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72);
}

dialog.auth-modal {
  width: min(465px, 92vw);
}

dialog.modal::backdrop {
  background: rgba(7, 9, 14, 0.76);
  backdrop-filter: blur(5px);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 650;
}

.modal-sub {
  margin: 0.12rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.12s, background-color 0.12s, border-color 0.12s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.lightbox-body {
  padding: 1rem 1.2rem 1.2rem;
  overflow-y: auto;
  max-height: calc(90vh - 64px);
}

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07090e;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 300px;
  max-height: 55vh;
  overflow: hidden;
}

.media-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.media-stage img,
.media-stage video {
  max-width: 100%;
  max-height: 54vh;
  object-fit: contain;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(12, 14, 20, 0.85);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 2;
  transition: border-color 0.14s, background-color 0.14s;
}

.nav-btn:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.25);
}

.nav-btn.prev { left: 10px; }
.nav-btn.next { right: 10px; }

.thumb-strip {
  display: flex;
  gap: 0.38rem;
  margin-top: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.thumb-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.14s, background-color 0.14s;
}

.thumb-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #e0e7ff;
}

.lb-meta {
  margin-top: 0.85rem;
}

.lb-caption {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.lb-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.lb-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.json-details summary {
  cursor: pointer;
  font-size: 0.76rem;
  color: var(--muted);
}

.json-details pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.73rem;
  font-family: var(--font-mono);
  overflow-x: auto;
  max-height: 220px;
}

.auth-form {
  padding: 1rem 1.2rem 1.2rem;
}

.auth-auto-card {
  padding: 1rem 1.05rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.auth-auto-title {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.auth-auto-desc {
  margin: 0 0 0.9rem;
  font-size: 0.79rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.65rem 0 0.95rem;
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(129, 140, 248, 0.45);
  color: #c7d2fe;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.user-avatar.lg {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}
