:root {
  --bg: #f0f2f5;
  --ink: #050505;
  --muted: #65676b;
  --card: #fff;
  --line: #dadde1;
  --accent: #1877f2;
  --blue: #1d4ed8;
  --orange: #b45309;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px;
}

h1, h2, h3 { margin: 0; }

h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

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

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

.page-head {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

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

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.panel-head small {
  color: var(--muted);
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  min-height: 120px;
  resize: vertical;
}

.upload-panel {
  display: grid;
  gap: 10px;
}

.upload-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.upload-head h3 { font-size: 15px; }

.upload-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.upload-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  min-width: 96px;
}

.file-drop {
  display: grid;
  gap: 8px;
  justify-items: start;
  border: 1px dashed #99b8b3;
  border-radius: 8px;
  background: #f0f2f5;
  padding: 16px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.file-drop strong {
  color: var(--ink);
  font-size: 15px;
}

.file-drop small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-drop.is-dragover {
  border-color: var(--accent);
  background: #e7f3ff;
}

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

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.upload-preview-empty {
  grid-column: 1 / -1;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--orange);
  padding: 12px;
  font-weight: 700;
}

.upload-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: grid;
  gap: 0;
  cursor: grab;
}

.upload-card:active { cursor: grabbing; }

.upload-card.is-main {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(24, 119, 242, .14);
}

.upload-card.is-drag-target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-thumb {
  position: relative;
  background: #f2f2ef;
}

.upload-thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  background: #f2f2ef;
}

.upload-index {
  position: absolute;
  top: 7px;
  left: 7px;
  min-width: 26px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(24, 119, 242, .94);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.upload-main-badge {
  position: absolute;
  right: 7px;
  top: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--accent);
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
}

.upload-info {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.upload-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-size {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.upload-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.mini-btn {
  min-height: 30px;
  border: 1px solid #cbd5d1;
  border-radius: 7px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 6px;
}

.mini-btn.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.mini-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

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

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

.btn {
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.secondary {
  background: #fff;
  color: var(--accent);
}

.btn.blue {
  background: var(--blue);
  border-color: var(--blue);
}

.btn.warning {
  background: var(--orange);
  border-color: var(--orange);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  min-height: 62px;
}

.step strong {
  display: block;
  font-size: 13px;
}

.step span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.step.active {
  border-color: var(--accent);
  background: #e7f3ff;
}

.step.done {
  border-color: #86efac;
  background: #f0fdf4;
}

.step.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.preview-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.preview-tile img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
  background: #f2f2ef;
}

.preview-tile figcaption {
  padding: 7px 9px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.video-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111827;
}

.video-wrap video {
  width: 100%;
  max-height: 720px;
  display: block;
  background: #111827;
}

.sections {
  display: grid;
  gap: 16px;
}

.job-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.meta-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  padding: 9px 10px;
}

.meta-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meta-box strong {
  display: block;
  font-size: 18px;
}

.log-box {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  padding: 10px;
  white-space: pre-wrap;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.empty {
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--orange);
  padding: 12px;
  font-weight: 700;
}

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

.library-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.library-item button {
  min-width: 92px;
}

@media (max-width: 980px) {
  .studio-grid { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  main { padding: 24px 14px; }
  .inline-grid, .job-meta, .status-strip { grid-template-columns: 1fr; }
  .panel-head { display: grid; }
  .upload-head { display: grid; }
  .upload-head span { text-align: left; }
  .upload-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions .btn { width: 100%; }
}

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

/* === Facebook theme polish (auto-added 2026-05-29) === */
:root { --line-soft: #e4e6eb; --accent-tint: #e7f3ff; }
body { -webkit-font-smoothing: antialiased; }
.nav-btn { border: none; background: transparent; color: var(--muted); border-radius: 8px; transition: background .15s, color .15s; }
.nav-btn:hover { background: var(--line-soft); color: var(--ink); }
.nav-btn.active { background: var(--accent-tint); color: var(--accent); }
.panel, .form-section, .result-panel, .recent-panel, .run-progress-panel,
.status-strip div, .step, .meta-box, .library-item, .preview-tile, .upload-card, .recent-card {
  border-color: var(--line-soft);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}