:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #edf3ef;
  --text: #17211c;
  --muted: #68736d;
  --line: #d8e1db;
  --brand: #16865f;
  --brand-strong: #0f6c4b;
  --danger: #c83d3d;
  --warning: #a76512;
  --success: #16865f;
  --shadow: 0 18px 42px rgba(23, 33, 28, 0.08);
}

body.dark {
  color-scheme: dark;
  --bg: #111712;
  --surface: #17211b;
  --surface-soft: #213028;
  --text: #eef5f0;
  --muted: #9baaa1;
  --line: #314239;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-size: 22px;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.1;
}

.brand span,
.muted,
.hint,
.meta {
  color: var(--muted);
}

.brand span,
.hint,
.meta {
  font-size: 13px;
}

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

.nav-item {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 760;
}

.nav-item svg,
.icon-button svg,
.primary-button svg,
.dropzone svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: 0 0 auto;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.sidebar-note {
  margin-top: auto;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 134, 95, 0.14);
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.panel,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 108px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  font-size: 34px;
  line-height: 1;
}

.stat-card.danger strong,
.status-pill.failed {
  color: var(--danger);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  min-height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.publish-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1.12fr) minmax(360px, 0.88fr);
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.publish-form,
.publish-side {
  display: grid;
  gap: 14px;
}

.dropzone {
  min-height: 174px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: center;
}

.dropzone input {
  display: none;
}

.dropzone svg {
  width: 34px;
  height: 34px;
  color: var(--brand);
}

.dropzone.is-dragging {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(22, 134, 95, 0.14);
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.toggle-field {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 134, 95, 0.16);
}

.two-fields {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 12px;
}

.caption-head {
  display: grid;
}

.thumbnail-row {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: var(--surface-soft);
}

.thumbnail-row p {
  margin: 5px 0 0;
}

.thumbnail-actions,
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.file-button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.platform-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.platform-card {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-weight: 850;
}

.platform-card input,
.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.platform-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.facebook .platform-icon {
  background: #1877f2;
}

.instagram .platform-icon {
  background: linear-gradient(135deg, #f58529, #dd2a7b 55%, #515bd4);
}

.youtube .platform-icon {
  background: #ff0033;
}

.primary-button,
.secondary-button,
.text-button,
.segmented button {
  border-radius: 8px;
  font-weight: 850;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
}

.primary-button {
  background: var(--brand);
  color: white;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.primary-button.compact {
  width: fit-content;
}

.secondary-button,
.text-button {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.text-button {
  min-height: 36px;
  padding: 0 11px;
}

.action-row {
  justify-content: flex-end;
}

.preview-panel,
.progress-panel,
.log-panel {
  align-content: start;
}

.video-frame {
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0b0f0c;
}

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.76);
  text-align: center;
  padding: 24px;
}

.thumb-preview {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface-soft);
}

.thumb-preview img {
  width: 100%;
  height: 100%;
  max-height: 160px;
  object-fit: cover;
}

.progress-bar {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-soft);
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 0.25s ease;
}

.pipeline,
.log-list,
.queue-stack,
.history-grid,
.connection-list {
  display: grid;
  gap: 10px;
}

.step-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 78px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step-row span,
.queue-number {
  min-width: 34px;
  min-height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 900;
}

.step-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-transform: capitalize;
}

.step-row.done span {
  color: white;
  background: var(--success);
}

.step-row.running span,
.step-row.waiting span {
  color: white;
  background: var(--warning);
}

.step-row.failed span {
  color: white;
  background: var(--danger);
}

.step-row.skipped {
  opacity: 0.55;
}

.log-list {
  max-height: 280px;
  overflow: auto;
}

.log-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.log-row time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.queue-item,
.active-job,
.connection-row {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.active-job,
.connection-row {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 12px;
}

.status-pill {
  min-width: 88px;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: capitalize;
}

.status-pill.published {
  color: var(--success);
}

.status-pill.uploading,
.status-pill.queue,
.status-pill.draft {
  color: var(--warning);
}

.segmented {
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 3px;
}

.segmented button {
  min-width: 78px;
  border: 0;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface-soft);
  color: var(--text);
}

.history-card {
  min-height: 124px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-thumb {
  width: 112px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.history-thumb img,
.thumb-placeholder {
  width: 100%;
  height: 100%;
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #16865f, #243f6b);
  color: white;
  font-size: 32px;
  font-weight: 900;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.settings-panel {
  max-width: 760px;
  display: grid;
  gap: 14px;
}

.connection-row strong {
  color: var(--success);
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.advanced-settings summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 850;
}

.advanced-settings[open] {
  display: grid;
  gap: 12px;
}

.toggle-field {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.empty {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 20px;
}

.empty.small {
  min-height: 80px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .publish-workspace,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .video-frame {
    max-height: 520px;
  }
}

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

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

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

  .nav-item {
    justify-content: center;
    font-size: 0;
  }

  .nav-item svg {
    width: 22px;
    height: 22px;
  }

  .sidebar-note {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 18px 14px;
  }

  .panel-head,
  .thumbnail-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .two-fields,
  .platform-picker,
  .history-card {
    grid-template-columns: 1fr;
  }

  .publish-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-thumb {
    width: 100%;
  }

  .segmented {
    width: 100%;
    overflow: auto;
  }

  .segmented button {
    flex: 1;
    min-width: max-content;
  }
}
