:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --border: #e3e6eb;
  --text: #16181d; --muted: #5d6573; --accent: #e8590c; --accent-text: #ffffff; --accent-soft: #fff1e8;
  --ok: #1f7a3d; --ok-soft: #e7f6ec; --warn: #9a6400; --warn-soft: #fff6dd; --err: #b42318; --err-soft: #fdecea;
  --info: #1d5fbf; --info-soft: #e8f0fc;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%235d6573' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --border: #2a2f39;
    --text: #e8eaee; --muted: #9aa3b2; --accent: #ff7a2f; --accent-soft: #2e1c11;
    --ok: #4cc77a; --ok-soft: #12261a; --warn: #f0b440; --warn-soft: #2a2210; --err: #ff6b5f; --err-soft: #2c1513;
    --info: #6ea8ff; --info-soft: #132036; --shadow: none;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%239aa3b2' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-weight: 700; color: var(--text); display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; align-items: center; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 64px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.head-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.head-actions .row { align-items: center; }
.head-actions form { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Forms */
label { display: block; font-weight: 600; font-size: .85rem; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], input[type=search],
input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; min-height: 40px; }
/* Our own chevron: the native one (iOS especially) ignores the padding, so the text sat on the border. */
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: var(--chevron);
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=file] { font: inherit; max-width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: .92rem; margin: 6px 0; }
.check input { margin-top: 4px; width: 16px; height: 16px; flex: none; }
.form-row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 40px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--err); }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* Badges & alerts */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.error { background: var(--err-soft); color: var(--err); }
.problem { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.problem-actions { display: flex; gap: 6px; }
.problem-actions form { margin: 0; }
.alert.info { background: var(--info-soft); color: var(--info); }
.list-plain { margin: 0; padding-left: 18px; }
.list-plain li { margin: 3px 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }

/* Stepper */
.stepper { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; margin: 12px 0 0; scrollbar-width: thin; }
.step { flex: 1 0 86px; font-size: .72rem; text-align: center; color: var(--muted); }
.step::before { content: ""; display: block; height: 5px; border-radius: 3px; background: var(--border); margin-bottom: 5px; }
.step.done::before { background: var(--ok); }
.step.current::before { background: var(--accent); }
.step.current { color: var(--text); font-weight: 700; }

/* Media */
video, .cover-img { width: 100%; border-radius: 10px; background: #000; display: block; }
.vertical { max-width: 340px; aspect-ratio: 9 / 16; object-fit: contain; margin: 0 auto; }
.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; }
.scene { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; padding: 0; color: var(--text); font: inherit; text-align: left; }
.scene img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.scene span { display: block; font-size: .75rem; padding: 3px 6px; }
.scene:hover { outline: 2px solid var(--accent); }
.ref-thumb { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--surface-2); flex: none; }

