:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f0f0f4;
  --line: #e3e3ea;
  --text: #1a1a22;
  --muted: #6b6b7a;
  --accent: #5b5bd6;
  --accent-soft: #ececfd;
  --accent-text: #ffffff;
  --danger: #d13d4a;
  --star: #e2a400;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 4px 16px rgba(20, 20, 40, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111116; --surface: #1a1a21; --surface-2: #23232c; --line: #2e2e39;
    --text: #ececf2; --muted: #9a9aab; --accent: #8585f0; --accent-soft: #2a2a4a;
    --accent-text: #0f0f1a; --danger: #ff6b76; --star: #ffc433;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111116; --surface: #1a1a21; --surface-2: #23232c; --line: #2e2e39;
  --text: #ececf2; --muted: #9a9aab; --accent: #8585f0; --accent-soft: #2a2a4a;
  --accent-text: #0f0f1a; --danger: #ff6b76; --star: #ffc433; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { color: var(--star); border-color: var(--star); }
.icon-btn[aria-pressed="true"] svg { fill: var(--star); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center;
}
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0 0 8px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.login-card .brand-mark { margin: 0 auto; width: 40px; height: 40px; }
.err { color: var(--danger); }

.brand-mark {
  display: inline-block; width: 26px; height: 26px; border-radius: 8px; background: var(--accent);
  background-image: linear-gradient(var(--accent-text), var(--accent-text)), linear-gradient(var(--accent-text), var(--accent-text)), linear-gradient(var(--accent-text), var(--accent-text));
  background-size: 60% 9%, 60% 9%, 40% 9%; background-position: 50% 30%, 50% 50%, 30% 70%; background-repeat: no-repeat;
}

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 10px 20px 0;
}
.top-row { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; font-size: 16px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; max-width: 640px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 9px 0; min-width: 0; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin-left: auto; }
.view-toggle button { border: 0; background: var(--surface); padding: 8px 10px; display: grid; place-items: center; color: var(--muted); }
.view-toggle button.on { background: var(--accent-soft); color: var(--accent); }
.menu { position: relative; }
.menu summary { list-style: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; display: grid;
}
.menu-pop button, .menu-pop a { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 7px; color: inherit; text-decoration: none; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); }

