:root {
  --bg: #f1f0ec;
  --panel: #ffffff;
  --panel-2: #faf9f7;
  --ink: #17171a;
  --ink-2: #4c4c52;
  --ink-3: #82828a;
  --line: #e2e0da;
  --line-2: #d3d0c8;
  --accent: #1f6f5c;
  --accent-soft: #e8f1ee;
  --danger: #b8452f;
  --warn: #b07d1c;
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(23, 23, 26, .05);
  --shadow-2: 0 18px 40px -28px rgba(23, 23, 26, .45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 26px; height: 26px; color: var(--ink); }
.brand strong { display: block; font-size: 14px; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: 11.5px; color: var(--ink-3); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--panel-2); border-color: #bfbcb2; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: #fff; color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2c2c31; }
.btn.small { padding: 6px 9px; font-size: 11.5px; font-weight: 600; }
.btn svg { width: 15px; height: 15px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 316px minmax(360px, 1fr) 366px;
  gap: 18px;
  align-items: start;
  max-width: 1660px;
  margin: 0 auto;
  padding: 18px 22px 8px;
}
.col { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.col-head h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.col-head p { margin: 3px 0 0; font-size: 11.8px; color: var(--ink-3); }

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 13px 14px;
  box-shadow: var(--shadow-1);
}
.card h3 {
  margin: 0 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.field input[type="text"], .field input[type="number"], .field select {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: #fff; color: var(--ink);
  font: inherit; font-size: 12.5px;
}
.field input[type="text"]:focus, .field input[type="number"]:focus, .field select:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.field.color { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.field.color > span { order: 1; }
.field.color input[type="color"] { order: 2; }
input[type="color"] {
  width: 34px; height: 26px; padding: 2px;
  border: 1px solid var(--line-2); border-radius: 7px; background: #fff; cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); height: 18px; }
.field .val { font-size: 11px; color: var(--ink-3); font-weight: 600; align-self: flex-end; margin-top: -2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 9px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); margin: 7px 0 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.seg { display: flex; gap: 3px; background: #f0eeea; border-radius: 9px; padding: 3px; }
.seg button {
  flex: 1; padding: 5px 6px;
  border: none; border-radius: 7px; background: transparent;
  font: inherit; font-size: 11.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }

.preset-row { display: flex; gap: 6px; margin-bottom: 10px; }
.chip {
  flex: 1; padding: 6px 8px;
  border: 1px solid var(--line-2); border-radius: 99px; background: #fff;
  font: inherit; font-size: 11.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- pratinjau ---------- */
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.phone {
  width: 336px; max-width: 100%;
  aspect-ratio: 9 / 16;
  background: #0d0d0f;
  border-radius: 36px;
  padding: 9px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .18), 0 30px 60px -30px rgba(0, 0, 0, .55), inset 0 0 0 1px #2a2a2e;
  position: relative;
}
.phone::before {
  content: ""; position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
  width: 62px; height: 5px; border-radius: 99px; background: #26262b; z-index: 5;
}
.phone-screen {
  position: relative; width: 100%; height: 100%;
  border-radius: 28px; overflow: hidden; background: #fff;
}
.stage { position: absolute; inset: 0; overflow: hidden; }

.scene-visual { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.scene-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-visual .placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-family: "Inter", sans-serif;
}
.scene-visual .placeholder svg { width: 46px; height: 46px; stroke-width: 1.3; opacity: .5; }
.scene-visual .placeholder .ph-label { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; opacity: .55; font-weight: 700; }

.overlay-text {
  position: absolute; left: 8%; right: 8%; top: 16%;
  text-align: left;
  font-family: "Bebas Neue", Impact, sans-serif;
  line-height: 1.02;
  letter-spacing: .01em;
  opacity: 0;
  transition: opacity .18s ease;
}
.overlay-text.show { opacity: 1; }

.subtitle-zone {
  position: absolute; left: 6%; right: 6%;
  display: flex; justify-content: center;
  transition: top .2s, bottom .2s;
}
.subtitle-zone.pos-bawah { bottom: 12%; }
.subtitle-zone.pos-tengah-bawah { bottom: 30%; }
.subtitle-zone.pos-tengah { top: 46%; bottom: auto; }

.subtitle-line {
  font-family: "Inter", sans-serif;
  text-align: center;
  line-height: 1.18;
  text-wrap: balance;
  paint-order: stroke fill;
}
.subtitle-line .w { display: inline-block; margin: 0 .2em; }
.subtitle-line .w.aktif { }

.cta-layer {
  position: absolute; left: 8%; right: 8%; bottom: 4%;
  text-align: center; opacity: 0; transition: opacity .2s;
}
.cta-layer.show { opacity: 1; }
.cta-layer span {
  display: inline-block;
  font-family: "Inter", sans-serif; font-weight: 800;
  padding: .5em .8em; border-radius: 8px;
}

.safe-area { position: absolute; inset: 0; opacity: 0; transition: opacity .2s; pointer-events: none; }
.safe-area.show { opacity: 1; }
.safe-area i { position: absolute; left: 0; right: 0; height: 8%; background: rgba(31, 111, 92, .12); border: 1px dashed rgba(31, 111, 92, .55); }
.safe-area .safe-top { top: 0; border-width: 0 0 1px; }
.safe-area .safe-bottom { bottom: 0; border-width: 1px 0 0; }

.scene-badge {
  position: absolute; top: 18px; right: 14px;
  font-size: 9px; letter-spacing: .12em; font-weight: 700;
  padding: 3px 6px; border-radius: 5px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-family: "Inter", sans-serif;
}

.phone-controls { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff; color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.aktif { background: var(--ink); color: #fff; border-color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
#btn-play .ic-pause { display: none; }
#btn-play.playing .ic-play { display: none; }
#btn-play.playing .ic-pause { display: block; }

.timecode { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); font-weight: 600; letter-spacing: .02em; }
.timecode .sep { color: var(--ink-3); margin: 0 3px; }

.scene-strip { display: flex; gap: 4px; width: 336px; max-width: 100%; }
.scene-strip button {
  flex: 1; height: 5px; border: none; border-radius: 99px; background: var(--line-2);
  cursor: pointer; padding: 0;
}
.scene-strip button.done { background: #b9b6ad; }
.scene-strip button.now { background: var(--ink); }

.warn-card h3 { margin-bottom: 8px; }
.warn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warn-list li {
  display: flex; gap: 7px; align-items: flex-start;
  font-size: 11.8px; color: var(--ink-2); line-height: 1.4;
}
.warn-list li svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 2px; }
.warn-list li.ok svg { color: var(--accent); }
.warn-list li.warn svg { color: var(--warn); }
.warn-list li.bad svg { color: var(--danger); }

/* ---------- adegan ---------- */
.add-row { display: flex; gap: 6px; flex-wrap: wrap; }
.scene-list { display: flex; flex-direction: column; gap: 8px; }
.scene-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px 10px;
  box-shadow: var(--shadow-1);
  transition: border-color .15s, box-shadow .15s;
}
.scene-item.aktif { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), var(--shadow-2); }
.scene-top { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.scene-no {
  width: 22px; height: 22px; flex: 0 0 22px;
  display: grid; place-items: center;
  border-radius: 6px; background: var(--ink); color: #fff;
  font-size: 11px; font-weight: 700;
}
.scene-top select { flex: 1; min-width: 0; }
.scene-top input[type="number"] { width: 54px; }
.scene-acts { display: flex; gap: 2px; }
.mini-btn {
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--ink-3); cursor: pointer; padding: 0;
}
.mini-btn:hover { background: #f1efeb; color: var(--ink); border-color: var(--line); }
.mini-btn.del:hover { color: var(--danger); }
.mini-btn svg { width: 14px; height: 14px; }

.scene-item select, .scene-item input[type="number"], .scene-item input[type="text"], .scene-item textarea {
  border: 1px solid var(--line-2); border-radius: 7px;
  padding: 5px 7px; font: inherit; font-size: 12px; color: var(--ink); background: #fff;
  width: 100%;
}
.scene-item textarea { resize: vertical; min-height: 48px; line-height: 1.35; }
.scene-item label.mini { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin: 0 0 3px; }
.scene-row2 { display: grid; grid-template-columns: 1fr 96px; gap: 7px; align-items: start; margin-top: 6px; }
.ref-box { display: flex; flex-direction: column; gap: 3px; }
.ref-thumb {
  position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 8px;
  border: 1px dashed var(--line-2); background: #faf9f6;
  display: grid; place-items: center; overflow: hidden; cursor: pointer;
  color: var(--ink-3);
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-thumb .x {
  position: absolute; top: 2px; right: 2px; width: 17px; height: 17px;
  border-radius: 5px; background: rgba(0, 0, 0, .6); color: #fff;
  display: grid; place-items: center; font-size: 10px; line-height: 1;
}
.ref-thumb svg { width: 18px; height: 18px; }
.ref-meta { font-size: 9.5px; color: var(--ink-3); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hint { font-size: 11px; color: var(--ink-3); margin: 2px 0 0; line-height: 1.45; }

/* ---------- prompt ---------- */
.prompt-section {
  max-width: 1660px; margin: 6px auto 40px; padding: 0 22px;
}
.prompt-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.prompt-title h2 { margin: 0; font-size: 15px; }
.prompt-title p { margin: 3px 0 0; font-size: 11.8px; color: var(--ink-3); }
.prompt-actions { display: flex; gap: 7px; }
.prompt-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow-1);
}
#prompt-out {
  width: 100%; min-height: 420px; max-height: 62vh;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfaf8;
  padding: 12px 13px; resize: vertical;
  font-family: "SFMono-Regular", "DejaVu Sans Mono", Menlo, monospace;
  font-size: 11.5px; line-height: 1.55; color: #24242a;
}
.prompt-side h3 { margin: 2px 0 8px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.pack-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.pack-list li { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); font-family: "SFMono-Regular", "DejaVu Sans Mono", monospace; }
.pack-list li svg { width: 13px; height: 13px; color: var(--ink-3); flex: 0 0 13px; }
.pack-list li.baru { color: var(--ink); font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: #fff; padding: 9px 15px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 300px minmax(320px, 1fr) 330px; gap: 14px; padding: 14px; }
  .prompt-section { padding: 0 14px; }
  .prompt-body { grid-template-columns: 1fr; }
}
@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .col-preview { order: -1; }
  .phone { width: 300px; }
  .scene-strip { width: 300px; }
}
/* ---------- modal ide & referensi ---------- */
[hidden] { display: none !important; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(23, 23, 26, .42);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: min(980px, 100%); max-height: 92vh; overflow: auto;
  background: var(--panel); border-radius: 16px;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .65);
}
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 16px 20px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.modal-head p { margin: 4px 0 0; font-size: 11.8px; color: var(--ink-3); max-width: 62ch; }
.modal-body { padding: 16px 20px 20px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.modal textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 10px; font: inherit; font-size: 12.5px; line-height: 1.45;
  background: #fff; color: var(--ink); resize: vertical;
}
.modal textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.modal-right { display: flex; flex-direction: column; gap: 7px; }
#ide-prompt, #ide-jawaban {
  font-family: "SFMono-Regular", "DejaVu Sans Mono", Menlo, monospace;
  font-size: 11.5px; min-height: 158px; background: #fbfaf8;
}
.modal-step {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; margin-bottom: 1px;
}
.modal-step b {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
}
.modal .btn.primary { justify-content: center; }

@media (max-width: 860px) {
  .modal-grid { grid-template-columns: 1fr; }
  .modal { max-height: 94vh; }
}
