:root {
  --bg: #f6f4f1; --card: #ffffff; --ink: #1c1a18; --muted: #77716a; --line: #e6e1da;
  --accent: #c92a2a; --accent-ink: #ffffff; --good: #2f9e44; --bad: #e03131; --warn: #f08c00;
  --chip: #f1ede7; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --r: 14px; --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312; --card: #1e1c1a; --ink: #f2efea; --muted: #a39d95; --line: #2f2c29;
    --accent: #ff5c5c; --chip: #2a2724; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
/* App frame (same fix as the finance app): the page never scrolls, only <main> does, and the tab bar is the last
   row of the frame — so iOS can't lift it after the keyboard or a sheet closes. --app-h is set from JS. */
html, body { height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: var(--app-h, 100dvh); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); box-sizing: border-box;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.page { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }
h1 { font-size: 24px; margin: 8px 0 12px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 18px 0 8px; }
a { color: var(--accent); }
.center { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.seg button { white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; background: var(--chip); font-size: 12.5px; font-weight: 600; }
.chip.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.chip.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.accent { background: var(--accent); color: var(--accent-ink); }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 650;
  padding: 10px 14px; border-radius: 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  text-decoration: none; min-height: 42px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.bad { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 13.5px; }
.btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn:disabled { opacity: .5; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--muted); border-top-color: transparent; animation: spin .7s linear infinite; }
.btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
label.field, .field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13.5px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
.hint { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.clip { padding: 0; overflow: hidden; }
.clip .media { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 12px; }
.clip video, .clip .poster { width: 132px; aspect-ratio: 9/16; border-radius: 10px; background: #000; object-fit: cover; display: block; }
.clip .poster { border: 0; padding: 0; cursor: pointer; position: relative; }
.clip .poster img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.clip .poster span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.clip .hook { font-weight: 800; font-size: 16px; line-height: 1.25; }
.clip .score { font-weight: 800; font-size: 22px; color: var(--accent); }
.clip .actions { display: grid; grid-template-columns: 1fr 1fr 1fr; border-top: 1px solid var(--line); }
.clip .actions button { border: 0; border-radius: 0; min-height: 48px; background: transparent; }
.clip .actions button + button { border-left: 1px solid var(--line); }
.progress { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty b { display: block; font-size: 40px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.log { font-size: 12.5px; max-height: 320px; overflow: auto; }
.log div { padding: 5px 0; border-bottom: 1px solid var(--line); }
#tabs {
  position: relative; flex: none; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); z-index: 10;
}
#tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 650; position: relative; }
#tabs a svg { width: 24px; height: 24px; }
#tabs a { font-size: 10.5px; }
#tabs a.on { color: var(--accent); }
#tabs a i { position: absolute; top: 6px; left: calc(50% + 8px); background: var(--accent); color: #fff; font-style: normal; font-size: 10.5px; font-weight: 800; border-radius: 99px; padding: 0 5px; min-width: 17px; text-align: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 30; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 720px; max-height: 92vh; margin: auto auto 0; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.sheet-head h2 { margin: 0; }
.sheet-body { padding: 6px 16px calc(20px + env(safe-area-inset-bottom)); }
.big-video { width: 100%; max-height: 62vh; aspect-ratio: 9/16; background: #000; border-radius: 12px; display: block; margin: 0 auto 12px; object-fit: contain; }
pre.caption { white-space: pre-wrap; font: inherit; font-size: 13.5px; background: var(--chip); border-radius: 10px; padding: 10px; margin: 6px 0; }
.login { max-width: 360px; margin: 10vh auto 0; }
.logo { font-size: 46px; text-align: center; }

/* line icons */
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#tabs a svg.ico { stroke-width: 1.7; }
#tabs a.on svg.ico { stroke-width: 2.2; }
/* copy feedback */
.btn.copied { background: var(--good); border-color: var(--good); color: #fff; animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
/* groups by source video */
.group { margin: 14px 0 6px; }
.group-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.group-head .title { flex: 1; min-width: 0; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head .chev { transition: transform .2s; }
.group.closed .chev { transform: rotate(-90deg); }
.group.closed .group-body { display: none; }
.group-body { padding-top: 8px; }
.group-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
/* selection */
.clip { position: relative; }
.pick { position: absolute; top: 10px; left: 10px; z-index: 2; width: 26px; height: 26px; border-radius: 8px; border: 2px solid #fff; background: rgba(0,0,0,.35); display: grid; place-items: center; cursor: pointer; }
.pick.on { background: var(--accent); border-color: var(--accent); }
.pick svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; }
.clip.picked { outline: 2px solid var(--accent); }
.bulkbar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 10px 12px; margin-top: 10px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.bulkbar .grow { font-weight: 700; }
/* queue control */
.qbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 10px; font-size: 13.5px; }
.qbar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.qbar.paused .dot { background: var(--warn); }

/* queue panels */
.qpanel { border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin-bottom: 12px; overflow: hidden; }
.qhead { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.qhead .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.qhead .dot.working { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); animation: breathe 1.6s ease-in-out infinite; }
.qhead .dot.paused { background: var(--warn); }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--good) 10%, transparent); } }
.qhead .chev { transition: transform .2s; transform: rotate(-90deg); }
.qpanel.open .qhead .chev { transform: none; }
.qtitle { font-weight: 750; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qsub { font-size: 12.5px; color: var(--muted); }
.qlist { border-top: 1px solid var(--line); max-height: 320px; overflow-y: auto; }
.qrow { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.qrow.working { background: color-mix(in srgb, var(--good) 7%, transparent); }
.qrow.paused { opacity: .65; }
.qrow .progress { margin-top: 5px; }
.qicon { width: 28px; text-align: center; font-size: 17px; flex: none; }
.qbadge { width: 28px; height: 22px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: none; }

/* one queue item's own pause / resume (44px tap target, icon only) */
.qbtn { flex: none; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.qbtn .ico { width: 18px; height: 18px; margin: 0; }
.qbtn.on { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* small preview player: own controls, fullscreen at the top right (the select box sits top-left) */
.clip .pv { position: relative; width: 132px; aspect-ratio: 9/16; border-radius: 10px; overflow: hidden; background: #000; }
.clip .pv video { width: 100%; height: 100%; border-radius: 0; }
.pv-fs { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; border-radius: 10px; padding: 0;
  display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; }
.pv-fs .ico { width: 18px; height: 18px; margin: 0; }
.pv-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #fff; }
.pv-play[hidden] { display: none; }
.pv-play .ico { width: 34px; height: 34px; fill: #fff; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }
.pv-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; display: flex; align-items: flex-end; cursor: pointer; }
.pv-bar::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.3); }
.pv-bar i { position: relative; display: block; height: 4px; width: 0; background: var(--accent); }

/* Kisah Seram: card action row buttons are flat cells */
.clip .actions .btn { border: 0; border-radius: 0; min-height: 48px; background: transparent; }
.clip .actions .btn + .btn { border-left: 1px solid var(--line); }
.clip .actions .btn.good { color: var(--good); }
.clip .actions .btn.primary { color: var(--accent); }
