/* Gaya dari ui-ux-pro-max: gelap, merah muda video + biru linimasa, interaksi mikro singkat. Tanpa font luar (CSP). */
:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #a3b1c6;
  --primary: #f472b6;
  --on-primary: #0f172a;
  --primary-strong: #ec4899;
  --accent: #60a5fa;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --ring: #f9a8d4;
  --radius: 12px;
  --space: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fast: 150ms ease-out;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: calc(var(--space) * 2); }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 16px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.brand { display: flex; align-items: center; gap: var(--space); font-size: 1.25rem; font-weight: 700; }
.brand .icon { color: var(--primary); fill: currentColor; stroke: none; width: 24px; height: 24px; }
.muted { color: var(--muted); }
.small-text { font-size: 0.875rem; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space); flex-wrap: wrap; }

/* Kartu dan isian */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: calc(var(--space) * 2); margin: 0 0 calc(var(--space) * 2); min-width: 0; }
.card.inner { background: var(--surface-2); }
fieldset.card { display: grid; gap: var(--space); }
legend { font-weight: 700; font-size: 1.0625rem; padding: 0 4px; float: left; width: 100%; margin-bottom: 4px; }
label { font-weight: 500; font-size: 0.9375rem; display: block; }
input:not([type=radio]):not([type=checkbox]), select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  transition: border-color var(--fast), box-shadow var(--fast);
}
input[type=file] { padding: 10px; cursor: pointer; }
input::placeholder { color: #7c8aa0; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--danger); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(244, 114, 182, 0.35); }
.hint { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--danger); font-size: 0.9375rem; min-height: 0; }
.error:empty { display: none; }
.with-button { display: flex; gap: var(--space); }
.with-button input { flex: 1; }

