:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev-2: #1e2230;
  --border: #2a2f3d;
  --text: #e8eaf0;
  --text-dim: #9aa1b2;
  --accent: #5b8def;
  --accent-hover: #6e9bf5;
  --danger: #e5566b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- Login ---------- */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1a2440 0%, #0f1115 60%);
}
.login-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px; width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-dim); margin: 0 0 24px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: var(--radius); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  background: var(--accent); color: #fff; border: none; padding: 11px;
  border-radius: var(--radius); font-weight: 600; font-size: 14px; margin-top: 4px;
}
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- App layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--bg-elev);
  border-right: 1px solid var(--border); padding: 20px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.brand { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.btn-primary, .btn-secondary, .btn-ghost {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 500; width: 100%;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #262b3a; }
.btn-ghost { background: transparent; color: var(--text-dim); margin-top: auto; }
.btn-ghost:hover { color: var(--text); }

.nav { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius); color: var(--text-dim); font-weight: 500;
}
.nav-item.active { background: var(--bg-elev-2); color: var(--text); }

.android-box {
  margin-top: 12px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-elev-2);
}
.android-label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.android-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; }
.android-dot.on { background: #2ea043; box-shadow: 0 0 6px #2ea043; }
.android-dot.off { background: #6b7280; }
.android-status-text { font-size: 11px; color: var(--text-dim); margin: 6px 0 10px; }
.android-actions { display: flex; gap: 6px; }
.btn-small { width: auto; flex: 1; padding: 7px 8px; font-size: 12px; justify-content: center; text-align: center; text-decoration: none; }

.storage-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.storage-label { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.storage-bar { height: 6px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.storage-bar-fill { height: 100%; background: var(--accent); width: 0%; transition: width .3s; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
}
.breadcrumb { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.breadcrumb span { cursor: pointer; color: var(--text-dim); }
.breadcrumb span:last-child { color: var(--text); cursor: default; }
.breadcrumb .sep { color: var(--text-dim); }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 14px; width: 260px;
}
.search-wrap svg { width: 16px; height: 16px; color: var(--text-dim); }
.search-wrap input {
  background: transparent; border: none; outline: none; color: var(--text);
  width: 100%; font-size: 13px;
}

.file-grid {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; align-content: start;
}
.file-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; display: flex; flex-direction: column; align-items: center;
  gap: 10px; cursor: pointer; user-select: none; transition: background .15s, border-color .15s;
  text-align: center;
}
.file-card:hover { background: var(--bg-elev-2); border-color: #3a4055; }
.file-card .icon { font-size: 40px; line-height: 1; position: relative; }
.file-card .thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.file-card .name { font-size: 12.5px; word-break: break-word; max-width: 100%; line-height: 1.3; }
.file-card .meta { font-size: 11px; color: var(--text-dim); }
.file-card { position: relative; }
.public-badge {
  position: absolute; top: 8px; right: 8px; background: #2ea043; color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 10px; letter-spacing: .3px;
}

.user-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 200px; overflow-y: auto; }
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px;
}
.user-row .uname { font-weight: 600; }
.user-row .uquota { color: var(--text-dim); font-size: 11px; }
.user-row .udel { background: transparent; border: none; color: var(--danger); font-size: 13px; padding: 2px 6px; }
.admin-add { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-dim); gap: 12px;
}
.empty-icon { font-size: 48px; opacity: .6; }

/* ---------- Drop zone ---------- */
.drop-zone-overlay {
  position: absolute; inset: 0; background: rgba(91,141,239,.12);
  border: 3px dashed var(--accent); border-radius: 12px; margin: 12px;
  display: flex; align-items: center; justify-content: center; z-index: 50;
  pointer-events: none;
}
.drop-zone-msg { font-size: 20px; font-weight: 600; color: var(--accent); }

/* ---------- Context menu ---------- */
.ctx-menu {
  position: fixed; background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; z-index: 200; min-width: 140px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.ctx-item { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.ctx-item:hover { background: var(--bg-elev); }
.ctx-item[data-action="delete"] { color: var(--danger); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-content {
  position: relative; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; max-width: 80vw; max-height: 85vh; overflow: auto;
}
.modal-small { width: 320px; }
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.modal-content input {
  width: 100%; background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius); font-size: 14px; outline: none;
}
.modal-content input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal-close {
  position: absolute; top: 10px; right: 10px; background: transparent; border: none;
  color: var(--text-dim); font-size: 16px; padding: 6px 10px;
}
.modal-close:hover { color: var(--text); }
#previewBody img, #previewBody video { max-width: 78vw; max-height: 78vh; display: block; border-radius: 6px; }
#previewBody iframe { width: 78vw; height: 78vh; border: none; border-radius: 6px; }
#previewBody pre { max-width: 78vw; max-height: 78vh; overflow: auto; white-space: pre-wrap; }

/* ---------- Upload toast ---------- */
.upload-toast {
  position: fixed; bottom: 24px; right: 24px; width: 280px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 400;
}
.upload-toast-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.upload-toast-bar { height: 6px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.upload-toast-fill { height: 100%; background: var(--accent); width: 0%; transition: width .2s; }
.upload-toast-status { font-size: 11px; color: var(--text-dim); margin-top: 8px; }

/* ---------- Public share page ---------- */
.pub-wrap { max-width: 900px; margin: 0 auto; padding: 32px 20px; }
.pub-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.pub-header .brand { font-size: 18px; font-weight: 700; }
.pub-breadcrumb { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.pub-breadcrumb span { cursor: pointer; color: var(--accent); }
.pub-single { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; }
.pub-single img, .pub-single video { max-width: 100%; max-height: 70vh; border-radius: 10px; }

@media (max-width: 720px) {
  .sidebar { width: 76px; padding: 16px 10px; }
  .brand, .nav-item span, .btn-primary span, .btn-secondary span { display: none; }
  .search-wrap { width: 160px; }
}