/* Segment editor */
.seg { display: grid; grid-template-columns: 34px 1fr 1fr 1.2fr; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface-2); }
.seg .seg-n { font-weight: 700; color: var(--muted); align-self: center; text-align: center; }
.seg .seg-reason { grid-column: 2 / -1; }
.seg .seg-tools { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { margin-top: 0; }

.progress-box { display: none; align-items: center; gap: 10px; }
.progress-box.on { display: flex; }
.spinner { flex: none; width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.next-action { background: var(--accent-soft); border: 1px solid transparent; border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin: 16px 0; }
.qc-item { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.qc-item:last-child { border-bottom: 0; }
.qc-item .badge { flex: none; width: 52px; text-align: center; }
.timeline { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
.timeline li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.onboard li { margin: 6px 0; }
.onboard .done { color: var(--ok); text-decoration: line-through; }

@media (max-width: 640px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; gap: 6px; }
  .nav { order: 3; width: 100%; flex: none; }
  .seg { grid-template-columns: 1fr 1fr; }
  .seg .seg-n { grid-column: 1 / -1; text-align: left; }
  .seg .seg-reason, .seg .seg-tools { grid-column: 1 / -1; }
  .card { padding: 14px; }
  h1 { font-size: 1.3rem; }
  .hide-sm { display: none !important; }
  .nav { gap: 2px; }
  .nav a, .more summary { padding: 6px 6px; font-size: .9rem; }
  .brand { font-size: .95rem; }
}

/* Draft edit plan suggestion */
.draft { margin-top: 12px; padding: 12px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.draft .card-head { gap: 6px; flex-wrap: wrap; justify-content: flex-start; }
.draft table { background: var(--surface); }

/* Automation form */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
details.paste summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
details.paste[open] summary { margin-bottom: 8px; }

/* ---- Simplified navigation ---- */
.nav .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: .75rem; font-weight: 700; text-align: center; }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ▾"; font-size: .8em; }
.more.active summary, .more[open] summary { color: var(--text); background: var(--surface-2); }
.more-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 30; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12);
  display: grid; }
.more-menu a { padding: 8px 10px; }

/* ---- Beranda ---- */
.todo { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 16px; }
.todo-item { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.todo-item b { font-size: 1.5rem; line-height: 1; }
.todo-item span { margin-left: auto; color: var(--info); font-weight: 600; white-space: nowrap; }
.todo-item:hover { text-decoration: none; border-color: var(--accent); }
.todo-item.primary { background: var(--accent-soft); border-color: var(--accent); }
.todo-item.primary span { color: var(--accent); }
.todo-item.done { color: var(--muted); }
.todo-item.done b { color: var(--ok); }
.channel-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.channel-grid .card + .card { margin-top: 0; }
.channel-card { display: grid; gap: 12px; align-content: start; }
.channel-card p, .channel-card .alert { margin: 0; }
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc-head h2 { margin: 0; font-size: 1.15rem; }
.cc-head h2 a { color: var(--text); }
.cc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cc-stats a { display: grid; gap: 2px; padding: 8px 6px; border-radius: 8px; background: var(--surface-2); color: var(--text); text-align: center; }
.cc-stats a:hover { text-decoration: none; outline: 1px solid var(--border); }
.cc-stats b { font-size: 1.25rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cc-stats span { font-size: .72rem; color: var(--muted); }
.cc-stats a.hot { background: var(--accent-soft); }
.cc-stats a.hot b { color: var(--accent); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick input, .quick .hint, .quick button { flex: 1 1 100%; }
.quick select { flex: 1 1 120px; width: auto; }
.quick .hint { margin: -2px 0 0; }
.retry-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 4px 0 0; }
.retry-row .btn { flex: none; }
.empty-start { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; }
.empty-start h2 { margin: 0; }

/* ---- Review queue ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .88rem; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip b { margin-left: 4px; }
.review { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.review-media video { width: 100%; aspect-ratio: 9 / 16; max-height: 78vh; background: #000; border-radius: var(--radius); display: block; }
.review-info { display: grid; gap: 12px; }
.review-info p, .review-info form { margin: 0; }
.review-title { font-size: 1.35rem; margin: 0; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.facts li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.err-text { color: var(--err); }
.checks { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px 8px; margin: 0 0 6px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.publish-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--border); }
.publish-override { grid-column: 1 / -1; justify-self: end; }
@media (max-width: 760px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review-media video { max-height: 70vh; }
  .publish-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .channel-grid { grid-template-columns: minmax(0, 1fr); }
}
.more-menu .linklike { width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; color: var(--err); font: inherit; cursor: pointer; border-radius: 8px; }
.more-menu .linklike:hover { background: var(--surface-2); }

.meter { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; min-width: 2px; }
.when-day { margin-bottom: 10px; }
.when-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 4px; }
.when-slot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.when-slot input { margin: 0; }
.when-slot.pick { border-color: var(--ok); background: var(--ok-soft); }
.when-slot .small { flex-basis: 100%; }

/* Foldable cards */
.fold-head { cursor: pointer; user-select: none; position: relative; padding-right: 26px; }
.fold-head::after { content: "▾"; position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--muted); transition: transform .15s; }
.folded > .fold-head::after { transform: translateY(-50%) rotate(-90deg); }
.folded > .fold-head { margin-bottom: 0; }
.folded > *:not(.fold-head) { display: none !important; }

/* Step progress while a video is being made */
.poll-bar { width: 140px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: var(--accent); transition: width .4s; }

/* Review: one confirmation, big actions */
.decide { display: grid; gap: 10px; }
.check.confirm { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.sticky-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) {
  .sticky-actions { position: sticky; bottom: 0; z-index: 10; background: var(--surface); padding: 10px 0 12px;
                    border-top: 1px solid var(--border); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .sticky-actions .btn { flex: 1 1 100%; justify-content: center; }
  .when-slots { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
.credit-line { margin: 6px 0 0; }
