:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1b2230;
  --muted: #667085;
  --line: #e2e5ea;
  --hover: #f0f2f5;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --folder: #d9962b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1e26;
    --ink: #e8ebf0;
    --muted: #98a1b2;
    --line: #2a303b;
    --hover: #222732;
    --accent: #2dd4bf;
    --accent-ink: #0b1f1c;
    --danger: #f97066;
    --folder: #e0a64a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.01em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }
.error { min-height: 22px; margin: 0 0 12px; color: var(--danger); font-size: 14px; }

/* ---------- App ---------- */
.shell { max-width: 960px; margin: 0 auto; padding: 0 16px 80px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 0;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.who { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.crumbs button {
  border: 0; background: none; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumbs button:hover { background: var(--hover); color: var(--ink); }
.crumbs button:last-child { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--line); }
.actions { display: flex; gap: 8px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row {
  display: grid; grid-template-columns: 1fr 100px 120px 96px; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row.head { color: var(--muted); font-size: 13px; padding-top: 8px; padding-bottom: 8px; background: var(--bg); }
.row.item:hover { background: var(--hover); }
.name { display: flex; align-items: center; gap: 12px; min-width: 0; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name svg { width: 22px; height: 22px; flex: none; color: var(--muted); }
.name svg.folder { color: var(--folder); }
.meta { color: var(--muted); font-size: 14px; }
.tools { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; }
.row.item:hover .tools, .row.item:focus-within .tools { opacity: 1; }
.tools button {
  border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); display: grid;
}
.tools button:hover { background: var(--line); color: var(--ink); }
.tools button.del:hover { color: var(--danger); }
.tools svg { width: 18px; height: 18px; }

.empty { padding: 56px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 16px; }

.usage { margin-top: 14px; color: var(--muted); font-size: 13px; }

.drop {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(2px);
  font-size: 20px; font-weight: 600;
}
.drop.on { display: grid; }
.drop div { padding: 40px 56px; border: 2px dashed var(--accent); border-radius: 16px; color: var(--accent); }

.progress {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  width: min(360px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; display: none; font-size: 14px;
}
.progress.on { display: block; }
.progress .track { margin-top: 8px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  display: none; max-width: calc(100% - 32px);
}
.toast.on { display: block; }

dialog {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  padding: 22px; width: min(400px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog p { margin: 0 0 14px; color: var(--muted); }
dialog input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); margin-bottom: 16px; }
dialog .btns { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr 84px; }
  .row .date, .row.head .date, .row.head .tools-h { display: none; }
  .tools { opacity: 1; grid-column: 1 / -1; justify-content: flex-start; margin-top: -4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- Galeri (grid) ---------- */
.panel.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.panel.grid .row.head { display: none; }
.panel.grid .empty { grid-column: 1 / -1; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  transition: border-color .15s;
}
.tile:hover { border-color: var(--accent); }
.tile-media {
  width: 100%; aspect-ratio: 1; padding: 0; border: none; border-radius: 8px;
  background: var(--hover); display: grid; place-items: center; overflow: hidden; cursor: pointer;
}
.tile-media svg { width: 42px; height: 42px; color: var(--muted); }
.tile-media svg.folder { color: var(--folder); }
.tile-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: 12px; color: var(--muted); margin-top: -2px; }
.tile-tools { position: absolute; top: 11px; right: 11px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; }
@media (hover: none) { .tile-tools { opacity: 1; } }
.tile-tools button {
  width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(4px);
  border: 1px solid var(--line);
}
.tile-tools button.del { color: var(--danger); }
.tile-tools svg { width: 15px; height: 15px; }
.thumb { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: none; }

/* ---------- Lightbox ---------- */
body.lb-open { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 60; background: rgba(9, 11, 15, .93); display: flex; align-items: center; justify-content: center; }
.lb[hidden] { display: none; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 58px 72px 16px; }
.lb video { max-width: 100%; max-height: 100%; padding: 58px 72px 16px; background: #000; }
.lb video[hidden] { display: none; }

/* Badge ▶ + cover video di grid & daftar */
.vid { position: relative; width: 100%; height: 100%; display: block; }
.vid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vid .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none;
}
.vid .play::before {
  content: ''; position: absolute; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
}
.vid .play::after {
  content: ''; position: absolute; z-index: 1; margin-left: 2px;
  border-style: solid; border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
}
.tile-media .vid .play::before { width: 34px; height: 34px; }
.tile-media .vid .play::after { border-width: 7px 0 7px 12px; }
.name .vid { width: 34px; height: 34px; }
.name .vid .play::before { width: 20px; height: 20px; }
.name .vid .play::after { border-width: 4px 0 4px 7px; }
.lb-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 12px 16px; color: #fff;
}
#lbName { font-size: 14px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.lb-btn {
  color: #fff; font-size: 14px; text-decoration: none; cursor: pointer;
  background: rgba(255,255,255,.12); border: none; border-radius: 8px; padding: 7px 12px;
}
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding-bottom: 4px;
}
.lb-nav:hover { background: rgba(255,255,255,.24); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
@media (max-width: 640px) {
  .lb img { padding: 60px 8px 76px; }
  .lb-nav { top: auto; bottom: 16px; transform: none; }
}