.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.tabs button b { font-weight: 500; opacity: .7; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.filter-right { display: flex; gap: 8px; align-items: center; }
.filter-right select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background-color: var(--surface); max-width: 260px;
}

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: thin; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--text); white-space: nowrap;
}
.chip span { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.on span { color: inherit; opacity: .8; }
.chip.zero { opacity: .45; }

/* ---------- results ---------- */
main { padding: 12px 20px 60px; }
.summary { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s;
  display: block; width: 100%; text-align: left; padding: 0;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb { position: relative; background: var(--surface-2); overflow: hidden; aspect-ratio: 4 / 5; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb .noimg { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 12px; }
.badge {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.62); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px;
}
.badge svg { width: 11px; height: 11px; fill: #fff; stroke: none; }
.badge.right { left: auto; right: 8px; }
.fav-dot { position: absolute; right: 8px; bottom: 8px; color: var(--star); }
.fav-dot svg { fill: var(--star); stroke: none; width: 16px; height: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.copy-fab {
  position: absolute; right: 8px; top: 8px; opacity: 0; transition: opacity .15s;
  background: rgba(255,255,255,.95); color: #1a1a22; border: 0; border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600;
}
.card:hover .copy-fab, .card:focus-within .copy-fab { opacity: 1; }
@media (hover: none) { .copy-fab { opacity: 1; } }
.card-body { padding: 10px 12px 12px; }
.card-prompt {
  margin: 0; font-size: 13px; line-height: 1.45; min-height: calc(1.45em * 3); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.card-meta .cat { background: var(--accent-soft); color: var(--accent); padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.card-meta .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* list view */
.list { display: grid; gap: 10px; }
.list .card { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.list .card:hover { transform: none; }
.list .thumb { aspect-ratio: 4 / 5; height: auto; }
.list .card { align-items: start; }
.list .card-body { padding: 12px 14px; display: flex; flex-direction: column; }
.list .card-prompt { -webkit-line-clamp: 6; font-size: 13.5px; min-height: 0; }
.list .card-meta { margin-top: auto; padding-top: 8px; }
.list .copy-fab { opacity: 1; position: static; align-self: flex-start; margin-top: 8px; background: var(--accent-soft); color: var(--accent); }

/* ---------- viewer ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(10, 10, 20, .65); backdrop-filter: blur(2px); }
.viewer { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.viewer-inner { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr); max-height: calc(100vh - 32px); }
.viewer-media { background: #0c0c10; display: grid; gap: 4px; align-content: center; overflow: auto; min-height: 300px; position: relative; }
.viewer-media img { width: 100%; max-height: calc(100vh - 40px); object-fit: contain; display: block; }
.viewer-media video { width: 100%; max-height: calc(100vh - 40px); display: block; background: #000; }
.badge, .copy-fab, .fav-dot { z-index: 2; }
.hover-vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.viewer-media.multi { grid-template-columns: 1fr 1fr; align-content: start; }
.viewer-media.multi img { max-height: none; aspect-ratio: 1; object-fit: cover; }
.play-link {
  position: absolute; inset: 0; display: grid; place-items: center; text-decoration: none;
}
.play-link span {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600;
}
.play-link svg { fill: #fff; stroke: none; }
.viewer-side { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; overflow: auto; min-height: 0; }
.viewer-head { display: flex; align-items: center; gap: 8px; }
.viewer-head .close { margin-left: auto; flex: none; }
.pill { background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.prompt-box { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; flex: 1 1 auto; overflow: auto; min-height: 120px; }
.prompt-box pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prompt-box textarea { width: 100%; min-height: 240px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface); font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; }
.viewer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.viewer-meta { display: grid; gap: 10px; }
.viewer-meta label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.viewer-meta select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background-color: var(--surface); color: var(--text); font-size: 14px; }
.viewer-meta .row { display: flex; gap: 6px; flex-wrap: wrap; }
.viewer-meta p { margin: 0; }
.viewer-nav { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- categories dialog ---------- */
.cat-dlg { width: min(720px, calc(100vw - 32px)); padding: 18px 20px; }
.cat-head { display: flex; align-items: center; justify-content: space-between; }
.cat-head h2 { margin: 0; font-size: 18px; }
#catList { display: grid; gap: 10px; max-height: 60vh; overflow: auto; margin: 12px 0; }
.cat-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 8px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.cat-row input, .cat-row textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.cat-row textarea { min-height: 56px; resize: vertical; font-size: 12.5px; }
.cat-row .acts { display: grid; gap: 6px; }
.cat-foot { display: flex; justify-content: space-between; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 500;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .top { padding: 8px 16px 0; }
  .brand-name { display: none; }
  .view-toggle { display: none; }
  .filter-row { gap: 8px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding: 6px 8px; }
  .filter-right { width: 100%; }
  .filter-right select { flex: 1; min-width: 0; }
  main { padding: 10px 16px 60px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 8px 10px 10px; }
  .card-prompt { font-size: 12px; }
  .card-meta .src { display: none; }
  .viewer { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  .viewer-inner { grid-template-columns: 1fr; max-height: 100vh; height: 100vh; overflow: auto; }
  .viewer-media { min-height: 0; max-height: 50vh; }
  .viewer-media img, .viewer-media video { max-height: 55vh; }
  .viewer-side { overflow: visible; }
  .cat-row { grid-template-columns: 1fr; }
}

/* ---------- dropdown seragam ---------- */
select {
  -webkit-appearance: none; appearance: none;
  padding-right: 38px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  cursor: pointer; line-height: 1.3;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.grp-list { display: grid; gap: 4px; max-height: 60vh; overflow: auto; margin-top: 12px; }
.grp-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.grp-row:hover { background: var(--surface-2); }
.grp-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.grp-row b { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.grp-row:has(input:not(:checked)) span { color: var(--muted); text-decoration: line-through; }

/* ---------- siri langkah ---------- */
.steps-box { display: grid; gap: 8px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.steps button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 500; }
.steps button:hover { border-color: var(--accent); }
.steps button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.small-btn { justify-self: start; padding: 5px 10px; font-size: 12.5px; }
.steps-badge { background: var(--accent); color: var(--accent-text); }
