/* ---------- Tema monokrom (gelap = default; terang bila data-theme="light", diatur js/theme.js) ---------- */
:root {
  color-scheme: dark;
  --base: #0A0A0A; --surface: #111111; --raised: #1A1A1A; --line: #262626; --line-strong: #3A3A3A;
  --ink: #FAFAFA; --mute: #8F8F8F; --faint: #5C5C5C;
  --accent: #FAFAFA; --on-accent: #0A0A0A; --accent-ink: #FAFAFA; --ring: rgba(250, 250, 250, .14);
  --sk1: #141414; --sk2: #1D1D1D; --scrim: rgba(0, 0, 0, .6);
}
html[data-theme="light"] {
  color-scheme: light;
  --base: #FAFAFA; --surface: #FFFFFF; --raised: #F0F0F0; --line: #E4E4E4; --line-strong: #CFCFCF;
  --ink: #0A0A0A; --mute: #666666; --faint: #A3A3A3;
  --accent: #0A0A0A; --on-accent: #FAFAFA; --accent-ink: #0A0A0A; --ring: rgba(10, 10, 10, .12);
  --sk1: #EDEDED; --sk2: #F7F7F7; --scrim: rgba(0, 0, 0, .35);
}

/* Warna Tailwind (sudah terkompilasi, hex tetap) diarahkan ke variabel tema */
html .bg-surface { background-color: var(--surface); }
html .bg-raised, html .hover\:bg-raised:hover { background-color: var(--raised); }
html .bg-accent { background-color: var(--accent); }
html .border-line { border-color: var(--line); }
html .border-accent\/40 { border-color: var(--line-strong); }
html .focus\:border-accent:focus { border-color: var(--ink); }
html .focus\:ring-accent\/20:focus { --tw-ring-color: var(--ring); }
html .text-ink, html .hover\:text-ink:hover { color: var(--ink); }
html .text-mute, html .placeholder\:text-mute::placeholder { color: var(--mute); }
html .text-line { color: var(--line); }
html .text-accent { color: var(--accent-ink); }
html .text-\[\#04121C\] { color: var(--on-accent); }
html .text-\[\#3A3A43\] { color: var(--line-strong); }
html body.bg-night { background-color: var(--base); }

html { scroll-behavior: smooth; background: var(--base); }
body { background: var(--base); color: var(--ink); -webkit-tap-highlight-color: transparent; }
::selection { background: var(--ink); color: var(--base); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 2.75rem; padding: 0 1.1rem; border-radius: .75rem; font-size: .9rem; font-weight: 600;
  white-space: nowrap; cursor: pointer; border: 1px solid transparent;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { opacity: .86; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--raised); border-color: var(--line-strong); }
.btn-danger { background: transparent; color: #FB7185; border-color: #4C1D2A; height: 2.25rem; padding: 0 .8rem; font-size: .8rem; }
.btn-danger:hover { background: #2A1119; }
.btn-sm { height: 2.25rem; padding: 0 .8rem; font-size: .8rem; border-radius: .6rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .75rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--raised); border-color: var(--line-strong); }

/* ---------- Gambar (tile masonry) ---------- */
.tile { position: relative; border-radius: .85rem; overflow: hidden; background: var(--surface); }
.tile-img { display: block; width: 100%; background: var(--raised); }
.tile-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, opacity .3s; }
.tile:hover .tile-img img { transform: scale(1.03); }
.tile-dl {
  position: absolute; right: .5rem; bottom: .5rem; display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff;
  border: 1px solid rgba(255, 255, 255, .28); transition: background-color .15s, color .15s;
}
.tile-dl:hover { background: #fff; color: #0A0A0A; }
.tile-label {
  position: absolute; inset: auto 0 0 0; padding: 1.6rem 3.2rem .65rem .7rem; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent); color: #fff;
  font-size: .78rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (hover: hover) {
  .tile-label { opacity: 0; transition: opacity .2s; }
  .tile:hover .tile-label, .tile:focus-within .tile-label { opacity: 1; }
}
.badge-new {
  position: absolute; left: .5rem; top: .5rem; padding: .05rem .45rem; border-radius: .4rem;
  background: #fff; color: #0A0A0A; font: 600 .62rem/1.1rem "JetBrains Mono", ui-monospace, monospace;
}

/* Tombol unduh di atas preview (halaman file) */
.preview-dl {
  position: absolute; left: 0; right: 0; bottom: 1rem; margin: 0 auto; display: grid; place-items: center;
  width: 3rem; height: 3rem; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff;
  border: 1px solid rgba(255, 255, 255, .28); transition: background-color .15s, color .15s;
}
.preview-dl:hover { background: #fff; color: #0A0A0A; }

/* ---------- Folder ---------- */
.folder .mosaic { overflow: hidden; border-radius: .95rem; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s; }
.folder:hover .mosaic { border-color: var(--line-strong); }
.folder .mosaic img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--sk1) 25%, var(--sk2) 37%, var(--sk1) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Dialog / bottom sheet ---------- */
.sheet {
  padding: 0; border: 1px solid var(--line); border-radius: 1.1rem; background: var(--surface); color: var(--ink);
  width: min(94vw, 26rem); max-height: 86vh; overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.sheet::backdrop { background: var(--scrim); }
@media (max-width: 639px) {
  .sheet { margin: auto auto 0; width: 100%; max-width: none; border-radius: 1.25rem 1.25rem 0 0; border-bottom: 0; }
}
.opt {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .8rem 1rem; text-align: start; font-size: .95rem; border-radius: .7rem; color: var(--ink);
}
.opt:hover { background: var(--raised); }
.opt[aria-checked="true"] { background: var(--raised); }
.opt .tick { color: var(--ink); opacity: 0; }
.opt[aria-checked="true"] .tick { opacity: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; z-index: 60;
  padding: .65rem 1rem; border-radius: 999px; background: var(--ink); color: var(--base); font-size: .85rem; font-weight: 600;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Form (admin) ---------- */
.field {
  width: 100%; height: 2.75rem; padding: 0 .85rem; border-radius: .7rem;
  background: var(--base); border: 1px solid var(--line); color: var(--ink); font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea.field { height: auto; padding: .7rem .85rem; resize: vertical; min-height: 4.5rem; }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238E8E98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.2rem; }
[dir="rtl"] select.field { background-position: left .75rem center; padding-right: .85rem; padding-left: 2.2rem; }
.field::placeholder { color: var(--faint); }
.field:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ring); }
.label { display: block; margin-bottom: .4rem; font-size: .78rem; font-weight: 600; color: var(--mute); letter-spacing: .02em; }
.hint { margin-top: .35rem; font-size: .75rem; color: var(--mute); }

.seg { display: inline-flex; padding: .2rem; border-radius: .8rem; background: var(--surface); border: 1px solid var(--line); }
.seg button { padding: .45rem 1rem; border-radius: .6rem; font-size: .85rem; font-weight: 600; color: var(--mute); }
.seg button.is-active { background: var(--raised); color: var(--ink); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; text-align: center;
  padding: 1.6rem 1rem; border-radius: .9rem; border: 1.5px dashed var(--line-strong); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--raised); }

.progress { height: 5px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.row { display: flex; align-items: center; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; padding: .1rem .5rem; border-radius: 999px; font: 500 .68rem/1.1rem "JetBrains Mono", ui-monospace, monospace; background: var(--raised); color: var(--mute); }
.chip.ok { color: #4ADE80; } .chip.err { color: #FB7185; } .chip.busy { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Header & elemen kecil ---------- */
.site-header { background: var(--base); }
.link-pill { background: var(--surface); }
.link-pill:hover { background: var(--raised); border-color: var(--line-strong); }

/* Pilihan tema di Settings */
.seg-full { display: flex; margin: 0 1rem .5rem; }
.seg-full button { flex: 1; transition: background-color .15s, color .15s; }

/* ---------- Transisi antar halaman ----------
   Browser modern: View Transitions (header tetap diam, konten memudar + naik sedikit).
   Browser lama: animasi .page-in pada #app (dipicu js/app.js). Dimatikan bila "kurangi gerakan". */
.site-header { view-transition-name: site-header; }
::view-transition-group(site-header) { animation: none; }
::view-transition-image-pair(root) { isolation: isolate; }
::view-transition-old(root) { animation: vt-out .15s ease both; mix-blend-mode: normal; }
::view-transition-new(root) { animation: vt-in .3s cubic-bezier(.2, .7, .2, 1) both; mix-blend-mode: normal; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); } }
.page-in { animation: vt-in .3s cubic-bezier(.2, .7, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
