:root {
  --bg: #0e1621;
  --surface: #17212b;
  --surface2: #1d2a35;
  --hover: #232f3b;
  --line: #263542;
  --accent: #3390ec;
  --accent-dark: #2b7fd6;
  --text: #eaf1f8;
  --muted: #7d94a8;
  --err: #ff6b6b;
  --ok: #4caf7d;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 18px; margin: 10px 0 0; font-size: 13px; }
button { font-family: inherit; }

/* ---------- inputs & buttons ---------- */
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 10px 12px; font-size: 14px; width: 100%; font-family: inherit;
}
textarea { resize: vertical; font: 12px/1.5 ui-monospace, Consolas, monospace; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
select { width: auto; cursor: pointer; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; margin-top: 8px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.iconbtn {
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 15px; line-height: 1;
}
.iconbtn:hover { border-color: var(--accent); }
.iconbtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- auth / setup ---------- */
.fullcenter {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(900px 500px at 50% -10%, #1b2a3a, var(--bg) 65%);
}
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 400px; max-width: 92vw; box-shadow: var(--shadow); }
.auth-logo { font-size: 40px; text-align: center; }
.auth-card h1 { text-align: center; margin: 6px 0 4px; font-size: 22px; }
.auth-card label { display: block; margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.auth-card label input { margin-top: 6px; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand span { opacity: .95; }
.searchbox { flex: 1; max-width: 620px; display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--line); border-radius: 22px; padding: 0 14px; }
.searchbox:focus-within { border-color: var(--accent); }
.searchbox input { border: 0; background: transparent; padding: 9px 0; }
.searchbox .s-ic { opacity: .6; }
.s-clear { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #6f5bd6); display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.acc-name { font-size: 13px; color: var(--muted); }

.body { flex: 1; display: flex; min-height: 0; }

/* ---------- sidebar ---------- */
.sidebar { width: 240px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); }
.newbtn { font-size: 15px; padding: 12px; box-shadow: var(--shadow); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; cursor: pointer; color: var(--text); font-size: 14px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: rgba(51,144,236,.16); color: #cfe4fb; font-weight: 600; }
.storage-card { margin-top: auto; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.st-title { font-size: 12px; color: var(--muted); }
.st-num { font-size: 15px; font-weight: 600; margin: 4px 0 2px; }
.st-cat { font-size: 12px; color: var(--accent); margin-bottom: 12px; min-height: 14px; }
.st-dest { display: flex; gap: 10px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 12px; }
.dest-ic { font-size: 16px; }
.dest-lbl { font-size: 11px; color: var(--muted); }
.dest-val { font-size: 13px; font-weight: 600; word-break: break-word; }

/* ---------- content ---------- */
.content { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 24px 60px; position: relative; }
.crumbbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 600; flex-wrap: wrap; }
.breadcrumb .crumb { cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--text); }
.breadcrumb .crumb:hover { background: var(--hover); }
.breadcrumb .crumb.current { cursor: default; }
.breadcrumb .crumb.current:hover { background: none; }
.breadcrumb .sep { color: var(--muted); font-weight: 400; }
.view-tools { display: flex; align-items: center; gap: 8px; }

/* ---------- items ---------- */
.items.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.items.list { display: flex; flex-direction: column; gap: 6px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; cursor: pointer; position: relative; transition: border-color .12s, background .12s;
  user-select: none;
}
.card:hover { border-color: #35506b; background: var(--surface2); }
.card.selected { border-color: var(--accent); background: rgba(51,144,236,.10); }
.card .thumb { font-size: 40px; height: 70px; display: grid; place-items: center; }
.card .thumb img { max-width: 100%; max-height: 70px; border-radius: 8px; object-fit: cover; }
.card .cname { font-size: 13px; font-weight: 600; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cmeta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.card .badge { margin-left: 2px; }
.card .kebab { position: absolute; top: 8px; right: 8px; opacity: 0; background: rgba(0,0,0,.35); border: 0; color: #fff; border-radius: 7px; width: 26px; height: 26px; cursor: pointer; font-size: 15px; }
.card:hover .kebab, .card.selected .kebab { opacity: 1; }

/* list rows */
.items.list .card { display: flex; align-items: center; gap: 14px; padding: 10px 14px; }
.items.list .card .thumb { font-size: 22px; height: auto; width: 30px; }
.items.list .card .thumb img { max-height: 30px; }
.items.list .card .cname { margin: 0; flex: 1; }
.items.list .card .cmeta { margin: 0; width: 150px; text-align: right; }
.items.list .card .kebab { position: static; opacity: .5; margin-left: 6px; }

.empty { text-align: center; color: var(--muted); padding: 70px 20px; }
.empty .big { font-size: 46px; margin-bottom: 10px; }

/* drop overlay */
.drop-overlay { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(51,144,236,.10); display: none; place-items: center; font-size: 18px; font-weight: 600; color: #cfe4fb; pointer-events: none; z-index: 3; }
.content.dragging .drop-overlay { display: grid; }

/* ---------- context menu ---------- */
.ctxmenu { position: fixed; z-index: 50; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 180px; }
.ctxmenu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: var(--text); padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; text-align: left; }
.ctxmenu button:hover { background: var(--hover); }
.ctxmenu button.danger:hover { background: rgba(255,107,107,.15); color: var(--err); }
.ctxmenu .divider { height: 1px; background: var(--line); margin: 5px 4px; }

/* sidebar pop menu (Baru) */
.popmenu { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; margin-top: -6px; }
.popmenu button { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--text); padding: 10px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; text-align: left; }
.popmenu button:hover { background: var(--hover); }

/* ---------- upload toasts ---------- */
.uploads { position: fixed; right: 20px; bottom: 20px; width: 320px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.up-item { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; box-shadow: var(--shadow); font-size: 13px; }
.up-top { display: flex; justify-content: space-between; gap: 10px; }
.up-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-pct { color: var(--muted); flex-shrink: 0; }
.bar { height: 5px; background: var(--surface); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up-item.done .bar > i { background: var(--ok); }
.up-item.done .up-pct { color: var(--ok); }
.up-item.err { border-color: var(--err); }
.up-item.err .up-pct { color: var(--err); }

/* ---------- media viewer ---------- */
.viewer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.86); z-index: 55; display: flex; flex-direction: column; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid #222; }
.viewer-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; gap: 8px; flex-shrink: 0; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 20px; overflow: auto; }
.viewer-body img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer-body video { max-width: 100%; max-height: 100%; border-radius: 8px; background: #000; }
.viewer-body audio { width: min(520px, 90vw); }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.viewer-body .txtview { width: min(900px, 92vw); max-height: 100%; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text); }
.viewer-body .noprev { text-align: center; color: var(--muted); }
.viewer-body .noprev .btn { display: inline-block; margin-top: 14px; }
.viewer-body .loading { color: var(--muted); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 60; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.tree { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.tree-item:hover { background: var(--hover); }
.tree-item.sel { background: rgba(51,144,236,.18); color: #cfe4fb; }

@media (max-width: 720px) {
  .sidebar { width: 76px; padding: 12px 8px; }
  .newbtn { font-size: 0; padding: 12px 0; }
  .newbtn::before { content: '＋'; font-size: 18px; }
  .nav-item { font-size: 0; justify-content: center; }
  .nav-item::first-letter { font-size: 16px; }
  .storage-card, .acc-name { display: none; }
}
