:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --line: #d7dde3;
  --text: #18212a;
  --muted: #667684;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(24, 33, 42, 0.12);
}

/* v2 dashboard shell */
:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #0d131b;
  --surface-2: #141c27;
  --line: #223041;
  --text: #edf4ff;
  --muted: #93a4b8;
  --accent: #9b4dff;
  --accent-2: #22c7a9;
  --danger: #ff6b5d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(146, 81, 255, 0.18), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(34, 199, 169, 0.12), transparent 28%),
    var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 18, 0.92);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark > i {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.brand-mark strong,
.brand-mark span,
.side-nav a {
  display: block;
}

.brand-mark span {
  margin-top: 8px;
  color: #b071ff;
  font-size: 12px;
  font-weight: 700;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
}

.side-nav a:hover,
.side-nav a:focus-visible {
  color: var(--text);
  background: linear-gradient(135deg, rgba(155, 77, 255, 0.45), rgba(45, 33, 111, 0.7));
}

.workspace {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 11, 16, 0.88);
  backdrop-filter: blur(18px);
}

.topbar,
.command-panel,
.metric-grid,
.icloud-panel,
.youtube-panel,
.url-panel,
.result-panel,
.empty-state,
.dashboard-columns {
  width: min(1280px, calc(100% - 48px));
  margin-left: auto;
  margin-right: auto;
}

.command-panel,
.metric-card,
.dashboard-card,
.icloud-panel,
.youtube-panel,
.url-panel,
.result-panel,
.empty-state {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 27, 39, 0.96), rgba(10, 16, 24, 0.96));
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.22);
}

.command-panel {
  margin-top: 24px;
  padding: 22px;
  border-radius: 8px;
}

.command-panel-head,
.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.command-panel h2,
.dashboard-card h2 {
  font-size: 18px;
}

.command-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.privacy-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.unified-url-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 112px 160px;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.unified-url-row input,
.url-row input,
select {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}

.unified-url-row input {
  min-height: 44px;
  border: 0;
  background: transparent;
}

.platform-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.platform-strip span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
  border-radius: 8px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 28px;
}

.metric-card.success strong {
  color: #51d68d;
}

.metric-card.danger strong,
.danger-text {
  color: var(--danger);
}

