:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #66757f;
  --line: #d8e0e3;
  --paper: #ffffff;
  --soft: #f4f8f7;
  --green: #0b8f70;
  --green-dark: #06664f;
  --coral: #f05a3c;
  --amber: #f2b84b;
  --blue: #2f7df6;
  --shadow: 0 24px 70px rgba(22, 41, 48, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(11, 143, 112, 0.1), transparent 32%),
    linear-gradient(225deg, rgba(240, 90, 60, 0.11), transparent 30%),
    #eef4f3;
  color: var(--ink);
  font-family: "Inter", "Noto Sans Thai", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

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

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar,
.preview-header,
.approval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.98;
  max-width: 760px;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.demo-pill,
.job-state,
.status-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--green-dark);
  font-weight: 800;
  white-space: nowrap;
}

.pulse {
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 6px rgba(240, 90, 60, 0.14);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.status-step {
  color: var(--muted);
}

.status-step.active {
  border-color: rgba(11, 143, 112, 0.5);
  background: #e7f6f1;
  color: var(--green-dark);
}

.panels {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.preview-panel,
.library-panel {
  border: 1px solid rgba(216, 224, 227, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.preview-panel {
  padding: 22px;
}

.library-panel {
  margin-top: 18px;
  padding: 22px;
}

.field-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

label,
legend {
  display: block;
  margin-bottom: 9px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input[type="url"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  outline: none;
}

input[type="url"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(11, 143, 112, 0.16);
}

.icon-button,
.primary-action,
.secondary-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  min-width: 64px;
  padding: 0 12px;
  background: var(--ink);
  color: #fff;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented label {
  margin: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span,
.check-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented span {
  justify-content: center;
  padding: 0 10px;
  text-align: center;
}

.segmented input:checked + span {
  border-color: var(--green);
  background: #e7f6f1;
  color: var(--green-dark);
}

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

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

.check-row {
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 10px;
  color: var(--ink);
  font-weight: 700;
}

.check-row:last-child {
  margin-bottom: 0;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.destination-group.is-muted {
  opacity: 0.42;
}

.primary-action {
  width: 100%;
  background: var(--coral);
  color: #fff;
  box-shadow: 0 12px 26px rgba(240, 90, 60, 0.24);
}

.notice {
  padding: 12px 14px;
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: #fff8e7;
  color: #58451d;
  line-height: 1.55;
}

.caption-box {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.caption-box p {
  margin-bottom: 12px;
  color: #2f3f46;
  line-height: 1.7;
}

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

.tag-row span {
  padding: 6px 10px;
  border-radius: 8px;
  background: #e7eefb;
  color: #1d4fa4;
  font-size: 0.82rem;
  font-weight: 800;
}

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

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

.product-art {
  position: relative;
  min-height: 280px;
  background:
    radial-gradient(circle at 24% 25%, rgba(242, 184, 75, 0.9), transparent 22%),
    linear-gradient(145deg, #ff7b54 0%, #ffcb5c 48%, #24b99a 100%);
}

.product-art img {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bag-shape {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 132px;
  height: 152px;
  border-radius: 8px 8px 22px 22px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(-6deg);
  box-shadow: 0 22px 44px rgba(22, 41, 48, 0.25);
}

.bag-shape::before {
  content: "";
  position: absolute;
  left: 32px;
  top: -28px;
  width: 64px;
  height: 54px;
  border: 10px solid #fff;
  border-bottom: 0;
  border-radius: 60px 60px 0 0;
}

.bag-shape::after {
  content: "S";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--coral);
  font-size: 4rem;
  font-weight: 900;
}

.price-tag {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 1;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
}

.spark {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
}

.spark-one {
  right: 28px;
  top: 34px;
  width: 46px;
  height: 46px;
}

.spark-two {
  right: 82px;
  bottom: 42px;
  width: 28px;
  height: 28px;
}

.video-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(47, 125, 246, 0.95), rgba(23, 33, 38, 0.96)),
    #172126;
  color: #fff;
}

.play-icon {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}

.play-icon::after {
  content: "";
  position: absolute;
  margin: 22px 0 0 29px;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 22px solid #fff;
}

.reel-bars {
  position: absolute;
  left: 18px;
  bottom: 22px;
  display: flex;
  gap: 5px;
  align-items: end;
}

.reel-bars span {
  display: block;
  width: 8px;
  border-radius: 8px;
  background: var(--amber);
}

.reel-bars span:nth-child(1) {
  height: 24px;
}

.reel-bars span:nth-child(2) {
  height: 42px;
}

.reel-bars span:nth-child(3) {
  height: 32px;
}

.video-frame p {
  position: absolute;
  right: 16px;
  bottom: 16px;
  margin: 0;
  font-weight: 900;
}

.media-copy {
  padding: 14px;
}

.media-copy p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.approval-row {
  margin-top: 16px;
}

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

.secondary-action:not(:disabled):hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.compact-action {
  flex: 0 0 auto;
  min-width: 108px;
  min-height: 40px;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

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

.library-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--soft);
}

.library-item-body {
  padding: 12px;
}

.library-item-body strong {
  display: block;
  margin-bottom: 6px;
}

.library-item-body p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .panels,
  .media-grid,
  .destination-grid,
  .library-list {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  h1 {
    font-size: 2.35rem;
  }

  .control-panel,
  .preview-panel {
    padding: 16px;
  }

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

  .input-row,
  .approval-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .product-art,
  .video-frame {
    min-height: 230px;
  }
}