/* Pilihan bersegmen dari radio biasa: tetap bisa dipakai dengan papan ketik */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; border: 1px solid var(--border); }
.segmented label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; cursor: pointer; text-align: center; padding: 6px 8px; transition: background var(--fast), color var(--fast); color: var(--muted); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--primary); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--ring); outline-offset: 1px; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation;
  transition: background var(--fast), border-color var(--fast), transform 100ms ease-out, opacity var(--fast);
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not([disabled]) { background: #f9a8d4; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover:not([disabled]) { border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover:not([disabled]) { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.primary.destructive { background: var(--danger); }
.btn.primary.destructive:hover:not([disabled]) { background: #fca5a5; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 0.9375rem; }
.btn.wide { width: 100%; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--on-primary); border-right-color: transparent; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Kerangka halaman */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); display: grid; gap: 12px; padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 10; }
.pages { order: 3; flex: 1 0 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--border); }
.page-link { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 6px 8px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9375rem; text-align: center; transition: background var(--fast), color var(--fast); }
.page-link:hover { color: var(--text); }
.page-link[aria-current=page] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--primary); }
.page-link[aria-current=page] .icon { color: var(--primary); }
@media (max-width: 420px) { .page-link .icon { display: none; } }
@media (min-width: 960px) { .pages { order: 0; flex: 0 1 640px; } }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 16px 0; }
.tab { min-height: 48px; background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; font: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: color var(--fast), border-color var(--fast); }
.tab[aria-pressed=true] { color: var(--text); border-bottom-color: var(--primary); }
.count { background: var(--accent); color: var(--bg); border-radius: 999px; font-size: 0.75rem; min-width: 22px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.layout { padding: 16px; max-width: 1280px; margin: 0 auto; }
.wide-page { padding: 16px; max-width: 1280px; margin: 0 auto; }
.split { display: grid; gap: 24px; align-items: start; }
.split > section { min-width: 0; }
.section-hint { margin: -8px 0 12px; }
.list { display: grid; gap: 12px; margin-bottom: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panel { min-width: 0; }
.layout:not(.show-orders) #orders { display: none; }
.layout.show-orders #new { display: none; }

@media (min-width: 960px) {
  .tabs { display: none; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; padding: 24px; }
  .layout #new, .layout #orders { display: block !important; }
  #orders { position: sticky; top: 88px; max-height: calc(100dvh - 112px); overflow-y: auto; padding-right: 4px; }
  .wide-page { padding: 24px; }
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .command-groups { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Unggahan */
.upload { display: grid; gap: 6px; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width 200ms ease-out; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* Rentang */
.ranges { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.range { display: grid; gap: var(--space); margin: 0; transition: box-shadow var(--fast); }
.range.active { box-shadow: 0 0 0 2px var(--primary); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space); }
.actions .btn { flex: 1 1 160px; }

/* Galeri gaya */
.gallery-box summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gallery-box[open] summary { margin-bottom: 12px; }
.gallery-group { font-size: 0.875rem; color: var(--muted); text-transform: capitalize; margin: 12px 0 8px; font-weight: 600; }
.gallery { display: block; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tile { display: grid; gap: 4px; text-align: left; padding: 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; transition: border-color var(--fast), transform 100ms ease-out; }
.tile:hover { border-color: var(--accent); }
.tile:active { transform: scale(0.98); }
.tile[aria-pressed=true] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.tile img, .tile .ph { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 0.75rem; }
.tile strong { font-size: 0.875rem; }
.tile span { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }

/* Masalah pesanan */
.problems { background: rgba(248, 113, 113, 0.1); border: 1px solid var(--danger); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.problems ul { margin: 6px 0 0; padding-left: 20px; }

/* Daftar pesanan */
.order-list { display: grid; gap: 12px; }
.order { display: grid; gap: 10px; margin: 0; }
.order-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.order-meta { display: grid; gap: 2px; min-width: 0; }
.order-meta .src { overflow-wrap: anywhere; font-size: 0.9375rem; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.working, .badge.queued { color: var(--accent); }
.badge.done { color: var(--ok); }
.badge.failed { color: var(--danger); }
.badge.paused { color: var(--warn); }
.badge.cancelled { color: var(--muted); }
.badge.idle { color: var(--text); }
.badge.stopped { color: var(--danger); }
.items:empty { display: none; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { display: grid; gap: 6px; padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.item-line { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 0.9375rem; }
.item video { display: block; margin: 0 auto; width: auto; max-width: 100%; max-height: 60dvh; border-radius: 8px; background: #000; }
.reason { color: var(--danger); font-size: 0.875rem; }
.paused-note { color: var(--warn); font-size: 0.875rem; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* Proses */
.service { display: grid; gap: 10px; margin: 0; }
.stock { display: grid; gap: 12px; }
.stock .service { background: var(--surface-2); }
.stock-total { font-size: 0.9375rem; }
.stock-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stock-list li { display: grid; gap: 4px; font-size: 0.9375rem; }
.stock-list progress::-webkit-progress-value { background: var(--primary); }
.stock-list progress::-moz-progress-bar { background: var(--primary); }
.run { display: grid; gap: 10px; margin: 0; }
.log-box summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--muted); }
.log-box summary:hover { color: var(--text); }
.log { margin: 0; max-height: 50dvh; overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font: 0.8125rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: #dbe4f0; }

/* Perintah */
.search { flex: 0 1 320px; margin-bottom: 16px; }
.command-groups { display: grid; gap: 16px 24px; align-items: start; }
.command-group { display: grid; gap: 8px; min-width: 0; }
.group-title { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 8px 0 0; }
.command { margin: 0; padding: 0; }
.command summary { cursor: pointer; list-style: none; display: grid; gap: 2px; padding: 12px 16px; min-height: 48px; border-radius: var(--radius); transition: background var(--fast); }
.command summary::-webkit-details-marker { display: none; }
.command summary:hover { background: var(--surface-2); }
.command[open] summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.command-title { font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.command-title::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform var(--fast); flex: none; margin-right: 4px; }
.command[open] .command-title::after { transform: rotate(-135deg); }
.command-form { display: grid; gap: 12px; padding: 16px; }
.field { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.inline-runs { display: grid; gap: 12px; }
.inline-runs:empty { display: none; }

/* Galeri konten */
.gallery-bar { display: grid; gap: 12px; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 8px; }
.search-field { flex: 1 1 180px; }
.filter-toggle[aria-expanded=true] { box-shadow: inset 0 0 0 1px var(--primary); }
.filter-panel { flex: 1 0 100%; display: grid; gap: 8px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.filter-result { margin-bottom: 16px; min-height: 44px; }
.content-group { margin-bottom: 24px; }
.group-head { margin-bottom: 12px; }
.contents { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 960px) { .contents { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.content { display: grid; grid-template-rows: auto 1fr; padding: 0; margin: 0; overflow: hidden; }
.media { aspect-ratio: 9 / 16; background: #000; display: grid; }
.media video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cover { position: relative; display: grid; place-items: center; padding: 0; border: 0; background: var(--surface-2); cursor: pointer; overflow: hidden; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.play { position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(15, 23, 42, 0.7); color: var(--text); border: 1px solid var(--border); transition: transform var(--fast), background var(--fast); }
.play .icon { fill: currentColor; stroke: none; width: 24px; height: 24px; margin-left: 3px; }
.cover:hover .play { background: var(--primary); color: var(--on-primary); transform: scale(1.05); }
.cover:focus-visible { outline-offset: -3px; }
.content-body { display: grid; gap: 6px; padding: 10px 12px 12px; align-content: start; min-width: 0; }
.content-title { font-size: 0.9375rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.9375rem; }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat .icon { width: 16px; height: 16px; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.chip.linked { color: var(--ok); border-color: currentColor; }
.chip.linked::before { content: "✓ "; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.tag.origin-stock { color: var(--accent); border-color: currentColor; }
.tag.origin-order { color: var(--warn); border-color: currentColor; }
.tag.mark-favorite, .mark-toggle.mark-favorite[aria-pressed=true] { color: var(--primary); border-color: currentColor; }
.tag.mark-fix, .mark-toggle.mark-fix[aria-pressed=true] { color: var(--danger); border-color: currentColor; }
.tag.mark-checked, .mark-toggle.mark-checked[aria-pressed=true] { color: var(--ok); border-color: currentColor; }
.tag.running { color: var(--accent); }
.mark-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.mark-toggle[aria-pressed=true] { background: var(--surface-2); }
.mark-toggle[aria-pressed=true]::before { content: "✓"; }
.dialog-section { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.content-actions { display: grid; gap: 12px; }
.content-actions .with-button { flex-wrap: wrap; }
.content-actions .with-button select { flex: 1 1 160px; min-width: 0; }
.content-actions .with-button input { flex: 1 1 90px; }
.content-run:empty { display: none; }
.content-run { display: grid; gap: 8px; }
.content-run .log { max-height: 30dvh; }
.content-info:empty { display: none; }
.content-info .src { color: var(--accent); overflow-wrap: anywhere; }
.content-dialog { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.links .src { overflow-wrap: anywhere; color: var(--accent); }
.numbers { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0; }
.numbers div { display: grid; gap: 0; text-align: center; background: var(--surface); border-radius: 8px; padding: 6px 2px; }
.numbers dt { font-size: 0.75rem; color: var(--muted); }
.numbers dd { margin: 0; font-weight: 600; }
@media (max-width: 420px) { .numbers { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.link-form { display: grid; gap: 8px; }

/* Pesan singkat */
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; width: max-content; max-width: calc(100% - 32px); background: var(--surface-2); color: var(--text); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); animation: rise 200ms ease-out; }
.toast.bad { border-color: var(--danger); }

/* Dialog di halaman (pengganti confirm()) */
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog { display: grid; gap: 12px; padding: 20px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
dialog[open] { animation: rise 200ms ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