.platform-pill {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.platform-pill.instagram {
  background: rgba(34, 199, 169, 0.15);
  color: #5ff0d0;
}

.platform-pill.warning {
  background: rgba(255, 183, 77, 0.14);
  color: #ffc266;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
  margin-bottom: 28px;
}

.dashboard-card {
  padding: 18px;
  border-radius: 8px;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.compact-row strong,
.compact-row span {
  display: block;
}

.compact-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.compat-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  margin: 12px 0;
}

.compat-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.compat-row strong,
.compat-row small {
  display: block;
}

.compat-row small {
  color: var(--muted);
}

.privacy-mode .media-card img,
.privacy-mode .compact-row strong,
.privacy-mode .job-item h3,
.privacy-mode .card-body h3 {
  filter: blur(8px);
}

.privacy-mode .media-card:hover img,
.privacy-mode .compact-row:hover strong,
.privacy-mode .job-item:hover h3,
.privacy-mode .card-body:hover h3 {
  filter: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .metric-grid,
  .dashboard-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .command-panel,
  .metric-grid,
  .icloud-panel,
  .youtube-panel,
  .url-panel,
  .result-panel,
  .empty-state,
  .dashboard-columns {
    width: calc(100% - 24px);
  }
  .topbar,
  .command-panel-head,
  .card-title-row {
    flex-direction: column;
  }
  .unified-url-row,
  .platform-strip,
  .metric-grid,
  .dashboard-columns,
  .side-nav {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1120px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.eyebrow,
.meta-line {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.3;
}

.platform-pill {
  min-width: 94px;
  padding: 9px 12px;
  border-radius: 999px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.platform-pill.instagram {
  background: #fff1f2;
  color: #be123c;
}

.platform-pill.x {
  background: #f1f5f9;
  color: #111827;
}

.url-panel {
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--line);
}

.url-panel > label,
.profile-panel > label,
.youtube-panel > label,
.select-label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px 118px 132px;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.secondary-button {
  color: var(--text);
  background: var(--surface-2);
}

.danger-button {
  color: #fff;
  background: #b91c1c;
}

.options-row {
  display: grid;
  grid-template-columns: 120px minmax(180px, 260px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.utility-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.utility-links a {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.utility-links svg {
  width: 17px;
  height: 17px;
}

.select-label {
  margin-bottom: 0;
  padding-bottom: 13px;
}

.option-help {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.threads-browser-fallback {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.threads-browser-fallback p {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.inline-check {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.inline-check input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.result-panel {
  padding: 28px 32px 0;
}

.profile-panel,
.youtube-panel {
  padding: 28px 32px 32px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

.youtube-result {
  margin-top: 22px;
}

.web-panel {
  background: #f7fbfa;
}

.web-search-control {
  min-width: min(260px, 100%);
  min-height: 42px;
  margin: 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.web-search-control svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}

.web-search-control input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.web-search-control input:focus {
  outline: 0;
}

.web-load-more {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 220px;
}

.list-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.list-summary-row .meta-line {
  margin: 0;
}

.secondary-button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  flex: 0 0 auto;
}

.profile-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-statuses {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#serverHealthPill.warning {
  color: #92400e;
  border-color: #fcd34d;
  background: #fffbeb;
}

#serverHealthPill.error {
  color: #991b1b;
  border-color: #fca5a5;
  background: #fff1f2;
}

.result-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  padding-bottom: 18px;
}

#youtubeGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.playlist-section {
  display: grid;
  gap: 12px;
}

.playlist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.playlist-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.playlist-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.playlist-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.playlist-toggle {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}

.playlist-grid {
  padding-bottom: 0;
}

.media-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sort-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sort-toggle button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.sort-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.tag-search {
  min-height: 42px;
  display: inline-grid;
  grid-template-columns: auto minmax(120px, 180px) auto;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tag-search svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.tag-search input {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
}

.tag-search input:focus {
  outline: none;
  box-shadow: none;
}

.tag-search button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tag-search button:disabled {
  opacity: 0.35;
  cursor: default;
}

.top-download-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.top-download-control span {
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.top-download-control button {
  min-height: 38px;
  padding: 0 12px;
}

.date-note {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-note.inline {
  display: inline-flex;
  margin-top: 0;
  min-height: 24px;
  align-items: center;
  padding: 0 7px;
  border-radius: 6px;
  background: #f8fafc;
}

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.tag-row.inline {
  margin-top: 0;
}

.tag-row button {
  padding: 4px 6px;
  min-height: 0;
  border: 0;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.tag-row button:hover {
  background: #e0f2fe;
  color: #0369a1;
}

.tag-row button.hash-tag {
  background: #fef3c7;
  color: #92400e;
}

.tag-row button.hash-tag:hover {
  background: #fde68a;
  color: #78350f;
}

.media-card input {
  position: absolute;
  inset: 12px auto auto 12px;
  z-index: 2;
  width: 22px;
  height: 22px;
  min-height: auto;
  accent-color: var(--accent);
}

.thumb {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: #dde5ea;
  overflow: hidden;
}

.thumb-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.thumb-link:hover img {
  transform: scale(1.03);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.thumb svg {
  width: 42px;
  height: 42px;
  color: var(--muted);
}

.card-body {
  min-height: 86px;
  padding: 12px;
}

.card-body h3 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.video {
  background: #e0f2fe;
  color: #0369a1;
}

.badge.shorts {
  background: #fee2e2;
  color: #991b1b;
}

.badge.photo {
  background: #dcfce7;
  color: #166534;
}

.download-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -32px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.download-bar p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.download-links {
  margin: 0 0 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.progress-box {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.analysis-slots {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.analysis-slots-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.analysis-slots-head h3 {
  margin: 0;
  font-size: 15px;
}

.analysis-slots-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.analysis-slot-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.analysis-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analysis-slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.analysis-slot.error {
  border-color: #fca5a5;
}

.analysis-slot-main,
.analysis-slot-stop {
  border: 0;
  background: transparent;
  color: inherit;
}

.analysis-slot-main {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  justify-content: stretch;
  align-items: stretch;
  text-align: left;
  cursor: pointer;
}

.analysis-slot-main strong,
.analysis-slot-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-slot-main strong {
  font-size: 13px;
}

.analysis-slot-main span {
  color: var(--muted);
  font-size: 12px;
}

.analysis-slot-stop {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  cursor: pointer;
}

.analysis-slot-stop:hover {
  background: #eef6f5;
}

.job-list {
  margin: 0 0 16px;
  display: grid;
  gap: 12px;
}

.job-list h3 {
  margin: 0;
  font-size: 15px;
}

.job-list-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.job-list-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.job-items {
  display: grid;
  gap: 10px;
}

.job-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.job-item.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.job-item.error {
  border-color: #fecaca;
  background: #fff7f7;
}

.job-item-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.job-item-head h3 {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;
}

.job-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.job-actions span {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  color: var(--accent-2);
}

.restart-button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}

.restart-button.link-button {
  text-decoration: none;
}

.clear-done-button,
.clear-all-button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}

.clear-done-button {
  border-color: #fecaca;
  color: #991b1b;
  background: #fff7f7;
}

.clear-all-button {
  border-color: #cbd5e1;
  color: #334155;
  background: #f8fafc;
}

.delete-job-button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
  border-color: #fed7aa;
  color: #9a3412;
  background: #fff7ed;
}

.job-item-meta,
.job-message {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.job-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 12px 0 8px;
}

.job-progress.total {
  margin: 0;
}

.job-progress strong {
  font-size: 12px;
  color: var(--text);
}

.file-list.mini {
  margin-top: 10px;
}

.job-log {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.job-log summary {
  cursor: pointer;
  font-weight: 800;
}

.job-log pre {
  max-height: 150px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  white-space: pre-wrap;
}

.download-links h3 {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.3;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-list a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-2);
  background: #fff;
  text-decoration: none;
  font-weight: 700;
  word-break: break-word;
}

.file-list svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.file-note {
  color: var(--muted);
  font-weight: 700;
  word-break: break-word;
}

.icloud-panel {
  margin: 0 18px 18px;
  padding: 18px;
  border: 1px solid #cfe3ef;
  border-radius: 12px;
  background: linear-gradient(135deg, #f5fbff 0%, #ffffff 70%);
}

.icloud-panel-head,
.icloud-path-row,
.icloud-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.icloud-panel h2 {
  margin: 4px 0 6px;
}

.icloud-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.setting-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.setting-toggle input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.setting-toggle span {
  display: grid;
  gap: 5px;
}

.setting-toggle small,
.icloud-safety-note {
  color: var(--muted);
  line-height: 1.45;
}

.icloud-path-row {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.icloud-actions {
  flex: 0 0 auto;
}

.icloud-path-row {
  flex-wrap: wrap;
}

.icloud-path-row > .file-note {
  flex: 1 1 260px;
}

.icloud-path-row > .icloud-actions {
  flex: 1 1 520px;
  min-width: 0;
}

.icloud-actions select {
  width: auto;
  min-width: 210px;
  flex: 0 1 260px;
}

.secondary-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 800;
}

.icloud-safety-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf7ff;
  font-size: 13px;
}

.icloud-progress {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.icloud-progress .file-note {
  margin: 8px 0 0;
}

.compat-progress {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.compat-progress p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.icloud-folder-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.icloud-folder-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
}

.icloud-folder-card strong {
  grid-column: 1 / -1;
  margin-bottom: 3px;
}

.sync-failed,
.icloud-failures {
  color: var(--danger);
}

.icloud-failures {
  margin-top: 10px;
  padding: 11px;
  border-radius: 9px;
  background: #fff1f1;
}

.icloud-failures p {
  margin: 5px 0 0;
  word-break: break-word;
}

.result-warning {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.empty-state svg {
  width: 52px;
  height: 52px;
}

.empty-state p {
  margin: 0;
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: #18212a;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .result-head,
  .download-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .icloud-folder-stats {
    grid-template-columns: 1fr;
  }

  .url-panel,
  .result-panel,
  .profile-panel,
  .youtube-panel,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .url-row,
  .options-row {
    grid-template-columns: 1fr;
  }

  .icloud-panel {
    margin-left: 10px;
    margin-right: 10px;
  }

  .icloud-panel-head,
  .icloud-path-row {
    align-items: stretch;
    flex-direction: column;
  }

  .icloud-settings-grid {
    grid-template-columns: 1fr;
  }

  .icloud-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .select-label {
    padding-bottom: 0;
  }

  .download-bar {
    margin-left: -18px;
    margin-right: -18px;
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* v2 final cleanup: keep legacy panels functional while making the whole dashboard dark. */
:root {
  color-scheme: dark;
  --bg: #070b10;
  --surface: #0c121a;
  --surface-2: #121b27;
  --surface-3: #172231;
  --line: #263548;
  --text: #edf4ff;
  --muted: #94a5ba;
  --accent: #9b4dff;
  --accent-2: #22c7a9;
  --danger: #ff6b5d;
  --warning: #ffc266;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(146, 81, 255, 0.16), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(34, 199, 169, 0.10), transparent 26%),
    var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
  padding: 0;
  background: transparent;
}

.workspace {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.topbar,
.command-panel,
.metric-grid,
.icloud-panel,
.youtube-panel,
.url-panel,
.result-panel,
.empty-state,
.dashboard-columns {
  width: calc(100% - 48px);
  max-width: 1680px;
  margin-left: 24px;
  margin-right: 24px;
}

.topbar {
  padding: 22px 24px;
  background: rgba(7, 11, 16, 0.90);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.command-panel,
.metric-card,
.dashboard-card,
.icloud-panel,
.youtube-panel,
.url-panel,
.result-panel,
.empty-state,
.analysis-slots,
.analysis-slot,
.progress-box,
.job-item,
.download-links,
.setting-toggle,
.icloud-progress,
.icloud-folder-card,
.icloud-failures,
.media-card,
.sort-toggle,
.web-search-control,
.tag-search,
.secondary-link,
.file-list a {
  border-color: var(--line);
  color: var(--text);
  background: linear-gradient(180deg, rgba(18, 27, 39, 0.97), rgba(10, 16, 24, 0.97));
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.20);
}

.youtube-panel,
.url-panel,
.result-panel,
.empty-state,
.icloud-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.youtube-panel,
.url-panel {
  padding: 22px;
}

.result-panel {
  padding: 22px 22px 0;
}

.empty-state {
  min-height: 230px;
}

.metric-grid {
  margin-top: 16px;
}

.icloud-panel {
  padding: 18px;
}

h1,
h2,
h3,
strong,
label,
.card-body h3,
.playlist-head h3,
.analysis-slots-head h3 {
  color: var(--text);
}

p,
small,
.eyebrow,
.meta-line,
.option-help,
.file-note,
.job-item-meta,
.job-message,
.compact-row span,
.progress-meta,
.playlist-head span,
.top-download-control span {
  color: var(--muted);
}

input,
select,
textarea {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}

input::placeholder,
textarea::placeholder {
  color: #7f90a5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 77, 255, 0.20);
}

button,
.secondary-button,
.secondary-link,
.utility-links a {
  white-space: nowrap;
}

button {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.secondary-button,
.secondary-link,
.utility-links a {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.065);
}

.danger-button,
.clear-done-button,
.delete-job-button,
.toast.error {
  color: #fff;
  background: rgba(221, 74, 63, 0.88);
}

.platform-pill {
  min-width: auto;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}

.platform-pill.instagram,
#serverHealthPill.warning {
  color: var(--warning);
  background: rgba(255, 194, 102, 0.12);
}

.platform-pill.x {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

#serverHealthPill.error,
.job-item.error {
  color: #ff9b91;
  border-color: rgba(255, 107, 93, 0.42);
  background: rgba(255, 107, 93, 0.10);
}

.job-item.done {
  border-color: rgba(81, 214, 141, 0.35);
  background: rgba(81, 214, 141, 0.10);
}

.download-bar {
  margin-left: -22px;
  margin-right: -22px;
  background: rgba(7, 11, 16, 0.88);
  border-top-color: var(--line);
}

.download-links {
  margin-bottom: 86px;
}

.thumb {
  background: #111a25;
}

.badge,
.date-note.inline,
.tag-row button {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
}

.badge.video {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.16);
}

.badge.shorts,
.badge.photo {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
}

.tag-row button.hash-tag {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.14);
}

.url-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.web-panel .url-row,
.url-panel .url-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.unified-url-row {
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
}

.platform-strip {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.icloud-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icloud-safety-note {
  background: rgba(34, 199, 169, 0.10);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-grid,
  .dashboard-columns,
  .icloud-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
    padding: 0;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px;
    background: rgba(7, 11, 16, 0.96);
  }

  .brand-mark {
    margin-bottom: 0;
  }

  .side-nav {
    display: none;
  }

  .topbar,
  .command-panel,
  .metric-grid,
  .icloud-panel,
  .youtube-panel,
  .url-panel,
  .result-panel,
  .empty-state,
  .dashboard-columns {
    width: calc(100% - 24px);
    margin-left: 12px;
    margin-right: 12px;
  }

  .topbar {
    position: static;
    padding: 16px;
  }

  .command-panel,
  .youtube-panel,
  .url-panel,
  .result-panel,
  .icloud-panel {
    padding: 16px;
  }

  .unified-url-row,
  .url-row,
  .web-panel .url-row,
  .url-panel .url-row,
  .options-row,
  .platform-strip,
  .metric-grid,
  .dashboard-columns,
  .icloud-settings-grid,
  .icloud-folder-stats {
    grid-template-columns: 1fr;
  }

  .unified-url-row {
    padding: 10px;
  }

  .unified-url-row > svg {
    display: none;
  }

  .topbar-statuses,
  .result-actions,
  .icloud-actions {
    justify-content: flex-start;
  }

  .topbar-statuses .platform-pill {
    flex: 1 1 calc(50% - 8px);
    font-size: 12px;
  }

  .platform-strip span {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .media-grid {
    grid-template-columns: 1fr;
  }

  .download-bar {
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Keep preview failure and retry visible next to the submitted URL. */
.preview-status { margin: 16px 0; padding: 16px; border: 1px solid #526779; border-radius: 10px; background: #16222d; color: #eef4fb; }
.preview-status strong { display: block; font-size: 16px; line-height: 1.5; }
.preview-status p { margin: 8px 0; line-height: 1.65; overflow-wrap: anywhere; }
.preview-status .preview-elapsed { color: #bbc8d6; font-size: 13px; }
.preview-status-error { border-color: #cf8767; background: #30231f; }
.preview-status button { margin-top: 8px; min-height: 44px; }
.preview-status button:focus-visible { outline: 3px solid #e9c875; outline-offset: 3px; }
@media (max-width: 600px) { .preview-status button { width: 100%; } }
