:root {
  --bg: #f7f8fb;
  --card: #fff;
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --orange: #ee4d2d;
  --orange-2: #ff9800;
  --purple: #7c3aed;
  --green: #15803d;
  --shadow: 0 10px 30px rgba(31, 41, 55, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Noto Sans Thai", "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { height: 62px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.brand span { color: var(--orange); font-weight: 600; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--orange); }
.page-shell { max-width: 1180px; margin: 0 auto; padding: 34px 20px 70px; }
.hero { margin-bottom: 26px; }
.eyebrow { color: var(--orange); font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .14em; }
h1 { margin: 8px 0 5px; font-size: clamp(26px, 4vw, 42px); letter-spacing: -.04em; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }
.layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.product-panel { position: sticky; top: 16px; padding: 18px; }
.step-card { padding: 20px; margin-bottom: 16px; }
.step-label { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; margin-bottom: 15px; }
.step-label span { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; border-radius: 8px; color: #fff; background: linear-gradient(135deg, var(--purple), #4f46e5); font-size: 12px; }
.product-image-wrap { position: relative; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; background: #f3f4f6; border-radius: 12px; }
.product-image-wrap img { width: 100%; height: 100%; object-fit: contain; display: none; }
.product-image-wrap img.ready { display: block; }
.image-placeholder { color: var(--muted); font-size: 12px; text-align: center; padding: 20px; }
.product-panel h2 { margin: 16px 0 5px; font-size: 17px; line-height: 1.45; }
.product-meta { color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 18px; }
.product-price { color: var(--orange); font-size: 22px; font-weight: 800; margin-top: 8px; }
.load-status { color: var(--muted); font-size: 11px; margin-top: 10px; min-height: 16px; }
.option-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.option-card { min-height: 72px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); padding: 11px 9px; text-align: left; transition: .18s ease; }
.option-card strong, .option-card small { display: block; }
.option-card strong { font-size: 12px; }
.option-card small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.option-card:hover { border-color: #f59e0b; transform: translateY(-1px); }
.option-card.active { border-color: var(--orange-2); box-shadow: 0 0 0 2px rgba(245, 158, 11, .16); background: #fffaf2; }
.scene-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.scene-pill { border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 10px 6px; color: var(--ink); }
.scene-pill b, .scene-pill span, .scene-pill small { display: block; }
.scene-pill b { color: var(--orange); font-size: 21px; line-height: 1; }
.scene-pill span { margin-top: 5px; font-weight: 700; font-size: 12px; }
.scene-pill small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.scene-pill.active { border-color: var(--orange-2); background: #fff7ed; }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card { display: flex; gap: 9px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.mode-card input { margin-top: 3px; accent-color: var(--orange); }
.mode-card > span { font-size: 19px; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { font-size: 12px; }
.mode-card small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.mode-card.active { border-color: var(--orange-2); background: #fffaf2; }
.prompt-wrap { margin-top: 15px; }
.prompt-heading { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
#promptEditor { width: 100%; border: 1px solid #d1d5db; border-radius: 10px; resize: vertical; padding: 11px; color: #253047; background: #fafafa; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
#promptEditor:focus { outline: 2px solid rgba(245, 158, 11, .35); border-color: var(--orange-2); }
.prompt-summary { margin-top: 12px; padding: 10px 12px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 9px; color: #475569; font-size: 12px; }
.generation-mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.api-key-panel { margin-top: 12px; padding: 12px; border: 1px solid #fed7aa; border-radius: 10px; background: #fffaf2; }
.api-key-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.api-key-heading label { color: var(--ink); font-size: 12px; font-weight: 800; }
.api-key-heading a { color: #c2410c; font-size: 11px; font-weight: 800; }
#genaiproApiKey { width: 100%; border: 1px solid #fdba74; border-radius: 9px; padding: 11px 12px; color: #253047; background: #fff; font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
#genaiproApiKey:focus { outline: 2px solid rgba(245, 158, 11, .35); border-color: var(--orange-2); }
#apiKeyHelp { margin: 7px 0 0; color: #7c2d12; font-size: 10px; line-height: 1.55; }
.action-row { display: flex; gap: 9px; margin-top: 15px; }
.secondary-btn, .orange-btn { border: 0; border-radius: 10px; padding: 12px 15px; font-weight: 800; font-size: 13px; }
.secondary-btn { background: #eef2ff; color: #4f46e5; }
.orange-btn { flex: 1; color: #fff; background: linear-gradient(135deg, var(--orange), var(--orange-2)); box-shadow: 0 5px 14px rgba(238, 77, 45, .22); }
.orange-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.orange-btn:disabled, .secondary-btn:disabled { cursor: wait; opacity: .55; transform: none; }
.generation-status { margin-top: 12px; font-size: 12px; min-height: 20px; }
.status-info { color: #475569; }
.status-success { color: var(--green); }
.status-error { color: #b91c1c; background: #fef2f2; border-radius: 8px; padding: 9px; }
.status-error a { color: #b91c1c; font-weight: 800; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.result-card { padding: 10px; background: #0f172a; border-radius: 10px; color: #fff; }
.result-card video { display: block; width: 100%; border-radius: 7px; background: #000; }
.result-card a { display: inline-block; margin-top: 7px; color: #fdba74; font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 130%); padding: 10px 15px; border-radius: 9px; background: #172033; color: #fff; font-size: 12px; transition: transform .2s ease; z-index: 20; }
.toast.show { transform: translate(-50%, 0); }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .product-panel { position: static; display: grid; grid-template-columns: 150px 1fr; column-gap: 16px; }
  .product-panel .step-label, .product-panel .load-status { grid-column: 1 / -1; }
  .product-panel h2, .product-panel .product-meta, .product-panel .product-price { grid-column: 2; }
  .product-image-wrap { grid-row: 2 / span 4; }
  .option-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  .page-shell { padding: 24px 12px 50px; }
  .option-grid, .scene-options, .mode-row, .generation-mode-row, .result-grid { grid-template-columns: 1fr 1fr; }
  .action-row { flex-direction: column; }
  .product-panel { display: block; }
  .product-image-wrap { margin-bottom: 14px; }
}
