/* MotionCraft — Light Editorial. Lihat DESIGN.md. */

:root {
  --paper: #F6F4EF;
  --ink: #1A1917;
  --muted: #6B665C;
  --line: #DED9CE;
  --line-soft: #EAE6DD;
  --panel: #FFFFFF;
  --accent: #C8401F;
  --accent-ink: #FFFFFF;
  --ok: #2F6B3C;
  --warn: #9A6B00;
  --err: #A32B1C;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --s1: 6px; --s2: 10px; --s3: 16px; --s4: 24px; --s5: 36px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
/* atribut hidden HARUS menang atas display apapun (class dgn display:flex
   menimpa rule UA [hidden] kalau tidak dipaksa — bug "Nothing running yet"). */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.wordmark { display: flex; align-items: baseline; gap: var(--s2); }
.mark { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -0.01em; }
.tag { color: var(--muted); font-size: 12px; }
.topbar-meta { display: flex; gap: var(--s3); }
.engine-unknown { color: var(--muted); font-size: 12px; }
.engine-ok { color: var(--ok); font-size: 12px; }
.engine-off { color: var(--err); font-size: 12px; }

/* ---------- workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.15fr) minmax(320px, 1fr);
  gap: 0;
  min-height: calc(100vh - 61px);
}
.col { padding: var(--s4); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s3); }
.col:last-child { border-right: 0; }
.col h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 17px;
  margin: 0; letter-spacing: -0.01em;
}
.col-hint { color: var(--muted); font-size: 12.5px; margin: calc(-1 * var(--s2)) 0 0; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 500; letter-spacing: 0.01em; }
.field.grow { flex: 1; min-height: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }

input, select, textarea {
  font-family: var(--font-body); font-size: 13px; color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 9px;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus,
.btn-quiet:focus-visible, .btn-accent:focus-visible, .btn-icon:focus-visible,
.preset:focus-visible, .check input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ---------- buttons ---------- */
.btn-accent, .btn-quiet, .btn-icon {
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  border-radius: var(--r-sm); cursor: pointer; border: 1px solid transparent;
  padding: 9px 14px; white-space: nowrap;
}
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(0.94); }
.btn-accent:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-quiet { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--muted); }
.btn-quiet:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon { background: transparent; border: 0; font-size: 20px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.btn-icon:hover { color: var(--ink); }
.wide { width: 100%; }

/* ---------- reference block ---------- */
.ref-block {
  border: 1px solid var(--line-soft); border-left: 3px solid var(--accent);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3); background: #FBFAF7;
  display: flex; flex-direction: column; gap: 6px;
}
.check-ref { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.check-ref input { width: auto; accent-color: var(--accent); }
.ref-hint { margin: 0; font-size: 11.5px; color: var(--muted); }
#ref-note { font-size: 12.5px; }
#ref-note:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- prompt block ---------- */
.prompt-block { display: flex; flex-direction: column; gap: var(--s1); }
.block-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); font-weight: 500; }
.mono-box {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
  background: #FBFAF7; border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  padding: var(--s2); white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; margin: 0; color: #37342C;
}
textarea.mono-box { max-height: 260px; resize: vertical; }

/* ---------- preview ---------- */
.viewport-wrap { position: relative; }
.viewport {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background:
    linear-gradient(45deg, #EFEBE2 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(45deg, transparent 75%, #EFEBE2 75%) 0 0 / 20px 20px,
    var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.viewport iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.stage-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: var(--s4); color: var(--muted); font-size: 12.5px;
}
.stage-badge { position: absolute; top: 8px; right: 8px; }
.stage-badge span { font-family: var(--font-mono); font-size: 10px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }

.transport { display: flex; align-items: center; gap: var(--s2); }
.transport-spacer { flex: 1; }
.timecode { font-size: 11px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.check input { width: auto; accent-color: var(--accent); }

/* ---------- queue bar (preview sebelum bulk export) ---------- */
.queue-bar {
  display: flex; align-items: center; gap: var(--s2);
  border: 1px solid var(--line-soft); border-left: 3px solid var(--accent);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3); background: #FBFAF7;
}
.q-title { font-size: 12px; font-weight: 500; color: var(--ink); }
.q-label { font-size: 11px; color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- code column ---------- */
.code-actions { display: flex; gap: var(--s2); }
.action-spacer { flex: 1; }
.bulk-row { display: flex; align-items: center; gap: var(--s2); }
.bulk-row .mono { font-size: 11px; color: var(--muted); }
.code-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-family: var(--font-mono); min-height: 15px; }
.warn { color: var(--warn); }

/* ---------- modal ---------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; background: rgba(26,25,23,0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: var(--s4); }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); width: min(560px, 100%); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0; }
.modal-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--line-soft); }

.preset-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.preset {
  text-align: left; font-family: var(--font-body); font-size: 12.5px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.preset small { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.preset.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset:hover { border-color: var(--muted); }

.estimate { font-size: 11.5px; color: var(--muted); }
.progress { display: flex; align-items: center; gap: var(--s2); }
.progress-track { flex: 1; height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
#export-text { font-size: 11px; color: var(--muted); min-width: 38px; text-align: right; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .col { border-right: 0; border-bottom: 1px solid var(--line); }
  .viewport { aspect-ratio: 16 / 9; }
}
@media (max-width: 560px) {
  .topbar { padding: var(--s2) var(--s3); }
  .col { padding: var(--s3); }
  .grid-2, .grid-3, .preset-row { grid-template-columns: 1fr; }
}

/* ---------- License gate ---------- */
body.locked > *:not(#license-gate) { filter: blur(6px); pointer-events: none; user-select: none; }
body.locked #license-gate { display: flex; }
#license-gate { position: fixed; inset: 0; display: none; z-index: 100; }
#license-gate .modal-card { width: min(440px, 92vw); }
#lic-form { display: flex; flex-direction: column; gap: 14px; }
#lic-btn { width: 100%; padding: 10px 0; }
.license-badge { font-size: 12px; font-weight: 600; letter-spacing: .02em; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-soft); background: #EFEAE2; color: var(--ink); }
.license-ok { background: #E7F0E6; border-color: #C6D8C4; color: #2F5D31; }
#btn-lic-logout[hidden] { display: none; }
