:root {
  color-scheme: light;
  --ink: #15171a;
  --muted: #68707d;
  --line: #dde3ea;
  --page: #f6f7f9;
  --surface: #ffffff;
  --soft: #eef3f6;
  --accent: #007f78;
  --accent-dark: #005f5a;
  --amber: #f2c94c;
  --danger: #b3261e;
  --ok: #16834a;
  --shadow: 0 18px 46px rgba(20, 28, 38, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #101418;
  color: #f7f9fb;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--amber);
  color: #101418;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.05;
}

h2 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  font-size: 17px;
}

.brand span,
.queue-card small {
  color: #a9b1ba;
  font-size: 13px;
}

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

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #cdd4dc;
  text-align: left;
  font-weight: 750;
}

.nav-tab:hover,
.nav-tab.active {
  background: #222a31;
  color: #fff;
}

.queue-card {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 11px;
  align-items: center;
  min-height: 64px;
  padding: 12px;
  border: 1px solid #29323b;
  border-radius: 10px;
  background: #171d23;
}

.queue-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
}

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

#jobForm {
  display: block;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: grid;
  gap: 18px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.create-grid {
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.intake-panel,
.run-panel,
.results-panel,
.history-panel,
.settings-grid {
  padding: 18px;
}

.intake-panel {
  display: grid;
  gap: 16px;
}

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

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 150px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(0, 127, 120, 0.16);
  border-color: var(--accent);
}

.check {
  grid-template-columns: 20px 1fr;
  align-items: center;
  min-height: 44px;
}

.check input {
  width: 20px;
  min-height: 20px;
  padding: 0;
}

.primary-action,
.secondary-action,
.icon-button,
.account-card button,
.button-link,
.post-actions button,
.publish-panel button,
.attempt-row button,
.queue-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  font-weight: 850;
}

.primary-action,
.secondary-action {
  gap: 9px;
  min-height: 46px;
  padding: 0 16px;
}

.primary-action {
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
}

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

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
}

.log {
  height: 232px;
  overflow: auto;
  border-radius: 10px;
  background: #11161b;
  color: #eaf0f5;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.results,
.library-grid {
  display: grid;
  gap: 16px;
}

.results {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.library-grid {
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
}

.clip-card,
.posting-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.clip-card video,
.posting-card video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #11161b;
}

.clip-card footer,
.posting-body {
  padding: 12px;
}

.clip-card footer {
  display: grid;
  gap: 9px;
}

.clip-title {
  font-weight: 850;
  overflow-wrap: anywhere;
}

.file-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-link {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

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

.job-row {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
  text-align: left;
}

.job-row:hover,
.job-row.active {
  border-color: var(--accent);
}

.badge,
.count-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 7px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.badge {
  background: #edf4f4;
  color: var(--accent-dark);
  text-transform: uppercase;
}

.badge.failed {
  background: #fae8e6;
  color: var(--danger);
}

.badge.succeeded,
.badge.posted {
  background: #e8f5ee;
  color: var(--ok);
}

.badge.uploading,
.badge.submitted,
.badge.review,
.badge.approved,
.badge.processing {
  background: #fff7dc;
  color: #8a6500;
}

.badge.canceled,
.badge.permanently_failed {
  background: #eceff3;
  color: #555f6d;
}

.count-pill,
.tag {
  background: var(--soft);
  color: var(--muted);
}

.danger-tag {
  background: #fae8e6;
  color: var(--danger);
}

.job-url {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.account-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.account-card.connected {
  border-color: rgba(22, 131, 74, 0.42);
}

.account-card p {
  margin-top: 4px;
  color: var(--muted);
}

.account-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.account-card button,
.button-link,
.post-actions button,
.publish-panel button,
.attempt-row button {
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  background: #101418;
  color: #fff;
  text-decoration: none;
}

.account-copy {
  min-width: 0;
}

.account-scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.account-actions {
  display: flex;
  justify-content: end;
}

.account-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
}

.account-icon.youtube {
  background: #ffe9e7;
  color: #c4302b;
}

.account-icon.tiktok {
  background: #eaf4ff;
  color: #0f6ca8;
}

.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--soft);
}

.notice {
  border: 1px solid rgba(0, 127, 120, 0.26);
  border-radius: 9px;
  padding: 12px 14px;
  background: #edf8f6;
  color: var(--accent-dark);
  font-weight: 800;
}

.notice.error {
  border-color: rgba(179, 38, 30, 0.28);
  background: #fae8e6;
  color: var(--danger);
}

.policy-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.policy-strip > div {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: #fff;
}

.policy-strip strong {
  font-size: 13px;
}

.policy-strip span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.posting-body {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.posting-body textarea {
  width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.publish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.publish-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: #fbfcfd;
}

.publish-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-fields {
  grid-template-columns: 1fr 1fr;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.mini-check input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.attempt-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.queue-panel,
.audit-panel {
  padding: 16px;
}

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

.queue-row {
  display: grid;
  grid-template-columns: auto minmax(140px, 0.8fr) minmax(0, 1fr) auto minmax(130px, auto);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.queue-row > span:nth-child(3),
.queue-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-row small {
  grid-column: 1 / -1;
  color: var(--danger);
}

.queue-actions {
  display: flex;
  justify-content: end;
  gap: 7px;
}

.attempt-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.attempt-row > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.posting-title-row {
  display: grid;
  gap: 10px;
}

.posting-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.status-field {
  max-width: 170px;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.audit-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) 80px auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.audit-row > span:last-child {
  overflow-wrap: anywhere;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
  max-width: 920px;
}

.empty {
  color: var(--muted);
  padding: 14px 0;
}

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

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .queue-card {
    position: static;
    margin-top: 18px;
  }

  .create-grid,
  .account-grid,
  .settings-grid,
  .policy-strip,
  .library-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 18px;
  }
}

@media (max-width: 620px) {
  .page-head,
  .field-row,
  .job-row,
  .account-card {
    grid-template-columns: 1fr;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions button,
  .account-actions .button-link {
    width: 100%;
  }

  .page-head {
    display: grid;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .compact-fields,
  .attempt-row,
  .queue-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .queue-actions {
    justify-content: stretch;
  }

  .queue-actions button {
    flex: 1 1 auto;
  }
}
