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

* {
  box-sizing: border-box;
}

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,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 21px;
  line-height: 1.2;
}

p {
  color: var(--muted);
}

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

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

.page-head p {
  margin-top: 8px;
}

.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;
}

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

.status-strip div,
.form-section,
.result-panel,
.recent-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip div {
  padding: 12px 14px;
}

.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.status-strip strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.status-strip-action {
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-all-btn {
  width: 100%;
  min-height: 60px;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fff;
  color: #dc2626;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.clear-all-btn:hover {
  background: #dc2626;
  color: #fff;
}

.clear-all-btn:active {
  background: #991b1b;
  border-color: #991b1b;
}

.ops-form {
  display: grid;
  gap: 14px;
}

.form-section,
.result-panel,
.recent-panel {
  padding: 16px;
}

.workflow-section {
  border-color: #bfdbfe;
  background: #f8fbff;
}

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

.workflow-card {
  position: relative;
  display: grid;
  min-height: 116px;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 14px 14px 44px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.workflow-card:hover {
  border-color: var(--accent);
}

.workflow-card input {
  position: absolute;
  top: 16px;
  left: 14px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.workflow-card.is-active {
  border-color: var(--accent);
  background: #e7f3ff;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, .14);
}

.workflow-card-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.workflow-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mode-hidden {
  display: none !important;
}

.section-title {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

label small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.wide {
  grid-column: 1 / -1;
}

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

input,
select {
  min-height: 42px;
}

textarea {
  resize: vertical;
}

.folder-price-panel {
  display: grid;
  gap: 10px;
  padding: 10px 0 0;
}

.folder-price-panel[hidden] {
  display: none !important;
}

.folder-price-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.folder-price-head strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.folder-price-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.secondary-btn.compact {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.folder-price-rows {
  display: grid;
  gap: 8px;
}

.folder-price-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(120px, .45fr) minmax(120px, .45fr);
  gap: 8px;
  align-items: end;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft, var(--line));
}

.folder-price-name {
  min-width: 0;
}

.folder-price-name strong,
.folder-price-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-price-name strong {
  color: var(--ink);
  font-size: 13px;
}

.folder-price-name span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.folder-price-row label {
  gap: 5px;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(24, 119, 242, .18);
  border-color: var(--accent);
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.upload-box {
  position: relative;
  min-height: 150px;
  border: 1px dashed #b7c5c1;
  border-radius: 8px;
  background: #fbfaf7;
  padding: 12px;
  align-content: start;
}

.upload-box.mapping-guide {
  border-color: #9db5d4;
  background: #f8fbff;
}

.upload-box.is-drag-over {
  border: 2px dashed #1877f2;
  background: #e7f3ff;
}

.upload-box.is-drag-over::before {
  content: "Thả file vào đây";
  position: absolute;
  inset: 10px;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(236, 253, 245, .86);
  color: #1877f2;
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
}

.upload-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-box span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

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

.upload-box output {
  display: block;
  overflow-wrap: anywhere;
}

.upload-pick-btn {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.upload-pick-btn:hover {
  border-color: #1877f2;
}

.file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  min-height: 216px;
  overflow-x: auto;
  padding: 6px 0 4px;
  scroll-snap-type: x proximity;
}

.file-thumb {
  position: relative;
  flex: 0 0 216px;
  width: 216px;
  cursor: grab;
  scroll-snap-align: start;
  user-select: none;
}

.file-thumb.is-dragging {
  cursor: grabbing;
  opacity: .5;
}

.file-thumb.drag-over-before {
  border-left: 4px solid #1877f2;
}

.file-thumb.drag-over-after {
  border-right: 4px solid #1877f2;
}

.file-thumb img,
.file-thumb video,
.file-thumb .file-icon {
  display: block;
  width: 216px;
  height: 216px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  object-fit: cover;
}

.file-thumb img,
.file-thumb video {
  cursor: zoom-in;
  transition: transform .12s ease, box-shadow .12s ease;
}

.file-thumb img:hover,
.file-thumb video:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
}

.file-thumb .file-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  padding: 10px;
}

.file-thumb em {
  display: block;
  width: 216px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.thumb-remove:hover {
  background: #991b1b;
}

/* Lightbox preview */
.vh-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .85);
  padding: 24px;
}

.vh-preview-backdrop.is-open {
  display: flex;
}

.vh-preview-box {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.vh-preview-media {
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vh-preview-media img,
.vh-preview-media video {
  max-width: 95vw;
  max-height: 85vh;
  display: block;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

.vh-preview-name {
  color: #f8fafc;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  max-width: 95vw;
  word-break: break-all;
}

.vh-preview-close {
  position: absolute;
  top: -42px;
  right: 0;
  background: #fff;
  color: #050505;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 800;
  cursor: pointer;
}

.vh-preview-close:hover {
  background: #f1f5f9;
}

/* Restore notification */
.vh-restored-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
}

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

.run-progress-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.run-progress-panel[hidden] {
  display: none;
}

.run-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.run-progress-head strong {
  color: var(--ink);
  font-size: 15px;
}

.run-progress-head span {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.run-progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.run-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1877f2, #22c55e);
  transition: width .2s ease;
}

.run-progress-steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.run-progress-steps li.is-active {
  color: var(--accent);
}

.run-progress-steps li.is-done {
  color: #047857;
}

.run-progress-steps li.is-error {
  color: var(--danger);
}

.run-progress-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.run-progress-links a,
.run-progress-links span,
.run-progress-links button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  background: #fff;
  color: #344054;
  padding: 7px 10px;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.run-progress-links a.primary,
.run-progress-links button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-btn,
.secondary-btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.primary-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  border: 1px solid #cbd5d1;
  background: #fff;
  color: #344054;
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: wait;
  opacity: .62;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.save-state.is-error {
  color: var(--danger);
}

.save-state.is-ok {
  color: var(--accent);
}

.result-panel,
.recent-panel {
  margin-top: 16px;
}

#promptOutput {
  margin-top: 12px;
  min-height: 320px;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfaf7;
}

.recent-card strong {
  display: block;
  margin-bottom: 4px;
}

.recent-card p {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.recent-card button {
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 860px) {
  main {
    padding: 24px 14px;
  }

  .status-strip,
  .field-grid,
  .folder-price-row,
  .upload-grid,
  .workflow-options {
    grid-template-columns: 1fr;
  }

  .folder-price-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions > *,
  .result-actions > * {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .status-strip {
    grid-template-columns: 1fr 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);
}
