/* Tema: gelap sebagai bawaan (seperti server Anda sekarang); tombol di pojok kanan atas beralih ke terang. */
:root, :root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-2: #0f1829;
  --surface: #141e31;
  --surface-2: #1b2740;
  --line: #26344f;
  --text: #eef3fb;
  --muted: #93a3bd;
  --accent: #4cc2ff;
  --accent-ink: #04202f;
  --accent-soft: rgba(76, 194, 255, 0.14);
  --warm: #ffb454;
  --danger: #ff7b7b;
  --danger-ink: #2c0707;
  --ok: #56d99a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f6fb;
  --bg-2: #e9eef6;
  --surface: #ffffff;
  --surface-2: #f0f4fa;
  --line: #d8e0ec;
  --text: #0f1b2d;
  --muted: #5b6b84;
  --accent: #0a74c9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 116, 201, 0.1);
  --warm: #b86a00;
  --danger: #c93636;
  --danger-ink: #ffffff;
  --ok: #17935c;
  --shadow: 0 18px 50px rgba(20, 40, 80, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
code {
  padding: 0.12em 0.4em;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  border-radius: 6px;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.offscreen { position: fixed; left: -9999px; top: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px); }
.btn.primary { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger-ink); background: var(--danger); border-color: transparent; }
.btn.small { min-height: 2.2rem; padding: 0.35rem 0.85rem; font-size: 0.92rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(255, 123, 123, 0.12); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

[data-theme="dark"] .icon-sun, :root:not([data-theme]) .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon, :root:not([data-theme]) .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* ---------- Bilah atas ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.logo {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 11px;
}
.tabs { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.tab { text-decoration: none; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.top-actions { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.top-actions form { margin: 0; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .brand span:last-child { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .tab { flex: 1; justify-content: center; padding: 0.55rem 0.4rem; }
  .tab span { font-size: 0.85rem; }
}
@media (max-width: 420px) {
  .tab .icon { display: none; }
}

/* ---------- Tata letak ---------- */
.container { width: 100%; max-width: 68rem; margin: 0 auto; padding: 1.75rem 1rem 4rem; }
.pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}
.lead { max-width: 40rem; margin-bottom: 1.25rem; color: var(--muted); }
.hint { margin-top: 1.5rem; font-size: 0.92rem; color: var(--muted); }

.usage { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; font-size: 0.9rem; color: var(--muted); }
.meter { width: 9rem; height: 6px; overflow: hidden; background: var(--surface-2); border-radius: 99px; }
.meter-bar { width: 0; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s; }

.alert {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid;
  border-radius: 12px;
  font-size: 0.95rem;
}
.alert.error { color: var(--danger); border-color: var(--danger); background: rgba(255, 123, 123, 0.08); }
.alert.warn { color: var(--warm); border-color: var(--warm); background: rgba(255, 180, 84, 0.08); }

/* ---------- Unggah ---------- */
.dropzone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  padding: 1.4rem 1.5rem;
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone > .icon { width: 2.2rem; height: 2.2rem; color: var(--accent); }
.dropzone div { display: grid; flex: 1; min-width: 12rem; }
.dropzone strong { font-size: 1.05rem; }
.dropzone span { color: var(--muted); font-size: 0.92rem; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 3px dashed var(--accent);
  pointer-events: none;
}
.drop-overlay .icon { width: 3rem; height: 3rem; }
.drop-overlay p { margin-top: 0.5rem; font-size: 1.3rem; font-weight: 700; }

.uploads { display: grid; gap: 0.5rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.upload {
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: opacity 0.4s;
}
.upload.out { opacity: 0; }
.upload-top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.45rem; font-size: 0.92rem; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload-state { flex: none; color: var(--muted); }
.upload.ok .upload-state { color: var(--ok); }
.upload.bad .upload-state { color: var(--danger); }
.bar { height: 6px; overflow: hidden; background: var(--surface-2); border-radius: 99px; }
.bar-fill { width: 0; height: 100%; background: var(--accent); transition: width 0.12s; }
.upload.ok .bar-fill { background: var(--ok); }
.upload.bad .bar-fill { background: var(--danger); }

/* ---------- Bilah alat ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.5rem 0 1rem; }
.search {
  position: relative;
  flex: 1 1 14rem;
  display: flex;
  align-items: center;
}
.search .icon { position: absolute; left: 0.85rem; color: var(--muted); pointer-events: none; }
input[type="search"], input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.55rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search input { padding-left: 2.5rem; }
select { width: auto; cursor: pointer; }
textarea { resize: vertical; line-height: 1.5; }
.seg { display: inline-flex; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.seg button {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.seg button.on { color: var(--accent); background: var(--accent-soft); }

/* ---------- Daftar file ---------- */
.files { display: grid; gap: 0.9rem; }
.files.grid { grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); }
@media (max-width: 600px) {
  .files.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .files.big { grid-template-columns: 1fr; }
  .fact .icon-btn { width: 2.1rem; height: 2.1rem; }
}
.files.big { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.files.list { grid-template-columns: 1fr; gap: 0.5rem; }

.file {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.file:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.file-open { display: block; width: 100%; padding: 0; color: inherit; background: none; border: 0; cursor: pointer; }
.thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  color: var(--accent);
  background: var(--surface-2);
}
.thumb > .icon { width: 2.2rem; height: 2.2rem; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .ext {
  position: absolute;
  left: 0.6rem;
  bottom: 0.5rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-radius: 6px;
}
.kind-slides .thumb, .thumb.kind-slides { color: var(--warm); }
.thumb.kind-pdf { color: var(--danger); }
.thumb.kind-audio, .thumb.kind-video { color: var(--ok); }

.finfo { display: grid; gap: 0.1rem; padding: 0.7rem 0.85rem 0.3rem; min-width: 0; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; color: var(--muted); }
.fact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.1rem; padding: 0.25rem 0.5rem 0.6rem; }
.note-row .fact { justify-content: flex-end; }
.files.big .fact { padding: 0.35rem 0.85rem 0.85rem; }

.files.list .file { flex-direction: row; align-items: center; border-radius: 14px; }
.files.list .file-open { width: 4.2rem; flex: none; }
.files.list .thumb { aspect-ratio: 1; }
.files.list .thumb > .icon { width: 1.5rem; height: 1.5rem; }
.files.list .thumb .ext { display: none; }
.files.list .finfo { flex: 1; padding: 0.5rem 0.9rem; }
.files.list .fact { padding: 0.25rem 0.6rem 0.25rem 0; flex: none; flex-wrap: nowrap; justify-content: flex-end; }

@media (max-width: 560px) {
  .files.list .file { flex-wrap: wrap; }
  .files.list .fact { width: 100%; padding: 0 0.5rem 0.5rem; justify-content: flex-end; }
}

.empty {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
}
.empty .icon { width: 2rem; height: 2rem; color: var(--accent); }
.empty p { max-width: 24rem; }

/* ---------- Catatan ---------- */
.note-form { display: grid; gap: 0.75rem; max-width: 42rem; margin-bottom: 1.5rem; }
.note-form .btn { justify-self: start; }
.notes { display: grid; gap: 0.7rem; max-width: 42rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.note { padding: 0.9rem 1rem 0.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.4rem; }
.note-time { font-size: 0.82rem; color: var(--muted); }

/* ---------- Bagikan ---------- */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 2rem; }
.qr-box {
  display: grid;
  place-items: center;
  width: 17rem;
  min-height: 17rem;
  padding: 1rem;
  background: #fff;
  border-radius: 20px;
}
.qr-box img { width: 100%; height: auto; image-rendering: pixelated; }
.qr-missing { color: #333; font-size: 0.92rem; text-align: center; }
.qr-missing code { color: #000; background: #eee; }
.share-info { display: grid; flex: 1; gap: 0.75rem; min-width: 16rem; max-width: 30rem; }
.share-info p { color: var(--muted); }
.addr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.addr-row code { padding: 0.55rem 0.8rem; font-size: 1rem; overflow-wrap: anywhere; }

.speedframe { display: block; width: 100%; height: min(72vh, 42rem); background: #fff; border: 1px solid var(--line); border-radius: 16px; }

/* ---------- Dialog ---------- */
dialog {
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 8, 16, 0.72); backdrop-filter: blur(3px); }

#asker { width: min(26rem, calc(100vw - 2rem)); }
#asker form { display: grid; gap: 0.9rem; padding: 1.4rem; }
#asker-text { color: var(--muted); overflow-wrap: anywhere; }
.asker-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.3rem; }

#viewer {
  width: min(78rem, calc(100vw - 1.5rem));
  height: min(52rem, calc(100vh - 1.5rem));
  max-width: none;
  max-height: none;
  overflow: hidden;
}
#viewer[open] { display: flex; flex-direction: column; }
.viewer-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.8rem 0.6rem 1.1rem; border-bottom: 1px solid var(--line); }
.viewer-head h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.viewer-actions { display: flex; align-items: center; gap: 0.4rem; }
.viewer-body { position: relative; display: grid; flex: 1; place-items: center; min-height: 0; background: var(--bg-2); }
.viewer-body img, .viewer-body video { width: 100%; height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; background: #fff; border: 0; }
.textview {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.1rem 1.3rem;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.audio-wrap { display: grid; justify-items: center; gap: 1.2rem; width: min(30rem, 90%); }
.audio-wrap audio { width: 100%; }
.icon.big { width: 4rem; height: 4rem; color: var(--ok); }
.viewer-wait { display: grid; justify-items: center; gap: 1rem; padding: 2rem; text-align: center; color: var(--muted); }
.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transform: translateY(-50%);
}
.nav-arrow.prev { left: 0.8rem; }
.nav-arrow.next { right: 0.8rem; }
.nav-arrow:hover { background: var(--surface-2); }

@media (max-width: 560px) {
  #viewer { width: 100vw; height: 100dvh; max-width: 100vw; border-radius: 0; border: 0; }
  .viewer-actions .btn span { display: none; }
  .viewer-actions .btn { padding: 0.55rem; }
}

.spinner {
  width: 2.4rem;
  height: 2.4rem;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 90; display: grid; gap: 0.5rem; max-width: min(24rem, calc(100vw - 2rem)); }
.toast {
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s;
}
.toast.error { border-left-color: var(--danger); }
.toast.out { opacity: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Halaman masuk ---------- */
.login { max-width: 24rem; margin: 12vh auto 0; padding: 0 1.25rem; display: grid; gap: 1rem; }
.login p { color: var(--muted); }
.login form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.4rem; font-weight: 600; }

/* ---------- Halaman utama (index.html) ---------- */
.hero { padding: 4.5rem 0 2.5rem; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.8rem); max-width: 14ch; letter-spacing: -0.035em; }
.hero p { max-width: 34rem; margin: 1.1rem 0 1.8rem; font-size: 1.1rem; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.hero .addr { color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem; margin: 1rem 0 3rem; }
.card { display: grid; gap: 0.5rem; padding: 1.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.card .icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.card p { color: var(--muted); }
.about { max-width: 40rem; margin-bottom: 2.5rem; }
.about h2 { margin-bottom: 0.6rem; }
.about p { color: var(--muted); }
.footer { padding: 2rem 1rem; text-align: center; font-size: 0.9rem; color: var(--muted); }

/* ---------- Mode presentasi ---------- */
body.present { height: 100vh; height: 100dvh; overflow: hidden; background: #000; color: #fff; }
body.nocursor { cursor: none; }
.stage { position: fixed; inset: 0; display: grid; place-items: center; }
.stage img { max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; background: #fff; }
.loader { position: absolute; display: grid; justify-items: center; gap: 1rem; padding: 2rem; text-align: center; color: #c8d3e6; }
.loader.bad p { color: #ff9a9a; }
.ptop, .pbar { position: fixed; z-index: 5; transition: opacity 0.3s; }
.ptop { top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; background: linear-gradient(#000a, transparent); }
.ptop .icon-btn, .pbar .icon-btn { color: #fff; background: rgba(255, 255, 255, 0.12); }
.ptop .icon-btn:hover, .pbar .icon-btn:hover { background: rgba(255, 255, 255, 0.24); }
.ptitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; opacity: 0.85; }
.pbar {
  left: 50%;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(34rem, calc(100vw - 1.5rem));
  padding: 0.5rem 0.7rem;
  background: rgba(10, 16, 28, 0.82);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
}
.pcount { flex: none; min-width: 4.6rem; font-variant-numeric: tabular-nums; text-align: center; }
.pprogress { flex: 1; height: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.2); border-radius: 99px; }
.pprogress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
.pbar.idle, .ptop.idle { opacity: 0; pointer-events: none; }

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